babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * 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.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * 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.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. /**
  1057. * Prepass texture index for color
  1058. */
  1059. static readonly PREPASS_COLOR_INDEX: number;
  1060. /**
  1061. * Prepass texture index for irradiance
  1062. */
  1063. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1064. /**
  1065. * Prepass texture index for depth + normal
  1066. */
  1067. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1068. /**
  1069. * Prepass texture index for albedo
  1070. */
  1071. static readonly PREPASS_ALBEDO_INDEX: number;
  1072. }
  1073. }
  1074. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1075. import { Nullable } from "babylonjs/types";
  1076. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1077. /**
  1078. * This represents the required contract to create a new type of texture loader.
  1079. */
  1080. export interface IInternalTextureLoader {
  1081. /**
  1082. * Defines wether the loader supports cascade loading the different faces.
  1083. */
  1084. supportCascades: boolean;
  1085. /**
  1086. * This returns if the loader support the current file information.
  1087. * @param extension defines the file extension of the file being loaded
  1088. * @param mimeType defines the optional mime type of the file being loaded
  1089. * @returns true if the loader can load the specified file
  1090. */
  1091. canLoad(extension: string, mimeType?: string): boolean;
  1092. /**
  1093. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1094. * @param data contains the texture data
  1095. * @param texture defines the BabylonJS internal texture
  1096. * @param createPolynomials will be true if polynomials have been requested
  1097. * @param onLoad defines the callback to trigger once the texture is ready
  1098. * @param onError defines the callback to trigger in case of error
  1099. */
  1100. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1101. /**
  1102. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1103. * @param data contains the texture data
  1104. * @param texture defines the BabylonJS internal texture
  1105. * @param callback defines the method to call once ready to upload
  1106. */
  1107. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1108. }
  1109. }
  1110. declare module "babylonjs/Engines/IPipelineContext" {
  1111. /**
  1112. * Class used to store and describe the pipeline context associated with an effect
  1113. */
  1114. export interface IPipelineContext {
  1115. /**
  1116. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1117. */
  1118. isAsync: boolean;
  1119. /**
  1120. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1121. */
  1122. isReady: boolean;
  1123. /** @hidden */
  1124. _getVertexShaderCode(): string | null;
  1125. /** @hidden */
  1126. _getFragmentShaderCode(): string | null;
  1127. /** @hidden */
  1128. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1129. }
  1130. }
  1131. declare module "babylonjs/Meshes/dataBuffer" {
  1132. /**
  1133. * Class used to store gfx data (like WebGLBuffer)
  1134. */
  1135. export class DataBuffer {
  1136. /**
  1137. * Gets or sets the number of objects referencing this buffer
  1138. */
  1139. references: number;
  1140. /** Gets or sets the size of the underlying buffer */
  1141. capacity: number;
  1142. /**
  1143. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1144. */
  1145. is32Bits: boolean;
  1146. /**
  1147. * Gets the underlying buffer
  1148. */
  1149. get underlyingResource(): any;
  1150. }
  1151. }
  1152. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1153. /** @hidden */
  1154. export interface IShaderProcessor {
  1155. attributeProcessor?: (attribute: string) => string;
  1156. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1157. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1158. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1159. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1160. lineProcessor?: (line: string, isFragment: boolean) => string;
  1161. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1162. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1163. }
  1164. }
  1165. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1166. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1167. /** @hidden */
  1168. export interface ProcessingOptions {
  1169. defines: string[];
  1170. indexParameters: any;
  1171. isFragment: boolean;
  1172. shouldUseHighPrecisionShader: boolean;
  1173. supportsUniformBuffers: boolean;
  1174. shadersRepository: string;
  1175. includesShadersStore: {
  1176. [key: string]: string;
  1177. };
  1178. processor?: IShaderProcessor;
  1179. version: string;
  1180. platformName: string;
  1181. lookForClosingBracketForUniformBuffer?: boolean;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1185. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1186. /** @hidden */
  1187. export class ShaderCodeNode {
  1188. line: string;
  1189. children: ShaderCodeNode[];
  1190. additionalDefineKey?: string;
  1191. additionalDefineValue?: string;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. process(preprocessors: {
  1196. [key: string]: string;
  1197. }, options: ProcessingOptions): string;
  1198. }
  1199. }
  1200. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1201. /** @hidden */
  1202. export class ShaderCodeCursor {
  1203. private _lines;
  1204. lineIndex: number;
  1205. get currentLine(): string;
  1206. get canRead(): boolean;
  1207. set lines(value: string[]);
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1213. /** @hidden */
  1214. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1215. process(preprocessors: {
  1216. [key: string]: string;
  1217. }, options: ProcessingOptions): string;
  1218. }
  1219. }
  1220. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1221. /** @hidden */
  1222. export class ShaderDefineExpression {
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. private static _OperatorPriority;
  1227. private static _Stack;
  1228. static postfixToInfix(postfix: string[]): string;
  1229. static infixToPostfix(infix: string): string[];
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1233. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderCodeTestNode extends ShaderCodeNode {
  1237. testExpression: ShaderDefineExpression;
  1238. isValid(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1244. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1245. /** @hidden */
  1246. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. not: boolean;
  1249. constructor(define: string, not?: boolean);
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1259. leftOperand: ShaderDefineExpression;
  1260. rightOperand: ShaderDefineExpression;
  1261. isTrue(preprocessors: {
  1262. [key: string]: string;
  1263. }): boolean;
  1264. }
  1265. }
  1266. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1267. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1268. /** @hidden */
  1269. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1270. leftOperand: ShaderDefineExpression;
  1271. rightOperand: ShaderDefineExpression;
  1272. isTrue(preprocessors: {
  1273. [key: string]: string;
  1274. }): boolean;
  1275. }
  1276. }
  1277. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1278. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1279. /** @hidden */
  1280. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1281. define: string;
  1282. operand: string;
  1283. testValue: string;
  1284. constructor(define: string, operand: string, testValue: string);
  1285. isTrue(preprocessors: {
  1286. [key: string]: string;
  1287. }): boolean;
  1288. }
  1289. }
  1290. declare module "babylonjs/Offline/IOfflineProvider" {
  1291. /**
  1292. * Class used to enable access to offline support
  1293. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1294. */
  1295. export interface IOfflineProvider {
  1296. /**
  1297. * Gets a boolean indicating if scene must be saved in the database
  1298. */
  1299. enableSceneOffline: boolean;
  1300. /**
  1301. * Gets a boolean indicating if textures must be saved in the database
  1302. */
  1303. enableTexturesOffline: boolean;
  1304. /**
  1305. * Open the offline support and make it available
  1306. * @param successCallback defines the callback to call on success
  1307. * @param errorCallback defines the callback to call on error
  1308. */
  1309. open(successCallback: () => void, errorCallback: () => void): void;
  1310. /**
  1311. * Loads an image from the offline support
  1312. * @param url defines the url to load from
  1313. * @param image defines the target DOM image
  1314. */
  1315. loadImage(url: string, image: HTMLImageElement): void;
  1316. /**
  1317. * Loads a file from offline support
  1318. * @param url defines the URL to load from
  1319. * @param sceneLoaded defines a callback to call on success
  1320. * @param progressCallBack defines a callback to call when progress changed
  1321. * @param errorCallback defines a callback to call on error
  1322. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1323. */
  1324. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1325. }
  1326. }
  1327. declare module "babylonjs/Misc/filesInputStore" {
  1328. /**
  1329. * Class used to help managing file picking and drag'n'drop
  1330. * File Storage
  1331. */
  1332. export class FilesInputStore {
  1333. /**
  1334. * List of files ready to be loaded
  1335. */
  1336. static FilesToLoad: {
  1337. [key: string]: File;
  1338. };
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/retryStrategy" {
  1342. import { WebRequest } from "babylonjs/Misc/webRequest";
  1343. /**
  1344. * Class used to define a retry strategy when error happens while loading assets
  1345. */
  1346. export class RetryStrategy {
  1347. /**
  1348. * Function used to defines an exponential back off strategy
  1349. * @param maxRetries defines the maximum number of retries (3 by default)
  1350. * @param baseInterval defines the interval between retries
  1351. * @returns the strategy function to use
  1352. */
  1353. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1354. }
  1355. }
  1356. declare module "babylonjs/Misc/baseError" {
  1357. /**
  1358. * @ignore
  1359. * Application error to support additional information when loading a file
  1360. */
  1361. export abstract class BaseError extends Error {
  1362. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1363. }
  1364. }
  1365. declare module "babylonjs/Misc/fileTools" {
  1366. import { WebRequest } from "babylonjs/Misc/webRequest";
  1367. import { Nullable } from "babylonjs/types";
  1368. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1369. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1370. import { BaseError } from "babylonjs/Misc/baseError";
  1371. /** @ignore */
  1372. export class LoadFileError extends BaseError {
  1373. request?: WebRequest;
  1374. file?: File;
  1375. /**
  1376. * Creates a new LoadFileError
  1377. * @param message defines the message of the error
  1378. * @param request defines the optional web request
  1379. * @param file defines the optional file
  1380. */
  1381. constructor(message: string, object?: WebRequest | File);
  1382. }
  1383. /** @ignore */
  1384. export class RequestFileError extends BaseError {
  1385. request: WebRequest;
  1386. /**
  1387. * Creates a new LoadFileError
  1388. * @param message defines the message of the error
  1389. * @param request defines the optional web request
  1390. */
  1391. constructor(message: string, request: WebRequest);
  1392. }
  1393. /** @ignore */
  1394. export class ReadFileError extends BaseError {
  1395. file: File;
  1396. /**
  1397. * Creates a new ReadFileError
  1398. * @param message defines the message of the error
  1399. * @param file defines the optional file
  1400. */
  1401. constructor(message: string, file: File);
  1402. }
  1403. /**
  1404. * @hidden
  1405. */
  1406. export class FileTools {
  1407. /**
  1408. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1409. */
  1410. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1411. /**
  1412. * Gets or sets the base URL to use to load assets
  1413. */
  1414. static BaseUrl: string;
  1415. /**
  1416. * Default behaviour for cors in the application.
  1417. * It can be a string if the expected behavior is identical in the entire app.
  1418. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1419. */
  1420. static CorsBehavior: string | ((url: string | string[]) => string);
  1421. /**
  1422. * Gets or sets a function used to pre-process url before using them to load assets
  1423. */
  1424. static PreprocessUrl: (url: string) => string;
  1425. /**
  1426. * Removes unwanted characters from an url
  1427. * @param url defines the url to clean
  1428. * @returns the cleaned url
  1429. */
  1430. private static _CleanUrl;
  1431. /**
  1432. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1433. * @param url define the url we are trying
  1434. * @param element define the dom element where to configure the cors policy
  1435. */
  1436. static SetCorsBehavior(url: string | string[], element: {
  1437. crossOrigin: string | null;
  1438. }): void;
  1439. /**
  1440. * Loads an image as an HTMLImageElement.
  1441. * @param input url string, ArrayBuffer, or Blob to load
  1442. * @param onLoad callback called when the image successfully loads
  1443. * @param onError callback called when the image fails to load
  1444. * @param offlineProvider offline provider for caching
  1445. * @param mimeType optional mime type
  1446. * @returns the HTMLImageElement of the loaded image
  1447. */
  1448. 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>;
  1449. /**
  1450. * Reads a file from a File object
  1451. * @param file defines the file to load
  1452. * @param onSuccess defines the callback to call when data is loaded
  1453. * @param onProgress defines the callback to call during loading process
  1454. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1455. * @param onError defines the callback to call when an error occurs
  1456. * @returns a file request object
  1457. */
  1458. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1459. /**
  1460. * Loads a file from a url
  1461. * @param url url to load
  1462. * @param onSuccess callback called when the file successfully loads
  1463. * @param onProgress callback called while file is loading (if the server supports this mode)
  1464. * @param offlineProvider defines the offline provider for caching
  1465. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1466. * @param onError callback called when the file fails to load
  1467. * @returns a file request object
  1468. */
  1469. 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;
  1470. /**
  1471. * Loads a file
  1472. * @param url url to load
  1473. * @param onSuccess callback called when the file successfully loads
  1474. * @param onProgress callback called while file is loading (if the server supports this mode)
  1475. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1476. * @param onError callback called when the file fails to load
  1477. * @param onOpened callback called when the web request is opened
  1478. * @returns a file request object
  1479. */
  1480. 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;
  1481. /**
  1482. * Checks if the loaded document was accessed via `file:`-Protocol.
  1483. * @returns boolean
  1484. */
  1485. static IsFileURL(): boolean;
  1486. }
  1487. }
  1488. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1489. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1490. import { WebRequest } from "babylonjs/Misc/webRequest";
  1491. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1492. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1493. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1494. /** @hidden */
  1495. export class ShaderProcessor {
  1496. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1497. private static _ProcessPrecision;
  1498. private static _ExtractOperation;
  1499. private static _BuildSubExpression;
  1500. private static _BuildExpression;
  1501. private static _MoveCursorWithinIf;
  1502. private static _MoveCursor;
  1503. private static _EvaluatePreProcessors;
  1504. private static _PreparePreProcessors;
  1505. private static _ProcessShaderConversion;
  1506. private static _ProcessIncludes;
  1507. /**
  1508. * Loads a file from a url
  1509. * @param url url to load
  1510. * @param onSuccess callback called when the file successfully loads
  1511. * @param onProgress callback called while file is loading (if the server supports this mode)
  1512. * @param offlineProvider defines the offline provider for caching
  1513. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1514. * @param onError callback called when the file fails to load
  1515. * @returns a file request object
  1516. * @hidden
  1517. */
  1518. 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;
  1519. }
  1520. }
  1521. declare module "babylonjs/Maths/math.like" {
  1522. import { float, int, DeepImmutable } from "babylonjs/types";
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IColor4Like {
  1527. r: float;
  1528. g: float;
  1529. b: float;
  1530. a: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IColor3Like {
  1536. r: float;
  1537. g: float;
  1538. b: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector4Like {
  1544. x: float;
  1545. y: float;
  1546. z: float;
  1547. w: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IVector3Like {
  1553. x: float;
  1554. y: float;
  1555. z: float;
  1556. }
  1557. /**
  1558. * @hidden
  1559. */
  1560. export interface IVector2Like {
  1561. x: float;
  1562. y: float;
  1563. }
  1564. /**
  1565. * @hidden
  1566. */
  1567. export interface IMatrixLike {
  1568. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1569. updateFlag: int;
  1570. }
  1571. /**
  1572. * @hidden
  1573. */
  1574. export interface IViewportLike {
  1575. x: float;
  1576. y: float;
  1577. width: float;
  1578. height: float;
  1579. }
  1580. /**
  1581. * @hidden
  1582. */
  1583. export interface IPlaneLike {
  1584. normal: IVector3Like;
  1585. d: float;
  1586. normalize(): void;
  1587. }
  1588. }
  1589. declare module "babylonjs/Materials/iEffectFallbacks" {
  1590. import { Effect } from "babylonjs/Materials/effect";
  1591. /**
  1592. * Interface used to define common properties for effect fallbacks
  1593. */
  1594. export interface IEffectFallbacks {
  1595. /**
  1596. * Removes the defines that should be removed when falling back.
  1597. * @param currentDefines defines the current define statements for the shader.
  1598. * @param effect defines the current effect we try to compile
  1599. * @returns The resulting defines with defines of the current rank removed.
  1600. */
  1601. reduce(currentDefines: string, effect: Effect): string;
  1602. /**
  1603. * Removes the fallback from the bound mesh.
  1604. */
  1605. unBindMesh(): void;
  1606. /**
  1607. * Checks to see if more fallbacks are still availible.
  1608. */
  1609. hasMoreFallbacks: boolean;
  1610. }
  1611. }
  1612. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1613. /**
  1614. * Class used to evalaute queries containing `and` and `or` operators
  1615. */
  1616. export class AndOrNotEvaluator {
  1617. /**
  1618. * Evaluate a query
  1619. * @param query defines the query to evaluate
  1620. * @param evaluateCallback defines the callback used to filter result
  1621. * @returns true if the query matches
  1622. */
  1623. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1624. private static _HandleParenthesisContent;
  1625. private static _SimplifyNegation;
  1626. }
  1627. }
  1628. declare module "babylonjs/Misc/tags" {
  1629. /**
  1630. * Class used to store custom tags
  1631. */
  1632. export class Tags {
  1633. /**
  1634. * Adds support for tags on the given object
  1635. * @param obj defines the object to use
  1636. */
  1637. static EnableFor(obj: any): void;
  1638. /**
  1639. * Removes tags support
  1640. * @param obj defines the object to use
  1641. */
  1642. static DisableFor(obj: any): void;
  1643. /**
  1644. * Gets a boolean indicating if the given object has tags
  1645. * @param obj defines the object to use
  1646. * @returns a boolean
  1647. */
  1648. static HasTags(obj: any): boolean;
  1649. /**
  1650. * Gets the tags available on a given object
  1651. * @param obj defines the object to use
  1652. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1653. * @returns the tags
  1654. */
  1655. static GetTags(obj: any, asString?: boolean): any;
  1656. /**
  1657. * Adds tags to an object
  1658. * @param obj defines the object to use
  1659. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1660. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1661. */
  1662. static AddTagsTo(obj: any, tagsString: string): void;
  1663. /**
  1664. * @hidden
  1665. */
  1666. static _AddTagTo(obj: any, tag: string): void;
  1667. /**
  1668. * Removes specific tags from a specific object
  1669. * @param obj defines the object to use
  1670. * @param tagsString defines the tags to remove
  1671. */
  1672. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1673. /**
  1674. * @hidden
  1675. */
  1676. static _RemoveTagFrom(obj: any, tag: string): void;
  1677. /**
  1678. * Defines if tags hosted on an object match a given query
  1679. * @param obj defines the object to use
  1680. * @param tagsQuery defines the tag query
  1681. * @returns a boolean
  1682. */
  1683. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1684. }
  1685. }
  1686. declare module "babylonjs/Maths/math.scalar" {
  1687. /**
  1688. * Scalar computation library
  1689. */
  1690. export class Scalar {
  1691. /**
  1692. * Two pi constants convenient for computation.
  1693. */
  1694. static TwoPi: number;
  1695. /**
  1696. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1697. * @param a number
  1698. * @param b number
  1699. * @param epsilon (default = 1.401298E-45)
  1700. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1701. */
  1702. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1703. /**
  1704. * Returns a string : the upper case translation of the number i to hexadecimal.
  1705. * @param i number
  1706. * @returns the upper case translation of the number i to hexadecimal.
  1707. */
  1708. static ToHex(i: number): string;
  1709. /**
  1710. * Returns -1 if value is negative and +1 is value is positive.
  1711. * @param value the value
  1712. * @returns the value itself if it's equal to zero.
  1713. */
  1714. static Sign(value: number): number;
  1715. /**
  1716. * Returns the value itself if it's between min and max.
  1717. * Returns min if the value is lower than min.
  1718. * Returns max if the value is greater than max.
  1719. * @param value the value to clmap
  1720. * @param min the min value to clamp to (default: 0)
  1721. * @param max the max value to clamp to (default: 1)
  1722. * @returns the clamped value
  1723. */
  1724. static Clamp(value: number, min?: number, max?: number): number;
  1725. /**
  1726. * the log2 of value.
  1727. * @param value the value to compute log2 of
  1728. * @returns the log2 of value.
  1729. */
  1730. static Log2(value: number): number;
  1731. /**
  1732. * Loops the value, so that it is never larger than length and never smaller than 0.
  1733. *
  1734. * This is similar to the modulo operator but it works with floating point numbers.
  1735. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1736. * With t = 5 and length = 2.5, the result would be 0.0.
  1737. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1738. * @param value the value
  1739. * @param length the length
  1740. * @returns the looped value
  1741. */
  1742. static Repeat(value: number, length: number): number;
  1743. /**
  1744. * Normalize the value between 0.0 and 1.0 using min and max values
  1745. * @param value value to normalize
  1746. * @param min max to normalize between
  1747. * @param max min to normalize between
  1748. * @returns the normalized value
  1749. */
  1750. static Normalize(value: number, min: number, max: number): number;
  1751. /**
  1752. * Denormalize the value from 0.0 and 1.0 using min and max values
  1753. * @param normalized value to denormalize
  1754. * @param min max to denormalize between
  1755. * @param max min to denormalize between
  1756. * @returns the denormalized value
  1757. */
  1758. static Denormalize(normalized: number, min: number, max: number): number;
  1759. /**
  1760. * Calculates the shortest difference between two given angles given in degrees.
  1761. * @param current current angle in degrees
  1762. * @param target target angle in degrees
  1763. * @returns the delta
  1764. */
  1765. static DeltaAngle(current: number, target: number): number;
  1766. /**
  1767. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1768. * @param tx value
  1769. * @param length length
  1770. * @returns The returned value will move back and forth between 0 and length
  1771. */
  1772. static PingPong(tx: number, length: number): number;
  1773. /**
  1774. * Interpolates between min and max with smoothing at the limits.
  1775. *
  1776. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1777. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1778. * @param from from
  1779. * @param to to
  1780. * @param tx value
  1781. * @returns the smooth stepped value
  1782. */
  1783. static SmoothStep(from: number, to: number, tx: number): number;
  1784. /**
  1785. * Moves a value current towards target.
  1786. *
  1787. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1788. * Negative values of maxDelta pushes the value away from target.
  1789. * @param current current value
  1790. * @param target target value
  1791. * @param maxDelta max distance to move
  1792. * @returns resulting value
  1793. */
  1794. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1795. /**
  1796. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1797. *
  1798. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1799. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1800. * @param current current value
  1801. * @param target target value
  1802. * @param maxDelta max distance to move
  1803. * @returns resulting angle
  1804. */
  1805. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1806. /**
  1807. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1808. * @param start start value
  1809. * @param end target value
  1810. * @param amount amount to lerp between
  1811. * @returns the lerped value
  1812. */
  1813. static Lerp(start: number, end: number, amount: number): number;
  1814. /**
  1815. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1817. * @param start start value
  1818. * @param end target value
  1819. * @param amount amount to lerp between
  1820. * @returns the lerped value
  1821. */
  1822. static LerpAngle(start: number, end: number, amount: number): number;
  1823. /**
  1824. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1825. * @param a start value
  1826. * @param b target value
  1827. * @param value value between a and b
  1828. * @returns the inverseLerp value
  1829. */
  1830. static InverseLerp(a: number, b: number, value: number): number;
  1831. /**
  1832. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1833. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1834. * @param value1 spline value
  1835. * @param tangent1 spline value
  1836. * @param value2 spline value
  1837. * @param tangent2 spline value
  1838. * @param amount input value
  1839. * @returns hermite result
  1840. */
  1841. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1842. /**
  1843. * Returns a random float number between and min and max values
  1844. * @param min min value of random
  1845. * @param max max value of random
  1846. * @returns random value
  1847. */
  1848. static RandomRange(min: number, max: number): number;
  1849. /**
  1850. * This function returns percentage of a number in a given range.
  1851. *
  1852. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1853. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1854. * @param number to convert to percentage
  1855. * @param min min range
  1856. * @param max max range
  1857. * @returns the percentage
  1858. */
  1859. static RangeToPercent(number: number, min: number, max: number): number;
  1860. /**
  1861. * This function returns number that corresponds to the percentage in a given range.
  1862. *
  1863. * PercentToRange(0.34,0,100) will return 34.
  1864. * @param percent to convert to number
  1865. * @param min min range
  1866. * @param max max range
  1867. * @returns the number
  1868. */
  1869. static PercentToRange(percent: number, min: number, max: number): number;
  1870. /**
  1871. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1872. * @param angle The angle to normalize in radian.
  1873. * @return The converted angle.
  1874. */
  1875. static NormalizeRadians(angle: number): number;
  1876. }
  1877. }
  1878. declare module "babylonjs/Maths/math.constants" {
  1879. /**
  1880. * Constant used to convert a value to gamma space
  1881. * @ignorenaming
  1882. */
  1883. export const ToGammaSpace: number;
  1884. /**
  1885. * Constant used to convert a value to linear space
  1886. * @ignorenaming
  1887. */
  1888. export const ToLinearSpace = 2.2;
  1889. /**
  1890. * Constant used to define the minimal number value in Babylon.js
  1891. * @ignorenaming
  1892. */
  1893. let Epsilon: number;
  1894. export { Epsilon };
  1895. }
  1896. declare module "babylonjs/Maths/math.viewport" {
  1897. /**
  1898. * Class used to represent a viewport on screen
  1899. */
  1900. export class Viewport {
  1901. /** viewport left coordinate */
  1902. x: number;
  1903. /** viewport top coordinate */
  1904. y: number;
  1905. /**viewport width */
  1906. width: number;
  1907. /** viewport height */
  1908. height: number;
  1909. /**
  1910. * Creates a Viewport object located at (x, y) and sized (width, height)
  1911. * @param x defines viewport left coordinate
  1912. * @param y defines viewport top coordinate
  1913. * @param width defines the viewport width
  1914. * @param height defines the viewport height
  1915. */
  1916. constructor(
  1917. /** viewport left coordinate */
  1918. x: number,
  1919. /** viewport top coordinate */
  1920. y: number,
  1921. /**viewport width */
  1922. width: number,
  1923. /** viewport height */
  1924. height: number);
  1925. /**
  1926. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1927. * @param renderWidth defines the rendering width
  1928. * @param renderHeight defines the rendering height
  1929. * @returns a new Viewport
  1930. */
  1931. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1932. /**
  1933. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1934. * @param renderWidth defines the rendering width
  1935. * @param renderHeight defines the rendering height
  1936. * @param ref defines the target viewport
  1937. * @returns the current viewport
  1938. */
  1939. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1940. /**
  1941. * Returns a new Viewport copied from the current one
  1942. * @returns a new Viewport
  1943. */
  1944. clone(): Viewport;
  1945. }
  1946. }
  1947. declare module "babylonjs/Misc/arrayTools" {
  1948. /**
  1949. * Class containing a set of static utilities functions for arrays.
  1950. */
  1951. export class ArrayTools {
  1952. /**
  1953. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1954. * @param size the number of element to construct and put in the array
  1955. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1956. * @returns a new array filled with new objects
  1957. */
  1958. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1959. }
  1960. }
  1961. declare module "babylonjs/Maths/math.plane" {
  1962. import { DeepImmutable } from "babylonjs/types";
  1963. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1964. /**
  1965. * Represents a plane by the equation ax + by + cz + d = 0
  1966. */
  1967. export class Plane {
  1968. private static _TmpMatrix;
  1969. /**
  1970. * Normal of the plane (a,b,c)
  1971. */
  1972. normal: Vector3;
  1973. /**
  1974. * d component of the plane
  1975. */
  1976. d: number;
  1977. /**
  1978. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1979. * @param a a component of the plane
  1980. * @param b b component of the plane
  1981. * @param c c component of the plane
  1982. * @param d d component of the plane
  1983. */
  1984. constructor(a: number, b: number, c: number, d: number);
  1985. /**
  1986. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1987. */
  1988. asArray(): number[];
  1989. /**
  1990. * @returns a new plane copied from the current Plane.
  1991. */
  1992. clone(): Plane;
  1993. /**
  1994. * @returns the string "Plane".
  1995. */
  1996. getClassName(): string;
  1997. /**
  1998. * @returns the Plane hash code.
  1999. */
  2000. getHashCode(): number;
  2001. /**
  2002. * Normalize the current Plane in place.
  2003. * @returns the updated Plane.
  2004. */
  2005. normalize(): Plane;
  2006. /**
  2007. * Applies a transformation the plane and returns the result
  2008. * @param transformation the transformation matrix to be applied to the plane
  2009. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2010. */
  2011. transform(transformation: DeepImmutable<Matrix>): Plane;
  2012. /**
  2013. * Compute the dot product between the point and the plane normal
  2014. * @param point point to calculate the dot product with
  2015. * @returns the dot product (float) of the point coordinates and the plane normal.
  2016. */
  2017. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2018. /**
  2019. * Updates the current Plane from the plane defined by the three given points.
  2020. * @param point1 one of the points used to contruct the plane
  2021. * @param point2 one of the points used to contruct the plane
  2022. * @param point3 one of the points used to contruct the plane
  2023. * @returns the updated Plane.
  2024. */
  2025. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2026. /**
  2027. * Checks if the plane is facing a given direction
  2028. * @param direction the direction to check if the plane is facing
  2029. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2030. * @returns True is the vector "direction" is the same side than the plane normal.
  2031. */
  2032. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2033. /**
  2034. * Calculates the distance to a point
  2035. * @param point point to calculate distance to
  2036. * @returns the signed distance (float) from the given point to the Plane.
  2037. */
  2038. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2039. /**
  2040. * Creates a plane from an array
  2041. * @param array the array to create a plane from
  2042. * @returns a new Plane from the given array.
  2043. */
  2044. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2045. /**
  2046. * Creates a plane from three points
  2047. * @param point1 point used to create the plane
  2048. * @param point2 point used to create the plane
  2049. * @param point3 point used to create the plane
  2050. * @returns a new Plane defined by the three given points.
  2051. */
  2052. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2053. /**
  2054. * Creates a plane from an origin point and a normal
  2055. * @param origin origin of the plane to be constructed
  2056. * @param normal normal of the plane to be constructed
  2057. * @returns a new Plane the normal vector to this plane at the given origin point.
  2058. * Note : the vector "normal" is updated because normalized.
  2059. */
  2060. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2061. /**
  2062. * Calculates the distance from a plane and a point
  2063. * @param origin origin of the plane to be constructed
  2064. * @param normal normal of the plane to be constructed
  2065. * @param point point to calculate distance to
  2066. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2067. */
  2068. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2069. }
  2070. }
  2071. declare module "babylonjs/Engines/performanceConfigurator" {
  2072. /** @hidden */
  2073. export class PerformanceConfigurator {
  2074. /** @hidden */
  2075. static MatrixUse64Bits: boolean;
  2076. /** @hidden */
  2077. static MatrixTrackPrecisionChange: boolean;
  2078. /** @hidden */
  2079. static MatrixCurrentType: any;
  2080. /** @hidden */
  2081. static MatrixTrackedMatrices: Array<any> | null;
  2082. /** @hidden */
  2083. static SetMatrixPrecision(use64bits: boolean): void;
  2084. }
  2085. }
  2086. declare module "babylonjs/Maths/math.vector" {
  2087. import { Viewport } from "babylonjs/Maths/math.viewport";
  2088. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2089. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2090. import { Plane } from "babylonjs/Maths/math.plane";
  2091. /**
  2092. * Class representing a vector containing 2 coordinates
  2093. */
  2094. export class Vector2 {
  2095. /** defines the first coordinate */
  2096. x: number;
  2097. /** defines the second coordinate */
  2098. y: number;
  2099. /**
  2100. * Creates a new Vector2 from the given x and y coordinates
  2101. * @param x defines the first coordinate
  2102. * @param y defines the second coordinate
  2103. */
  2104. constructor(
  2105. /** defines the first coordinate */
  2106. x?: number,
  2107. /** defines the second coordinate */
  2108. y?: number);
  2109. /**
  2110. * Gets a string with the Vector2 coordinates
  2111. * @returns a string with the Vector2 coordinates
  2112. */
  2113. toString(): string;
  2114. /**
  2115. * Gets class name
  2116. * @returns the string "Vector2"
  2117. */
  2118. getClassName(): string;
  2119. /**
  2120. * Gets current vector hash code
  2121. * @returns the Vector2 hash code as a number
  2122. */
  2123. getHashCode(): number;
  2124. /**
  2125. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2126. * @param array defines the source array
  2127. * @param index defines the offset in source array
  2128. * @returns the current Vector2
  2129. */
  2130. toArray(array: FloatArray, index?: number): Vector2;
  2131. /**
  2132. * Update the current vector from an array
  2133. * @param array defines the destination array
  2134. * @param index defines the offset in the destination array
  2135. * @returns the current Vector3
  2136. */
  2137. fromArray(array: FloatArray, index?: number): Vector2;
  2138. /**
  2139. * Copy the current vector to an array
  2140. * @returns a new array with 2 elements: the Vector2 coordinates.
  2141. */
  2142. asArray(): number[];
  2143. /**
  2144. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2145. * @param source defines the source Vector2
  2146. * @returns the current updated Vector2
  2147. */
  2148. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2149. /**
  2150. * Sets the Vector2 coordinates with the given floats
  2151. * @param x defines the first coordinate
  2152. * @param y defines the second coordinate
  2153. * @returns the current updated Vector2
  2154. */
  2155. copyFromFloats(x: number, y: number): Vector2;
  2156. /**
  2157. * Sets the Vector2 coordinates with the given floats
  2158. * @param x defines the first coordinate
  2159. * @param y defines the second coordinate
  2160. * @returns the current updated Vector2
  2161. */
  2162. set(x: number, y: number): Vector2;
  2163. /**
  2164. * Add another vector with the current one
  2165. * @param otherVector defines the other vector
  2166. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2167. */
  2168. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2171. * @param otherVector defines the other vector
  2172. * @param result defines the target vector
  2173. * @returns the unmodified current Vector2
  2174. */
  2175. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2176. /**
  2177. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2178. * @param otherVector defines the other vector
  2179. * @returns the current updated Vector2
  2180. */
  2181. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2182. /**
  2183. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2184. * @param otherVector defines the other vector
  2185. * @returns a new Vector2
  2186. */
  2187. addVector3(otherVector: Vector3): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2190. * @param otherVector defines the other vector
  2191. * @returns a new Vector2
  2192. */
  2193. subtract(otherVector: Vector2): Vector2;
  2194. /**
  2195. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2196. * @param otherVector defines the other vector
  2197. * @param result defines the target vector
  2198. * @returns the unmodified current Vector2
  2199. */
  2200. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2201. /**
  2202. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2203. * @param otherVector defines the other vector
  2204. * @returns the current updated Vector2
  2205. */
  2206. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Multiplies in place the current Vector2 coordinates by the given ones
  2209. * @param otherVector defines the other vector
  2210. * @returns the current updated Vector2
  2211. */
  2212. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2213. /**
  2214. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2215. * @param otherVector defines the other vector
  2216. * @returns a new Vector2
  2217. */
  2218. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2221. * @param otherVector defines the other vector
  2222. * @param result defines the target vector
  2223. * @returns the unmodified current Vector2
  2224. */
  2225. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2228. * @param x defines the first coordinate
  2229. * @param y defines the second coordinate
  2230. * @returns a new Vector2
  2231. */
  2232. multiplyByFloats(x: number, y: number): Vector2;
  2233. /**
  2234. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2235. * @param otherVector defines the other vector
  2236. * @returns a new Vector2
  2237. */
  2238. divide(otherVector: Vector2): Vector2;
  2239. /**
  2240. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2241. * @param otherVector defines the other vector
  2242. * @param result defines the target vector
  2243. * @returns the unmodified current Vector2
  2244. */
  2245. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2246. /**
  2247. * Divides the current Vector2 coordinates by the given ones
  2248. * @param otherVector defines the other vector
  2249. * @returns the current updated Vector2
  2250. */
  2251. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vector2 with current Vector2 negated coordinates
  2254. * @returns a new Vector2
  2255. */
  2256. negate(): Vector2;
  2257. /**
  2258. * Negate this vector in place
  2259. * @returns this
  2260. */
  2261. negateInPlace(): Vector2;
  2262. /**
  2263. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2264. * @param result defines the Vector3 object where to store the result
  2265. * @returns the current Vector2
  2266. */
  2267. negateToRef(result: Vector2): Vector2;
  2268. /**
  2269. * Multiply the Vector2 coordinates by scale
  2270. * @param scale defines the scaling factor
  2271. * @returns the current updated Vector2
  2272. */
  2273. scaleInPlace(scale: number): Vector2;
  2274. /**
  2275. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2276. * @param scale defines the scaling factor
  2277. * @returns a new Vector2
  2278. */
  2279. scale(scale: number): Vector2;
  2280. /**
  2281. * Scale the current Vector2 values by a factor to a given Vector2
  2282. * @param scale defines the scale factor
  2283. * @param result defines the Vector2 object where to store the result
  2284. * @returns the unmodified current Vector2
  2285. */
  2286. scaleToRef(scale: number, result: Vector2): Vector2;
  2287. /**
  2288. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2289. * @param scale defines the scale factor
  2290. * @param result defines the Vector2 object where to store the result
  2291. * @returns the unmodified current Vector2
  2292. */
  2293. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2294. /**
  2295. * Gets a boolean if two vectors are equals
  2296. * @param otherVector defines the other vector
  2297. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2298. */
  2299. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2300. /**
  2301. * Gets a boolean if two vectors are equals (using an epsilon value)
  2302. * @param otherVector defines the other vector
  2303. * @param epsilon defines the minimal distance to consider equality
  2304. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2305. */
  2306. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2307. /**
  2308. * Gets a new Vector2 from current Vector2 floored values
  2309. * @returns a new Vector2
  2310. */
  2311. floor(): Vector2;
  2312. /**
  2313. * Gets a new Vector2 from current Vector2 floored values
  2314. * @returns a new Vector2
  2315. */
  2316. fract(): Vector2;
  2317. /**
  2318. * Gets the length of the vector
  2319. * @returns the vector length (float)
  2320. */
  2321. length(): number;
  2322. /**
  2323. * Gets the vector squared length
  2324. * @returns the vector squared length (float)
  2325. */
  2326. lengthSquared(): number;
  2327. /**
  2328. * Normalize the vector
  2329. * @returns the current updated Vector2
  2330. */
  2331. normalize(): Vector2;
  2332. /**
  2333. * Gets a new Vector2 copied from the Vector2
  2334. * @returns a new Vector2
  2335. */
  2336. clone(): Vector2;
  2337. /**
  2338. * Gets a new Vector2(0, 0)
  2339. * @returns a new Vector2
  2340. */
  2341. static Zero(): Vector2;
  2342. /**
  2343. * Gets a new Vector2(1, 1)
  2344. * @returns a new Vector2
  2345. */
  2346. static One(): Vector2;
  2347. /**
  2348. * Gets a new Vector2 set from the given index element of the given array
  2349. * @param array defines the data source
  2350. * @param offset defines the offset in the data source
  2351. * @returns a new Vector2
  2352. */
  2353. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2354. /**
  2355. * Sets "result" from the given index element of the given array
  2356. * @param array defines the data source
  2357. * @param offset defines the offset in the data source
  2358. * @param result defines the target vector
  2359. */
  2360. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2361. /**
  2362. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2363. * @param value1 defines 1st point of control
  2364. * @param value2 defines 2nd point of control
  2365. * @param value3 defines 3rd point of control
  2366. * @param value4 defines 4th point of control
  2367. * @param amount defines the interpolation factor
  2368. * @returns a new Vector2
  2369. */
  2370. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2371. /**
  2372. * 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".
  2373. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2374. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2375. * @param value defines the value to clamp
  2376. * @param min defines the lower limit
  2377. * @param max defines the upper limit
  2378. * @returns a new Vector2
  2379. */
  2380. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2381. /**
  2382. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2383. * @param value1 defines the 1st control point
  2384. * @param tangent1 defines the outgoing tangent
  2385. * @param value2 defines the 2nd control point
  2386. * @param tangent2 defines the incoming tangent
  2387. * @param amount defines the interpolation factor
  2388. * @returns a new Vector2
  2389. */
  2390. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2391. /**
  2392. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2393. * @param start defines the start vector
  2394. * @param end defines the end vector
  2395. * @param amount defines the interpolation factor
  2396. * @returns a new Vector2
  2397. */
  2398. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2399. /**
  2400. * Gets the dot product of the vector "left" and the vector "right"
  2401. * @param left defines first vector
  2402. * @param right defines second vector
  2403. * @returns the dot product (float)
  2404. */
  2405. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2406. /**
  2407. * Returns a new Vector2 equal to the normalized given vector
  2408. * @param vector defines the vector to normalize
  2409. * @returns a new Vector2
  2410. */
  2411. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2414. * @param left defines 1st vector
  2415. * @param right defines 2nd vector
  2416. * @returns a new Vector2
  2417. */
  2418. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2419. /**
  2420. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2421. * @param left defines 1st vector
  2422. * @param right defines 2nd vector
  2423. * @returns a new Vector2
  2424. */
  2425. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2426. /**
  2427. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2428. * @param vector defines the vector to transform
  2429. * @param transformation defines the matrix to apply
  2430. * @returns a new Vector2
  2431. */
  2432. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2433. /**
  2434. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2435. * @param vector defines the vector to transform
  2436. * @param transformation defines the matrix to apply
  2437. * @param result defines the target vector
  2438. */
  2439. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2440. /**
  2441. * Determines if a given vector is included in a triangle
  2442. * @param p defines the vector to test
  2443. * @param p0 defines 1st triangle point
  2444. * @param p1 defines 2nd triangle point
  2445. * @param p2 defines 3rd triangle point
  2446. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2447. */
  2448. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2449. /**
  2450. * Gets the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines first vector
  2452. * @param value2 defines second vector
  2453. * @returns the distance between vectors
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines first vector
  2459. * @param value2 defines second vector
  2460. * @returns the squared distance between vectors
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2463. /**
  2464. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2465. * @param value1 defines first vector
  2466. * @param value2 defines second vector
  2467. * @returns a new Vector2
  2468. */
  2469. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2470. /**
  2471. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2472. * @param p defines the middle point
  2473. * @param segA defines one point of the segment
  2474. * @param segB defines the other point of the segment
  2475. * @returns the shortest distance
  2476. */
  2477. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2478. }
  2479. /**
  2480. * Class used to store (x,y,z) vector representation
  2481. * A Vector3 is the main object used in 3D geometry
  2482. * It can represent etiher the coordinates of a point the space, either a direction
  2483. * Reminder: js uses a left handed forward facing system
  2484. */
  2485. export class Vector3 {
  2486. private static _UpReadOnly;
  2487. private static _ZeroReadOnly;
  2488. /** @hidden */
  2489. _x: number;
  2490. /** @hidden */
  2491. _y: number;
  2492. /** @hidden */
  2493. _z: number;
  2494. /** @hidden */
  2495. _isDirty: boolean;
  2496. /** Gets or sets the x coordinate */
  2497. get x(): number;
  2498. set x(value: number);
  2499. /** Gets or sets the y coordinate */
  2500. get y(): number;
  2501. set y(value: number);
  2502. /** Gets or sets the z coordinate */
  2503. get z(): number;
  2504. set z(value: number);
  2505. /**
  2506. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2507. * @param x defines the first coordinates (on X axis)
  2508. * @param y defines the second coordinates (on Y axis)
  2509. * @param z defines the third coordinates (on Z axis)
  2510. */
  2511. constructor(x?: number, y?: number, z?: number);
  2512. /**
  2513. * Creates a string representation of the Vector3
  2514. * @returns a string with the Vector3 coordinates.
  2515. */
  2516. toString(): string;
  2517. /**
  2518. * Gets the class name
  2519. * @returns the string "Vector3"
  2520. */
  2521. getClassName(): string;
  2522. /**
  2523. * Creates the Vector3 hash code
  2524. * @returns a number which tends to be unique between Vector3 instances
  2525. */
  2526. getHashCode(): number;
  2527. /**
  2528. * Creates an array containing three elements : the coordinates of the Vector3
  2529. * @returns a new array of numbers
  2530. */
  2531. asArray(): number[];
  2532. /**
  2533. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2534. * @param array defines the destination array
  2535. * @param index defines the offset in the destination array
  2536. * @returns the current Vector3
  2537. */
  2538. toArray(array: FloatArray, index?: number): Vector3;
  2539. /**
  2540. * Update the current vector from an array
  2541. * @param array defines the destination array
  2542. * @param index defines the offset in the destination array
  2543. * @returns the current Vector3
  2544. */
  2545. fromArray(array: FloatArray, index?: number): Vector3;
  2546. /**
  2547. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2548. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2549. */
  2550. toQuaternion(): Quaternion;
  2551. /**
  2552. * Adds the given vector to the current Vector3
  2553. * @param otherVector defines the second operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Adds the given coordinates to the current Vector3
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2567. * @param otherVector defines the second operand
  2568. * @returns the resulting Vector3
  2569. */
  2570. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2571. /**
  2572. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2573. * @param otherVector defines the second operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2578. /**
  2579. * Subtract the given vector from the current Vector3
  2580. * @param otherVector defines the second operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2584. /**
  2585. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2586. * @param otherVector defines the second operand
  2587. * @returns the resulting Vector3
  2588. */
  2589. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2592. * @param otherVector defines the second operand
  2593. * @param result defines the Vector3 object where to store the result
  2594. * @returns the current Vector3
  2595. */
  2596. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2597. /**
  2598. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2599. * @param x defines the x coordinate of the operand
  2600. * @param y defines the y coordinate of the operand
  2601. * @param z defines the z coordinate of the operand
  2602. * @returns the resulting Vector3
  2603. */
  2604. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2605. /**
  2606. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2607. * @param x defines the x coordinate of the operand
  2608. * @param y defines the y coordinate of the operand
  2609. * @param z defines the z coordinate of the operand
  2610. * @param result defines the Vector3 object where to store the result
  2611. * @returns the current Vector3
  2612. */
  2613. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2614. /**
  2615. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2616. * @returns a new Vector3
  2617. */
  2618. negate(): Vector3;
  2619. /**
  2620. * Negate this vector in place
  2621. * @returns this
  2622. */
  2623. negateInPlace(): Vector3;
  2624. /**
  2625. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2626. * @param result defines the Vector3 object where to store the result
  2627. * @returns the current Vector3
  2628. */
  2629. negateToRef(result: Vector3): Vector3;
  2630. /**
  2631. * Multiplies the Vector3 coordinates by the float "scale"
  2632. * @param scale defines the multiplier factor
  2633. * @returns the current updated Vector3
  2634. */
  2635. scaleInPlace(scale: number): Vector3;
  2636. /**
  2637. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2638. * @param scale defines the multiplier factor
  2639. * @returns a new Vector3
  2640. */
  2641. scale(scale: number): Vector3;
  2642. /**
  2643. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2644. * @param scale defines the multiplier factor
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. scaleToRef(scale: number, result: Vector3): Vector3;
  2649. /**
  2650. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2651. * @param scale defines the scale factor
  2652. * @param result defines the Vector3 object where to store the result
  2653. * @returns the unmodified current Vector3
  2654. */
  2655. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2656. /**
  2657. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2658. * @param origin defines the origin of the projection ray
  2659. * @param plane defines the plane to project to
  2660. * @returns the projected vector3
  2661. */
  2662. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2663. /**
  2664. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2665. * @param origin defines the origin of the projection ray
  2666. * @param plane defines the plane to project to
  2667. * @param result defines the Vector3 where to store the result
  2668. */
  2669. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2670. /**
  2671. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2672. * @param otherVector defines the second operand
  2673. * @returns true if both vectors are equals
  2674. */
  2675. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2676. /**
  2677. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2678. * @param otherVector defines the second operand
  2679. * @param epsilon defines the minimal distance to define values as equals
  2680. * @returns true if both vectors are distant less than epsilon
  2681. */
  2682. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2683. /**
  2684. * Returns true if the current Vector3 coordinates equals the given floats
  2685. * @param x defines the x coordinate of the operand
  2686. * @param y defines the y coordinate of the operand
  2687. * @param z defines the z coordinate of the operand
  2688. * @returns true if both vectors are equals
  2689. */
  2690. equalsToFloats(x: number, y: number, z: number): boolean;
  2691. /**
  2692. * Multiplies the current Vector3 coordinates by the given ones
  2693. * @param otherVector defines the second operand
  2694. * @returns the current updated Vector3
  2695. */
  2696. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2697. /**
  2698. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2699. * @param otherVector defines the second operand
  2700. * @returns the new Vector3
  2701. */
  2702. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2703. /**
  2704. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2705. * @param otherVector defines the second operand
  2706. * @param result defines the Vector3 object where to store the result
  2707. * @returns the current Vector3
  2708. */
  2709. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2710. /**
  2711. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the new Vector3
  2716. */
  2717. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2720. * @param otherVector defines the second operand
  2721. * @returns the new Vector3
  2722. */
  2723. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2724. /**
  2725. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2726. * @param otherVector defines the second operand
  2727. * @param result defines the Vector3 object where to store the result
  2728. * @returns the current Vector3
  2729. */
  2730. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2731. /**
  2732. * Divides the current Vector3 coordinates by the given ones.
  2733. * @param otherVector defines the second operand
  2734. * @returns the current updated Vector3
  2735. */
  2736. divideInPlace(otherVector: Vector3): Vector3;
  2737. /**
  2738. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2739. * @param other defines the second operand
  2740. * @returns the current updated Vector3
  2741. */
  2742. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2743. /**
  2744. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2745. * @param other defines the second operand
  2746. * @returns the current updated Vector3
  2747. */
  2748. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2749. /**
  2750. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2751. * @param x defines the x coordinate of the operand
  2752. * @param y defines the y coordinate of the operand
  2753. * @param z defines the z coordinate of the operand
  2754. * @returns the current updated Vector3
  2755. */
  2756. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2757. /**
  2758. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2759. * @param x defines the x coordinate of the operand
  2760. * @param y defines the y coordinate of the operand
  2761. * @param z defines the z coordinate of the operand
  2762. * @returns the current updated Vector3
  2763. */
  2764. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2765. /**
  2766. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2767. * Check if is non uniform within a certain amount of decimal places to account for this
  2768. * @param epsilon the amount the values can differ
  2769. * @returns if the the vector is non uniform to a certain number of decimal places
  2770. */
  2771. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2772. /**
  2773. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2774. */
  2775. get isNonUniform(): boolean;
  2776. /**
  2777. * Gets a new Vector3 from current Vector3 floored values
  2778. * @returns a new Vector3
  2779. */
  2780. floor(): Vector3;
  2781. /**
  2782. * Gets a new Vector3 from current Vector3 floored values
  2783. * @returns a new Vector3
  2784. */
  2785. fract(): Vector3;
  2786. /**
  2787. * Gets the length of the Vector3
  2788. * @returns the length of the Vector3
  2789. */
  2790. length(): number;
  2791. /**
  2792. * Gets the squared length of the Vector3
  2793. * @returns squared length of the Vector3
  2794. */
  2795. lengthSquared(): number;
  2796. /**
  2797. * Normalize the current Vector3.
  2798. * Please note that this is an in place operation.
  2799. * @returns the current updated Vector3
  2800. */
  2801. normalize(): Vector3;
  2802. /**
  2803. * Reorders the x y z properties of the vector in place
  2804. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2805. * @returns the current updated vector
  2806. */
  2807. reorderInPlace(order: string): this;
  2808. /**
  2809. * Rotates the vector around 0,0,0 by a quaternion
  2810. * @param quaternion the rotation quaternion
  2811. * @param result vector to store the result
  2812. * @returns the resulting vector
  2813. */
  2814. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2815. /**
  2816. * Rotates a vector around a given point
  2817. * @param quaternion the rotation quaternion
  2818. * @param point the point to rotate around
  2819. * @param result vector to store the result
  2820. * @returns the resulting vector
  2821. */
  2822. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2823. /**
  2824. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2825. * The cross product is then orthogonal to both current and "other"
  2826. * @param other defines the right operand
  2827. * @returns the cross product
  2828. */
  2829. cross(other: Vector3): Vector3;
  2830. /**
  2831. * Normalize the current Vector3 with the given input length.
  2832. * Please note that this is an in place operation.
  2833. * @param len the length of the vector
  2834. * @returns the current updated Vector3
  2835. */
  2836. normalizeFromLength(len: number): Vector3;
  2837. /**
  2838. * Normalize the current Vector3 to a new vector
  2839. * @returns the new Vector3
  2840. */
  2841. normalizeToNew(): Vector3;
  2842. /**
  2843. * Normalize the current Vector3 to the reference
  2844. * @param reference define the Vector3 to update
  2845. * @returns the updated Vector3
  2846. */
  2847. normalizeToRef(reference: Vector3): Vector3;
  2848. /**
  2849. * Creates a new Vector3 copied from the current Vector3
  2850. * @returns the new Vector3
  2851. */
  2852. clone(): Vector3;
  2853. /**
  2854. * Copies the given vector coordinates to the current Vector3 ones
  2855. * @param source defines the source Vector3
  2856. * @returns the current updated Vector3
  2857. */
  2858. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2859. /**
  2860. * Copies the given floats to the current Vector3 coordinates
  2861. * @param x defines the x coordinate of the operand
  2862. * @param y defines the y coordinate of the operand
  2863. * @param z defines the z coordinate of the operand
  2864. * @returns the current updated Vector3
  2865. */
  2866. copyFromFloats(x: number, y: number, z: number): Vector3;
  2867. /**
  2868. * Copies the given floats to the current Vector3 coordinates
  2869. * @param x defines the x coordinate of the operand
  2870. * @param y defines the y coordinate of the operand
  2871. * @param z defines the z coordinate of the operand
  2872. * @returns the current updated Vector3
  2873. */
  2874. set(x: number, y: number, z: number): Vector3;
  2875. /**
  2876. * Copies the given float to the current Vector3 coordinates
  2877. * @param v defines the x, y and z coordinates of the operand
  2878. * @returns the current updated Vector3
  2879. */
  2880. setAll(v: number): Vector3;
  2881. /**
  2882. * Get the clip factor between two vectors
  2883. * @param vector0 defines the first operand
  2884. * @param vector1 defines the second operand
  2885. * @param axis defines the axis to use
  2886. * @param size defines the size along the axis
  2887. * @returns the clip factor
  2888. */
  2889. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2890. /**
  2891. * Get angle between two vectors
  2892. * @param vector0 angle between vector0 and vector1
  2893. * @param vector1 angle between vector0 and vector1
  2894. * @param normal direction of the normal
  2895. * @return the angle between vector0 and vector1
  2896. */
  2897. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2898. /**
  2899. * Returns a new Vector3 set from the index "offset" of the given array
  2900. * @param array defines the source array
  2901. * @param offset defines the offset in the source array
  2902. * @returns the new Vector3
  2903. */
  2904. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2907. * @param array defines the source array
  2908. * @param offset defines the offset in the source array
  2909. * @returns the new Vector3
  2910. * @deprecated Please use FromArray instead.
  2911. */
  2912. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2913. /**
  2914. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2915. * @param array defines the source array
  2916. * @param offset defines the offset in the source array
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2920. /**
  2921. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2922. * @param array defines the source array
  2923. * @param offset defines the offset in the source array
  2924. * @param result defines the Vector3 where to store the result
  2925. * @deprecated Please use FromArrayToRef instead.
  2926. */
  2927. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2928. /**
  2929. * Sets the given vector "result" with the given floats.
  2930. * @param x defines the x coordinate of the source
  2931. * @param y defines the y coordinate of the source
  2932. * @param z defines the z coordinate of the source
  2933. * @param result defines the Vector3 where to store the result
  2934. */
  2935. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2936. /**
  2937. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2938. * @returns a new empty Vector3
  2939. */
  2940. static Zero(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2943. * @returns a new unit Vector3
  2944. */
  2945. static One(): Vector3;
  2946. /**
  2947. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2948. * @returns a new up Vector3
  2949. */
  2950. static Up(): Vector3;
  2951. /**
  2952. * Gets a up Vector3 that must not be updated
  2953. */
  2954. static get UpReadOnly(): DeepImmutable<Vector3>;
  2955. /**
  2956. * Gets a zero Vector3 that must not be updated
  2957. */
  2958. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2961. * @returns a new down Vector3
  2962. */
  2963. static Down(): Vector3;
  2964. /**
  2965. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2966. * @param rightHandedSystem is the scene right-handed (negative z)
  2967. * @returns a new forward Vector3
  2968. */
  2969. static Forward(rightHandedSystem?: boolean): Vector3;
  2970. /**
  2971. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2972. * @param rightHandedSystem is the scene right-handed (negative-z)
  2973. * @returns a new forward Vector3
  2974. */
  2975. static Backward(rightHandedSystem?: boolean): Vector3;
  2976. /**
  2977. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2978. * @returns a new right Vector3
  2979. */
  2980. static Right(): Vector3;
  2981. /**
  2982. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2983. * @returns a new left Vector3
  2984. */
  2985. static Left(): Vector3;
  2986. /**
  2987. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2988. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2989. * @param vector defines the Vector3 to transform
  2990. * @param transformation defines the transformation matrix
  2991. * @returns the transformed Vector3
  2992. */
  2993. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2994. /**
  2995. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2996. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2997. * @param vector defines the Vector3 to transform
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3004. * This method computes tranformed coordinates only, not transformed direction vectors
  3005. * @param x define the x coordinate of the source vector
  3006. * @param y define the y coordinate of the source vector
  3007. * @param z define the z coordinate of the source vector
  3008. * @param transformation defines the transformation matrix
  3009. * @param result defines the Vector3 where to store the result
  3010. */
  3011. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3012. /**
  3013. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3014. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3015. * @param vector defines the Vector3 to transform
  3016. * @param transformation defines the transformation matrix
  3017. * @returns the new Vector3
  3018. */
  3019. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3020. /**
  3021. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3022. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3023. * @param vector defines the Vector3 to transform
  3024. * @param transformation defines the transformation matrix
  3025. * @param result defines the Vector3 where to store the result
  3026. */
  3027. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3028. /**
  3029. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3030. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3031. * @param x define the x coordinate of the source vector
  3032. * @param y define the y coordinate of the source vector
  3033. * @param z define the z coordinate of the source vector
  3034. * @param transformation defines the transformation matrix
  3035. * @param result defines the Vector3 where to store the result
  3036. */
  3037. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3038. /**
  3039. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3040. * @param value1 defines the first control point
  3041. * @param value2 defines the second control point
  3042. * @param value3 defines the third control point
  3043. * @param value4 defines the fourth control point
  3044. * @param amount defines the amount on the spline to use
  3045. * @returns the new Vector3
  3046. */
  3047. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3048. /**
  3049. * 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"
  3050. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3051. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3052. * @param value defines the current value
  3053. * @param min defines the lower range value
  3054. * @param max defines the upper range value
  3055. * @returns the new Vector3
  3056. */
  3057. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3058. /**
  3059. * 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"
  3060. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3061. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3062. * @param value defines the current value
  3063. * @param min defines the lower range value
  3064. * @param max defines the upper range value
  3065. * @param result defines the Vector3 where to store the result
  3066. */
  3067. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3068. /**
  3069. * Checks if a given vector is inside a specific range
  3070. * @param v defines the vector to test
  3071. * @param min defines the minimum range
  3072. * @param max defines the maximum range
  3073. */
  3074. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3075. /**
  3076. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3077. * @param value1 defines the first control point
  3078. * @param tangent1 defines the first tangent vector
  3079. * @param value2 defines the second control point
  3080. * @param tangent2 defines the second tangent vector
  3081. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3082. * @returns the new Vector3
  3083. */
  3084. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3085. /**
  3086. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3087. * @param start defines the start value
  3088. * @param end defines the end value
  3089. * @param amount max defines amount between both (between 0 and 1)
  3090. * @returns the new Vector3
  3091. */
  3092. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3093. /**
  3094. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3095. * @param start defines the start value
  3096. * @param end defines the end value
  3097. * @param amount max defines amount between both (between 0 and 1)
  3098. * @param result defines the Vector3 where to store the result
  3099. */
  3100. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3101. /**
  3102. * Returns the dot product (float) between the vectors "left" and "right"
  3103. * @param left defines the left operand
  3104. * @param right defines the right operand
  3105. * @returns the dot product
  3106. */
  3107. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3108. /**
  3109. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3110. * The cross product is then orthogonal to both "left" and "right"
  3111. * @param left defines the left operand
  3112. * @param right defines the right operand
  3113. * @returns the cross product
  3114. */
  3115. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3116. /**
  3117. * Sets the given vector "result" with the cross product of "left" and "right"
  3118. * The cross product is then orthogonal to both "left" and "right"
  3119. * @param left defines the left operand
  3120. * @param right defines the right operand
  3121. * @param result defines the Vector3 where to store the result
  3122. */
  3123. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3124. /**
  3125. * Returns a new Vector3 as the normalization of the given vector
  3126. * @param vector defines the Vector3 to normalize
  3127. * @returns the new Vector3
  3128. */
  3129. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3130. /**
  3131. * Sets the given vector "result" with the normalization of the given first vector
  3132. * @param vector defines the Vector3 to normalize
  3133. * @param result defines the Vector3 where to store the result
  3134. */
  3135. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3136. /**
  3137. * Project a Vector3 onto screen space
  3138. * @param vector defines the Vector3 to project
  3139. * @param world defines the world matrix to use
  3140. * @param transform defines the transform (view x projection) matrix to use
  3141. * @param viewport defines the screen viewport to use
  3142. * @returns the new Vector3
  3143. */
  3144. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3145. /** @hidden */
  3146. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3147. /**
  3148. * Unproject from screen space to object space
  3149. * @param source defines the screen space Vector3 to use
  3150. * @param viewportWidth defines the current width of the viewport
  3151. * @param viewportHeight defines the current height of the viewport
  3152. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3153. * @param transform defines the transform (view x projection) matrix to use
  3154. * @returns the new Vector3
  3155. */
  3156. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3157. /**
  3158. * Unproject from screen space to object space
  3159. * @param source defines the screen space Vector3 to use
  3160. * @param viewportWidth defines the current width of the viewport
  3161. * @param viewportHeight defines the current height of the viewport
  3162. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3163. * @param view defines the view matrix to use
  3164. * @param projection defines the projection matrix to use
  3165. * @returns the new Vector3
  3166. */
  3167. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3168. /**
  3169. * Unproject from screen space to object space
  3170. * @param source defines the screen space Vector3 to use
  3171. * @param viewportWidth defines the current width of the viewport
  3172. * @param viewportHeight defines the current height of the viewport
  3173. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3174. * @param view defines the view matrix to use
  3175. * @param projection defines the projection matrix to use
  3176. * @param result defines the Vector3 where to store the result
  3177. */
  3178. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3179. /**
  3180. * Unproject from screen space to object space
  3181. * @param sourceX defines the screen space x coordinate to use
  3182. * @param sourceY defines the screen space y coordinate to use
  3183. * @param sourceZ defines the screen space z coordinate to use
  3184. * @param viewportWidth defines the current width of the viewport
  3185. * @param viewportHeight defines the current height of the viewport
  3186. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3187. * @param view defines the view matrix to use
  3188. * @param projection defines the projection matrix to use
  3189. * @param result defines the Vector3 where to store the result
  3190. */
  3191. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3192. /**
  3193. * Gets the minimal coordinate values between two Vector3
  3194. * @param left defines the first operand
  3195. * @param right defines the second operand
  3196. * @returns the new Vector3
  3197. */
  3198. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3199. /**
  3200. * Gets the maximal coordinate values between two Vector3
  3201. * @param left defines the first operand
  3202. * @param right defines the second operand
  3203. * @returns the new Vector3
  3204. */
  3205. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3206. /**
  3207. * Returns the distance between the vectors "value1" and "value2"
  3208. * @param value1 defines the first operand
  3209. * @param value2 defines the second operand
  3210. * @returns the distance
  3211. */
  3212. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3213. /**
  3214. * Returns the squared distance between the vectors "value1" and "value2"
  3215. * @param value1 defines the first operand
  3216. * @param value2 defines the second operand
  3217. * @returns the squared distance
  3218. */
  3219. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3220. /**
  3221. * Returns a new Vector3 located at the center between "value1" and "value2"
  3222. * @param value1 defines the first operand
  3223. * @param value2 defines the second operand
  3224. * @returns the new Vector3
  3225. */
  3226. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3227. /**
  3228. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3229. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3230. * to something in order to rotate it from its local system to the given target system
  3231. * Note: axis1, axis2 and axis3 are normalized during this operation
  3232. * @param axis1 defines the first axis
  3233. * @param axis2 defines the second axis
  3234. * @param axis3 defines the third axis
  3235. * @returns a new Vector3
  3236. */
  3237. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3238. /**
  3239. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3240. * @param axis1 defines the first axis
  3241. * @param axis2 defines the second axis
  3242. * @param axis3 defines the third axis
  3243. * @param ref defines the Vector3 where to store the result
  3244. */
  3245. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3246. }
  3247. /**
  3248. * Vector4 class created for EulerAngle class conversion to Quaternion
  3249. */
  3250. export class Vector4 {
  3251. /** x value of the vector */
  3252. x: number;
  3253. /** y value of the vector */
  3254. y: number;
  3255. /** z value of the vector */
  3256. z: number;
  3257. /** w value of the vector */
  3258. w: number;
  3259. /**
  3260. * Creates a Vector4 object from the given floats.
  3261. * @param x x value of the vector
  3262. * @param y y value of the vector
  3263. * @param z z value of the vector
  3264. * @param w w value of the vector
  3265. */
  3266. constructor(
  3267. /** x value of the vector */
  3268. x: number,
  3269. /** y value of the vector */
  3270. y: number,
  3271. /** z value of the vector */
  3272. z: number,
  3273. /** w value of the vector */
  3274. w: number);
  3275. /**
  3276. * Returns the string with the Vector4 coordinates.
  3277. * @returns a string containing all the vector values
  3278. */
  3279. toString(): string;
  3280. /**
  3281. * Returns the string "Vector4".
  3282. * @returns "Vector4"
  3283. */
  3284. getClassName(): string;
  3285. /**
  3286. * Returns the Vector4 hash code.
  3287. * @returns a unique hash code
  3288. */
  3289. getHashCode(): number;
  3290. /**
  3291. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3292. * @returns the resulting array
  3293. */
  3294. asArray(): number[];
  3295. /**
  3296. * Populates the given array from the given index with the Vector4 coordinates.
  3297. * @param array array to populate
  3298. * @param index index of the array to start at (default: 0)
  3299. * @returns the Vector4.
  3300. */
  3301. toArray(array: FloatArray, index?: number): Vector4;
  3302. /**
  3303. * Update the current vector from an array
  3304. * @param array defines the destination array
  3305. * @param index defines the offset in the destination array
  3306. * @returns the current Vector3
  3307. */
  3308. fromArray(array: FloatArray, index?: number): Vector4;
  3309. /**
  3310. * Adds the given vector to the current Vector4.
  3311. * @param otherVector the vector to add
  3312. * @returns the updated Vector4.
  3313. */
  3314. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3315. /**
  3316. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3317. * @param otherVector the vector to add
  3318. * @returns the resulting vector
  3319. */
  3320. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3321. /**
  3322. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3323. * @param otherVector the vector to add
  3324. * @param result the vector to store the result
  3325. * @returns the current Vector4.
  3326. */
  3327. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3328. /**
  3329. * Subtract in place the given vector from the current Vector4.
  3330. * @param otherVector the vector to subtract
  3331. * @returns the updated Vector4.
  3332. */
  3333. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3336. * @param otherVector the vector to add
  3337. * @returns the new vector with the result
  3338. */
  3339. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3342. * @param otherVector the vector to subtract
  3343. * @param result the vector to store the result
  3344. * @returns the current Vector4.
  3345. */
  3346. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3347. /**
  3348. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3349. */
  3350. /**
  3351. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3352. * @param x value to subtract
  3353. * @param y value to subtract
  3354. * @param z value to subtract
  3355. * @param w value to subtract
  3356. * @returns new vector containing the result
  3357. */
  3358. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3359. /**
  3360. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3361. * @param x value to subtract
  3362. * @param y value to subtract
  3363. * @param z value to subtract
  3364. * @param w value to subtract
  3365. * @param result the vector to store the result in
  3366. * @returns the current Vector4.
  3367. */
  3368. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3371. * @returns a new vector with the negated values
  3372. */
  3373. negate(): Vector4;
  3374. /**
  3375. * Negate this vector in place
  3376. * @returns this
  3377. */
  3378. negateInPlace(): Vector4;
  3379. /**
  3380. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3381. * @param result defines the Vector3 object where to store the result
  3382. * @returns the current Vector4
  3383. */
  3384. negateToRef(result: Vector4): Vector4;
  3385. /**
  3386. * Multiplies the current Vector4 coordinates by scale (float).
  3387. * @param scale the number to scale with
  3388. * @returns the updated Vector4.
  3389. */
  3390. scaleInPlace(scale: number): Vector4;
  3391. /**
  3392. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3393. * @param scale the number to scale with
  3394. * @returns a new vector with the result
  3395. */
  3396. scale(scale: number): Vector4;
  3397. /**
  3398. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3399. * @param scale the number to scale with
  3400. * @param result a vector to store the result in
  3401. * @returns the current Vector4.
  3402. */
  3403. scaleToRef(scale: number, result: Vector4): Vector4;
  3404. /**
  3405. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3406. * @param scale defines the scale factor
  3407. * @param result defines the Vector4 object where to store the result
  3408. * @returns the unmodified current Vector4
  3409. */
  3410. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3411. /**
  3412. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3413. * @param otherVector the vector to compare against
  3414. * @returns true if they are equal
  3415. */
  3416. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3417. /**
  3418. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3419. * @param otherVector vector to compare against
  3420. * @param epsilon (Default: very small number)
  3421. * @returns true if they are equal
  3422. */
  3423. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3424. /**
  3425. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3426. * @param x x value to compare against
  3427. * @param y y value to compare against
  3428. * @param z z value to compare against
  3429. * @param w w value to compare against
  3430. * @returns true if equal
  3431. */
  3432. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3433. /**
  3434. * Multiplies in place the current Vector4 by the given one.
  3435. * @param otherVector vector to multiple with
  3436. * @returns the updated Vector4.
  3437. */
  3438. multiplyInPlace(otherVector: Vector4): Vector4;
  3439. /**
  3440. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3441. * @param otherVector vector to multiple with
  3442. * @returns resulting new vector
  3443. */
  3444. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3447. * @param otherVector vector to multiple with
  3448. * @param result vector to store the result
  3449. * @returns the current Vector4.
  3450. */
  3451. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3452. /**
  3453. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3454. * @param x x value multiply with
  3455. * @param y y value multiply with
  3456. * @param z z value multiply with
  3457. * @param w w value multiply with
  3458. * @returns resulting new vector
  3459. */
  3460. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3461. /**
  3462. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3463. * @param otherVector vector to devide with
  3464. * @returns resulting new vector
  3465. */
  3466. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3467. /**
  3468. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3469. * @param otherVector vector to devide with
  3470. * @param result vector to store the result
  3471. * @returns the current Vector4.
  3472. */
  3473. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3474. /**
  3475. * Divides the current Vector3 coordinates by the given ones.
  3476. * @param otherVector vector to devide with
  3477. * @returns the updated Vector3.
  3478. */
  3479. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3480. /**
  3481. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3482. * @param other defines the second operand
  3483. * @returns the current updated Vector4
  3484. */
  3485. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3488. * @param other defines the second operand
  3489. * @returns the current updated Vector4
  3490. */
  3491. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3492. /**
  3493. * Gets a new Vector4 from current Vector4 floored values
  3494. * @returns a new Vector4
  3495. */
  3496. floor(): Vector4;
  3497. /**
  3498. * Gets a new Vector4 from current Vector3 floored values
  3499. * @returns a new Vector4
  3500. */
  3501. fract(): Vector4;
  3502. /**
  3503. * Returns the Vector4 length (float).
  3504. * @returns the length
  3505. */
  3506. length(): number;
  3507. /**
  3508. * Returns the Vector4 squared length (float).
  3509. * @returns the length squared
  3510. */
  3511. lengthSquared(): number;
  3512. /**
  3513. * Normalizes in place the Vector4.
  3514. * @returns the updated Vector4.
  3515. */
  3516. normalize(): Vector4;
  3517. /**
  3518. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3519. * @returns this converted to a new vector3
  3520. */
  3521. toVector3(): Vector3;
  3522. /**
  3523. * Returns a new Vector4 copied from the current one.
  3524. * @returns the new cloned vector
  3525. */
  3526. clone(): Vector4;
  3527. /**
  3528. * Updates the current Vector4 with the given one coordinates.
  3529. * @param source the source vector to copy from
  3530. * @returns the updated Vector4.
  3531. */
  3532. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3533. /**
  3534. * Updates the current Vector4 coordinates with the given floats.
  3535. * @param x float to copy from
  3536. * @param y float to copy from
  3537. * @param z float to copy from
  3538. * @param w float to copy from
  3539. * @returns the updated Vector4.
  3540. */
  3541. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3542. /**
  3543. * Updates the current Vector4 coordinates with the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @returns the updated Vector4.
  3549. */
  3550. set(x: number, y: number, z: number, w: number): Vector4;
  3551. /**
  3552. * Copies the given float to the current Vector3 coordinates
  3553. * @param v defines the x, y, z and w coordinates of the operand
  3554. * @returns the current updated Vector3
  3555. */
  3556. setAll(v: number): Vector4;
  3557. /**
  3558. * Returns a new Vector4 set from the starting index of the given array.
  3559. * @param array the array to pull values from
  3560. * @param offset the offset into the array to start at
  3561. * @returns the new vector
  3562. */
  3563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3564. /**
  3565. * Updates the given vector "result" from the starting index of the given array.
  3566. * @param array the array to pull values from
  3567. * @param offset the offset into the array to start at
  3568. * @param result the vector to store the result in
  3569. */
  3570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3571. /**
  3572. * Updates the given vector "result" from the starting index of the given Float32Array.
  3573. * @param array the array to pull values from
  3574. * @param offset the offset into the array to start at
  3575. * @param result the vector to store the result in
  3576. */
  3577. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3578. /**
  3579. * Updates the given vector "result" coordinates from the given floats.
  3580. * @param x float to set from
  3581. * @param y float to set from
  3582. * @param z float to set from
  3583. * @param w float to set from
  3584. * @param result the vector to the floats in
  3585. */
  3586. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3587. /**
  3588. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3589. * @returns the new vector
  3590. */
  3591. static Zero(): Vector4;
  3592. /**
  3593. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3594. * @returns the new vector
  3595. */
  3596. static One(): Vector4;
  3597. /**
  3598. * Returns a new normalized Vector4 from the given one.
  3599. * @param vector the vector to normalize
  3600. * @returns the vector
  3601. */
  3602. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3603. /**
  3604. * Updates the given vector "result" from the normalization of the given one.
  3605. * @param vector the vector to normalize
  3606. * @param result the vector to store the result in
  3607. */
  3608. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3609. /**
  3610. * Returns a vector with the minimum values from the left and right vectors
  3611. * @param left left vector to minimize
  3612. * @param right right vector to minimize
  3613. * @returns a new vector with the minimum of the left and right vector values
  3614. */
  3615. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3616. /**
  3617. * Returns a vector with the maximum values from the left and right vectors
  3618. * @param left left vector to maximize
  3619. * @param right right vector to maximize
  3620. * @returns a new vector with the maximum of the left and right vector values
  3621. */
  3622. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3623. /**
  3624. * Returns the distance (float) between the vectors "value1" and "value2".
  3625. * @param value1 value to calulate the distance between
  3626. * @param value2 value to calulate the distance between
  3627. * @return the distance between the two vectors
  3628. */
  3629. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3630. /**
  3631. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3632. * @param value1 value to calulate the distance between
  3633. * @param value2 value to calulate the distance between
  3634. * @return the distance between the two vectors squared
  3635. */
  3636. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3637. /**
  3638. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3639. * @param value1 value to calulate the center between
  3640. * @param value2 value to calulate the center between
  3641. * @return the center between the two vectors
  3642. */
  3643. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3644. /**
  3645. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3646. * This methods computes transformed normalized direction vectors only.
  3647. * @param vector the vector to transform
  3648. * @param transformation the transformation matrix to apply
  3649. * @returns the new vector
  3650. */
  3651. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3652. /**
  3653. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3654. * This methods computes transformed normalized direction vectors only.
  3655. * @param vector the vector to transform
  3656. * @param transformation the transformation matrix to apply
  3657. * @param result the vector to store the result in
  3658. */
  3659. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3660. /**
  3661. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3662. * This methods computes transformed normalized direction vectors only.
  3663. * @param x value to transform
  3664. * @param y value to transform
  3665. * @param z value to transform
  3666. * @param w value to transform
  3667. * @param transformation the transformation matrix to apply
  3668. * @param result the vector to store the results in
  3669. */
  3670. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3671. /**
  3672. * Creates a new Vector4 from a Vector3
  3673. * @param source defines the source data
  3674. * @param w defines the 4th component (default is 0)
  3675. * @returns a new Vector4
  3676. */
  3677. static FromVector3(source: Vector3, w?: number): Vector4;
  3678. }
  3679. /**
  3680. * Class used to store quaternion data
  3681. * @see https://en.wikipedia.org/wiki/Quaternion
  3682. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3683. */
  3684. export class Quaternion {
  3685. /** @hidden */
  3686. _x: number;
  3687. /** @hidden */
  3688. _y: number;
  3689. /** @hidden */
  3690. _z: number;
  3691. /** @hidden */
  3692. _w: number;
  3693. /** @hidden */
  3694. _isDirty: boolean;
  3695. /** Gets or sets the x coordinate */
  3696. get x(): number;
  3697. set x(value: number);
  3698. /** Gets or sets the y coordinate */
  3699. get y(): number;
  3700. set y(value: number);
  3701. /** Gets or sets the z coordinate */
  3702. get z(): number;
  3703. set z(value: number);
  3704. /** Gets or sets the w coordinate */
  3705. get w(): number;
  3706. set w(value: number);
  3707. /**
  3708. * Creates a new Quaternion from the given floats
  3709. * @param x defines the first component (0 by default)
  3710. * @param y defines the second component (0 by default)
  3711. * @param z defines the third component (0 by default)
  3712. * @param w defines the fourth component (1.0 by default)
  3713. */
  3714. constructor(x?: number, y?: number, z?: number, w?: number);
  3715. /**
  3716. * Gets a string representation for the current quaternion
  3717. * @returns a string with the Quaternion coordinates
  3718. */
  3719. toString(): string;
  3720. /**
  3721. * Gets the class name of the quaternion
  3722. * @returns the string "Quaternion"
  3723. */
  3724. getClassName(): string;
  3725. /**
  3726. * Gets a hash code for this quaternion
  3727. * @returns the quaternion hash code
  3728. */
  3729. getHashCode(): number;
  3730. /**
  3731. * Copy the quaternion to an array
  3732. * @returns a new array populated with 4 elements from the quaternion coordinates
  3733. */
  3734. asArray(): number[];
  3735. /**
  3736. * Check if two quaternions are equals
  3737. * @param otherQuaternion defines the second operand
  3738. * @return true if the current quaternion and the given one coordinates are strictly equals
  3739. */
  3740. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3741. /**
  3742. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3743. * @param otherQuaternion defines the other quaternion
  3744. * @param epsilon defines the minimal distance to consider equality
  3745. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3746. */
  3747. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3748. /**
  3749. * Clone the current quaternion
  3750. * @returns a new quaternion copied from the current one
  3751. */
  3752. clone(): Quaternion;
  3753. /**
  3754. * Copy a quaternion to the current one
  3755. * @param other defines the other quaternion
  3756. * @returns the updated current quaternion
  3757. */
  3758. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3759. /**
  3760. * Updates the current quaternion with the given float coordinates
  3761. * @param x defines the x coordinate
  3762. * @param y defines the y coordinate
  3763. * @param z defines the z coordinate
  3764. * @param w defines the w coordinate
  3765. * @returns the updated current quaternion
  3766. */
  3767. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3768. /**
  3769. * Updates the current quaternion from the given float coordinates
  3770. * @param x defines the x coordinate
  3771. * @param y defines the y coordinate
  3772. * @param z defines the z coordinate
  3773. * @param w defines the w coordinate
  3774. * @returns the updated current quaternion
  3775. */
  3776. set(x: number, y: number, z: number, w: number): Quaternion;
  3777. /**
  3778. * Adds two quaternions
  3779. * @param other defines the second operand
  3780. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3781. */
  3782. add(other: DeepImmutable<Quaternion>): Quaternion;
  3783. /**
  3784. * Add a quaternion to the current one
  3785. * @param other defines the quaternion to add
  3786. * @returns the current quaternion
  3787. */
  3788. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3789. /**
  3790. * Subtract two quaternions
  3791. * @param other defines the second operand
  3792. * @returns a new quaternion as the subtraction result of the given one from the current one
  3793. */
  3794. subtract(other: Quaternion): Quaternion;
  3795. /**
  3796. * Multiplies the current quaternion by a scale factor
  3797. * @param value defines the scale factor
  3798. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3799. */
  3800. scale(value: number): Quaternion;
  3801. /**
  3802. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3803. * @param scale defines the scale factor
  3804. * @param result defines the Quaternion object where to store the result
  3805. * @returns the unmodified current quaternion
  3806. */
  3807. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3808. /**
  3809. * Multiplies in place the current quaternion by a scale factor
  3810. * @param value defines the scale factor
  3811. * @returns the current modified quaternion
  3812. */
  3813. scaleInPlace(value: number): Quaternion;
  3814. /**
  3815. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3816. * @param scale defines the scale factor
  3817. * @param result defines the Quaternion object where to store the result
  3818. * @returns the unmodified current quaternion
  3819. */
  3820. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3821. /**
  3822. * Multiplies two quaternions
  3823. * @param q1 defines the second operand
  3824. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3825. */
  3826. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3827. /**
  3828. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3829. * @param q1 defines the second operand
  3830. * @param result defines the target quaternion
  3831. * @returns the current quaternion
  3832. */
  3833. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3834. /**
  3835. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3836. * @param q1 defines the second operand
  3837. * @returns the currentupdated quaternion
  3838. */
  3839. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3842. * @param ref defines the target quaternion
  3843. * @returns the current quaternion
  3844. */
  3845. conjugateToRef(ref: Quaternion): Quaternion;
  3846. /**
  3847. * Conjugates in place (1-q) the current quaternion
  3848. * @returns the current updated quaternion
  3849. */
  3850. conjugateInPlace(): Quaternion;
  3851. /**
  3852. * Conjugates in place (1-q) the current quaternion
  3853. * @returns a new quaternion
  3854. */
  3855. conjugate(): Quaternion;
  3856. /**
  3857. * Gets length of current quaternion
  3858. * @returns the quaternion length (float)
  3859. */
  3860. length(): number;
  3861. /**
  3862. * Normalize in place the current quaternion
  3863. * @returns the current updated quaternion
  3864. */
  3865. normalize(): Quaternion;
  3866. /**
  3867. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3868. * @param order is a reserved parameter and is ignore for now
  3869. * @returns a new Vector3 containing the Euler angles
  3870. */
  3871. toEulerAngles(order?: string): Vector3;
  3872. /**
  3873. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3874. * @param result defines the vector which will be filled with the Euler angles
  3875. * @param order is a reserved parameter and is ignore for now
  3876. * @returns the current unchanged quaternion
  3877. */
  3878. toEulerAnglesToRef(result: Vector3): Quaternion;
  3879. /**
  3880. * Updates the given rotation matrix with the current quaternion values
  3881. * @param result defines the target matrix
  3882. * @returns the current unchanged quaternion
  3883. */
  3884. toRotationMatrix(result: Matrix): Quaternion;
  3885. /**
  3886. * Updates the current quaternion from the given rotation matrix values
  3887. * @param matrix defines the source matrix
  3888. * @returns the current updated quaternion
  3889. */
  3890. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3891. /**
  3892. * Creates a new quaternion from a rotation matrix
  3893. * @param matrix defines the source matrix
  3894. * @returns a new quaternion created from the given rotation matrix values
  3895. */
  3896. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3897. /**
  3898. * Updates the given quaternion with the given rotation matrix values
  3899. * @param matrix defines the source matrix
  3900. * @param result defines the target quaternion
  3901. */
  3902. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3903. /**
  3904. * Returns the dot product (float) between the quaternions "left" and "right"
  3905. * @param left defines the left operand
  3906. * @param right defines the right operand
  3907. * @returns the dot product
  3908. */
  3909. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3910. /**
  3911. * Checks if the two quaternions are close to each other
  3912. * @param quat0 defines the first quaternion to check
  3913. * @param quat1 defines the second quaternion to check
  3914. * @returns true if the two quaternions are close to each other
  3915. */
  3916. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3917. /**
  3918. * Creates an empty quaternion
  3919. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3920. */
  3921. static Zero(): Quaternion;
  3922. /**
  3923. * Inverse a given quaternion
  3924. * @param q defines the source quaternion
  3925. * @returns a new quaternion as the inverted current quaternion
  3926. */
  3927. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3928. /**
  3929. * Inverse a given quaternion
  3930. * @param q defines the source quaternion
  3931. * @param result the quaternion the result will be stored in
  3932. * @returns the result quaternion
  3933. */
  3934. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3935. /**
  3936. * Creates an identity quaternion
  3937. * @returns the identity quaternion
  3938. */
  3939. static Identity(): Quaternion;
  3940. /**
  3941. * Gets a boolean indicating if the given quaternion is identity
  3942. * @param quaternion defines the quaternion to check
  3943. * @returns true if the quaternion is identity
  3944. */
  3945. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3946. /**
  3947. * Creates a quaternion from a rotation around an axis
  3948. * @param axis defines the axis to use
  3949. * @param angle defines the angle to use
  3950. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3951. */
  3952. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3953. /**
  3954. * Creates a rotation around an axis and stores it into the given quaternion
  3955. * @param axis defines the axis to use
  3956. * @param angle defines the angle to use
  3957. * @param result defines the target quaternion
  3958. * @returns the target quaternion
  3959. */
  3960. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3961. /**
  3962. * Creates a new quaternion from data stored into an array
  3963. * @param array defines the data source
  3964. * @param offset defines the offset in the source array where the data starts
  3965. * @returns a new quaternion
  3966. */
  3967. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3968. /**
  3969. * Updates the given quaternion "result" from the starting index of the given array.
  3970. * @param array the array to pull values from
  3971. * @param offset the offset into the array to start at
  3972. * @param result the quaternion to store the result in
  3973. */
  3974. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3975. /**
  3976. * Create a quaternion from Euler rotation angles
  3977. * @param x Pitch
  3978. * @param y Yaw
  3979. * @param z Roll
  3980. * @returns the new Quaternion
  3981. */
  3982. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3983. /**
  3984. * Updates a quaternion from Euler rotation angles
  3985. * @param x Pitch
  3986. * @param y Yaw
  3987. * @param z Roll
  3988. * @param result the quaternion to store the result
  3989. * @returns the updated quaternion
  3990. */
  3991. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3992. /**
  3993. * Create a quaternion from Euler rotation vector
  3994. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3995. * @returns the new Quaternion
  3996. */
  3997. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3998. /**
  3999. * Updates a quaternion from Euler rotation vector
  4000. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4001. * @param result the quaternion to store the result
  4002. * @returns the updated quaternion
  4003. */
  4004. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4005. /**
  4006. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4007. * @param yaw defines the rotation around Y axis
  4008. * @param pitch defines the rotation around X axis
  4009. * @param roll defines the rotation around Z axis
  4010. * @returns the new quaternion
  4011. */
  4012. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4013. /**
  4014. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4015. * @param yaw defines the rotation around Y axis
  4016. * @param pitch defines the rotation around X axis
  4017. * @param roll defines the rotation around Z axis
  4018. * @param result defines the target quaternion
  4019. */
  4020. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4021. /**
  4022. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4023. * @param alpha defines the rotation around first axis
  4024. * @param beta defines the rotation around second axis
  4025. * @param gamma defines the rotation around third axis
  4026. * @returns the new quaternion
  4027. */
  4028. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4029. /**
  4030. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4031. * @param alpha defines the rotation around first axis
  4032. * @param beta defines the rotation around second axis
  4033. * @param gamma defines the rotation around third axis
  4034. * @param result defines the target quaternion
  4035. */
  4036. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4037. /**
  4038. * 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)
  4039. * @param axis1 defines the first axis
  4040. * @param axis2 defines the second axis
  4041. * @param axis3 defines the third axis
  4042. * @returns the new quaternion
  4043. */
  4044. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4045. /**
  4046. * 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
  4047. * @param axis1 defines the first axis
  4048. * @param axis2 defines the second axis
  4049. * @param axis3 defines the third axis
  4050. * @param ref defines the target quaternion
  4051. */
  4052. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4053. /**
  4054. * Interpolates between two quaternions
  4055. * @param left defines first quaternion
  4056. * @param right defines second quaternion
  4057. * @param amount defines the gradient to use
  4058. * @returns the new interpolated quaternion
  4059. */
  4060. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4061. /**
  4062. * Interpolates between two quaternions and stores it into a target quaternion
  4063. * @param left defines first quaternion
  4064. * @param right defines second quaternion
  4065. * @param amount defines the gradient to use
  4066. * @param result defines the target quaternion
  4067. */
  4068. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4069. /**
  4070. * Interpolate between two quaternions using Hermite interpolation
  4071. * @param value1 defines first quaternion
  4072. * @param tangent1 defines the incoming tangent
  4073. * @param value2 defines second quaternion
  4074. * @param tangent2 defines the outgoing tangent
  4075. * @param amount defines the target quaternion
  4076. * @returns the new interpolated quaternion
  4077. */
  4078. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4079. }
  4080. /**
  4081. * Class used to store matrix data (4x4)
  4082. */
  4083. export class Matrix {
  4084. /**
  4085. * Gets the precision of matrix computations
  4086. */
  4087. static get Use64Bits(): boolean;
  4088. private static _updateFlagSeed;
  4089. private static _identityReadOnly;
  4090. private _isIdentity;
  4091. private _isIdentityDirty;
  4092. private _isIdentity3x2;
  4093. private _isIdentity3x2Dirty;
  4094. /**
  4095. * Gets the update flag of the matrix which is an unique number for the matrix.
  4096. * It will be incremented every time the matrix data change.
  4097. * You can use it to speed the comparison between two versions of the same matrix.
  4098. */
  4099. updateFlag: number;
  4100. private readonly _m;
  4101. /**
  4102. * Gets the internal data of the matrix
  4103. */
  4104. get m(): DeepImmutable<Float32Array | Array<number>>;
  4105. /** @hidden */
  4106. _markAsUpdated(): void;
  4107. /** @hidden */
  4108. private _updateIdentityStatus;
  4109. /**
  4110. * Creates an empty matrix (filled with zeros)
  4111. */
  4112. constructor();
  4113. /**
  4114. * Check if the current matrix is identity
  4115. * @returns true is the matrix is the identity matrix
  4116. */
  4117. isIdentity(): boolean;
  4118. /**
  4119. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4120. * @returns true is the matrix is the identity matrix
  4121. */
  4122. isIdentityAs3x2(): boolean;
  4123. /**
  4124. * Gets the determinant of the matrix
  4125. * @returns the matrix determinant
  4126. */
  4127. determinant(): number;
  4128. /**
  4129. * Returns the matrix as a Float32Array or Array<number>
  4130. * @returns the matrix underlying array
  4131. */
  4132. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4133. /**
  4134. * Returns the matrix as a Float32Array or Array<number>
  4135. * @returns the matrix underlying array.
  4136. */
  4137. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4138. /**
  4139. * Inverts the current matrix in place
  4140. * @returns the current inverted matrix
  4141. */
  4142. invert(): Matrix;
  4143. /**
  4144. * Sets all the matrix elements to zero
  4145. * @returns the current matrix
  4146. */
  4147. reset(): Matrix;
  4148. /**
  4149. * Adds the current matrix with a second one
  4150. * @param other defines the matrix to add
  4151. * @returns a new matrix as the addition of the current matrix and the given one
  4152. */
  4153. add(other: DeepImmutable<Matrix>): Matrix;
  4154. /**
  4155. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4156. * @param other defines the matrix to add
  4157. * @param result defines the target matrix
  4158. * @returns the current matrix
  4159. */
  4160. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4161. /**
  4162. * Adds in place the given matrix to the current matrix
  4163. * @param other defines the second operand
  4164. * @returns the current updated matrix
  4165. */
  4166. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4167. /**
  4168. * Sets the given matrix to the current inverted Matrix
  4169. * @param other defines the target matrix
  4170. * @returns the unmodified current matrix
  4171. */
  4172. invertToRef(other: Matrix): Matrix;
  4173. /**
  4174. * add a value at the specified position in the current Matrix
  4175. * @param index the index of the value within the matrix. between 0 and 15.
  4176. * @param value the value to be added
  4177. * @returns the current updated matrix
  4178. */
  4179. addAtIndex(index: number, value: number): Matrix;
  4180. /**
  4181. * mutiply the specified position in the current Matrix by a value
  4182. * @param index the index of the value within the matrix. between 0 and 15.
  4183. * @param value the value to be added
  4184. * @returns the current updated matrix
  4185. */
  4186. multiplyAtIndex(index: number, value: number): Matrix;
  4187. /**
  4188. * Inserts the translation vector (using 3 floats) in the current matrix
  4189. * @param x defines the 1st component of the translation
  4190. * @param y defines the 2nd component of the translation
  4191. * @param z defines the 3rd component of the translation
  4192. * @returns the current updated matrix
  4193. */
  4194. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4195. /**
  4196. * Adds the translation vector (using 3 floats) in the current matrix
  4197. * @param x defines the 1st component of the translation
  4198. * @param y defines the 2nd component of the translation
  4199. * @param z defines the 3rd component of the translation
  4200. * @returns the current updated matrix
  4201. */
  4202. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4203. /**
  4204. * Inserts the translation vector in the current matrix
  4205. * @param vector3 defines the translation to insert
  4206. * @returns the current updated matrix
  4207. */
  4208. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Gets the translation value of the current matrix
  4211. * @returns a new Vector3 as the extracted translation from the matrix
  4212. */
  4213. getTranslation(): Vector3;
  4214. /**
  4215. * Fill a Vector3 with the extracted translation from the matrix
  4216. * @param result defines the Vector3 where to store the translation
  4217. * @returns the current matrix
  4218. */
  4219. getTranslationToRef(result: Vector3): Matrix;
  4220. /**
  4221. * Remove rotation and scaling part from the matrix
  4222. * @returns the updated matrix
  4223. */
  4224. removeRotationAndScaling(): Matrix;
  4225. /**
  4226. * Multiply two matrices
  4227. * @param other defines the second operand
  4228. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4229. */
  4230. multiply(other: DeepImmutable<Matrix>): Matrix;
  4231. /**
  4232. * Copy the current matrix from the given one
  4233. * @param other defines the source matrix
  4234. * @returns the current updated matrix
  4235. */
  4236. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4237. /**
  4238. * Populates the given array from the starting index with the current matrix values
  4239. * @param array defines the target array
  4240. * @param offset defines the offset in the target array where to start storing values
  4241. * @returns the current matrix
  4242. */
  4243. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4244. /**
  4245. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4246. * @param other defines the second operand
  4247. * @param result defines the matrix where to store the multiplication
  4248. * @returns the current matrix
  4249. */
  4250. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4251. /**
  4252. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4253. * @param other defines the second operand
  4254. * @param result defines the array where to store the multiplication
  4255. * @param offset defines the offset in the target array where to start storing values
  4256. * @returns the current matrix
  4257. */
  4258. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4259. /**
  4260. * Check equality between this matrix and a second one
  4261. * @param value defines the second matrix to compare
  4262. * @returns true is the current matrix and the given one values are strictly equal
  4263. */
  4264. equals(value: DeepImmutable<Matrix>): boolean;
  4265. /**
  4266. * Clone the current matrix
  4267. * @returns a new matrix from the current matrix
  4268. */
  4269. clone(): Matrix;
  4270. /**
  4271. * Returns the name of the current matrix class
  4272. * @returns the string "Matrix"
  4273. */
  4274. getClassName(): string;
  4275. /**
  4276. * Gets the hash code of the current matrix
  4277. * @returns the hash code
  4278. */
  4279. getHashCode(): number;
  4280. /**
  4281. * Decomposes the current Matrix into a translation, rotation and scaling components
  4282. * @param scale defines the scale vector3 given as a reference to update
  4283. * @param rotation defines the rotation quaternion given as a reference to update
  4284. * @param translation defines the translation vector3 given as a reference to update
  4285. * @returns true if operation was successful
  4286. */
  4287. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4288. /**
  4289. * Gets specific row of the matrix
  4290. * @param index defines the number of the row to get
  4291. * @returns the index-th row of the current matrix as a new Vector4
  4292. */
  4293. getRow(index: number): Nullable<Vector4>;
  4294. /**
  4295. * Sets the index-th row of the current matrix to the vector4 values
  4296. * @param index defines the number of the row to set
  4297. * @param row defines the target vector4
  4298. * @returns the updated current matrix
  4299. */
  4300. setRow(index: number, row: Vector4): Matrix;
  4301. /**
  4302. * Compute the transpose of the matrix
  4303. * @returns the new transposed matrix
  4304. */
  4305. transpose(): Matrix;
  4306. /**
  4307. * Compute the transpose of the matrix and store it in a given matrix
  4308. * @param result defines the target matrix
  4309. * @returns the current matrix
  4310. */
  4311. transposeToRef(result: Matrix): Matrix;
  4312. /**
  4313. * Sets the index-th row of the current matrix with the given 4 x float values
  4314. * @param index defines the row index
  4315. * @param x defines the x component to set
  4316. * @param y defines the y component to set
  4317. * @param z defines the z component to set
  4318. * @param w defines the w component to set
  4319. * @returns the updated current matrix
  4320. */
  4321. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4322. /**
  4323. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4324. * @param scale defines the scale factor
  4325. * @returns a new matrix
  4326. */
  4327. scale(scale: number): Matrix;
  4328. /**
  4329. * Scale the current matrix values by a factor to a given result matrix
  4330. * @param scale defines the scale factor
  4331. * @param result defines the matrix to store the result
  4332. * @returns the current matrix
  4333. */
  4334. scaleToRef(scale: number, result: Matrix): Matrix;
  4335. /**
  4336. * Scale the current matrix values by a factor and add the result to a given matrix
  4337. * @param scale defines the scale factor
  4338. * @param result defines the Matrix to store the result
  4339. * @returns the current matrix
  4340. */
  4341. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4342. /**
  4343. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4344. * @param ref matrix to store the result
  4345. */
  4346. toNormalMatrix(ref: Matrix): void;
  4347. /**
  4348. * Gets only rotation part of the current matrix
  4349. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4350. */
  4351. getRotationMatrix(): Matrix;
  4352. /**
  4353. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4354. * @param result defines the target matrix to store data to
  4355. * @returns the current matrix
  4356. */
  4357. getRotationMatrixToRef(result: Matrix): Matrix;
  4358. /**
  4359. * Toggles model matrix from being right handed to left handed in place and vice versa
  4360. */
  4361. toggleModelMatrixHandInPlace(): void;
  4362. /**
  4363. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4364. */
  4365. toggleProjectionMatrixHandInPlace(): void;
  4366. /**
  4367. * Creates a matrix from an array
  4368. * @param array defines the source array
  4369. * @param offset defines an offset in the source array
  4370. * @returns a new Matrix set from the starting index of the given array
  4371. */
  4372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4373. /**
  4374. * Copy the content of an array into a given matrix
  4375. * @param array defines the source array
  4376. * @param offset defines an offset in the source array
  4377. * @param result defines the target matrix
  4378. */
  4379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4380. /**
  4381. * Stores an array into a matrix after having multiplied each component by a given factor
  4382. * @param array defines the source array
  4383. * @param offset defines the offset in the source array
  4384. * @param scale defines the scaling factor
  4385. * @param result defines the target matrix
  4386. */
  4387. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4388. /**
  4389. * Gets an identity matrix that must not be updated
  4390. */
  4391. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4392. /**
  4393. * Stores a list of values (16) inside a given matrix
  4394. * @param initialM11 defines 1st value of 1st row
  4395. * @param initialM12 defines 2nd value of 1st row
  4396. * @param initialM13 defines 3rd value of 1st row
  4397. * @param initialM14 defines 4th value of 1st row
  4398. * @param initialM21 defines 1st value of 2nd row
  4399. * @param initialM22 defines 2nd value of 2nd row
  4400. * @param initialM23 defines 3rd value of 2nd row
  4401. * @param initialM24 defines 4th value of 2nd row
  4402. * @param initialM31 defines 1st value of 3rd row
  4403. * @param initialM32 defines 2nd value of 3rd row
  4404. * @param initialM33 defines 3rd value of 3rd row
  4405. * @param initialM34 defines 4th value of 3rd row
  4406. * @param initialM41 defines 1st value of 4th row
  4407. * @param initialM42 defines 2nd value of 4th row
  4408. * @param initialM43 defines 3rd value of 4th row
  4409. * @param initialM44 defines 4th value of 4th row
  4410. * @param result defines the target matrix
  4411. */
  4412. 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;
  4413. /**
  4414. * Creates new matrix from a list of values (16)
  4415. * @param initialM11 defines 1st value of 1st row
  4416. * @param initialM12 defines 2nd value of 1st row
  4417. * @param initialM13 defines 3rd value of 1st row
  4418. * @param initialM14 defines 4th value of 1st row
  4419. * @param initialM21 defines 1st value of 2nd row
  4420. * @param initialM22 defines 2nd value of 2nd row
  4421. * @param initialM23 defines 3rd value of 2nd row
  4422. * @param initialM24 defines 4th value of 2nd row
  4423. * @param initialM31 defines 1st value of 3rd row
  4424. * @param initialM32 defines 2nd value of 3rd row
  4425. * @param initialM33 defines 3rd value of 3rd row
  4426. * @param initialM34 defines 4th value of 3rd row
  4427. * @param initialM41 defines 1st value of 4th row
  4428. * @param initialM42 defines 2nd value of 4th row
  4429. * @param initialM43 defines 3rd value of 4th row
  4430. * @param initialM44 defines 4th value of 4th row
  4431. * @returns the new matrix
  4432. */
  4433. 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;
  4434. /**
  4435. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4436. * @param scale defines the scale vector3
  4437. * @param rotation defines the rotation quaternion
  4438. * @param translation defines the translation vector3
  4439. * @returns a new matrix
  4440. */
  4441. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4444. * @param scale defines the scale vector3
  4445. * @param rotation defines the rotation quaternion
  4446. * @param translation defines the translation vector3
  4447. * @param result defines the target matrix
  4448. */
  4449. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4450. /**
  4451. * Creates a new identity matrix
  4452. * @returns a new identity matrix
  4453. */
  4454. static Identity(): Matrix;
  4455. /**
  4456. * Creates a new identity matrix and stores the result in a given matrix
  4457. * @param result defines the target matrix
  4458. */
  4459. static IdentityToRef(result: Matrix): void;
  4460. /**
  4461. * Creates a new zero matrix
  4462. * @returns a new zero matrix
  4463. */
  4464. static Zero(): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the X axis
  4467. * @param angle defines the angle (in radians) to use
  4468. * @return the new matrix
  4469. */
  4470. static RotationX(angle: number): Matrix;
  4471. /**
  4472. * Creates a new matrix as the invert of a given matrix
  4473. * @param source defines the source matrix
  4474. * @returns the new matrix
  4475. */
  4476. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4477. /**
  4478. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4479. * @param angle defines the angle (in radians) to use
  4480. * @param result defines the target matrix
  4481. */
  4482. static RotationXToRef(angle: number, result: Matrix): void;
  4483. /**
  4484. * Creates a new rotation matrix for "angle" radians around the Y axis
  4485. * @param angle defines the angle (in radians) to use
  4486. * @return the new matrix
  4487. */
  4488. static RotationY(angle: number): Matrix;
  4489. /**
  4490. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4491. * @param angle defines the angle (in radians) to use
  4492. * @param result defines the target matrix
  4493. */
  4494. static RotationYToRef(angle: number, result: Matrix): void;
  4495. /**
  4496. * Creates a new rotation matrix for "angle" radians around the Z axis
  4497. * @param angle defines the angle (in radians) to use
  4498. * @return the new matrix
  4499. */
  4500. static RotationZ(angle: number): Matrix;
  4501. /**
  4502. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4503. * @param angle defines the angle (in radians) to use
  4504. * @param result defines the target matrix
  4505. */
  4506. static RotationZToRef(angle: number, result: Matrix): void;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the given axis
  4509. * @param axis defines the axis to use
  4510. * @param angle defines the angle (in radians) to use
  4511. * @return the new matrix
  4512. */
  4513. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4514. /**
  4515. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4516. * @param axis defines the axis to use
  4517. * @param angle defines the angle (in radians) to use
  4518. * @param result defines the target matrix
  4519. */
  4520. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4521. /**
  4522. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4523. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4524. * @param from defines the vector to align
  4525. * @param to defines the vector to align to
  4526. * @param result defines the target matrix
  4527. */
  4528. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4529. /**
  4530. * Creates a rotation matrix
  4531. * @param yaw defines the yaw angle in radians (Y axis)
  4532. * @param pitch defines the pitch angle in radians (X axis)
  4533. * @param roll defines the roll angle in radians (Z axis)
  4534. * @returns the new rotation matrix
  4535. */
  4536. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4537. /**
  4538. * Creates a rotation matrix and stores it in a given matrix
  4539. * @param yaw defines the yaw angle in radians (Y axis)
  4540. * @param pitch defines the pitch angle in radians (X axis)
  4541. * @param roll defines the roll angle in radians (Z axis)
  4542. * @param result defines the target matrix
  4543. */
  4544. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4545. /**
  4546. * Creates a scaling matrix
  4547. * @param x defines the scale factor on X axis
  4548. * @param y defines the scale factor on Y axis
  4549. * @param z defines the scale factor on Z axis
  4550. * @returns the new matrix
  4551. */
  4552. static Scaling(x: number, y: number, z: number): Matrix;
  4553. /**
  4554. * Creates a scaling matrix and stores it in a given matrix
  4555. * @param x defines the scale factor on X axis
  4556. * @param y defines the scale factor on Y axis
  4557. * @param z defines the scale factor on Z axis
  4558. * @param result defines the target matrix
  4559. */
  4560. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4561. /**
  4562. * Creates a translation matrix
  4563. * @param x defines the translation on X axis
  4564. * @param y defines the translation on Y axis
  4565. * @param z defines the translationon Z axis
  4566. * @returns the new matrix
  4567. */
  4568. static Translation(x: number, y: number, z: number): Matrix;
  4569. /**
  4570. * Creates a translation matrix and stores it in a given matrix
  4571. * @param x defines the translation on X axis
  4572. * @param y defines the translation on Y axis
  4573. * @param z defines the translationon Z axis
  4574. * @param result defines the target matrix
  4575. */
  4576. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4577. /**
  4578. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4579. * @param startValue defines the start value
  4580. * @param endValue defines the end value
  4581. * @param gradient defines the gradient factor
  4582. * @returns the new matrix
  4583. */
  4584. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4585. /**
  4586. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4587. * @param startValue defines the start value
  4588. * @param endValue defines the end value
  4589. * @param gradient defines the gradient factor
  4590. * @param result defines the Matrix object where to store data
  4591. */
  4592. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4593. /**
  4594. * Builds a new matrix whose values are computed by:
  4595. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4596. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4597. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4598. * @param startValue defines the first matrix
  4599. * @param endValue defines the second matrix
  4600. * @param gradient defines the gradient between the two matrices
  4601. * @returns the new matrix
  4602. */
  4603. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4604. /**
  4605. * Update a matrix to values which are computed by:
  4606. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4607. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4608. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4609. * @param startValue defines the first matrix
  4610. * @param endValue defines the second matrix
  4611. * @param gradient defines the gradient between the two matrices
  4612. * @param result defines the target matrix
  4613. */
  4614. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4615. /**
  4616. * 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"
  4617. * This function works in left handed mode
  4618. * @param eye defines the final position of the entity
  4619. * @param target defines where the entity should look at
  4620. * @param up defines the up vector for the entity
  4621. * @returns the new matrix
  4622. */
  4623. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4624. /**
  4625. * 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".
  4626. * This function works in left handed mode
  4627. * @param eye defines the final position of the entity
  4628. * @param target defines where the entity should look at
  4629. * @param up defines the up vector for the entity
  4630. * @param result defines the target matrix
  4631. */
  4632. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4633. /**
  4634. * 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"
  4635. * This function works in right handed mode
  4636. * @param eye defines the final position of the entity
  4637. * @param target defines where the entity should look at
  4638. * @param up defines the up vector for the entity
  4639. * @returns the new matrix
  4640. */
  4641. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4642. /**
  4643. * 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".
  4644. * This function works in right handed mode
  4645. * @param eye defines the final position of the entity
  4646. * @param target defines where the entity should look at
  4647. * @param up defines the up vector for the entity
  4648. * @param result defines the target matrix
  4649. */
  4650. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4651. /**
  4652. * Create a left-handed orthographic projection matrix
  4653. * @param width defines the viewport width
  4654. * @param height defines the viewport height
  4655. * @param znear defines the near clip plane
  4656. * @param zfar defines the far clip plane
  4657. * @returns a new matrix as a left-handed orthographic projection matrix
  4658. */
  4659. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4660. /**
  4661. * Store a left-handed orthographic projection to a given matrix
  4662. * @param width defines the viewport width
  4663. * @param height defines the viewport height
  4664. * @param znear defines the near clip plane
  4665. * @param zfar defines the far clip plane
  4666. * @param result defines the target matrix
  4667. */
  4668. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4669. /**
  4670. * Create a left-handed orthographic projection matrix
  4671. * @param left defines the viewport left coordinate
  4672. * @param right defines the viewport right coordinate
  4673. * @param bottom defines the viewport bottom coordinate
  4674. * @param top defines the viewport top coordinate
  4675. * @param znear defines the near clip plane
  4676. * @param zfar defines the far clip plane
  4677. * @returns a new matrix as a left-handed orthographic projection matrix
  4678. */
  4679. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4680. /**
  4681. * Stores a left-handed orthographic projection into a given matrix
  4682. * @param left defines the viewport left coordinate
  4683. * @param right defines the viewport right coordinate
  4684. * @param bottom defines the viewport bottom coordinate
  4685. * @param top defines the viewport top coordinate
  4686. * @param znear defines the near clip plane
  4687. * @param zfar defines the far clip plane
  4688. * @param result defines the target matrix
  4689. */
  4690. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4691. /**
  4692. * Creates a right-handed orthographic projection matrix
  4693. * @param left defines the viewport left coordinate
  4694. * @param right defines the viewport right coordinate
  4695. * @param bottom defines the viewport bottom coordinate
  4696. * @param top defines the viewport top coordinate
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a right-handed orthographic projection matrix
  4700. */
  4701. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Stores a right-handed orthographic projection into a given matrix
  4704. * @param left defines the viewport left coordinate
  4705. * @param right defines the viewport right coordinate
  4706. * @param bottom defines the viewport bottom coordinate
  4707. * @param top defines the viewport top coordinate
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. */
  4712. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4713. /**
  4714. * Creates a left-handed perspective projection matrix
  4715. * @param width defines the viewport width
  4716. * @param height defines the viewport height
  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 perspective projection matrix
  4720. */
  4721. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4722. /**
  4723. * Creates a left-handed perspective projection matrix
  4724. * @param fov defines the horizontal field of view
  4725. * @param aspect defines the aspect ratio
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @returns a new matrix as a left-handed perspective projection matrix
  4729. */
  4730. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4731. /**
  4732. * Stores a left-handed perspective projection into a given matrix
  4733. * @param fov defines the horizontal field of view
  4734. * @param aspect defines the aspect ratio
  4735. * @param znear defines the near clip plane
  4736. * @param zfar defines the far clip plane
  4737. * @param result defines the target matrix
  4738. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4739. */
  4740. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4741. /**
  4742. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4743. * @param fov defines the horizontal field of view
  4744. * @param aspect defines the aspect ratio
  4745. * @param znear defines the near clip plane
  4746. * @param zfar not used as infinity is used as far clip
  4747. * @param result defines the target matrix
  4748. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4749. */
  4750. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4751. /**
  4752. * Creates a right-handed perspective projection matrix
  4753. * @param fov defines the horizontal field of view
  4754. * @param aspect defines the aspect ratio
  4755. * @param znear defines the near clip plane
  4756. * @param zfar defines the far clip plane
  4757. * @returns a new matrix as a right-handed perspective projection matrix
  4758. */
  4759. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4760. /**
  4761. * Stores a right-handed perspective projection into a given matrix
  4762. * @param fov defines the horizontal field of view
  4763. * @param aspect defines the aspect ratio
  4764. * @param znear defines the near clip plane
  4765. * @param zfar defines the far clip plane
  4766. * @param result defines the target matrix
  4767. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4768. */
  4769. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4770. /**
  4771. * Stores a right-handed perspective projection into a given matrix
  4772. * @param fov defines the horizontal field of view
  4773. * @param aspect defines the aspect ratio
  4774. * @param znear defines the near clip plane
  4775. * @param zfar not used as infinity is used as far clip
  4776. * @param result defines the target matrix
  4777. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4778. */
  4779. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4780. /**
  4781. * Stores a perspective projection for WebVR info a given matrix
  4782. * @param fov defines the field of view
  4783. * @param znear defines the near clip plane
  4784. * @param zfar defines the far clip plane
  4785. * @param result defines the target matrix
  4786. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4787. */
  4788. static PerspectiveFovWebVRToRef(fov: {
  4789. upDegrees: number;
  4790. downDegrees: number;
  4791. leftDegrees: number;
  4792. rightDegrees: number;
  4793. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4794. /**
  4795. * Computes a complete transformation matrix
  4796. * @param viewport defines the viewport to use
  4797. * @param world defines the world matrix
  4798. * @param view defines the view matrix
  4799. * @param projection defines the projection matrix
  4800. * @param zmin defines the near clip plane
  4801. * @param zmax defines the far clip plane
  4802. * @returns the transformation matrix
  4803. */
  4804. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4805. /**
  4806. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4807. * @param matrix defines the matrix to use
  4808. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4809. */
  4810. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4811. /**
  4812. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4813. * @param matrix defines the matrix to use
  4814. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4815. */
  4816. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4817. /**
  4818. * Compute the transpose of a given matrix
  4819. * @param matrix defines the matrix to transpose
  4820. * @returns the new matrix
  4821. */
  4822. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4823. /**
  4824. * Compute the transpose of a matrix and store it in a target matrix
  4825. * @param matrix defines the matrix to transpose
  4826. * @param result defines the target matrix
  4827. */
  4828. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4829. /**
  4830. * Computes a reflection matrix from a plane
  4831. * @param plane defines the reflection plane
  4832. * @returns a new matrix
  4833. */
  4834. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4835. /**
  4836. * Computes a reflection matrix from a plane
  4837. * @param plane defines the reflection plane
  4838. * @param result defines the target matrix
  4839. */
  4840. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4841. /**
  4842. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4843. * @param xaxis defines the value of the 1st axis
  4844. * @param yaxis defines the value of the 2nd axis
  4845. * @param zaxis defines the value of the 3rd axis
  4846. * @param result defines the target matrix
  4847. */
  4848. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4849. /**
  4850. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4851. * @param quat defines the quaternion to use
  4852. * @param result defines the target matrix
  4853. */
  4854. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4855. }
  4856. /**
  4857. * @hidden
  4858. */
  4859. export class TmpVectors {
  4860. static Vector2: Vector2[];
  4861. static Vector3: Vector3[];
  4862. static Vector4: Vector4[];
  4863. static Quaternion: Quaternion[];
  4864. static Matrix: Matrix[];
  4865. }
  4866. }
  4867. declare module "babylonjs/Maths/math.path" {
  4868. import { DeepImmutable, Nullable } from "babylonjs/types";
  4869. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4870. /**
  4871. * Defines potential orientation for back face culling
  4872. */
  4873. export enum Orientation {
  4874. /**
  4875. * Clockwise
  4876. */
  4877. CW = 0,
  4878. /** Counter clockwise */
  4879. CCW = 1
  4880. }
  4881. /** Class used to represent a Bezier curve */
  4882. export class BezierCurve {
  4883. /**
  4884. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4885. * @param t defines the time
  4886. * @param x1 defines the left coordinate on X axis
  4887. * @param y1 defines the left coordinate on Y axis
  4888. * @param x2 defines the right coordinate on X axis
  4889. * @param y2 defines the right coordinate on Y axis
  4890. * @returns the interpolated value
  4891. */
  4892. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4893. }
  4894. /**
  4895. * Defines angle representation
  4896. */
  4897. export class Angle {
  4898. private _radians;
  4899. /**
  4900. * Creates an Angle object of "radians" radians (float).
  4901. * @param radians the angle in radians
  4902. */
  4903. constructor(radians: number);
  4904. /**
  4905. * Get value in degrees
  4906. * @returns the Angle value in degrees (float)
  4907. */
  4908. degrees(): number;
  4909. /**
  4910. * Get value in radians
  4911. * @returns the Angle value in radians (float)
  4912. */
  4913. radians(): number;
  4914. /**
  4915. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4916. * @param a defines first point as the origin
  4917. * @param b defines point
  4918. * @returns a new Angle
  4919. */
  4920. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4921. /**
  4922. * Gets a new Angle object from the given float in radians
  4923. * @param radians defines the angle value in radians
  4924. * @returns a new Angle
  4925. */
  4926. static FromRadians(radians: number): Angle;
  4927. /**
  4928. * Gets a new Angle object from the given float in degrees
  4929. * @param degrees defines the angle value in degrees
  4930. * @returns a new Angle
  4931. */
  4932. static FromDegrees(degrees: number): Angle;
  4933. }
  4934. /**
  4935. * This represents an arc in a 2d space.
  4936. */
  4937. export class Arc2 {
  4938. /** Defines the start point of the arc */
  4939. startPoint: Vector2;
  4940. /** Defines the mid point of the arc */
  4941. midPoint: Vector2;
  4942. /** Defines the end point of the arc */
  4943. endPoint: Vector2;
  4944. /**
  4945. * Defines the center point of the arc.
  4946. */
  4947. centerPoint: Vector2;
  4948. /**
  4949. * Defines the radius of the arc.
  4950. */
  4951. radius: number;
  4952. /**
  4953. * Defines the angle of the arc (from mid point to end point).
  4954. */
  4955. angle: Angle;
  4956. /**
  4957. * Defines the start angle of the arc (from start point to middle point).
  4958. */
  4959. startAngle: Angle;
  4960. /**
  4961. * Defines the orientation of the arc (clock wise/counter clock wise).
  4962. */
  4963. orientation: Orientation;
  4964. /**
  4965. * Creates an Arc object from the three given points : start, middle and end.
  4966. * @param startPoint Defines the start point of the arc
  4967. * @param midPoint Defines the midlle point of the arc
  4968. * @param endPoint Defines the end point of the arc
  4969. */
  4970. constructor(
  4971. /** Defines the start point of the arc */
  4972. startPoint: Vector2,
  4973. /** Defines the mid point of the arc */
  4974. midPoint: Vector2,
  4975. /** Defines the end point of the arc */
  4976. endPoint: Vector2);
  4977. }
  4978. /**
  4979. * Represents a 2D path made up of multiple 2D points
  4980. */
  4981. export class Path2 {
  4982. private _points;
  4983. private _length;
  4984. /**
  4985. * If the path start and end point are the same
  4986. */
  4987. closed: boolean;
  4988. /**
  4989. * Creates a Path2 object from the starting 2D coordinates x and y.
  4990. * @param x the starting points x value
  4991. * @param y the starting points y value
  4992. */
  4993. constructor(x: number, y: number);
  4994. /**
  4995. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4996. * @param x the added points x value
  4997. * @param y the added points y value
  4998. * @returns the updated Path2.
  4999. */
  5000. addLineTo(x: number, y: number): Path2;
  5001. /**
  5002. * 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.
  5003. * @param midX middle point x value
  5004. * @param midY middle point y value
  5005. * @param endX end point x value
  5006. * @param endY end point y value
  5007. * @param numberOfSegments (default: 36)
  5008. * @returns the updated Path2.
  5009. */
  5010. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5011. /**
  5012. * Closes the Path2.
  5013. * @returns the Path2.
  5014. */
  5015. close(): Path2;
  5016. /**
  5017. * Gets the sum of the distance between each sequential point in the path
  5018. * @returns the Path2 total length (float).
  5019. */
  5020. length(): number;
  5021. /**
  5022. * Gets the points which construct the path
  5023. * @returns the Path2 internal array of points.
  5024. */
  5025. getPoints(): Vector2[];
  5026. /**
  5027. * Retreives the point at the distance aways from the starting point
  5028. * @param normalizedLengthPosition the length along the path to retreive the point from
  5029. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5030. */
  5031. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5032. /**
  5033. * Creates a new path starting from an x and y position
  5034. * @param x starting x value
  5035. * @param y starting y value
  5036. * @returns a new Path2 starting at the coordinates (x, y).
  5037. */
  5038. static StartingAt(x: number, y: number): Path2;
  5039. }
  5040. /**
  5041. * Represents a 3D path made up of multiple 3D points
  5042. */
  5043. export class Path3D {
  5044. /**
  5045. * an array of Vector3, the curve axis of the Path3D
  5046. */
  5047. path: Vector3[];
  5048. private _curve;
  5049. private _distances;
  5050. private _tangents;
  5051. private _normals;
  5052. private _binormals;
  5053. private _raw;
  5054. private _alignTangentsWithPath;
  5055. private readonly _pointAtData;
  5056. /**
  5057. * new Path3D(path, normal, raw)
  5058. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5059. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5060. * @param path an array of Vector3, the curve axis of the Path3D
  5061. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5062. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5063. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5064. */
  5065. constructor(
  5066. /**
  5067. * an array of Vector3, the curve axis of the Path3D
  5068. */
  5069. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5070. /**
  5071. * Returns the Path3D array of successive Vector3 designing its curve.
  5072. * @returns the Path3D array of successive Vector3 designing its curve.
  5073. */
  5074. getCurve(): Vector3[];
  5075. /**
  5076. * Returns the Path3D array of successive Vector3 designing its curve.
  5077. * @returns the Path3D array of successive Vector3 designing its curve.
  5078. */
  5079. getPoints(): Vector3[];
  5080. /**
  5081. * @returns the computed length (float) of the path.
  5082. */
  5083. length(): number;
  5084. /**
  5085. * Returns an array populated with tangent vectors on each Path3D curve point.
  5086. * @returns an array populated with tangent vectors on each Path3D curve point.
  5087. */
  5088. getTangents(): Vector3[];
  5089. /**
  5090. * Returns an array populated with normal vectors on each Path3D curve point.
  5091. * @returns an array populated with normal vectors on each Path3D curve point.
  5092. */
  5093. getNormals(): Vector3[];
  5094. /**
  5095. * Returns an array populated with binormal vectors on each Path3D curve point.
  5096. * @returns an array populated with binormal vectors on each Path3D curve point.
  5097. */
  5098. getBinormals(): Vector3[];
  5099. /**
  5100. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5101. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5102. */
  5103. getDistances(): number[];
  5104. /**
  5105. * Returns an interpolated point along this path
  5106. * @param position the position of the point along this path, from 0.0 to 1.0
  5107. * @returns a new Vector3 as the point
  5108. */
  5109. getPointAt(position: number): Vector3;
  5110. /**
  5111. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5112. * @param position the position of the point along this path, from 0.0 to 1.0
  5113. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5114. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5115. */
  5116. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5117. /**
  5118. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5119. * @param position the position of the point along this path, from 0.0 to 1.0
  5120. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5121. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5122. */
  5123. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5124. /**
  5125. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5126. * @param position the position of the point along this path, from 0.0 to 1.0
  5127. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5128. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5129. */
  5130. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5131. /**
  5132. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5133. * @param position the position of the point along this path, from 0.0 to 1.0
  5134. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5135. */
  5136. getDistanceAt(position: number): number;
  5137. /**
  5138. * Returns the array index of the previous point of an interpolated point along this path
  5139. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5140. * @returns the array index
  5141. */
  5142. getPreviousPointIndexAt(position: number): number;
  5143. /**
  5144. * 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)
  5145. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5146. * @returns the sub position
  5147. */
  5148. getSubPositionAt(position: number): number;
  5149. /**
  5150. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5151. * @param target the vector of which to get the closest position to
  5152. * @returns the position of the closest virtual point on this path to the target vector
  5153. */
  5154. getClosestPositionTo(target: Vector3): number;
  5155. /**
  5156. * Returns a sub path (slice) of this path
  5157. * @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
  5158. * @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
  5159. * @returns a sub path (slice) of this path
  5160. */
  5161. slice(start?: number, end?: number): Path3D;
  5162. /**
  5163. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5164. * @param path path which all values are copied into the curves points
  5165. * @param firstNormal which should be projected onto the curve
  5166. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5167. * @returns the same object updated.
  5168. */
  5169. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5170. private _compute;
  5171. private _getFirstNonNullVector;
  5172. private _getLastNonNullVector;
  5173. private _normalVector;
  5174. /**
  5175. * Updates the point at data for an interpolated point along this curve
  5176. * @param position the position of the point along this curve, from 0.0 to 1.0
  5177. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5178. * @returns the (updated) point at data
  5179. */
  5180. private _updatePointAtData;
  5181. /**
  5182. * Updates the point at data from the specified parameters
  5183. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5184. * @param point the interpolated point
  5185. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5186. */
  5187. private _setPointAtData;
  5188. /**
  5189. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5190. */
  5191. private _updateInterpolationMatrix;
  5192. }
  5193. /**
  5194. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5195. * A Curve3 is designed from a series of successive Vector3.
  5196. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5197. */
  5198. export class Curve3 {
  5199. private _points;
  5200. private _length;
  5201. /**
  5202. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5203. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5204. * @param v1 (Vector3) the control point
  5205. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5206. * @param nbPoints (integer) the wanted number of points in the curve
  5207. * @returns the created Curve3
  5208. */
  5209. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5210. /**
  5211. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5212. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5213. * @param v1 (Vector3) the first control point
  5214. * @param v2 (Vector3) the second control point
  5215. * @param v3 (Vector3) the end point of the Cubic Bezier
  5216. * @param nbPoints (integer) the wanted number of points in the curve
  5217. * @returns the created Curve3
  5218. */
  5219. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5220. /**
  5221. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5222. * @param p1 (Vector3) the origin point of the Hermite Spline
  5223. * @param t1 (Vector3) the tangent vector at the origin point
  5224. * @param p2 (Vector3) the end point of the Hermite Spline
  5225. * @param t2 (Vector3) the tangent vector at the end point
  5226. * @param nbPoints (integer) the wanted number of points in the curve
  5227. * @returns the created Curve3
  5228. */
  5229. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5230. /**
  5231. * Returns a Curve3 object along a CatmullRom Spline curve :
  5232. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5233. * @param nbPoints (integer) the wanted number of points between each curve control points
  5234. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5238. /**
  5239. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5240. * A Curve3 is designed from a series of successive Vector3.
  5241. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5242. * @param points points which make up the curve
  5243. */
  5244. constructor(points: Vector3[]);
  5245. /**
  5246. * @returns the Curve3 stored array of successive Vector3
  5247. */
  5248. getPoints(): Vector3[];
  5249. /**
  5250. * @returns the computed length (float) of the curve.
  5251. */
  5252. length(): number;
  5253. /**
  5254. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5255. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5256. * curveA and curveB keep unchanged.
  5257. * @param curve the curve to continue from this curve
  5258. * @returns the newly constructed curve
  5259. */
  5260. continue(curve: DeepImmutable<Curve3>): Curve3;
  5261. private _computeLength;
  5262. }
  5263. }
  5264. declare module "babylonjs/Animations/easing" {
  5265. /**
  5266. * This represents the main contract an easing function should follow.
  5267. * Easing functions are used throughout the animation system.
  5268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export interface IEasingFunction {
  5271. /**
  5272. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5273. * of the easing function.
  5274. * The link below provides some of the most common examples of easing functions.
  5275. * @see https://easings.net/
  5276. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5277. * @returns the corresponding value on the curve defined by the easing function
  5278. */
  5279. ease(gradient: number): number;
  5280. }
  5281. /**
  5282. * Base class used for every default easing function.
  5283. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class EasingFunction implements IEasingFunction {
  5286. /**
  5287. * Interpolation follows the mathematical formula associated with the easing function.
  5288. */
  5289. static readonly EASINGMODE_EASEIN: number;
  5290. /**
  5291. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5292. */
  5293. static readonly EASINGMODE_EASEOUT: number;
  5294. /**
  5295. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5296. */
  5297. static readonly EASINGMODE_EASEINOUT: number;
  5298. private _easingMode;
  5299. /**
  5300. * Sets the easing mode of the current function.
  5301. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5302. */
  5303. setEasingMode(easingMode: number): void;
  5304. /**
  5305. * Gets the current easing mode.
  5306. * @returns the easing mode
  5307. */
  5308. getEasingMode(): number;
  5309. /**
  5310. * @hidden
  5311. */
  5312. easeInCore(gradient: number): number;
  5313. /**
  5314. * Given an input gradient between 0 and 1, this returns the corresponding value
  5315. * of the easing function.
  5316. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5317. * @returns the corresponding value on the curve defined by the easing function
  5318. */
  5319. ease(gradient: number): number;
  5320. }
  5321. /**
  5322. * Easing function with a circle shape (see link below).
  5323. * @see https://easings.net/#easeInCirc
  5324. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5325. */
  5326. export class CircleEase extends EasingFunction implements IEasingFunction {
  5327. /** @hidden */
  5328. easeInCore(gradient: number): number;
  5329. }
  5330. /**
  5331. * Easing function with a ease back shape (see link below).
  5332. * @see https://easings.net/#easeInBack
  5333. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5334. */
  5335. export class BackEase extends EasingFunction implements IEasingFunction {
  5336. /** Defines the amplitude of the function */
  5337. amplitude: number;
  5338. /**
  5339. * Instantiates a back ease easing
  5340. * @see https://easings.net/#easeInBack
  5341. * @param amplitude Defines the amplitude of the function
  5342. */
  5343. constructor(
  5344. /** Defines the amplitude of the function */
  5345. amplitude?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a bouncing shape (see link below).
  5351. * @see https://easings.net/#easeInBounce
  5352. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class BounceEase extends EasingFunction implements IEasingFunction {
  5355. /** Defines the number of bounces */
  5356. bounces: number;
  5357. /** Defines the amplitude of the bounce */
  5358. bounciness: number;
  5359. /**
  5360. * Instantiates a bounce easing
  5361. * @see https://easings.net/#easeInBounce
  5362. * @param bounces Defines the number of bounces
  5363. * @param bounciness Defines the amplitude of the bounce
  5364. */
  5365. constructor(
  5366. /** Defines the number of bounces */
  5367. bounces?: number,
  5368. /** Defines the amplitude of the bounce */
  5369. bounciness?: number);
  5370. /** @hidden */
  5371. easeInCore(gradient: number): number;
  5372. }
  5373. /**
  5374. * Easing function with a power of 3 shape (see link below).
  5375. * @see https://easings.net/#easeInCubic
  5376. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5377. */
  5378. export class CubicEase extends EasingFunction implements IEasingFunction {
  5379. /** @hidden */
  5380. easeInCore(gradient: number): number;
  5381. }
  5382. /**
  5383. * Easing function with an elastic shape (see link below).
  5384. * @see https://easings.net/#easeInElastic
  5385. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5386. */
  5387. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5388. /** Defines the number of oscillations*/
  5389. oscillations: number;
  5390. /** Defines the amplitude of the oscillations*/
  5391. springiness: number;
  5392. /**
  5393. * Instantiates an elastic easing function
  5394. * @see https://easings.net/#easeInElastic
  5395. * @param oscillations Defines the number of oscillations
  5396. * @param springiness Defines the amplitude of the oscillations
  5397. */
  5398. constructor(
  5399. /** Defines the number of oscillations*/
  5400. oscillations?: number,
  5401. /** Defines the amplitude of the oscillations*/
  5402. springiness?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with an exponential shape (see link below).
  5408. * @see https://easings.net/#easeInExpo
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5412. /** Defines the exponent of the function */
  5413. exponent: number;
  5414. /**
  5415. * Instantiates an exponential easing function
  5416. * @see https://easings.net/#easeInExpo
  5417. * @param exponent Defines the exponent of the function
  5418. */
  5419. constructor(
  5420. /** Defines the exponent of the function */
  5421. exponent?: number);
  5422. /** @hidden */
  5423. easeInCore(gradient: number): number;
  5424. }
  5425. /**
  5426. * Easing function with a power shape (see link below).
  5427. * @see https://easings.net/#easeInQuad
  5428. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5429. */
  5430. export class PowerEase extends EasingFunction implements IEasingFunction {
  5431. /** Defines the power of the function */
  5432. power: number;
  5433. /**
  5434. * Instantiates an power base easing function
  5435. * @see https://easings.net/#easeInQuad
  5436. * @param power Defines the power of the function
  5437. */
  5438. constructor(
  5439. /** Defines the power of the function */
  5440. power?: number);
  5441. /** @hidden */
  5442. easeInCore(gradient: number): number;
  5443. }
  5444. /**
  5445. * Easing function with a power of 2 shape (see link below).
  5446. * @see https://easings.net/#easeInQuad
  5447. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5448. */
  5449. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5450. /** @hidden */
  5451. easeInCore(gradient: number): number;
  5452. }
  5453. /**
  5454. * Easing function with a power of 4 shape (see link below).
  5455. * @see https://easings.net/#easeInQuart
  5456. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5457. */
  5458. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5459. /** @hidden */
  5460. easeInCore(gradient: number): number;
  5461. }
  5462. /**
  5463. * Easing function with a power of 5 shape (see link below).
  5464. * @see https://easings.net/#easeInQuint
  5465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5466. */
  5467. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5468. /** @hidden */
  5469. easeInCore(gradient: number): number;
  5470. }
  5471. /**
  5472. * Easing function with a sin shape (see link below).
  5473. * @see https://easings.net/#easeInSine
  5474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5475. */
  5476. export class SineEase extends EasingFunction implements IEasingFunction {
  5477. /** @hidden */
  5478. easeInCore(gradient: number): number;
  5479. }
  5480. /**
  5481. * Easing function with a bezier shape (see link below).
  5482. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5484. */
  5485. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5486. /** Defines the x component of the start tangent in the bezier curve */
  5487. x1: number;
  5488. /** Defines the y component of the start tangent in the bezier curve */
  5489. y1: number;
  5490. /** Defines the x component of the end tangent in the bezier curve */
  5491. x2: number;
  5492. /** Defines the y component of the end tangent in the bezier curve */
  5493. y2: number;
  5494. /**
  5495. * Instantiates a bezier function
  5496. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5497. * @param x1 Defines the x component of the start tangent in the bezier curve
  5498. * @param y1 Defines the y component of the start tangent in the bezier curve
  5499. * @param x2 Defines the x component of the end tangent in the bezier curve
  5500. * @param y2 Defines the y component of the end tangent in the bezier curve
  5501. */
  5502. constructor(
  5503. /** Defines the x component of the start tangent in the bezier curve */
  5504. x1?: number,
  5505. /** Defines the y component of the start tangent in the bezier curve */
  5506. y1?: number,
  5507. /** Defines the x component of the end tangent in the bezier curve */
  5508. x2?: number,
  5509. /** Defines the y component of the end tangent in the bezier curve */
  5510. y2?: number);
  5511. /** @hidden */
  5512. easeInCore(gradient: number): number;
  5513. }
  5514. }
  5515. declare module "babylonjs/Maths/math.color" {
  5516. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5517. /**
  5518. * Class used to hold a RBG color
  5519. */
  5520. export class Color3 {
  5521. /**
  5522. * Defines the red component (between 0 and 1, default is 0)
  5523. */
  5524. r: number;
  5525. /**
  5526. * Defines the green component (between 0 and 1, default is 0)
  5527. */
  5528. g: number;
  5529. /**
  5530. * Defines the blue component (between 0 and 1, default is 0)
  5531. */
  5532. b: number;
  5533. /**
  5534. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5535. * @param r defines the red component (between 0 and 1, default is 0)
  5536. * @param g defines the green component (between 0 and 1, default is 0)
  5537. * @param b defines the blue component (between 0 and 1, default is 0)
  5538. */
  5539. constructor(
  5540. /**
  5541. * Defines the red component (between 0 and 1, default is 0)
  5542. */
  5543. r?: number,
  5544. /**
  5545. * Defines the green component (between 0 and 1, default is 0)
  5546. */
  5547. g?: number,
  5548. /**
  5549. * Defines the blue component (between 0 and 1, default is 0)
  5550. */
  5551. b?: number);
  5552. /**
  5553. * Creates a string with the Color3 current values
  5554. * @returns the string representation of the Color3 object
  5555. */
  5556. toString(): string;
  5557. /**
  5558. * Returns the string "Color3"
  5559. * @returns "Color3"
  5560. */
  5561. getClassName(): string;
  5562. /**
  5563. * Compute the Color3 hash code
  5564. * @returns an unique number that can be used to hash Color3 objects
  5565. */
  5566. getHashCode(): number;
  5567. /**
  5568. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5569. * @param array defines the array where to store the r,g,b components
  5570. * @param index defines an optional index in the target array to define where to start storing values
  5571. * @returns the current Color3 object
  5572. */
  5573. toArray(array: FloatArray, index?: number): Color3;
  5574. /**
  5575. * Update the current color with values stored in an array from the starting index of the given array
  5576. * @param array defines the source array
  5577. * @param offset defines an offset in the source array
  5578. * @returns the current Color3 object
  5579. */
  5580. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5581. /**
  5582. * Returns a new Color4 object from the current Color3 and the given alpha
  5583. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5584. * @returns a new Color4 object
  5585. */
  5586. toColor4(alpha?: number): Color4;
  5587. /**
  5588. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5589. * @returns the new array
  5590. */
  5591. asArray(): number[];
  5592. /**
  5593. * Returns the luminance value
  5594. * @returns a float value
  5595. */
  5596. toLuminance(): number;
  5597. /**
  5598. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5599. * @param otherColor defines the second operand
  5600. * @returns the new Color3 object
  5601. */
  5602. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5603. /**
  5604. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5605. * @param otherColor defines the second operand
  5606. * @param result defines the Color3 object where to store the result
  5607. * @returns the current Color3
  5608. */
  5609. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5610. /**
  5611. * Determines equality between Color3 objects
  5612. * @param otherColor defines the second operand
  5613. * @returns true if the rgb values are equal to the given ones
  5614. */
  5615. equals(otherColor: DeepImmutable<Color3>): boolean;
  5616. /**
  5617. * Determines equality between the current Color3 object and a set of r,b,g values
  5618. * @param r defines the red component to check
  5619. * @param g defines the green component to check
  5620. * @param b defines the blue component to check
  5621. * @returns true if the rgb values are equal to the given ones
  5622. */
  5623. equalsFloats(r: number, g: number, b: number): boolean;
  5624. /**
  5625. * Multiplies in place each rgb value by scale
  5626. * @param scale defines the scaling factor
  5627. * @returns the updated Color3
  5628. */
  5629. scale(scale: number): Color3;
  5630. /**
  5631. * Multiplies the rgb values by scale and stores the result into "result"
  5632. * @param scale defines the scaling factor
  5633. * @param result defines the Color3 object where to store the result
  5634. * @returns the unmodified current Color3
  5635. */
  5636. scaleToRef(scale: number, result: Color3): Color3;
  5637. /**
  5638. * Scale the current Color3 values by a factor and add the result to a given Color3
  5639. * @param scale defines the scale factor
  5640. * @param result defines color to store the result into
  5641. * @returns the unmodified current Color3
  5642. */
  5643. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5644. /**
  5645. * Clamps the rgb values by the min and max values and stores the result into "result"
  5646. * @param min defines minimum clamping value (default is 0)
  5647. * @param max defines maximum clamping value (default is 1)
  5648. * @param result defines color to store the result into
  5649. * @returns the original Color3
  5650. */
  5651. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5652. /**
  5653. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5654. * @param otherColor defines the second operand
  5655. * @returns the new Color3
  5656. */
  5657. add(otherColor: DeepImmutable<Color3>): Color3;
  5658. /**
  5659. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5660. * @param otherColor defines the second operand
  5661. * @param result defines Color3 object to store the result into
  5662. * @returns the unmodified current Color3
  5663. */
  5664. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5665. /**
  5666. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5667. * @param otherColor defines the second operand
  5668. * @returns the new Color3
  5669. */
  5670. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5671. /**
  5672. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5673. * @param otherColor defines the second operand
  5674. * @param result defines Color3 object to store the result into
  5675. * @returns the unmodified current Color3
  5676. */
  5677. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5678. /**
  5679. * Copy the current object
  5680. * @returns a new Color3 copied the current one
  5681. */
  5682. clone(): Color3;
  5683. /**
  5684. * Copies the rgb values from the source in the current Color3
  5685. * @param source defines the source Color3 object
  5686. * @returns the updated Color3 object
  5687. */
  5688. copyFrom(source: DeepImmutable<Color3>): Color3;
  5689. /**
  5690. * Updates the Color3 rgb values from the given floats
  5691. * @param r defines the red component to read from
  5692. * @param g defines the green component to read from
  5693. * @param b defines the blue component to read from
  5694. * @returns the current Color3 object
  5695. */
  5696. copyFromFloats(r: number, g: number, b: number): Color3;
  5697. /**
  5698. * Updates the Color3 rgb values from the given floats
  5699. * @param r defines the red component to read from
  5700. * @param g defines the green component to read from
  5701. * @param b defines the blue component to read from
  5702. * @returns the current Color3 object
  5703. */
  5704. set(r: number, g: number, b: number): Color3;
  5705. /**
  5706. * Compute the Color3 hexadecimal code as a string
  5707. * @returns a string containing the hexadecimal representation of the Color3 object
  5708. */
  5709. toHexString(): string;
  5710. /**
  5711. * Computes a new Color3 converted from the current one to linear space
  5712. * @returns a new Color3 object
  5713. */
  5714. toLinearSpace(): Color3;
  5715. /**
  5716. * Converts current color in rgb space to HSV values
  5717. * @returns a new color3 representing the HSV values
  5718. */
  5719. toHSV(): Color3;
  5720. /**
  5721. * Converts current color in rgb space to HSV values
  5722. * @param result defines the Color3 where to store the HSV values
  5723. */
  5724. toHSVToRef(result: Color3): void;
  5725. /**
  5726. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5727. * @param convertedColor defines the Color3 object where to store the linear space version
  5728. * @returns the unmodified Color3
  5729. */
  5730. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5731. /**
  5732. * Computes a new Color3 converted from the current one to gamma space
  5733. * @returns a new Color3 object
  5734. */
  5735. toGammaSpace(): Color3;
  5736. /**
  5737. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5738. * @param convertedColor defines the Color3 object where to store the gamma space version
  5739. * @returns the unmodified Color3
  5740. */
  5741. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5742. private static _BlackReadOnly;
  5743. /**
  5744. * Convert Hue, saturation and value to a Color3 (RGB)
  5745. * @param hue defines the hue
  5746. * @param saturation defines the saturation
  5747. * @param value defines the value
  5748. * @param result defines the Color3 where to store the RGB values
  5749. */
  5750. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5751. /**
  5752. * Creates a new Color3 from the string containing valid hexadecimal values
  5753. * @param hex defines a string containing valid hexadecimal values
  5754. * @returns a new Color3 object
  5755. */
  5756. static FromHexString(hex: string): Color3;
  5757. /**
  5758. * Creates a new Color3 from the starting index of the given array
  5759. * @param array defines the source array
  5760. * @param offset defines an offset in the source array
  5761. * @returns a new Color3 object
  5762. */
  5763. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5764. /**
  5765. * Creates a new Color3 from the starting index element of the given array
  5766. * @param array defines the source array to read from
  5767. * @param offset defines the offset in the source array
  5768. * @param result defines the target Color3 object
  5769. */
  5770. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5771. /**
  5772. * Creates a new Color3 from integer values (< 256)
  5773. * @param r defines the red component to read from (value between 0 and 255)
  5774. * @param g defines the green component to read from (value between 0 and 255)
  5775. * @param b defines the blue component to read from (value between 0 and 255)
  5776. * @returns a new Color3 object
  5777. */
  5778. static FromInts(r: number, g: number, b: number): Color3;
  5779. /**
  5780. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5781. * @param start defines the start Color3 value
  5782. * @param end defines the end Color3 value
  5783. * @param amount defines the gradient value between start and end
  5784. * @returns a new Color3 object
  5785. */
  5786. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5787. /**
  5788. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5789. * @param left defines the start value
  5790. * @param right defines the end value
  5791. * @param amount defines the gradient factor
  5792. * @param result defines the Color3 object where to store the result
  5793. */
  5794. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5795. /**
  5796. * Returns a Color3 value containing a red color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Red(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a green color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Green(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a blue color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Blue(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a black color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Black(): Color3;
  5815. /**
  5816. * Gets a Color3 value containing a black color that must not be updated
  5817. */
  5818. static get BlackReadOnly(): DeepImmutable<Color3>;
  5819. /**
  5820. * Returns a Color3 value containing a white color
  5821. * @returns a new Color3 object
  5822. */
  5823. static White(): Color3;
  5824. /**
  5825. * Returns a Color3 value containing a purple color
  5826. * @returns a new Color3 object
  5827. */
  5828. static Purple(): Color3;
  5829. /**
  5830. * Returns a Color3 value containing a magenta color
  5831. * @returns a new Color3 object
  5832. */
  5833. static Magenta(): Color3;
  5834. /**
  5835. * Returns a Color3 value containing a yellow color
  5836. * @returns a new Color3 object
  5837. */
  5838. static Yellow(): Color3;
  5839. /**
  5840. * Returns a Color3 value containing a gray color
  5841. * @returns a new Color3 object
  5842. */
  5843. static Gray(): Color3;
  5844. /**
  5845. * Returns a Color3 value containing a teal color
  5846. * @returns a new Color3 object
  5847. */
  5848. static Teal(): Color3;
  5849. /**
  5850. * Returns a Color3 value containing a random color
  5851. * @returns a new Color3 object
  5852. */
  5853. static Random(): Color3;
  5854. }
  5855. /**
  5856. * Class used to hold a RBGA color
  5857. */
  5858. export class Color4 {
  5859. /**
  5860. * Defines the red component (between 0 and 1, default is 0)
  5861. */
  5862. r: number;
  5863. /**
  5864. * Defines the green component (between 0 and 1, default is 0)
  5865. */
  5866. g: number;
  5867. /**
  5868. * Defines the blue component (between 0 and 1, default is 0)
  5869. */
  5870. b: number;
  5871. /**
  5872. * Defines the alpha component (between 0 and 1, default is 1)
  5873. */
  5874. a: number;
  5875. /**
  5876. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5877. * @param r defines the red component (between 0 and 1, default is 0)
  5878. * @param g defines the green component (between 0 and 1, default is 0)
  5879. * @param b defines the blue component (between 0 and 1, default is 0)
  5880. * @param a defines the alpha component (between 0 and 1, default is 1)
  5881. */
  5882. constructor(
  5883. /**
  5884. * Defines the red component (between 0 and 1, default is 0)
  5885. */
  5886. r?: number,
  5887. /**
  5888. * Defines the green component (between 0 and 1, default is 0)
  5889. */
  5890. g?: number,
  5891. /**
  5892. * Defines the blue component (between 0 and 1, default is 0)
  5893. */
  5894. b?: number,
  5895. /**
  5896. * Defines the alpha component (between 0 and 1, default is 1)
  5897. */
  5898. a?: number);
  5899. /**
  5900. * Adds in place the given Color4 values to the current Color4 object
  5901. * @param right defines the second operand
  5902. * @returns the current updated Color4 object
  5903. */
  5904. addInPlace(right: DeepImmutable<Color4>): Color4;
  5905. /**
  5906. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5907. * @returns the new array
  5908. */
  5909. asArray(): number[];
  5910. /**
  5911. * Stores from the starting index in the given array the Color4 successive values
  5912. * @param array defines the array where to store the r,g,b components
  5913. * @param index defines an optional index in the target array to define where to start storing values
  5914. * @returns the current Color4 object
  5915. */
  5916. toArray(array: number[], index?: number): Color4;
  5917. /**
  5918. * Update the current color with values stored in an array from the starting index of the given array
  5919. * @param array defines the source array
  5920. * @param offset defines an offset in the source array
  5921. * @returns the current Color4 object
  5922. */
  5923. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5924. /**
  5925. * Determines equality between Color4 objects
  5926. * @param otherColor defines the second operand
  5927. * @returns true if the rgba values are equal to the given ones
  5928. */
  5929. equals(otherColor: DeepImmutable<Color4>): boolean;
  5930. /**
  5931. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5932. * @param right defines the second operand
  5933. * @returns a new Color4 object
  5934. */
  5935. add(right: DeepImmutable<Color4>): Color4;
  5936. /**
  5937. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5938. * @param right defines the second operand
  5939. * @returns a new Color4 object
  5940. */
  5941. subtract(right: DeepImmutable<Color4>): Color4;
  5942. /**
  5943. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5944. * @param right defines the second operand
  5945. * @param result defines the Color4 object where to store the result
  5946. * @returns the current Color4 object
  5947. */
  5948. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5949. /**
  5950. * Creates a new Color4 with the current Color4 values multiplied by scale
  5951. * @param scale defines the scaling factor to apply
  5952. * @returns a new Color4 object
  5953. */
  5954. scale(scale: number): Color4;
  5955. /**
  5956. * Multiplies the current Color4 values by scale and stores the result in "result"
  5957. * @param scale defines the scaling factor to apply
  5958. * @param result defines the Color4 object where to store the result
  5959. * @returns the current unmodified Color4
  5960. */
  5961. scaleToRef(scale: number, result: Color4): Color4;
  5962. /**
  5963. * Scale the current Color4 values by a factor and add the result to a given Color4
  5964. * @param scale defines the scale factor
  5965. * @param result defines the Color4 object where to store the result
  5966. * @returns the unmodified current Color4
  5967. */
  5968. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5969. /**
  5970. * Clamps the rgb values by the min and max values and stores the result into "result"
  5971. * @param min defines minimum clamping value (default is 0)
  5972. * @param max defines maximum clamping value (default is 1)
  5973. * @param result defines color to store the result into.
  5974. * @returns the cuurent Color4
  5975. */
  5976. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5977. /**
  5978. * Multipy an Color4 value by another and return a new Color4 object
  5979. * @param color defines the Color4 value to multiply by
  5980. * @returns a new Color4 object
  5981. */
  5982. multiply(color: Color4): Color4;
  5983. /**
  5984. * Multipy a Color4 value by another and push the result in a reference value
  5985. * @param color defines the Color4 value to multiply by
  5986. * @param result defines the Color4 to fill the result in
  5987. * @returns the result Color4
  5988. */
  5989. multiplyToRef(color: Color4, result: Color4): Color4;
  5990. /**
  5991. * Creates a string with the Color4 current values
  5992. * @returns the string representation of the Color4 object
  5993. */
  5994. toString(): string;
  5995. /**
  5996. * Returns the string "Color4"
  5997. * @returns "Color4"
  5998. */
  5999. getClassName(): string;
  6000. /**
  6001. * Compute the Color4 hash code
  6002. * @returns an unique number that can be used to hash Color4 objects
  6003. */
  6004. getHashCode(): number;
  6005. /**
  6006. * Creates a new Color4 copied from the current one
  6007. * @returns a new Color4 object
  6008. */
  6009. clone(): Color4;
  6010. /**
  6011. * Copies the given Color4 values into the current one
  6012. * @param source defines the source Color4 object
  6013. * @returns the current updated Color4 object
  6014. */
  6015. copyFrom(source: Color4): Color4;
  6016. /**
  6017. * Copies the given float values into the current one
  6018. * @param r defines the red component to read from
  6019. * @param g defines the green component to read from
  6020. * @param b defines the blue component to read from
  6021. * @param a defines the alpha component to read from
  6022. * @returns the current updated Color4 object
  6023. */
  6024. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6025. /**
  6026. * Copies the given float values into the current one
  6027. * @param r defines the red component to read from
  6028. * @param g defines the green component to read from
  6029. * @param b defines the blue component to read from
  6030. * @param a defines the alpha component to read from
  6031. * @returns the current updated Color4 object
  6032. */
  6033. set(r: number, g: number, b: number, a: number): Color4;
  6034. /**
  6035. * Compute the Color4 hexadecimal code as a string
  6036. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6037. * @returns a string containing the hexadecimal representation of the Color4 object
  6038. */
  6039. toHexString(returnAsColor3?: boolean): string;
  6040. /**
  6041. * Computes a new Color4 converted from the current one to linear space
  6042. * @returns a new Color4 object
  6043. */
  6044. toLinearSpace(): Color4;
  6045. /**
  6046. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6047. * @param convertedColor defines the Color4 object where to store the linear space version
  6048. * @returns the unmodified Color4
  6049. */
  6050. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6051. /**
  6052. * Computes a new Color4 converted from the current one to gamma space
  6053. * @returns a new Color4 object
  6054. */
  6055. toGammaSpace(): Color4;
  6056. /**
  6057. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6058. * @param convertedColor defines the Color4 object where to store the gamma space version
  6059. * @returns the unmodified Color4
  6060. */
  6061. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6062. /**
  6063. * Creates a new Color4 from the string containing valid hexadecimal values
  6064. * @param hex defines a string containing valid hexadecimal values
  6065. * @returns a new Color4 object
  6066. */
  6067. static FromHexString(hex: string): Color4;
  6068. /**
  6069. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6070. * @param left defines the start value
  6071. * @param right defines the end value
  6072. * @param amount defines the gradient factor
  6073. * @returns a new Color4 object
  6074. */
  6075. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6076. /**
  6077. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6078. * @param left defines the start value
  6079. * @param right defines the end value
  6080. * @param amount defines the gradient factor
  6081. * @param result defines the Color4 object where to store data
  6082. */
  6083. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6084. /**
  6085. * Creates a new Color4 from a Color3 and an alpha value
  6086. * @param color3 defines the source Color3 to read from
  6087. * @param alpha defines the alpha component (1.0 by default)
  6088. * @returns a new Color4 object
  6089. */
  6090. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6091. /**
  6092. * Creates a new Color4 from the starting index element of the given array
  6093. * @param array defines the source array to read from
  6094. * @param offset defines the offset in the source array
  6095. * @returns a new Color4 object
  6096. */
  6097. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6098. /**
  6099. * Creates a new Color4 from the starting index element of the given array
  6100. * @param array defines the source array to read from
  6101. * @param offset defines the offset in the source array
  6102. * @param result defines the target Color4 object
  6103. */
  6104. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6105. /**
  6106. * Creates a new Color3 from integer values (< 256)
  6107. * @param r defines the red component to read from (value between 0 and 255)
  6108. * @param g defines the green component to read from (value between 0 and 255)
  6109. * @param b defines the blue component to read from (value between 0 and 255)
  6110. * @param a defines the alpha component to read from (value between 0 and 255)
  6111. * @returns a new Color3 object
  6112. */
  6113. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6114. /**
  6115. * Check the content of a given array and convert it to an array containing RGBA data
  6116. * If the original array was already containing count * 4 values then it is returned directly
  6117. * @param colors defines the array to check
  6118. * @param count defines the number of RGBA data to expect
  6119. * @returns an array containing count * 4 values (RGBA)
  6120. */
  6121. static CheckColors4(colors: number[], count: number): number[];
  6122. }
  6123. /**
  6124. * @hidden
  6125. */
  6126. export class TmpColors {
  6127. static Color3: Color3[];
  6128. static Color4: Color4[];
  6129. }
  6130. }
  6131. declare module "babylonjs/Animations/animationKey" {
  6132. /**
  6133. * Defines an interface which represents an animation key frame
  6134. */
  6135. export interface IAnimationKey {
  6136. /**
  6137. * Frame of the key frame
  6138. */
  6139. frame: number;
  6140. /**
  6141. * Value at the specifies key frame
  6142. */
  6143. value: any;
  6144. /**
  6145. * The input tangent for the cubic hermite spline
  6146. */
  6147. inTangent?: any;
  6148. /**
  6149. * The output tangent for the cubic hermite spline
  6150. */
  6151. outTangent?: any;
  6152. /**
  6153. * The animation interpolation type
  6154. */
  6155. interpolation?: AnimationKeyInterpolation;
  6156. }
  6157. /**
  6158. * Enum for the animation key frame interpolation type
  6159. */
  6160. export enum AnimationKeyInterpolation {
  6161. /**
  6162. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6163. */
  6164. STEP = 1
  6165. }
  6166. }
  6167. declare module "babylonjs/Animations/animationRange" {
  6168. /**
  6169. * Represents the range of an animation
  6170. */
  6171. export class AnimationRange {
  6172. /**The name of the animation range**/
  6173. name: string;
  6174. /**The starting frame of the animation */
  6175. from: number;
  6176. /**The ending frame of the animation*/
  6177. to: number;
  6178. /**
  6179. * Initializes the range of an animation
  6180. * @param name The name of the animation range
  6181. * @param from The starting frame of the animation
  6182. * @param to The ending frame of the animation
  6183. */
  6184. constructor(
  6185. /**The name of the animation range**/
  6186. name: string,
  6187. /**The starting frame of the animation */
  6188. from: number,
  6189. /**The ending frame of the animation*/
  6190. to: number);
  6191. /**
  6192. * Makes a copy of the animation range
  6193. * @returns A copy of the animation range
  6194. */
  6195. clone(): AnimationRange;
  6196. }
  6197. }
  6198. declare module "babylonjs/Animations/animationEvent" {
  6199. /**
  6200. * Composed of a frame, and an action function
  6201. */
  6202. export class AnimationEvent {
  6203. /** The frame for which the event is triggered **/
  6204. frame: number;
  6205. /** The event to perform when triggered **/
  6206. action: (currentFrame: number) => void;
  6207. /** Specifies if the event should be triggered only once**/
  6208. onlyOnce?: boolean | undefined;
  6209. /**
  6210. * Specifies if the animation event is done
  6211. */
  6212. isDone: boolean;
  6213. /**
  6214. * Initializes the animation event
  6215. * @param frame The frame for which the event is triggered
  6216. * @param action The event to perform when triggered
  6217. * @param onlyOnce Specifies if the event should be triggered only once
  6218. */
  6219. constructor(
  6220. /** The frame for which the event is triggered **/
  6221. frame: number,
  6222. /** The event to perform when triggered **/
  6223. action: (currentFrame: number) => void,
  6224. /** Specifies if the event should be triggered only once**/
  6225. onlyOnce?: boolean | undefined);
  6226. /** @hidden */
  6227. _clone(): AnimationEvent;
  6228. }
  6229. }
  6230. declare module "babylonjs/Behaviors/behavior" {
  6231. import { Nullable } from "babylonjs/types";
  6232. /**
  6233. * Interface used to define a behavior
  6234. */
  6235. export interface Behavior<T> {
  6236. /** gets or sets behavior's name */
  6237. name: string;
  6238. /**
  6239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6240. */
  6241. init(): void;
  6242. /**
  6243. * Called when the behavior is attached to a target
  6244. * @param target defines the target where the behavior is attached to
  6245. */
  6246. attach(target: T): void;
  6247. /**
  6248. * Called when the behavior is detached from its target
  6249. */
  6250. detach(): void;
  6251. }
  6252. /**
  6253. * Interface implemented by classes supporting behaviors
  6254. */
  6255. export interface IBehaviorAware<T> {
  6256. /**
  6257. * Attach a behavior
  6258. * @param behavior defines the behavior to attach
  6259. * @returns the current host
  6260. */
  6261. addBehavior(behavior: Behavior<T>): T;
  6262. /**
  6263. * Remove a behavior from the current object
  6264. * @param behavior defines the behavior to detach
  6265. * @returns the current host
  6266. */
  6267. removeBehavior(behavior: Behavior<T>): T;
  6268. /**
  6269. * Gets a behavior using its name to search
  6270. * @param name defines the name to search
  6271. * @returns the behavior or null if not found
  6272. */
  6273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6274. }
  6275. }
  6276. declare module "babylonjs/Misc/smartArray" {
  6277. /**
  6278. * Defines an array and its length.
  6279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6280. */
  6281. export interface ISmartArrayLike<T> {
  6282. /**
  6283. * The data of the array.
  6284. */
  6285. data: Array<T>;
  6286. /**
  6287. * The active length of the array.
  6288. */
  6289. length: number;
  6290. }
  6291. /**
  6292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6293. */
  6294. export class SmartArray<T> implements ISmartArrayLike<T> {
  6295. /**
  6296. * The full set of data from the array.
  6297. */
  6298. data: Array<T>;
  6299. /**
  6300. * The active length of the array.
  6301. */
  6302. length: number;
  6303. protected _id: number;
  6304. /**
  6305. * Instantiates a Smart Array.
  6306. * @param capacity defines the default capacity of the array.
  6307. */
  6308. constructor(capacity: number);
  6309. /**
  6310. * Pushes a value at the end of the active data.
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Iterates over the active data and apply the lambda to them.
  6316. * @param func defines the action to apply on each value.
  6317. */
  6318. forEach(func: (content: T) => void): void;
  6319. /**
  6320. * Sorts the full sets of data.
  6321. * @param compareFn defines the comparison function to apply.
  6322. */
  6323. sort(compareFn: (a: T, b: T) => number): void;
  6324. /**
  6325. * Resets the active data to an empty array.
  6326. */
  6327. reset(): void;
  6328. /**
  6329. * Releases all the data from the array as well as the array.
  6330. */
  6331. dispose(): void;
  6332. /**
  6333. * Concats the active data with a given array.
  6334. * @param array defines the data to concatenate with.
  6335. */
  6336. concat(array: any): void;
  6337. /**
  6338. * Returns the position of a value in the active data.
  6339. * @param value defines the value to find the index for
  6340. * @returns the index if found in the active data otherwise -1
  6341. */
  6342. indexOf(value: T): number;
  6343. /**
  6344. * Returns whether an element is part of the active data.
  6345. * @param value defines the value to look for
  6346. * @returns true if found in the active data otherwise false
  6347. */
  6348. contains(value: T): boolean;
  6349. private static _GlobalId;
  6350. }
  6351. /**
  6352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6353. * The data in this array can only be present once
  6354. */
  6355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6356. private _duplicateId;
  6357. /**
  6358. * Pushes a value at the end of the active data.
  6359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6360. * @param value defines the object to push in the array.
  6361. */
  6362. push(value: T): void;
  6363. /**
  6364. * Pushes a value at the end of the active data.
  6365. * If the data is already present, it won t be added again
  6366. * @param value defines the object to push in the array.
  6367. * @returns true if added false if it was already present
  6368. */
  6369. pushNoDuplicate(value: T): boolean;
  6370. /**
  6371. * Resets the active data to an empty array.
  6372. */
  6373. reset(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * This ensures no dupplicate will be present in the result.
  6377. * @param array defines the data to concatenate with.
  6378. */
  6379. concatWithNoDuplicate(array: any): void;
  6380. }
  6381. }
  6382. declare module "babylonjs/Cameras/cameraInputsManager" {
  6383. import { Nullable } from "babylonjs/types";
  6384. import { Camera } from "babylonjs/Cameras/camera";
  6385. /**
  6386. * @ignore
  6387. * This is a list of all the different input types that are available in the application.
  6388. * Fo instance: ArcRotateCameraGamepadInput...
  6389. */
  6390. export var CameraInputTypes: {};
  6391. /**
  6392. * This is the contract to implement in order to create a new input class.
  6393. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6394. */
  6395. export interface ICameraInput<TCamera extends Camera> {
  6396. /**
  6397. * Defines the camera the input is attached to.
  6398. */
  6399. camera: Nullable<TCamera>;
  6400. /**
  6401. * Gets the class name of the current intput.
  6402. * @returns the class name
  6403. */
  6404. getClassName(): string;
  6405. /**
  6406. * Get the friendly name associated with the input class.
  6407. * @returns the input friendly name
  6408. */
  6409. getSimpleName(): string;
  6410. /**
  6411. * Attach the input controls to a specific dom element to get the input from.
  6412. * @param element Defines the element the controls should be listened from
  6413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6414. */
  6415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6416. /**
  6417. * Detach the current controls from the specified dom element.
  6418. * @param element Defines the element to stop listening the inputs from
  6419. */
  6420. detachControl(element: Nullable<HTMLElement>): void;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs?: () => void;
  6426. }
  6427. /**
  6428. * Represents a map of input types to input instance or input index to input instance.
  6429. */
  6430. export interface CameraInputsMap<TCamera extends Camera> {
  6431. /**
  6432. * Accessor to the input by input type.
  6433. */
  6434. [name: string]: ICameraInput<TCamera>;
  6435. /**
  6436. * Accessor to the input by input index.
  6437. */
  6438. [idx: number]: ICameraInput<TCamera>;
  6439. }
  6440. /**
  6441. * This represents the input manager used within a camera.
  6442. * It helps dealing with all the different kind of input attached to a camera.
  6443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6444. */
  6445. export class CameraInputsManager<TCamera extends Camera> {
  6446. /**
  6447. * Defines the list of inputs attahed to the camera.
  6448. */
  6449. attached: CameraInputsMap<TCamera>;
  6450. /**
  6451. * Defines the dom element the camera is collecting inputs from.
  6452. * This is null if the controls have not been attached.
  6453. */
  6454. attachedElement: Nullable<HTMLElement>;
  6455. /**
  6456. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6457. */
  6458. noPreventDefault: boolean;
  6459. /**
  6460. * Defined the camera the input manager belongs to.
  6461. */
  6462. camera: TCamera;
  6463. /**
  6464. * Update the current camera state depending on the inputs that have been used this frame.
  6465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6466. */
  6467. checkInputs: () => void;
  6468. /**
  6469. * Instantiate a new Camera Input Manager.
  6470. * @param camera Defines the camera the input manager blongs to
  6471. */
  6472. constructor(camera: TCamera);
  6473. /**
  6474. * Add an input method to a camera
  6475. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6476. * @param input camera input method
  6477. */
  6478. add(input: ICameraInput<TCamera>): void;
  6479. /**
  6480. * Remove a specific input method from a camera
  6481. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6482. * @param inputToRemove camera input method
  6483. */
  6484. remove(inputToRemove: ICameraInput<TCamera>): void;
  6485. /**
  6486. * Remove a specific input type from a camera
  6487. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6488. * @param inputType the type of the input to remove
  6489. */
  6490. removeByType(inputType: string): void;
  6491. private _addCheckInputs;
  6492. /**
  6493. * Attach the input controls to the currently attached dom element to listen the events from.
  6494. * @param input Defines the input to attach
  6495. */
  6496. attachInput(input: ICameraInput<TCamera>): void;
  6497. /**
  6498. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6499. * @param element Defines the dom element to collect the events from
  6500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6501. */
  6502. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6503. /**
  6504. * Detach the current manager inputs controls from a specific dom element.
  6505. * @param element Defines the dom element to collect the events from
  6506. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6507. */
  6508. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6509. /**
  6510. * Rebuild the dynamic inputCheck function from the current list of
  6511. * defined inputs in the manager.
  6512. */
  6513. rebuildInputCheck(): void;
  6514. /**
  6515. * Remove all attached input methods from a camera
  6516. */
  6517. clear(): void;
  6518. /**
  6519. * Serialize the current input manager attached to a camera.
  6520. * This ensures than once parsed,
  6521. * the input associated to the camera will be identical to the current ones
  6522. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6523. */
  6524. serialize(serializedCamera: any): void;
  6525. /**
  6526. * Parses an input manager serialized JSON to restore the previous list of inputs
  6527. * and states associated to a camera.
  6528. * @param parsedCamera Defines the JSON to parse
  6529. */
  6530. parse(parsedCamera: any): void;
  6531. }
  6532. }
  6533. declare module "babylonjs/Meshes/buffer" {
  6534. import { Nullable, DataArray } from "babylonjs/types";
  6535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6536. /**
  6537. * Class used to store data that will be store in GPU memory
  6538. */
  6539. export class Buffer {
  6540. private _engine;
  6541. private _buffer;
  6542. /** @hidden */
  6543. _data: Nullable<DataArray>;
  6544. private _updatable;
  6545. private _instanced;
  6546. private _divisor;
  6547. /**
  6548. * Gets the byte stride.
  6549. */
  6550. readonly byteStride: number;
  6551. /**
  6552. * Constructor
  6553. * @param engine the engine
  6554. * @param data the data to use for this buffer
  6555. * @param updatable whether the data is updatable
  6556. * @param stride the stride (optional)
  6557. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6558. * @param instanced whether the buffer is instanced (optional)
  6559. * @param useBytes set to true if the stride in in bytes (optional)
  6560. * @param divisor sets an optional divisor for instances (1 by default)
  6561. */
  6562. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6563. /**
  6564. * Create a new VertexBuffer based on the current buffer
  6565. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6566. * @param offset defines offset in the buffer (0 by default)
  6567. * @param size defines the size in floats of attributes (position is 3 for instance)
  6568. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6569. * @param instanced defines if the vertex buffer contains indexed data
  6570. * @param useBytes defines if the offset and stride are in bytes *
  6571. * @param divisor sets an optional divisor for instances (1 by default)
  6572. * @returns the new vertex buffer
  6573. */
  6574. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6575. /**
  6576. * Gets a boolean indicating if the Buffer is updatable?
  6577. * @returns true if the buffer is updatable
  6578. */
  6579. isUpdatable(): boolean;
  6580. /**
  6581. * Gets current buffer's data
  6582. * @returns a DataArray or null
  6583. */
  6584. getData(): Nullable<DataArray>;
  6585. /**
  6586. * Gets underlying native buffer
  6587. * @returns underlying native buffer
  6588. */
  6589. getBuffer(): Nullable<DataBuffer>;
  6590. /**
  6591. * Gets the stride in float32 units (i.e. byte stride / 4).
  6592. * May not be an integer if the byte stride is not divisible by 4.
  6593. * @returns the stride in float32 units
  6594. * @deprecated Please use byteStride instead.
  6595. */
  6596. getStrideSize(): number;
  6597. /**
  6598. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6599. * @param data defines the data to store
  6600. */
  6601. create(data?: Nullable<DataArray>): void;
  6602. /** @hidden */
  6603. _rebuild(): void;
  6604. /**
  6605. * Update current buffer data
  6606. * @param data defines the data to store
  6607. */
  6608. update(data: DataArray): void;
  6609. /**
  6610. * Updates the data directly.
  6611. * @param data the new data
  6612. * @param offset the new offset
  6613. * @param vertexCount the vertex count (optional)
  6614. * @param useBytes set to true if the offset is in bytes
  6615. */
  6616. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6617. /**
  6618. * Release all resources
  6619. */
  6620. dispose(): void;
  6621. }
  6622. /**
  6623. * Specialized buffer used to store vertex data
  6624. */
  6625. export class VertexBuffer {
  6626. /** @hidden */
  6627. _buffer: Buffer;
  6628. private _kind;
  6629. private _size;
  6630. private _ownsBuffer;
  6631. private _instanced;
  6632. private _instanceDivisor;
  6633. /**
  6634. * The byte type.
  6635. */
  6636. static readonly BYTE: number;
  6637. /**
  6638. * The unsigned byte type.
  6639. */
  6640. static readonly UNSIGNED_BYTE: number;
  6641. /**
  6642. * The short type.
  6643. */
  6644. static readonly SHORT: number;
  6645. /**
  6646. * The unsigned short type.
  6647. */
  6648. static readonly UNSIGNED_SHORT: number;
  6649. /**
  6650. * The integer type.
  6651. */
  6652. static readonly INT: number;
  6653. /**
  6654. * The unsigned integer type.
  6655. */
  6656. static readonly UNSIGNED_INT: number;
  6657. /**
  6658. * The float type.
  6659. */
  6660. static readonly FLOAT: number;
  6661. /**
  6662. * Gets or sets the instance divisor when in instanced mode
  6663. */
  6664. get instanceDivisor(): number;
  6665. set instanceDivisor(value: number);
  6666. /**
  6667. * Gets the byte stride.
  6668. */
  6669. readonly byteStride: number;
  6670. /**
  6671. * Gets the byte offset.
  6672. */
  6673. readonly byteOffset: number;
  6674. /**
  6675. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6676. */
  6677. readonly normalized: boolean;
  6678. /**
  6679. * Gets the data type of each component in the array.
  6680. */
  6681. readonly type: number;
  6682. /**
  6683. * Constructor
  6684. * @param engine the engine
  6685. * @param data the data to use for this vertex buffer
  6686. * @param kind the vertex buffer kind
  6687. * @param updatable whether the data is updatable
  6688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6689. * @param stride the stride (optional)
  6690. * @param instanced whether the buffer is instanced (optional)
  6691. * @param offset the offset of the data (optional)
  6692. * @param size the number of components (optional)
  6693. * @param type the type of the component (optional)
  6694. * @param normalized whether the data contains normalized data (optional)
  6695. * @param useBytes set to true if stride and offset are in bytes (optional)
  6696. * @param divisor defines the instance divisor to use (1 by default)
  6697. */
  6698. 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);
  6699. /** @hidden */
  6700. _rebuild(): void;
  6701. /**
  6702. * Returns the kind of the VertexBuffer (string)
  6703. * @returns a string
  6704. */
  6705. getKind(): string;
  6706. /**
  6707. * Gets a boolean indicating if the VertexBuffer is updatable?
  6708. * @returns true if the buffer is updatable
  6709. */
  6710. isUpdatable(): boolean;
  6711. /**
  6712. * Gets current buffer's data
  6713. * @returns a DataArray or null
  6714. */
  6715. getData(): Nullable<DataArray>;
  6716. /**
  6717. * Gets underlying native buffer
  6718. * @returns underlying native buffer
  6719. */
  6720. getBuffer(): Nullable<DataBuffer>;
  6721. /**
  6722. * Gets the stride in float32 units (i.e. byte stride / 4).
  6723. * May not be an integer if the byte stride is not divisible by 4.
  6724. * @returns the stride in float32 units
  6725. * @deprecated Please use byteStride instead.
  6726. */
  6727. getStrideSize(): number;
  6728. /**
  6729. * Returns the offset as a multiple of the type byte length.
  6730. * @returns the offset in bytes
  6731. * @deprecated Please use byteOffset instead.
  6732. */
  6733. getOffset(): number;
  6734. /**
  6735. * Returns the number of components per vertex attribute (integer)
  6736. * @returns the size in float
  6737. */
  6738. getSize(): number;
  6739. /**
  6740. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6741. * @returns true if this buffer is instanced
  6742. */
  6743. getIsInstanced(): boolean;
  6744. /**
  6745. * Returns the instancing divisor, zero for non-instanced (integer).
  6746. * @returns a number
  6747. */
  6748. getInstanceDivisor(): number;
  6749. /**
  6750. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6751. * @param data defines the data to store
  6752. */
  6753. create(data?: DataArray): void;
  6754. /**
  6755. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6756. * This function will create a new buffer if the current one is not updatable
  6757. * @param data defines the data to store
  6758. */
  6759. update(data: DataArray): void;
  6760. /**
  6761. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6762. * Returns the directly updated WebGLBuffer.
  6763. * @param data the new data
  6764. * @param offset the new offset
  6765. * @param useBytes set to true if the offset is in bytes
  6766. */
  6767. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6768. /**
  6769. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6770. */
  6771. dispose(): void;
  6772. /**
  6773. * Enumerates each value of this vertex buffer as numbers.
  6774. * @param count the number of values to enumerate
  6775. * @param callback the callback function called for each value
  6776. */
  6777. forEach(count: number, callback: (value: number, index: number) => void): void;
  6778. /**
  6779. * Positions
  6780. */
  6781. static readonly PositionKind: string;
  6782. /**
  6783. * Normals
  6784. */
  6785. static readonly NormalKind: string;
  6786. /**
  6787. * Tangents
  6788. */
  6789. static readonly TangentKind: string;
  6790. /**
  6791. * Texture coordinates
  6792. */
  6793. static readonly UVKind: string;
  6794. /**
  6795. * Texture coordinates 2
  6796. */
  6797. static readonly UV2Kind: string;
  6798. /**
  6799. * Texture coordinates 3
  6800. */
  6801. static readonly UV3Kind: string;
  6802. /**
  6803. * Texture coordinates 4
  6804. */
  6805. static readonly UV4Kind: string;
  6806. /**
  6807. * Texture coordinates 5
  6808. */
  6809. static readonly UV5Kind: string;
  6810. /**
  6811. * Texture coordinates 6
  6812. */
  6813. static readonly UV6Kind: string;
  6814. /**
  6815. * Colors
  6816. */
  6817. static readonly ColorKind: string;
  6818. /**
  6819. * Matrix indices (for bones)
  6820. */
  6821. static readonly MatricesIndicesKind: string;
  6822. /**
  6823. * Matrix weights (for bones)
  6824. */
  6825. static readonly MatricesWeightsKind: string;
  6826. /**
  6827. * Additional matrix indices (for bones)
  6828. */
  6829. static readonly MatricesIndicesExtraKind: string;
  6830. /**
  6831. * Additional matrix weights (for bones)
  6832. */
  6833. static readonly MatricesWeightsExtraKind: string;
  6834. /**
  6835. * Deduces the stride given a kind.
  6836. * @param kind The kind string to deduce
  6837. * @returns The deduced stride
  6838. */
  6839. static DeduceStride(kind: string): number;
  6840. /**
  6841. * Gets the byte length of the given type.
  6842. * @param type the type
  6843. * @returns the number of bytes
  6844. */
  6845. static GetTypeByteLength(type: number): number;
  6846. /**
  6847. * Enumerates each value of the given parameters as numbers.
  6848. * @param data the data to enumerate
  6849. * @param byteOffset the byte offset of the data
  6850. * @param byteStride the byte stride of the data
  6851. * @param componentCount the number of components per element
  6852. * @param componentType the type of the component
  6853. * @param count the number of values to enumerate
  6854. * @param normalized whether the data is normalized
  6855. * @param callback the callback function called for each value
  6856. */
  6857. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6858. private static _GetFloatValue;
  6859. }
  6860. }
  6861. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6862. import { Vector3 } from "babylonjs/Maths/math.vector";
  6863. import { Mesh } from "babylonjs/Meshes/mesh";
  6864. /**
  6865. * The options Interface for creating a Capsule Mesh
  6866. */
  6867. export interface ICreateCapsuleOptions {
  6868. /** The Orientation of the capsule. Default : Vector3.Up() */
  6869. orientation: Vector3;
  6870. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6871. subdivisions: number;
  6872. /** Number of cylindrical segments on the capsule. */
  6873. tessellation: number;
  6874. /** Height or Length of the capsule. */
  6875. height: number;
  6876. /** Radius of the capsule. */
  6877. radius: number;
  6878. /** Height or Length of the capsule. */
  6879. capSubdivisions: number;
  6880. /** Overwrite for the top radius. */
  6881. radiusTop?: number;
  6882. /** Overwrite for the bottom radius. */
  6883. radiusBottom?: number;
  6884. /** Overwrite for the top capSubdivisions. */
  6885. topCapSubdivisions?: number;
  6886. /** Overwrite for the bottom capSubdivisions. */
  6887. bottomCapSubdivisions?: number;
  6888. }
  6889. /**
  6890. * Class containing static functions to help procedurally build meshes
  6891. */
  6892. export class CapsuleBuilder {
  6893. /**
  6894. * Creates a capsule or a pill mesh
  6895. * @param name defines the name of the mesh
  6896. * @param options The constructors options.
  6897. * @param scene The scene the mesh is scoped to.
  6898. * @returns Capsule Mesh
  6899. */
  6900. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6901. }
  6902. }
  6903. declare module "babylonjs/Collisions/intersectionInfo" {
  6904. import { Nullable } from "babylonjs/types";
  6905. /**
  6906. * @hidden
  6907. */
  6908. export class IntersectionInfo {
  6909. bu: Nullable<number>;
  6910. bv: Nullable<number>;
  6911. distance: number;
  6912. faceId: number;
  6913. subMeshId: number;
  6914. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6915. }
  6916. }
  6917. declare module "babylonjs/Culling/boundingSphere" {
  6918. import { DeepImmutable } from "babylonjs/types";
  6919. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6920. import { Plane } from "babylonjs/Maths/math.plane";
  6921. /**
  6922. * Class used to store bounding sphere information
  6923. */
  6924. export class BoundingSphere {
  6925. /**
  6926. * Gets the center of the bounding sphere in local space
  6927. */
  6928. readonly center: Vector3;
  6929. /**
  6930. * Radius of the bounding sphere in local space
  6931. */
  6932. radius: number;
  6933. /**
  6934. * Gets the center of the bounding sphere in world space
  6935. */
  6936. readonly centerWorld: Vector3;
  6937. /**
  6938. * Radius of the bounding sphere in world space
  6939. */
  6940. radiusWorld: number;
  6941. /**
  6942. * Gets the minimum vector in local space
  6943. */
  6944. readonly minimum: Vector3;
  6945. /**
  6946. * Gets the maximum vector in local space
  6947. */
  6948. readonly maximum: Vector3;
  6949. private _worldMatrix;
  6950. private static readonly TmpVector3;
  6951. /**
  6952. * Creates a new bounding sphere
  6953. * @param min defines the minimum vector (in local space)
  6954. * @param max defines the maximum vector (in local space)
  6955. * @param worldMatrix defines the new world matrix
  6956. */
  6957. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6958. /**
  6959. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6960. * @param min defines the new minimum vector (in local space)
  6961. * @param max defines the new maximum vector (in local space)
  6962. * @param worldMatrix defines the new world matrix
  6963. */
  6964. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6965. /**
  6966. * Scale the current bounding sphere by applying a scale factor
  6967. * @param factor defines the scale factor to apply
  6968. * @returns the current bounding box
  6969. */
  6970. scale(factor: number): BoundingSphere;
  6971. /**
  6972. * Gets the world matrix of the bounding box
  6973. * @returns a matrix
  6974. */
  6975. getWorldMatrix(): DeepImmutable<Matrix>;
  6976. /** @hidden */
  6977. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6978. /**
  6979. * Tests if the bounding sphere is intersecting the frustum planes
  6980. * @param frustumPlanes defines the frustum planes to test
  6981. * @returns true if there is an intersection
  6982. */
  6983. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6984. /**
  6985. * Tests if the bounding sphere center is in between the frustum planes.
  6986. * Used for optimistic fast inclusion.
  6987. * @param frustumPlanes defines the frustum planes to test
  6988. * @returns true if the sphere center is in between the frustum planes
  6989. */
  6990. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6991. /**
  6992. * Tests if a point is inside the bounding sphere
  6993. * @param point defines the point to test
  6994. * @returns true if the point is inside the bounding sphere
  6995. */
  6996. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6997. /**
  6998. * Checks if two sphere intersct
  6999. * @param sphere0 sphere 0
  7000. * @param sphere1 sphere 1
  7001. * @returns true if the speres intersect
  7002. */
  7003. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7004. }
  7005. }
  7006. declare module "babylonjs/Culling/boundingBox" {
  7007. import { DeepImmutable } from "babylonjs/types";
  7008. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7009. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7010. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7011. import { Plane } from "babylonjs/Maths/math.plane";
  7012. /**
  7013. * Class used to store bounding box information
  7014. */
  7015. export class BoundingBox implements ICullable {
  7016. /**
  7017. * Gets the 8 vectors representing the bounding box in local space
  7018. */
  7019. readonly vectors: Vector3[];
  7020. /**
  7021. * Gets the center of the bounding box in local space
  7022. */
  7023. readonly center: Vector3;
  7024. /**
  7025. * Gets the center of the bounding box in world space
  7026. */
  7027. readonly centerWorld: Vector3;
  7028. /**
  7029. * Gets the extend size in local space
  7030. */
  7031. readonly extendSize: Vector3;
  7032. /**
  7033. * Gets the extend size in world space
  7034. */
  7035. readonly extendSizeWorld: Vector3;
  7036. /**
  7037. * Gets the OBB (object bounding box) directions
  7038. */
  7039. readonly directions: Vector3[];
  7040. /**
  7041. * Gets the 8 vectors representing the bounding box in world space
  7042. */
  7043. readonly vectorsWorld: Vector3[];
  7044. /**
  7045. * Gets the minimum vector in world space
  7046. */
  7047. readonly minimumWorld: Vector3;
  7048. /**
  7049. * Gets the maximum vector in world space
  7050. */
  7051. readonly maximumWorld: Vector3;
  7052. /**
  7053. * Gets the minimum vector in local space
  7054. */
  7055. readonly minimum: Vector3;
  7056. /**
  7057. * Gets the maximum vector in local space
  7058. */
  7059. readonly maximum: Vector3;
  7060. private _worldMatrix;
  7061. private static readonly TmpVector3;
  7062. /**
  7063. * @hidden
  7064. */
  7065. _tag: number;
  7066. /**
  7067. * Creates a new bounding box
  7068. * @param min defines the minimum vector (in local space)
  7069. * @param max defines the maximum vector (in local space)
  7070. * @param worldMatrix defines the new world matrix
  7071. */
  7072. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7073. /**
  7074. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7075. * @param min defines the new minimum vector (in local space)
  7076. * @param max defines the new maximum vector (in local space)
  7077. * @param worldMatrix defines the new world matrix
  7078. */
  7079. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7080. /**
  7081. * Scale the current bounding box by applying a scale factor
  7082. * @param factor defines the scale factor to apply
  7083. * @returns the current bounding box
  7084. */
  7085. scale(factor: number): BoundingBox;
  7086. /**
  7087. * Gets the world matrix of the bounding box
  7088. * @returns a matrix
  7089. */
  7090. getWorldMatrix(): DeepImmutable<Matrix>;
  7091. /** @hidden */
  7092. _update(world: DeepImmutable<Matrix>): void;
  7093. /**
  7094. * Tests if the bounding box is intersecting the frustum planes
  7095. * @param frustumPlanes defines the frustum planes to test
  7096. * @returns true if there is an intersection
  7097. */
  7098. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7099. /**
  7100. * Tests if the bounding box is entirely inside the frustum planes
  7101. * @param frustumPlanes defines the frustum planes to test
  7102. * @returns true if there is an inclusion
  7103. */
  7104. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7105. /**
  7106. * Tests if a point is inside the bounding box
  7107. * @param point defines the point to test
  7108. * @returns true if the point is inside the bounding box
  7109. */
  7110. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7111. /**
  7112. * Tests if the bounding box intersects with a bounding sphere
  7113. * @param sphere defines the sphere to test
  7114. * @returns true if there is an intersection
  7115. */
  7116. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7117. /**
  7118. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7119. * @param min defines the min vector to use
  7120. * @param max defines the max vector to use
  7121. * @returns true if there is an intersection
  7122. */
  7123. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7124. /**
  7125. * Tests if two bounding boxes are intersections
  7126. * @param box0 defines the first box to test
  7127. * @param box1 defines the second box to test
  7128. * @returns true if there is an intersection
  7129. */
  7130. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7131. /**
  7132. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7133. * @param minPoint defines the minimum vector of the bounding box
  7134. * @param maxPoint defines the maximum vector of the bounding box
  7135. * @param sphereCenter defines the sphere center
  7136. * @param sphereRadius defines the sphere radius
  7137. * @returns true if there is an intersection
  7138. */
  7139. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7140. /**
  7141. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7142. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7143. * @param frustumPlanes defines the frustum planes to test
  7144. * @return true if there is an inclusion
  7145. */
  7146. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7147. /**
  7148. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7149. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7150. * @param frustumPlanes defines the frustum planes to test
  7151. * @return true if there is an intersection
  7152. */
  7153. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7154. }
  7155. }
  7156. declare module "babylonjs/Collisions/collider" {
  7157. import { Nullable, IndicesArray } from "babylonjs/types";
  7158. import { Vector3 } from "babylonjs/Maths/math.vector";
  7159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7160. import { Plane } from "babylonjs/Maths/math.plane";
  7161. /** @hidden */
  7162. export class Collider {
  7163. /** Define if a collision was found */
  7164. collisionFound: boolean;
  7165. /**
  7166. * Define last intersection point in local space
  7167. */
  7168. intersectionPoint: Vector3;
  7169. /**
  7170. * Define last collided mesh
  7171. */
  7172. collidedMesh: Nullable<AbstractMesh>;
  7173. private _collisionPoint;
  7174. private _planeIntersectionPoint;
  7175. private _tempVector;
  7176. private _tempVector2;
  7177. private _tempVector3;
  7178. private _tempVector4;
  7179. private _edge;
  7180. private _baseToVertex;
  7181. private _destinationPoint;
  7182. private _slidePlaneNormal;
  7183. private _displacementVector;
  7184. /** @hidden */
  7185. _radius: Vector3;
  7186. /** @hidden */
  7187. _retry: number;
  7188. private _velocity;
  7189. private _basePoint;
  7190. private _epsilon;
  7191. /** @hidden */
  7192. _velocityWorldLength: number;
  7193. /** @hidden */
  7194. _basePointWorld: Vector3;
  7195. private _velocityWorld;
  7196. private _normalizedVelocity;
  7197. /** @hidden */
  7198. _initialVelocity: Vector3;
  7199. /** @hidden */
  7200. _initialPosition: Vector3;
  7201. private _nearestDistance;
  7202. private _collisionMask;
  7203. get collisionMask(): number;
  7204. set collisionMask(mask: number);
  7205. /**
  7206. * Gets the plane normal used to compute the sliding response (in local space)
  7207. */
  7208. get slidePlaneNormal(): Vector3;
  7209. /** @hidden */
  7210. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7211. /** @hidden */
  7212. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7213. /** @hidden */
  7214. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7215. /** @hidden */
  7216. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7217. /** @hidden */
  7218. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7219. /** @hidden */
  7220. _getResponse(pos: Vector3, vel: Vector3): void;
  7221. }
  7222. }
  7223. declare module "babylonjs/Culling/boundingInfo" {
  7224. import { DeepImmutable } from "babylonjs/types";
  7225. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7226. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7227. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7228. import { Plane } from "babylonjs/Maths/math.plane";
  7229. import { Collider } from "babylonjs/Collisions/collider";
  7230. /**
  7231. * Interface for cullable objects
  7232. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7233. */
  7234. export interface ICullable {
  7235. /**
  7236. * Checks if the object or part of the object is in the frustum
  7237. * @param frustumPlanes Camera near/planes
  7238. * @returns true if the object is in frustum otherwise false
  7239. */
  7240. isInFrustum(frustumPlanes: Plane[]): boolean;
  7241. /**
  7242. * Checks if a cullable object (mesh...) is in the camera frustum
  7243. * Unlike isInFrustum this cheks the full bounding box
  7244. * @param frustumPlanes Camera near/planes
  7245. * @returns true if the object is in frustum otherwise false
  7246. */
  7247. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7248. }
  7249. /**
  7250. * Info for a bounding data of a mesh
  7251. */
  7252. export class BoundingInfo implements ICullable {
  7253. /**
  7254. * Bounding box for the mesh
  7255. */
  7256. readonly boundingBox: BoundingBox;
  7257. /**
  7258. * Bounding sphere for the mesh
  7259. */
  7260. readonly boundingSphere: BoundingSphere;
  7261. private _isLocked;
  7262. private static readonly TmpVector3;
  7263. /**
  7264. * Constructs bounding info
  7265. * @param minimum min vector of the bounding box/sphere
  7266. * @param maximum max vector of the bounding box/sphere
  7267. * @param worldMatrix defines the new world matrix
  7268. */
  7269. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7270. /**
  7271. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7272. * @param min defines the new minimum vector (in local space)
  7273. * @param max defines the new maximum vector (in local space)
  7274. * @param worldMatrix defines the new world matrix
  7275. */
  7276. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7277. /**
  7278. * min vector of the bounding box/sphere
  7279. */
  7280. get minimum(): Vector3;
  7281. /**
  7282. * max vector of the bounding box/sphere
  7283. */
  7284. get maximum(): Vector3;
  7285. /**
  7286. * If the info is locked and won't be updated to avoid perf overhead
  7287. */
  7288. get isLocked(): boolean;
  7289. set isLocked(value: boolean);
  7290. /**
  7291. * Updates the bounding sphere and box
  7292. * @param world world matrix to be used to update
  7293. */
  7294. update(world: DeepImmutable<Matrix>): void;
  7295. /**
  7296. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7297. * @param center New center of the bounding info
  7298. * @param extend New extend of the bounding info
  7299. * @returns the current bounding info
  7300. */
  7301. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7302. /**
  7303. * Scale the current bounding info by applying a scale factor
  7304. * @param factor defines the scale factor to apply
  7305. * @returns the current bounding info
  7306. */
  7307. scale(factor: number): BoundingInfo;
  7308. /**
  7309. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7310. * @param frustumPlanes defines the frustum to test
  7311. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7312. * @returns true if the bounding info is in the frustum planes
  7313. */
  7314. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7315. /**
  7316. * Gets the world distance between the min and max points of the bounding box
  7317. */
  7318. get diagonalLength(): number;
  7319. /**
  7320. * Checks if a cullable object (mesh...) is in the camera frustum
  7321. * Unlike isInFrustum this cheks the full bounding box
  7322. * @param frustumPlanes Camera near/planes
  7323. * @returns true if the object is in frustum otherwise false
  7324. */
  7325. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7326. /** @hidden */
  7327. _checkCollision(collider: Collider): boolean;
  7328. /**
  7329. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7330. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7331. * @param point the point to check intersection with
  7332. * @returns if the point intersects
  7333. */
  7334. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7335. /**
  7336. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7337. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7338. * @param boundingInfo the bounding info to check intersection with
  7339. * @param precise if the intersection should be done using OBB
  7340. * @returns if the bounding info intersects
  7341. */
  7342. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7343. }
  7344. }
  7345. declare module "babylonjs/Maths/math.functions" {
  7346. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7347. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7348. /**
  7349. * Extracts minimum and maximum values from a list of indexed positions
  7350. * @param positions defines the positions to use
  7351. * @param indices defines the indices to the positions
  7352. * @param indexStart defines the start index
  7353. * @param indexCount defines the end index
  7354. * @param bias defines bias value to add to the result
  7355. * @return minimum and maximum values
  7356. */
  7357. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7358. minimum: Vector3;
  7359. maximum: Vector3;
  7360. };
  7361. /**
  7362. * Extracts minimum and maximum values from a list of positions
  7363. * @param positions defines the positions to use
  7364. * @param start defines the start index in the positions array
  7365. * @param count defines the number of positions to handle
  7366. * @param bias defines bias value to add to the result
  7367. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7368. * @return minimum and maximum values
  7369. */
  7370. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7371. minimum: Vector3;
  7372. maximum: Vector3;
  7373. };
  7374. }
  7375. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7376. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7377. /** @hidden */
  7378. export class WebGLDataBuffer extends DataBuffer {
  7379. private _buffer;
  7380. constructor(resource: WebGLBuffer);
  7381. get underlyingResource(): any;
  7382. }
  7383. }
  7384. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7385. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7386. import { Nullable } from "babylonjs/types";
  7387. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7388. /** @hidden */
  7389. export class WebGLPipelineContext implements IPipelineContext {
  7390. engine: ThinEngine;
  7391. program: Nullable<WebGLProgram>;
  7392. context?: WebGLRenderingContext;
  7393. vertexShader?: WebGLShader;
  7394. fragmentShader?: WebGLShader;
  7395. isParallelCompiled: boolean;
  7396. onCompiled?: () => void;
  7397. transformFeedback?: WebGLTransformFeedback | null;
  7398. vertexCompilationError: Nullable<string>;
  7399. fragmentCompilationError: Nullable<string>;
  7400. programLinkError: Nullable<string>;
  7401. programValidationError: Nullable<string>;
  7402. get isAsync(): boolean;
  7403. get isReady(): boolean;
  7404. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7405. _getVertexShaderCode(): string | null;
  7406. _getFragmentShaderCode(): string | null;
  7407. }
  7408. }
  7409. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7410. import { FloatArray, Nullable } from "babylonjs/types";
  7411. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7412. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7413. module "babylonjs/Engines/thinEngine" {
  7414. interface ThinEngine {
  7415. /**
  7416. * Create an uniform buffer
  7417. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7418. * @param elements defines the content of the uniform buffer
  7419. * @returns the webGL uniform buffer
  7420. */
  7421. createUniformBuffer(elements: FloatArray): DataBuffer;
  7422. /**
  7423. * Create a dynamic uniform buffer
  7424. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7425. * @param elements defines the content of the uniform buffer
  7426. * @returns the webGL uniform buffer
  7427. */
  7428. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7429. /**
  7430. * Update an existing uniform buffer
  7431. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7432. * @param uniformBuffer defines the target uniform buffer
  7433. * @param elements defines the content to update
  7434. * @param offset defines the offset in the uniform buffer where update should start
  7435. * @param count defines the size of the data to update
  7436. */
  7437. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7438. /**
  7439. * Bind an uniform buffer to the current webGL context
  7440. * @param buffer defines the buffer to bind
  7441. */
  7442. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7443. /**
  7444. * Bind a buffer to the current webGL context at a given location
  7445. * @param buffer defines the buffer to bind
  7446. * @param location defines the index where to bind the buffer
  7447. */
  7448. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7449. /**
  7450. * Bind a specific block at a given index in a specific shader program
  7451. * @param pipelineContext defines the pipeline context to use
  7452. * @param blockName defines the block name
  7453. * @param index defines the index where to bind the block
  7454. */
  7455. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7456. }
  7457. }
  7458. }
  7459. declare module "babylonjs/Materials/uniformBuffer" {
  7460. import { Nullable, FloatArray } from "babylonjs/types";
  7461. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7462. import { Engine } from "babylonjs/Engines/engine";
  7463. import { Effect } from "babylonjs/Materials/effect";
  7464. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7465. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7466. import { Color3 } from "babylonjs/Maths/math.color";
  7467. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7468. /**
  7469. * Uniform buffer objects.
  7470. *
  7471. * Handles blocks of uniform on the GPU.
  7472. *
  7473. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7474. *
  7475. * For more information, please refer to :
  7476. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7477. */
  7478. export class UniformBuffer {
  7479. private _engine;
  7480. private _buffer;
  7481. private _data;
  7482. private _bufferData;
  7483. private _dynamic?;
  7484. private _uniformLocations;
  7485. private _uniformSizes;
  7486. private _uniformLocationPointer;
  7487. private _needSync;
  7488. private _noUBO;
  7489. private _currentEffect;
  7490. /** @hidden */
  7491. _alreadyBound: boolean;
  7492. private static _MAX_UNIFORM_SIZE;
  7493. private static _tempBuffer;
  7494. /**
  7495. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7496. * This is dynamic to allow compat with webgl 1 and 2.
  7497. * You will need to pass the name of the uniform as well as the value.
  7498. */
  7499. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7500. /**
  7501. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7502. * This is dynamic to allow compat with webgl 1 and 2.
  7503. * You will need to pass the name of the uniform as well as the value.
  7504. */
  7505. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7506. /**
  7507. * Lambda to Update a single float in a uniform buffer.
  7508. * This is dynamic to allow compat with webgl 1 and 2.
  7509. * You will need to pass the name of the uniform as well as the value.
  7510. */
  7511. updateFloat: (name: string, x: number) => void;
  7512. /**
  7513. * Lambda to Update a vec2 of float in a uniform buffer.
  7514. * This is dynamic to allow compat with webgl 1 and 2.
  7515. * You will need to pass the name of the uniform as well as the value.
  7516. */
  7517. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7518. /**
  7519. * Lambda to Update a vec3 of float in a uniform buffer.
  7520. * This is dynamic to allow compat with webgl 1 and 2.
  7521. * You will need to pass the name of the uniform as well as the value.
  7522. */
  7523. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7524. /**
  7525. * Lambda to Update a vec4 of float in a uniform buffer.
  7526. * This is dynamic to allow compat with webgl 1 and 2.
  7527. * You will need to pass the name of the uniform as well as the value.
  7528. */
  7529. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7530. /**
  7531. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7532. * This is dynamic to allow compat with webgl 1 and 2.
  7533. * You will need to pass the name of the uniform as well as the value.
  7534. */
  7535. updateMatrix: (name: string, mat: Matrix) => void;
  7536. /**
  7537. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7538. * This is dynamic to allow compat with webgl 1 and 2.
  7539. * You will need to pass the name of the uniform as well as the value.
  7540. */
  7541. updateVector3: (name: string, vector: Vector3) => void;
  7542. /**
  7543. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7544. * This is dynamic to allow compat with webgl 1 and 2.
  7545. * You will need to pass the name of the uniform as well as the value.
  7546. */
  7547. updateVector4: (name: string, vector: Vector4) => void;
  7548. /**
  7549. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7550. * This is dynamic to allow compat with webgl 1 and 2.
  7551. * You will need to pass the name of the uniform as well as the value.
  7552. */
  7553. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7554. /**
  7555. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7556. * This is dynamic to allow compat with webgl 1 and 2.
  7557. * You will need to pass the name of the uniform as well as the value.
  7558. */
  7559. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7560. /**
  7561. * Instantiates a new Uniform buffer objects.
  7562. *
  7563. * Handles blocks of uniform on the GPU.
  7564. *
  7565. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7566. *
  7567. * For more information, please refer to :
  7568. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7569. * @param engine Define the engine the buffer is associated with
  7570. * @param data Define the data contained in the buffer
  7571. * @param dynamic Define if the buffer is updatable
  7572. */
  7573. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7574. /**
  7575. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7576. * or just falling back on setUniformXXX calls.
  7577. */
  7578. get useUbo(): boolean;
  7579. /**
  7580. * Indicates if the WebGL underlying uniform buffer is in sync
  7581. * with the javascript cache data.
  7582. */
  7583. get isSync(): boolean;
  7584. /**
  7585. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7586. * Also, a dynamic UniformBuffer will disable cache verification and always
  7587. * update the underlying WebGL uniform buffer to the GPU.
  7588. * @returns if Dynamic, otherwise false
  7589. */
  7590. isDynamic(): boolean;
  7591. /**
  7592. * The data cache on JS side.
  7593. * @returns the underlying data as a float array
  7594. */
  7595. getData(): Float32Array;
  7596. /**
  7597. * The underlying WebGL Uniform buffer.
  7598. * @returns the webgl buffer
  7599. */
  7600. getBuffer(): Nullable<DataBuffer>;
  7601. /**
  7602. * std140 layout specifies how to align data within an UBO structure.
  7603. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7604. * for specs.
  7605. */
  7606. private _fillAlignment;
  7607. /**
  7608. * Adds an uniform in the buffer.
  7609. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7610. * for the layout to be correct !
  7611. * @param name Name of the uniform, as used in the uniform block in the shader.
  7612. * @param size Data size, or data directly.
  7613. */
  7614. addUniform(name: string, size: number | number[]): void;
  7615. /**
  7616. * Adds a Matrix 4x4 to the uniform buffer.
  7617. * @param name Name of the uniform, as used in the uniform block in the shader.
  7618. * @param mat A 4x4 matrix.
  7619. */
  7620. addMatrix(name: string, mat: Matrix): void;
  7621. /**
  7622. * Adds a vec2 to the uniform buffer.
  7623. * @param name Name of the uniform, as used in the uniform block in the shader.
  7624. * @param x Define the x component value of the vec2
  7625. * @param y Define the y component value of the vec2
  7626. */
  7627. addFloat2(name: string, x: number, y: number): void;
  7628. /**
  7629. * Adds a vec3 to the uniform buffer.
  7630. * @param name Name of the uniform, as used in the uniform block in the shader.
  7631. * @param x Define the x component value of the vec3
  7632. * @param y Define the y component value of the vec3
  7633. * @param z Define the z component value of the vec3
  7634. */
  7635. addFloat3(name: string, x: number, y: number, z: number): void;
  7636. /**
  7637. * Adds a vec3 to the uniform buffer.
  7638. * @param name Name of the uniform, as used in the uniform block in the shader.
  7639. * @param color Define the vec3 from a Color
  7640. */
  7641. addColor3(name: string, color: Color3): void;
  7642. /**
  7643. * Adds a vec4 to the uniform buffer.
  7644. * @param name Name of the uniform, as used in the uniform block in the shader.
  7645. * @param color Define the rgb components from a Color
  7646. * @param alpha Define the a component of the vec4
  7647. */
  7648. addColor4(name: string, color: Color3, alpha: number): void;
  7649. /**
  7650. * Adds a vec3 to the uniform buffer.
  7651. * @param name Name of the uniform, as used in the uniform block in the shader.
  7652. * @param vector Define the vec3 components from a Vector
  7653. */
  7654. addVector3(name: string, vector: Vector3): void;
  7655. /**
  7656. * Adds a Matrix 3x3 to the uniform buffer.
  7657. * @param name Name of the uniform, as used in the uniform block in the shader.
  7658. */
  7659. addMatrix3x3(name: string): void;
  7660. /**
  7661. * Adds a Matrix 2x2 to the uniform buffer.
  7662. * @param name Name of the uniform, as used in the uniform block in the shader.
  7663. */
  7664. addMatrix2x2(name: string): void;
  7665. /**
  7666. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7667. */
  7668. create(): void;
  7669. /** @hidden */
  7670. _rebuild(): void;
  7671. /**
  7672. * Updates the WebGL Uniform Buffer on the GPU.
  7673. * If the `dynamic` flag is set to true, no cache comparison is done.
  7674. * Otherwise, the buffer will be updated only if the cache differs.
  7675. */
  7676. update(): void;
  7677. /**
  7678. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7679. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7680. * @param data Define the flattened data
  7681. * @param size Define the size of the data.
  7682. */
  7683. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7684. private _valueCache;
  7685. private _cacheMatrix;
  7686. private _updateMatrix3x3ForUniform;
  7687. private _updateMatrix3x3ForEffect;
  7688. private _updateMatrix2x2ForEffect;
  7689. private _updateMatrix2x2ForUniform;
  7690. private _updateFloatForEffect;
  7691. private _updateFloatForUniform;
  7692. private _updateFloat2ForEffect;
  7693. private _updateFloat2ForUniform;
  7694. private _updateFloat3ForEffect;
  7695. private _updateFloat3ForUniform;
  7696. private _updateFloat4ForEffect;
  7697. private _updateFloat4ForUniform;
  7698. private _updateMatrixForEffect;
  7699. private _updateMatrixForUniform;
  7700. private _updateVector3ForEffect;
  7701. private _updateVector3ForUniform;
  7702. private _updateVector4ForEffect;
  7703. private _updateVector4ForUniform;
  7704. private _updateColor3ForEffect;
  7705. private _updateColor3ForUniform;
  7706. private _updateColor4ForEffect;
  7707. private _updateColor4ForUniform;
  7708. /**
  7709. * Sets a sampler uniform on the effect.
  7710. * @param name Define the name of the sampler.
  7711. * @param texture Define the texture to set in the sampler
  7712. */
  7713. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7714. /**
  7715. * Directly updates the value of the uniform in the cache AND on the GPU.
  7716. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7717. * @param data Define the flattened data
  7718. */
  7719. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7720. /**
  7721. * Binds this uniform buffer to an effect.
  7722. * @param effect Define the effect to bind the buffer to
  7723. * @param name Name of the uniform block in the shader.
  7724. */
  7725. bindToEffect(effect: Effect, name: string): void;
  7726. /**
  7727. * Disposes the uniform buffer.
  7728. */
  7729. dispose(): void;
  7730. }
  7731. }
  7732. declare module "babylonjs/Misc/iInspectable" {
  7733. /**
  7734. * Enum that determines the text-wrapping mode to use.
  7735. */
  7736. export enum InspectableType {
  7737. /**
  7738. * Checkbox for booleans
  7739. */
  7740. Checkbox = 0,
  7741. /**
  7742. * Sliders for numbers
  7743. */
  7744. Slider = 1,
  7745. /**
  7746. * Vector3
  7747. */
  7748. Vector3 = 2,
  7749. /**
  7750. * Quaternions
  7751. */
  7752. Quaternion = 3,
  7753. /**
  7754. * Color3
  7755. */
  7756. Color3 = 4,
  7757. /**
  7758. * String
  7759. */
  7760. String = 5
  7761. }
  7762. /**
  7763. * Interface used to define custom inspectable properties.
  7764. * This interface is used by the inspector to display custom property grids
  7765. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7766. */
  7767. export interface IInspectable {
  7768. /**
  7769. * Gets the label to display
  7770. */
  7771. label: string;
  7772. /**
  7773. * Gets the name of the property to edit
  7774. */
  7775. propertyName: string;
  7776. /**
  7777. * Gets the type of the editor to use
  7778. */
  7779. type: InspectableType;
  7780. /**
  7781. * Gets the minimum value of the property when using in "slider" mode
  7782. */
  7783. min?: number;
  7784. /**
  7785. * Gets the maximum value of the property when using in "slider" mode
  7786. */
  7787. max?: number;
  7788. /**
  7789. * Gets the setp to use when using in "slider" mode
  7790. */
  7791. step?: number;
  7792. }
  7793. }
  7794. declare module "babylonjs/Misc/timingTools" {
  7795. /**
  7796. * Class used to provide helper for timing
  7797. */
  7798. export class TimingTools {
  7799. /**
  7800. * Polyfill for setImmediate
  7801. * @param action defines the action to execute after the current execution block
  7802. */
  7803. static SetImmediate(action: () => void): void;
  7804. }
  7805. }
  7806. declare module "babylonjs/Misc/instantiationTools" {
  7807. /**
  7808. * Class used to enable instatition of objects by class name
  7809. */
  7810. export class InstantiationTools {
  7811. /**
  7812. * Use this object to register external classes like custom textures or material
  7813. * to allow the laoders to instantiate them
  7814. */
  7815. static RegisteredExternalClasses: {
  7816. [key: string]: Object;
  7817. };
  7818. /**
  7819. * Tries to instantiate a new object from a given class name
  7820. * @param className defines the class name to instantiate
  7821. * @returns the new object or null if the system was not able to do the instantiation
  7822. */
  7823. static Instantiate(className: string): any;
  7824. }
  7825. }
  7826. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7827. /**
  7828. * Define options used to create a depth texture
  7829. */
  7830. export class DepthTextureCreationOptions {
  7831. /** Specifies whether or not a stencil should be allocated in the texture */
  7832. generateStencil?: boolean;
  7833. /** Specifies whether or not bilinear filtering is enable on the texture */
  7834. bilinearFiltering?: boolean;
  7835. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7836. comparisonFunction?: number;
  7837. /** Specifies if the created texture is a cube texture */
  7838. isCube?: boolean;
  7839. }
  7840. }
  7841. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7843. import { Nullable } from "babylonjs/types";
  7844. import { Scene } from "babylonjs/scene";
  7845. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7846. module "babylonjs/Engines/thinEngine" {
  7847. interface ThinEngine {
  7848. /**
  7849. * Creates a depth stencil cube texture.
  7850. * This is only available in WebGL 2.
  7851. * @param size The size of face edge in the cube texture.
  7852. * @param options The options defining the cube texture.
  7853. * @returns The cube texture
  7854. */
  7855. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7856. /**
  7857. * Creates a cube texture
  7858. * @param rootUrl defines the url where the files to load is located
  7859. * @param scene defines the current scene
  7860. * @param files defines the list of files to load (1 per face)
  7861. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7862. * @param onLoad defines an optional callback raised when the texture is loaded
  7863. * @param onError defines an optional callback raised if there is an issue to load the texture
  7864. * @param format defines the format of the data
  7865. * @param forcedExtension defines the extension to use to pick the right loader
  7866. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7867. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7868. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7869. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7870. * @returns the cube texture as an InternalTexture
  7871. */
  7872. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7873. /**
  7874. * Creates a cube texture
  7875. * @param rootUrl defines the url where the files to load is located
  7876. * @param scene defines the current scene
  7877. * @param files defines the list of files to load (1 per face)
  7878. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7879. * @param onLoad defines an optional callback raised when the texture is loaded
  7880. * @param onError defines an optional callback raised if there is an issue to load the texture
  7881. * @param format defines the format of the data
  7882. * @param forcedExtension defines the extension to use to pick the right loader
  7883. * @returns the cube texture as an InternalTexture
  7884. */
  7885. 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;
  7886. /**
  7887. * Creates a cube texture
  7888. * @param rootUrl defines the url where the files to load is located
  7889. * @param scene defines the current scene
  7890. * @param files defines the list of files to load (1 per face)
  7891. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7892. * @param onLoad defines an optional callback raised when the texture is loaded
  7893. * @param onError defines an optional callback raised if there is an issue to load the texture
  7894. * @param format defines the format of the data
  7895. * @param forcedExtension defines the extension to use to pick the right loader
  7896. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7897. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7898. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7899. * @returns the cube texture as an InternalTexture
  7900. */
  7901. 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;
  7902. /** @hidden */
  7903. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7904. /** @hidden */
  7905. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7906. /** @hidden */
  7907. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7908. /** @hidden */
  7909. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7910. /**
  7911. * @hidden
  7912. */
  7913. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7914. }
  7915. }
  7916. }
  7917. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7918. import { Nullable } from "babylonjs/types";
  7919. import { Scene } from "babylonjs/scene";
  7920. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7921. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7922. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7923. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7924. import { Observable } from "babylonjs/Misc/observable";
  7925. /**
  7926. * Class for creating a cube texture
  7927. */
  7928. export class CubeTexture extends BaseTexture {
  7929. private _delayedOnLoad;
  7930. /**
  7931. * Observable triggered once the texture has been loaded.
  7932. */
  7933. onLoadObservable: Observable<CubeTexture>;
  7934. /**
  7935. * The url of the texture
  7936. */
  7937. url: string;
  7938. /**
  7939. * Gets or sets the center of the bounding box associated with the cube texture.
  7940. * It must define where the camera used to render the texture was set
  7941. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7942. */
  7943. boundingBoxPosition: Vector3;
  7944. private _boundingBoxSize;
  7945. /**
  7946. * Gets or sets the size of the bounding box associated with the cube texture
  7947. * When defined, the cubemap will switch to local mode
  7948. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7949. * @example https://www.babylonjs-playground.com/#RNASML
  7950. */
  7951. set boundingBoxSize(value: Vector3);
  7952. /**
  7953. * Returns the bounding box size
  7954. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7955. */
  7956. get boundingBoxSize(): Vector3;
  7957. protected _rotationY: number;
  7958. /**
  7959. * Sets texture matrix rotation angle around Y axis in radians.
  7960. */
  7961. set rotationY(value: number);
  7962. /**
  7963. * Gets texture matrix rotation angle around Y axis radians.
  7964. */
  7965. get rotationY(): number;
  7966. /**
  7967. * Are mip maps generated for this texture or not.
  7968. */
  7969. get noMipmap(): boolean;
  7970. private _noMipmap;
  7971. private _files;
  7972. protected _forcedExtension: Nullable<string>;
  7973. private _extensions;
  7974. private _textureMatrix;
  7975. private _format;
  7976. private _createPolynomials;
  7977. /**
  7978. * Creates a cube texture from an array of image urls
  7979. * @param files defines an array of image urls
  7980. * @param scene defines the hosting scene
  7981. * @param noMipmap specifies if mip maps are not used
  7982. * @returns a cube texture
  7983. */
  7984. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7985. /**
  7986. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7987. * @param url defines the url of the prefiltered texture
  7988. * @param scene defines the scene the texture is attached to
  7989. * @param forcedExtension defines the extension of the file if different from the url
  7990. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7991. * @return the prefiltered texture
  7992. */
  7993. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7994. /**
  7995. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7996. * as prefiltered data.
  7997. * @param rootUrl defines the url of the texture or the root name of the six images
  7998. * @param null defines the scene or engine the texture is attached to
  7999. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8000. * @param noMipmap defines if mipmaps should be created or not
  8001. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8002. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8003. * @param onError defines a callback triggered in case of error during load
  8004. * @param format defines the internal format to use for the texture once loaded
  8005. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8006. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8007. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8008. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8009. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8010. * @return the cube texture
  8011. */
  8012. 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);
  8013. /**
  8014. * Get the current class name of the texture useful for serialization or dynamic coding.
  8015. * @returns "CubeTexture"
  8016. */
  8017. getClassName(): string;
  8018. /**
  8019. * Update the url (and optional buffer) of this texture if url was null during construction.
  8020. * @param url the url of the texture
  8021. * @param forcedExtension defines the extension to use
  8022. * @param onLoad callback called when the texture is loaded (defaults to null)
  8023. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8024. */
  8025. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8026. /**
  8027. * Delays loading of the cube texture
  8028. * @param forcedExtension defines the extension to use
  8029. */
  8030. delayLoad(forcedExtension?: string): void;
  8031. /**
  8032. * Returns the reflection texture matrix
  8033. * @returns the reflection texture matrix
  8034. */
  8035. getReflectionTextureMatrix(): Matrix;
  8036. /**
  8037. * Sets the reflection texture matrix
  8038. * @param value Reflection texture matrix
  8039. */
  8040. setReflectionTextureMatrix(value: Matrix): void;
  8041. /**
  8042. * Parses text to create a cube texture
  8043. * @param parsedTexture define the serialized text to read from
  8044. * @param scene defines the hosting scene
  8045. * @param rootUrl defines the root url of the cube texture
  8046. * @returns a cube texture
  8047. */
  8048. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8049. /**
  8050. * Makes a clone, or deep copy, of the cube texture
  8051. * @returns a new cube texture
  8052. */
  8053. clone(): CubeTexture;
  8054. }
  8055. }
  8056. declare module "babylonjs/Materials/materialDefines" {
  8057. /**
  8058. * Manages the defines for the Material
  8059. */
  8060. export class MaterialDefines {
  8061. /** @hidden */
  8062. protected _keys: string[];
  8063. private _isDirty;
  8064. /** @hidden */
  8065. _renderId: number;
  8066. /** @hidden */
  8067. _areLightsDirty: boolean;
  8068. /** @hidden */
  8069. _areLightsDisposed: boolean;
  8070. /** @hidden */
  8071. _areAttributesDirty: boolean;
  8072. /** @hidden */
  8073. _areTexturesDirty: boolean;
  8074. /** @hidden */
  8075. _areFresnelDirty: boolean;
  8076. /** @hidden */
  8077. _areMiscDirty: boolean;
  8078. /** @hidden */
  8079. _areImageProcessingDirty: boolean;
  8080. /** @hidden */
  8081. _normals: boolean;
  8082. /** @hidden */
  8083. _uvs: boolean;
  8084. /** @hidden */
  8085. _needNormals: boolean;
  8086. /** @hidden */
  8087. _needUVs: boolean;
  8088. [id: string]: any;
  8089. /**
  8090. * Specifies if the material needs to be re-calculated
  8091. */
  8092. get isDirty(): boolean;
  8093. /**
  8094. * Marks the material to indicate that it has been re-calculated
  8095. */
  8096. markAsProcessed(): void;
  8097. /**
  8098. * Marks the material to indicate that it needs to be re-calculated
  8099. */
  8100. markAsUnprocessed(): void;
  8101. /**
  8102. * Marks the material to indicate all of its defines need to be re-calculated
  8103. */
  8104. markAllAsDirty(): void;
  8105. /**
  8106. * Marks the material to indicate that image processing needs to be re-calculated
  8107. */
  8108. markAsImageProcessingDirty(): void;
  8109. /**
  8110. * Marks the material to indicate the lights need to be re-calculated
  8111. * @param disposed Defines whether the light is dirty due to dispose or not
  8112. */
  8113. markAsLightDirty(disposed?: boolean): void;
  8114. /**
  8115. * Marks the attribute state as changed
  8116. */
  8117. markAsAttributesDirty(): void;
  8118. /**
  8119. * Marks the texture state as changed
  8120. */
  8121. markAsTexturesDirty(): void;
  8122. /**
  8123. * Marks the fresnel state as changed
  8124. */
  8125. markAsFresnelDirty(): void;
  8126. /**
  8127. * Marks the misc state as changed
  8128. */
  8129. markAsMiscDirty(): void;
  8130. /**
  8131. * Rebuilds the material defines
  8132. */
  8133. rebuild(): void;
  8134. /**
  8135. * Specifies if two material defines are equal
  8136. * @param other - A material define instance to compare to
  8137. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8138. */
  8139. isEqual(other: MaterialDefines): boolean;
  8140. /**
  8141. * Clones this instance's defines to another instance
  8142. * @param other - material defines to clone values to
  8143. */
  8144. cloneTo(other: MaterialDefines): void;
  8145. /**
  8146. * Resets the material define values
  8147. */
  8148. reset(): void;
  8149. /**
  8150. * Converts the material define values to a string
  8151. * @returns - String of material define information
  8152. */
  8153. toString(): string;
  8154. }
  8155. }
  8156. declare module "babylonjs/Materials/colorCurves" {
  8157. import { Effect } from "babylonjs/Materials/effect";
  8158. /**
  8159. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8160. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8161. * 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;
  8162. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8163. */
  8164. export class ColorCurves {
  8165. private _dirty;
  8166. private _tempColor;
  8167. private _globalCurve;
  8168. private _highlightsCurve;
  8169. private _midtonesCurve;
  8170. private _shadowsCurve;
  8171. private _positiveCurve;
  8172. private _negativeCurve;
  8173. private _globalHue;
  8174. private _globalDensity;
  8175. private _globalSaturation;
  8176. private _globalExposure;
  8177. /**
  8178. * Gets the global Hue value.
  8179. * 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).
  8180. */
  8181. get globalHue(): number;
  8182. /**
  8183. * Sets the global Hue value.
  8184. * 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).
  8185. */
  8186. set globalHue(value: number);
  8187. /**
  8188. * Gets the global Density value.
  8189. * 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.
  8190. * Values less than zero provide a filter of opposite hue.
  8191. */
  8192. get globalDensity(): number;
  8193. /**
  8194. * Sets the global Density value.
  8195. * 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.
  8196. * Values less than zero provide a filter of opposite hue.
  8197. */
  8198. set globalDensity(value: number);
  8199. /**
  8200. * Gets the global Saturation value.
  8201. * 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.
  8202. */
  8203. get globalSaturation(): number;
  8204. /**
  8205. * Sets the global Saturation value.
  8206. * 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.
  8207. */
  8208. set globalSaturation(value: number);
  8209. /**
  8210. * Gets the global Exposure value.
  8211. * 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.
  8212. */
  8213. get globalExposure(): number;
  8214. /**
  8215. * Sets the global Exposure value.
  8216. * 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.
  8217. */
  8218. set globalExposure(value: number);
  8219. private _highlightsHue;
  8220. private _highlightsDensity;
  8221. private _highlightsSaturation;
  8222. private _highlightsExposure;
  8223. /**
  8224. * Gets the highlights Hue value.
  8225. * 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).
  8226. */
  8227. get highlightsHue(): number;
  8228. /**
  8229. * Sets the highlights Hue value.
  8230. * 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).
  8231. */
  8232. set highlightsHue(value: number);
  8233. /**
  8234. * Gets the highlights Density value.
  8235. * 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.
  8236. * Values less than zero provide a filter of opposite hue.
  8237. */
  8238. get highlightsDensity(): number;
  8239. /**
  8240. * Sets the highlights Density value.
  8241. * 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.
  8242. * Values less than zero provide a filter of opposite hue.
  8243. */
  8244. set highlightsDensity(value: number);
  8245. /**
  8246. * Gets the highlights Saturation value.
  8247. * 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.
  8248. */
  8249. get highlightsSaturation(): number;
  8250. /**
  8251. * Sets the highlights Saturation value.
  8252. * 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.
  8253. */
  8254. set highlightsSaturation(value: number);
  8255. /**
  8256. * Gets the highlights Exposure value.
  8257. * 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.
  8258. */
  8259. get highlightsExposure(): number;
  8260. /**
  8261. * Sets the highlights Exposure value.
  8262. * 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.
  8263. */
  8264. set highlightsExposure(value: number);
  8265. private _midtonesHue;
  8266. private _midtonesDensity;
  8267. private _midtonesSaturation;
  8268. private _midtonesExposure;
  8269. /**
  8270. * Gets the midtones Hue value.
  8271. * 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).
  8272. */
  8273. get midtonesHue(): number;
  8274. /**
  8275. * Sets the midtones Hue value.
  8276. * 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).
  8277. */
  8278. set midtonesHue(value: number);
  8279. /**
  8280. * Gets the midtones Density value.
  8281. * 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.
  8282. * Values less than zero provide a filter of opposite hue.
  8283. */
  8284. get midtonesDensity(): number;
  8285. /**
  8286. * Sets the midtones Density value.
  8287. * 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.
  8288. * Values less than zero provide a filter of opposite hue.
  8289. */
  8290. set midtonesDensity(value: number);
  8291. /**
  8292. * Gets the midtones Saturation value.
  8293. * 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.
  8294. */
  8295. get midtonesSaturation(): number;
  8296. /**
  8297. * Sets the midtones Saturation value.
  8298. * 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.
  8299. */
  8300. set midtonesSaturation(value: number);
  8301. /**
  8302. * Gets the midtones Exposure value.
  8303. * 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.
  8304. */
  8305. get midtonesExposure(): number;
  8306. /**
  8307. * Sets the midtones Exposure value.
  8308. * 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.
  8309. */
  8310. set midtonesExposure(value: number);
  8311. private _shadowsHue;
  8312. private _shadowsDensity;
  8313. private _shadowsSaturation;
  8314. private _shadowsExposure;
  8315. /**
  8316. * Gets the shadows Hue value.
  8317. * 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).
  8318. */
  8319. get shadowsHue(): number;
  8320. /**
  8321. * Sets the shadows Hue value.
  8322. * 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).
  8323. */
  8324. set shadowsHue(value: number);
  8325. /**
  8326. * Gets the shadows Density value.
  8327. * 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.
  8328. * Values less than zero provide a filter of opposite hue.
  8329. */
  8330. get shadowsDensity(): number;
  8331. /**
  8332. * Sets the shadows Density value.
  8333. * 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.
  8334. * Values less than zero provide a filter of opposite hue.
  8335. */
  8336. set shadowsDensity(value: number);
  8337. /**
  8338. * Gets the shadows Saturation value.
  8339. * 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.
  8340. */
  8341. get shadowsSaturation(): number;
  8342. /**
  8343. * Sets the shadows Saturation value.
  8344. * 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.
  8345. */
  8346. set shadowsSaturation(value: number);
  8347. /**
  8348. * Gets the shadows Exposure value.
  8349. * 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.
  8350. */
  8351. get shadowsExposure(): number;
  8352. /**
  8353. * Sets the shadows Exposure value.
  8354. * 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.
  8355. */
  8356. set shadowsExposure(value: number);
  8357. /**
  8358. * Returns the class name
  8359. * @returns The class name
  8360. */
  8361. getClassName(): string;
  8362. /**
  8363. * Binds the color curves to the shader.
  8364. * @param colorCurves The color curve to bind
  8365. * @param effect The effect to bind to
  8366. * @param positiveUniform The positive uniform shader parameter
  8367. * @param neutralUniform The neutral uniform shader parameter
  8368. * @param negativeUniform The negative uniform shader parameter
  8369. */
  8370. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8371. /**
  8372. * Prepare the list of uniforms associated with the ColorCurves effects.
  8373. * @param uniformsList The list of uniforms used in the effect
  8374. */
  8375. static PrepareUniforms(uniformsList: string[]): void;
  8376. /**
  8377. * Returns color grading data based on a hue, density, saturation and exposure value.
  8378. * @param filterHue The hue of the color filter.
  8379. * @param filterDensity The density of the color filter.
  8380. * @param saturation The saturation.
  8381. * @param exposure The exposure.
  8382. * @param result The result data container.
  8383. */
  8384. private getColorGradingDataToRef;
  8385. /**
  8386. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8387. * @param value The input slider value in range [-100,100].
  8388. * @returns Adjusted value.
  8389. */
  8390. private static applyColorGradingSliderNonlinear;
  8391. /**
  8392. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8393. * @param hue The hue (H) input.
  8394. * @param saturation The saturation (S) input.
  8395. * @param brightness The brightness (B) input.
  8396. * @result An RGBA color represented as Vector4.
  8397. */
  8398. private static fromHSBToRef;
  8399. /**
  8400. * Returns a value clamped between min and max
  8401. * @param value The value to clamp
  8402. * @param min The minimum of value
  8403. * @param max The maximum of value
  8404. * @returns The clamped value.
  8405. */
  8406. private static clamp;
  8407. /**
  8408. * Clones the current color curve instance.
  8409. * @return The cloned curves
  8410. */
  8411. clone(): ColorCurves;
  8412. /**
  8413. * Serializes the current color curve instance to a json representation.
  8414. * @return a JSON representation
  8415. */
  8416. serialize(): any;
  8417. /**
  8418. * Parses the color curve from a json representation.
  8419. * @param source the JSON source to parse
  8420. * @return The parsed curves
  8421. */
  8422. static Parse(source: any): ColorCurves;
  8423. }
  8424. }
  8425. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8426. import { Observable } from "babylonjs/Misc/observable";
  8427. import { Nullable } from "babylonjs/types";
  8428. import { Color4 } from "babylonjs/Maths/math.color";
  8429. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8430. import { Effect } from "babylonjs/Materials/effect";
  8431. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8432. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8433. /**
  8434. * Interface to follow in your material defines to integrate easily the
  8435. * Image proccessing functions.
  8436. * @hidden
  8437. */
  8438. export interface IImageProcessingConfigurationDefines {
  8439. IMAGEPROCESSING: boolean;
  8440. VIGNETTE: boolean;
  8441. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8442. VIGNETTEBLENDMODEOPAQUE: boolean;
  8443. TONEMAPPING: boolean;
  8444. TONEMAPPING_ACES: boolean;
  8445. CONTRAST: boolean;
  8446. EXPOSURE: boolean;
  8447. COLORCURVES: boolean;
  8448. COLORGRADING: boolean;
  8449. COLORGRADING3D: boolean;
  8450. SAMPLER3DGREENDEPTH: boolean;
  8451. SAMPLER3DBGRMAP: boolean;
  8452. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8453. }
  8454. /**
  8455. * @hidden
  8456. */
  8457. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8458. IMAGEPROCESSING: boolean;
  8459. VIGNETTE: boolean;
  8460. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8461. VIGNETTEBLENDMODEOPAQUE: boolean;
  8462. TONEMAPPING: boolean;
  8463. TONEMAPPING_ACES: boolean;
  8464. CONTRAST: boolean;
  8465. COLORCURVES: boolean;
  8466. COLORGRADING: boolean;
  8467. COLORGRADING3D: boolean;
  8468. SAMPLER3DGREENDEPTH: boolean;
  8469. SAMPLER3DBGRMAP: boolean;
  8470. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8471. EXPOSURE: boolean;
  8472. constructor();
  8473. }
  8474. /**
  8475. * This groups together the common properties used for image processing either in direct forward pass
  8476. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8477. * or not.
  8478. */
  8479. export class ImageProcessingConfiguration {
  8480. /**
  8481. * Default tone mapping applied in BabylonJS.
  8482. */
  8483. static readonly TONEMAPPING_STANDARD: number;
  8484. /**
  8485. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8486. * to other engines rendering to increase portability.
  8487. */
  8488. static readonly TONEMAPPING_ACES: number;
  8489. /**
  8490. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8491. */
  8492. colorCurves: Nullable<ColorCurves>;
  8493. private _colorCurvesEnabled;
  8494. /**
  8495. * Gets wether the color curves effect is enabled.
  8496. */
  8497. get colorCurvesEnabled(): boolean;
  8498. /**
  8499. * Sets wether the color curves effect is enabled.
  8500. */
  8501. set colorCurvesEnabled(value: boolean);
  8502. private _colorGradingTexture;
  8503. /**
  8504. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8505. */
  8506. get colorGradingTexture(): Nullable<BaseTexture>;
  8507. /**
  8508. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8509. */
  8510. set colorGradingTexture(value: Nullable<BaseTexture>);
  8511. private _colorGradingEnabled;
  8512. /**
  8513. * Gets wether the color grading effect is enabled.
  8514. */
  8515. get colorGradingEnabled(): boolean;
  8516. /**
  8517. * Sets wether the color grading effect is enabled.
  8518. */
  8519. set colorGradingEnabled(value: boolean);
  8520. private _colorGradingWithGreenDepth;
  8521. /**
  8522. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8523. */
  8524. get colorGradingWithGreenDepth(): boolean;
  8525. /**
  8526. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8527. */
  8528. set colorGradingWithGreenDepth(value: boolean);
  8529. private _colorGradingBGR;
  8530. /**
  8531. * Gets wether the color grading texture contains BGR values.
  8532. */
  8533. get colorGradingBGR(): boolean;
  8534. /**
  8535. * Sets wether the color grading texture contains BGR values.
  8536. */
  8537. set colorGradingBGR(value: boolean);
  8538. /** @hidden */
  8539. _exposure: number;
  8540. /**
  8541. * Gets the Exposure used in the effect.
  8542. */
  8543. get exposure(): number;
  8544. /**
  8545. * Sets the Exposure used in the effect.
  8546. */
  8547. set exposure(value: number);
  8548. private _toneMappingEnabled;
  8549. /**
  8550. * Gets wether the tone mapping effect is enabled.
  8551. */
  8552. get toneMappingEnabled(): boolean;
  8553. /**
  8554. * Sets wether the tone mapping effect is enabled.
  8555. */
  8556. set toneMappingEnabled(value: boolean);
  8557. private _toneMappingType;
  8558. /**
  8559. * Gets the type of tone mapping effect.
  8560. */
  8561. get toneMappingType(): number;
  8562. /**
  8563. * Sets the type of tone mapping effect used in BabylonJS.
  8564. */
  8565. set toneMappingType(value: number);
  8566. protected _contrast: number;
  8567. /**
  8568. * Gets the contrast used in the effect.
  8569. */
  8570. get contrast(): number;
  8571. /**
  8572. * Sets the contrast used in the effect.
  8573. */
  8574. set contrast(value: number);
  8575. /**
  8576. * Vignette stretch size.
  8577. */
  8578. vignetteStretch: number;
  8579. /**
  8580. * Vignette centre X Offset.
  8581. */
  8582. vignetteCentreX: number;
  8583. /**
  8584. * Vignette centre Y Offset.
  8585. */
  8586. vignetteCentreY: number;
  8587. /**
  8588. * Vignette weight or intensity of the vignette effect.
  8589. */
  8590. vignetteWeight: number;
  8591. /**
  8592. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8593. * if vignetteEnabled is set to true.
  8594. */
  8595. vignetteColor: Color4;
  8596. /**
  8597. * Camera field of view used by the Vignette effect.
  8598. */
  8599. vignetteCameraFov: number;
  8600. private _vignetteBlendMode;
  8601. /**
  8602. * Gets the vignette blend mode allowing different kind of effect.
  8603. */
  8604. get vignetteBlendMode(): number;
  8605. /**
  8606. * Sets the vignette blend mode allowing different kind of effect.
  8607. */
  8608. set vignetteBlendMode(value: number);
  8609. private _vignetteEnabled;
  8610. /**
  8611. * Gets wether the vignette effect is enabled.
  8612. */
  8613. get vignetteEnabled(): boolean;
  8614. /**
  8615. * Sets wether the vignette effect is enabled.
  8616. */
  8617. set vignetteEnabled(value: boolean);
  8618. private _applyByPostProcess;
  8619. /**
  8620. * Gets wether the image processing is applied through a post process or not.
  8621. */
  8622. get applyByPostProcess(): boolean;
  8623. /**
  8624. * Sets wether the image processing is applied through a post process or not.
  8625. */
  8626. set applyByPostProcess(value: boolean);
  8627. private _isEnabled;
  8628. /**
  8629. * Gets wether the image processing is enabled or not.
  8630. */
  8631. get isEnabled(): boolean;
  8632. /**
  8633. * Sets wether the image processing is enabled or not.
  8634. */
  8635. set isEnabled(value: boolean);
  8636. /**
  8637. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8638. */
  8639. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8640. /**
  8641. * Method called each time the image processing information changes requires to recompile the effect.
  8642. */
  8643. protected _updateParameters(): void;
  8644. /**
  8645. * Gets the current class name.
  8646. * @return "ImageProcessingConfiguration"
  8647. */
  8648. getClassName(): string;
  8649. /**
  8650. * Prepare the list of uniforms associated with the Image Processing effects.
  8651. * @param uniforms The list of uniforms used in the effect
  8652. * @param defines the list of defines currently in use
  8653. */
  8654. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8655. /**
  8656. * Prepare the list of samplers associated with the Image Processing effects.
  8657. * @param samplersList The list of uniforms used in the effect
  8658. * @param defines the list of defines currently in use
  8659. */
  8660. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8661. /**
  8662. * Prepare the list of defines associated to the shader.
  8663. * @param defines the list of defines to complete
  8664. * @param forPostProcess Define if we are currently in post process mode or not
  8665. */
  8666. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8667. /**
  8668. * Returns true if all the image processing information are ready.
  8669. * @returns True if ready, otherwise, false
  8670. */
  8671. isReady(): boolean;
  8672. /**
  8673. * Binds the image processing to the shader.
  8674. * @param effect The effect to bind to
  8675. * @param overrideAspectRatio Override the aspect ratio of the effect
  8676. */
  8677. bind(effect: Effect, overrideAspectRatio?: number): void;
  8678. /**
  8679. * Clones the current image processing instance.
  8680. * @return The cloned image processing
  8681. */
  8682. clone(): ImageProcessingConfiguration;
  8683. /**
  8684. * Serializes the current image processing instance to a json representation.
  8685. * @return a JSON representation
  8686. */
  8687. serialize(): any;
  8688. /**
  8689. * Parses the image processing from a json representation.
  8690. * @param source the JSON source to parse
  8691. * @return The parsed image processing
  8692. */
  8693. static Parse(source: any): ImageProcessingConfiguration;
  8694. private static _VIGNETTEMODE_MULTIPLY;
  8695. private static _VIGNETTEMODE_OPAQUE;
  8696. /**
  8697. * Used to apply the vignette as a mix with the pixel color.
  8698. */
  8699. static get VIGNETTEMODE_MULTIPLY(): number;
  8700. /**
  8701. * Used to apply the vignette as a replacement of the pixel color.
  8702. */
  8703. static get VIGNETTEMODE_OPAQUE(): number;
  8704. }
  8705. }
  8706. declare module "babylonjs/Shaders/postprocess.vertex" {
  8707. /** @hidden */
  8708. export var postprocessVertexShader: {
  8709. name: string;
  8710. shader: string;
  8711. };
  8712. }
  8713. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8714. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8715. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8716. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8717. module "babylonjs/Engines/thinEngine" {
  8718. interface ThinEngine {
  8719. /**
  8720. * Creates a new render target texture
  8721. * @param size defines the size of the texture
  8722. * @param options defines the options used to create the texture
  8723. * @returns a new render target texture stored in an InternalTexture
  8724. */
  8725. createRenderTargetTexture(size: number | {
  8726. width: number;
  8727. height: number;
  8728. layers?: number;
  8729. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8730. /**
  8731. * Creates a depth stencil texture.
  8732. * This is only available in WebGL 2 or with the depth texture extension available.
  8733. * @param size The size of face edge in the texture.
  8734. * @param options The options defining the texture.
  8735. * @returns The texture
  8736. */
  8737. createDepthStencilTexture(size: number | {
  8738. width: number;
  8739. height: number;
  8740. layers?: number;
  8741. }, options: DepthTextureCreationOptions): InternalTexture;
  8742. /** @hidden */
  8743. _createDepthStencilTexture(size: number | {
  8744. width: number;
  8745. height: number;
  8746. layers?: number;
  8747. }, options: DepthTextureCreationOptions): InternalTexture;
  8748. }
  8749. }
  8750. }
  8751. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8752. /**
  8753. * Defines the kind of connection point for node based material
  8754. */
  8755. export enum NodeMaterialBlockConnectionPointTypes {
  8756. /** Float */
  8757. Float = 1,
  8758. /** Int */
  8759. Int = 2,
  8760. /** Vector2 */
  8761. Vector2 = 4,
  8762. /** Vector3 */
  8763. Vector3 = 8,
  8764. /** Vector4 */
  8765. Vector4 = 16,
  8766. /** Color3 */
  8767. Color3 = 32,
  8768. /** Color4 */
  8769. Color4 = 64,
  8770. /** Matrix */
  8771. Matrix = 128,
  8772. /** Custom object */
  8773. Object = 256,
  8774. /** Detect type based on connection */
  8775. AutoDetect = 1024,
  8776. /** Output type that will be defined by input type */
  8777. BasedOnInput = 2048
  8778. }
  8779. }
  8780. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8781. /**
  8782. * Enum used to define the target of a block
  8783. */
  8784. export enum NodeMaterialBlockTargets {
  8785. /** Vertex shader */
  8786. Vertex = 1,
  8787. /** Fragment shader */
  8788. Fragment = 2,
  8789. /** Neutral */
  8790. Neutral = 4,
  8791. /** Vertex and Fragment */
  8792. VertexAndFragment = 3
  8793. }
  8794. }
  8795. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8796. /**
  8797. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8798. */
  8799. export enum NodeMaterialBlockConnectionPointMode {
  8800. /** Value is an uniform */
  8801. Uniform = 0,
  8802. /** Value is a mesh attribute */
  8803. Attribute = 1,
  8804. /** Value is a varying between vertex and fragment shaders */
  8805. Varying = 2,
  8806. /** Mode is undefined */
  8807. Undefined = 3
  8808. }
  8809. }
  8810. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8811. /**
  8812. * Enum used to define system values e.g. values automatically provided by the system
  8813. */
  8814. export enum NodeMaterialSystemValues {
  8815. /** World */
  8816. World = 1,
  8817. /** View */
  8818. View = 2,
  8819. /** Projection */
  8820. Projection = 3,
  8821. /** ViewProjection */
  8822. ViewProjection = 4,
  8823. /** WorldView */
  8824. WorldView = 5,
  8825. /** WorldViewProjection */
  8826. WorldViewProjection = 6,
  8827. /** CameraPosition */
  8828. CameraPosition = 7,
  8829. /** Fog Color */
  8830. FogColor = 8,
  8831. /** Delta time */
  8832. DeltaTime = 9
  8833. }
  8834. }
  8835. declare module "babylonjs/Maths/math.axis" {
  8836. import { Vector3 } from "babylonjs/Maths/math.vector";
  8837. /** Defines supported spaces */
  8838. export enum Space {
  8839. /** Local (object) space */
  8840. LOCAL = 0,
  8841. /** World space */
  8842. WORLD = 1,
  8843. /** Bone space */
  8844. BONE = 2
  8845. }
  8846. /** Defines the 3 main axes */
  8847. export class Axis {
  8848. /** X axis */
  8849. static X: Vector3;
  8850. /** Y axis */
  8851. static Y: Vector3;
  8852. /** Z axis */
  8853. static Z: Vector3;
  8854. }
  8855. }
  8856. declare module "babylonjs/Maths/math.frustum" {
  8857. import { Matrix } from "babylonjs/Maths/math.vector";
  8858. import { DeepImmutable } from "babylonjs/types";
  8859. import { Plane } from "babylonjs/Maths/math.plane";
  8860. /**
  8861. * Represents a camera frustum
  8862. */
  8863. export class Frustum {
  8864. /**
  8865. * Gets the planes representing the frustum
  8866. * @param transform matrix to be applied to the returned planes
  8867. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8868. */
  8869. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8870. /**
  8871. * Gets the near frustum plane transformed by the transform matrix
  8872. * @param transform transformation matrix to be applied to the resulting frustum plane
  8873. * @param frustumPlane the resuling frustum plane
  8874. */
  8875. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8876. /**
  8877. * Gets the far frustum plane transformed by the transform matrix
  8878. * @param transform transformation matrix to be applied to the resulting frustum plane
  8879. * @param frustumPlane the resuling frustum plane
  8880. */
  8881. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8882. /**
  8883. * Gets the left frustum plane transformed by the transform matrix
  8884. * @param transform transformation matrix to be applied to the resulting frustum plane
  8885. * @param frustumPlane the resuling frustum plane
  8886. */
  8887. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8888. /**
  8889. * Gets the right frustum plane transformed by the transform matrix
  8890. * @param transform transformation matrix to be applied to the resulting frustum plane
  8891. * @param frustumPlane the resuling frustum plane
  8892. */
  8893. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8894. /**
  8895. * Gets the top frustum plane transformed by the transform matrix
  8896. * @param transform transformation matrix to be applied to the resulting frustum plane
  8897. * @param frustumPlane the resuling frustum plane
  8898. */
  8899. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8900. /**
  8901. * Gets the bottom frustum plane transformed by the transform matrix
  8902. * @param transform transformation matrix to be applied to the resulting frustum plane
  8903. * @param frustumPlane the resuling frustum plane
  8904. */
  8905. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8906. /**
  8907. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8908. * @param transform transformation matrix to be applied to the resulting frustum planes
  8909. * @param frustumPlanes the resuling frustum planes
  8910. */
  8911. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8912. }
  8913. }
  8914. declare module "babylonjs/Maths/math.size" {
  8915. /**
  8916. * Interface for the size containing width and height
  8917. */
  8918. export interface ISize {
  8919. /**
  8920. * Width
  8921. */
  8922. width: number;
  8923. /**
  8924. * Heighht
  8925. */
  8926. height: number;
  8927. }
  8928. /**
  8929. * Size containing widht and height
  8930. */
  8931. export class Size implements ISize {
  8932. /**
  8933. * Width
  8934. */
  8935. width: number;
  8936. /**
  8937. * Height
  8938. */
  8939. height: number;
  8940. /**
  8941. * Creates a Size object from the given width and height (floats).
  8942. * @param width width of the new size
  8943. * @param height height of the new size
  8944. */
  8945. constructor(width: number, height: number);
  8946. /**
  8947. * Returns a string with the Size width and height
  8948. * @returns a string with the Size width and height
  8949. */
  8950. toString(): string;
  8951. /**
  8952. * "Size"
  8953. * @returns the string "Size"
  8954. */
  8955. getClassName(): string;
  8956. /**
  8957. * Returns the Size hash code.
  8958. * @returns a hash code for a unique width and height
  8959. */
  8960. getHashCode(): number;
  8961. /**
  8962. * Updates the current size from the given one.
  8963. * @param src the given size
  8964. */
  8965. copyFrom(src: Size): void;
  8966. /**
  8967. * Updates in place the current Size from the given floats.
  8968. * @param width width of the new size
  8969. * @param height height of the new size
  8970. * @returns the updated Size.
  8971. */
  8972. copyFromFloats(width: number, height: number): Size;
  8973. /**
  8974. * Updates in place the current Size from the given floats.
  8975. * @param width width to set
  8976. * @param height height to set
  8977. * @returns the updated Size.
  8978. */
  8979. set(width: number, height: number): Size;
  8980. /**
  8981. * Multiplies the width and height by numbers
  8982. * @param w factor to multiple the width by
  8983. * @param h factor to multiple the height by
  8984. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8985. */
  8986. multiplyByFloats(w: number, h: number): Size;
  8987. /**
  8988. * Clones the size
  8989. * @returns a new Size copied from the given one.
  8990. */
  8991. clone(): Size;
  8992. /**
  8993. * True if the current Size and the given one width and height are strictly equal.
  8994. * @param other the other size to compare against
  8995. * @returns True if the current Size and the given one width and height are strictly equal.
  8996. */
  8997. equals(other: Size): boolean;
  8998. /**
  8999. * The surface of the Size : width * height (float).
  9000. */
  9001. get surface(): number;
  9002. /**
  9003. * Create a new size of zero
  9004. * @returns a new Size set to (0.0, 0.0)
  9005. */
  9006. static Zero(): Size;
  9007. /**
  9008. * Sums the width and height of two sizes
  9009. * @param otherSize size to add to this size
  9010. * @returns a new Size set as the addition result of the current Size and the given one.
  9011. */
  9012. add(otherSize: Size): Size;
  9013. /**
  9014. * Subtracts the width and height of two
  9015. * @param otherSize size to subtract to this size
  9016. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9017. */
  9018. subtract(otherSize: Size): Size;
  9019. /**
  9020. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9021. * @param start starting size to lerp between
  9022. * @param end end size to lerp between
  9023. * @param amount amount to lerp between the start and end values
  9024. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9025. */
  9026. static Lerp(start: Size, end: Size, amount: number): Size;
  9027. }
  9028. }
  9029. declare module "babylonjs/Maths/math.vertexFormat" {
  9030. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9031. /**
  9032. * Contains position and normal vectors for a vertex
  9033. */
  9034. export class PositionNormalVertex {
  9035. /** the position of the vertex (defaut: 0,0,0) */
  9036. position: Vector3;
  9037. /** the normal of the vertex (defaut: 0,1,0) */
  9038. normal: Vector3;
  9039. /**
  9040. * Creates a PositionNormalVertex
  9041. * @param position the position of the vertex (defaut: 0,0,0)
  9042. * @param normal the normal of the vertex (defaut: 0,1,0)
  9043. */
  9044. constructor(
  9045. /** the position of the vertex (defaut: 0,0,0) */
  9046. position?: Vector3,
  9047. /** the normal of the vertex (defaut: 0,1,0) */
  9048. normal?: Vector3);
  9049. /**
  9050. * Clones the PositionNormalVertex
  9051. * @returns the cloned PositionNormalVertex
  9052. */
  9053. clone(): PositionNormalVertex;
  9054. }
  9055. /**
  9056. * Contains position, normal and uv vectors for a vertex
  9057. */
  9058. export class PositionNormalTextureVertex {
  9059. /** the position of the vertex (defaut: 0,0,0) */
  9060. position: Vector3;
  9061. /** the normal of the vertex (defaut: 0,1,0) */
  9062. normal: Vector3;
  9063. /** the uv of the vertex (default: 0,0) */
  9064. uv: Vector2;
  9065. /**
  9066. * Creates a PositionNormalTextureVertex
  9067. * @param position the position of the vertex (defaut: 0,0,0)
  9068. * @param normal the normal of the vertex (defaut: 0,1,0)
  9069. * @param uv the uv of the vertex (default: 0,0)
  9070. */
  9071. constructor(
  9072. /** the position of the vertex (defaut: 0,0,0) */
  9073. position?: Vector3,
  9074. /** the normal of the vertex (defaut: 0,1,0) */
  9075. normal?: Vector3,
  9076. /** the uv of the vertex (default: 0,0) */
  9077. uv?: Vector2);
  9078. /**
  9079. * Clones the PositionNormalTextureVertex
  9080. * @returns the cloned PositionNormalTextureVertex
  9081. */
  9082. clone(): PositionNormalTextureVertex;
  9083. }
  9084. }
  9085. declare module "babylonjs/Maths/math" {
  9086. export * from "babylonjs/Maths/math.axis";
  9087. export * from "babylonjs/Maths/math.color";
  9088. export * from "babylonjs/Maths/math.constants";
  9089. export * from "babylonjs/Maths/math.frustum";
  9090. export * from "babylonjs/Maths/math.path";
  9091. export * from "babylonjs/Maths/math.plane";
  9092. export * from "babylonjs/Maths/math.size";
  9093. export * from "babylonjs/Maths/math.vector";
  9094. export * from "babylonjs/Maths/math.vertexFormat";
  9095. export * from "babylonjs/Maths/math.viewport";
  9096. }
  9097. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9098. /**
  9099. * Enum defining the type of animations supported by InputBlock
  9100. */
  9101. export enum AnimatedInputBlockTypes {
  9102. /** No animation */
  9103. None = 0,
  9104. /** Time based animation. Will only work for floats */
  9105. Time = 1
  9106. }
  9107. }
  9108. declare module "babylonjs/Lights/shadowLight" {
  9109. import { Camera } from "babylonjs/Cameras/camera";
  9110. import { Scene } from "babylonjs/scene";
  9111. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9113. import { Light } from "babylonjs/Lights/light";
  9114. /**
  9115. * Interface describing all the common properties and methods a shadow light needs to implement.
  9116. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9117. * as well as binding the different shadow properties to the effects.
  9118. */
  9119. export interface IShadowLight extends Light {
  9120. /**
  9121. * The light id in the scene (used in scene.findLighById for instance)
  9122. */
  9123. id: string;
  9124. /**
  9125. * The position the shdow will be casted from.
  9126. */
  9127. position: Vector3;
  9128. /**
  9129. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9130. */
  9131. direction: Vector3;
  9132. /**
  9133. * The transformed position. Position of the light in world space taking parenting in account.
  9134. */
  9135. transformedPosition: Vector3;
  9136. /**
  9137. * The transformed direction. Direction of the light in world space taking parenting in account.
  9138. */
  9139. transformedDirection: Vector3;
  9140. /**
  9141. * The friendly name of the light in the scene.
  9142. */
  9143. name: string;
  9144. /**
  9145. * Defines the shadow projection clipping minimum z value.
  9146. */
  9147. shadowMinZ: number;
  9148. /**
  9149. * Defines the shadow projection clipping maximum z value.
  9150. */
  9151. shadowMaxZ: number;
  9152. /**
  9153. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9154. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9155. */
  9156. computeTransformedInformation(): boolean;
  9157. /**
  9158. * Gets the scene the light belongs to.
  9159. * @returns The scene
  9160. */
  9161. getScene(): Scene;
  9162. /**
  9163. * Callback defining a custom Projection Matrix Builder.
  9164. * This can be used to override the default projection matrix computation.
  9165. */
  9166. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9167. /**
  9168. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9169. * @param matrix The materix to updated with the projection information
  9170. * @param viewMatrix The transform matrix of the light
  9171. * @param renderList The list of mesh to render in the map
  9172. * @returns The current light
  9173. */
  9174. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9175. /**
  9176. * Gets the current depth scale used in ESM.
  9177. * @returns The scale
  9178. */
  9179. getDepthScale(): number;
  9180. /**
  9181. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9182. * @returns true if a cube texture needs to be use
  9183. */
  9184. needCube(): boolean;
  9185. /**
  9186. * Detects if the projection matrix requires to be recomputed this frame.
  9187. * @returns true if it requires to be recomputed otherwise, false.
  9188. */
  9189. needProjectionMatrixCompute(): boolean;
  9190. /**
  9191. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9192. */
  9193. forceProjectionMatrixCompute(): void;
  9194. /**
  9195. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9196. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9197. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9198. */
  9199. getShadowDirection(faceIndex?: number): Vector3;
  9200. /**
  9201. * Gets the minZ used for shadow according to both the scene and the light.
  9202. * @param activeCamera The camera we are returning the min for
  9203. * @returns the depth min z
  9204. */
  9205. getDepthMinZ(activeCamera: Camera): number;
  9206. /**
  9207. * Gets the maxZ used for shadow according to both the scene and the light.
  9208. * @param activeCamera The camera we are returning the max for
  9209. * @returns the depth max z
  9210. */
  9211. getDepthMaxZ(activeCamera: Camera): number;
  9212. }
  9213. /**
  9214. * Base implementation IShadowLight
  9215. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9216. */
  9217. export abstract class ShadowLight extends Light implements IShadowLight {
  9218. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9219. protected _position: Vector3;
  9220. protected _setPosition(value: Vector3): void;
  9221. /**
  9222. * Sets the position the shadow will be casted from. Also use as the light position for both
  9223. * point and spot lights.
  9224. */
  9225. get position(): Vector3;
  9226. /**
  9227. * Sets the position the shadow will be casted from. Also use as the light position for both
  9228. * point and spot lights.
  9229. */
  9230. set position(value: Vector3);
  9231. protected _direction: Vector3;
  9232. protected _setDirection(value: Vector3): void;
  9233. /**
  9234. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9235. * Also use as the light direction on spot and directional lights.
  9236. */
  9237. get direction(): Vector3;
  9238. /**
  9239. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9240. * Also use as the light direction on spot and directional lights.
  9241. */
  9242. set direction(value: Vector3);
  9243. protected _shadowMinZ: number;
  9244. /**
  9245. * Gets the shadow projection clipping minimum z value.
  9246. */
  9247. get shadowMinZ(): number;
  9248. /**
  9249. * Sets the shadow projection clipping minimum z value.
  9250. */
  9251. set shadowMinZ(value: number);
  9252. protected _shadowMaxZ: number;
  9253. /**
  9254. * Sets the shadow projection clipping maximum z value.
  9255. */
  9256. get shadowMaxZ(): number;
  9257. /**
  9258. * Gets the shadow projection clipping maximum z value.
  9259. */
  9260. set shadowMaxZ(value: number);
  9261. /**
  9262. * Callback defining a custom Projection Matrix Builder.
  9263. * This can be used to override the default projection matrix computation.
  9264. */
  9265. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9266. /**
  9267. * The transformed position. Position of the light in world space taking parenting in account.
  9268. */
  9269. transformedPosition: Vector3;
  9270. /**
  9271. * The transformed direction. Direction of the light in world space taking parenting in account.
  9272. */
  9273. transformedDirection: Vector3;
  9274. private _needProjectionMatrixCompute;
  9275. /**
  9276. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9277. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9278. */
  9279. computeTransformedInformation(): boolean;
  9280. /**
  9281. * Return the depth scale used for the shadow map.
  9282. * @returns the depth scale.
  9283. */
  9284. getDepthScale(): number;
  9285. /**
  9286. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9287. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9288. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9289. */
  9290. getShadowDirection(faceIndex?: number): Vector3;
  9291. /**
  9292. * Returns the ShadowLight absolute position in the World.
  9293. * @returns the position vector in world space
  9294. */
  9295. getAbsolutePosition(): Vector3;
  9296. /**
  9297. * Sets the ShadowLight direction toward the passed target.
  9298. * @param target The point to target in local space
  9299. * @returns the updated ShadowLight direction
  9300. */
  9301. setDirectionToTarget(target: Vector3): Vector3;
  9302. /**
  9303. * Returns the light rotation in euler definition.
  9304. * @returns the x y z rotation in local space.
  9305. */
  9306. getRotation(): Vector3;
  9307. /**
  9308. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9309. * @returns true if a cube texture needs to be use
  9310. */
  9311. needCube(): boolean;
  9312. /**
  9313. * Detects if the projection matrix requires to be recomputed this frame.
  9314. * @returns true if it requires to be recomputed otherwise, false.
  9315. */
  9316. needProjectionMatrixCompute(): boolean;
  9317. /**
  9318. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9319. */
  9320. forceProjectionMatrixCompute(): void;
  9321. /** @hidden */
  9322. _initCache(): void;
  9323. /** @hidden */
  9324. _isSynchronized(): boolean;
  9325. /**
  9326. * Computes the world matrix of the node
  9327. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9328. * @returns the world matrix
  9329. */
  9330. computeWorldMatrix(force?: boolean): Matrix;
  9331. /**
  9332. * Gets the minZ used for shadow according to both the scene and the light.
  9333. * @param activeCamera The camera we are returning the min for
  9334. * @returns the depth min z
  9335. */
  9336. getDepthMinZ(activeCamera: Camera): number;
  9337. /**
  9338. * Gets the maxZ used for shadow according to both the scene and the light.
  9339. * @param activeCamera The camera we are returning the max for
  9340. * @returns the depth max z
  9341. */
  9342. getDepthMaxZ(activeCamera: Camera): number;
  9343. /**
  9344. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9345. * @param matrix The materix to updated with the projection information
  9346. * @param viewMatrix The transform matrix of the light
  9347. * @param renderList The list of mesh to render in the map
  9348. * @returns The current light
  9349. */
  9350. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9351. }
  9352. }
  9353. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9354. /** @hidden */
  9355. export var packingFunctions: {
  9356. name: string;
  9357. shader: string;
  9358. };
  9359. }
  9360. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9361. /** @hidden */
  9362. export var bayerDitherFunctions: {
  9363. name: string;
  9364. shader: string;
  9365. };
  9366. }
  9367. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9368. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9369. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9370. /** @hidden */
  9371. export var shadowMapFragmentDeclaration: {
  9372. name: string;
  9373. shader: string;
  9374. };
  9375. }
  9376. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9377. /** @hidden */
  9378. export var clipPlaneFragmentDeclaration: {
  9379. name: string;
  9380. shader: string;
  9381. };
  9382. }
  9383. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9384. /** @hidden */
  9385. export var clipPlaneFragment: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9391. /** @hidden */
  9392. export var shadowMapFragment: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9398. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9399. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9400. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9401. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9402. /** @hidden */
  9403. export var shadowMapPixelShader: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9409. /** @hidden */
  9410. export var bonesDeclaration: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9416. /** @hidden */
  9417. export var morphTargetsVertexGlobalDeclaration: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9423. /** @hidden */
  9424. export var morphTargetsVertexDeclaration: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9430. /** @hidden */
  9431. export var instancesDeclaration: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9437. /** @hidden */
  9438. export var helperFunctions: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9444. /** @hidden */
  9445. export var shadowMapVertexDeclaration: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9451. /** @hidden */
  9452. export var clipPlaneVertexDeclaration: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9458. /** @hidden */
  9459. export var morphTargetsVertex: {
  9460. name: string;
  9461. shader: string;
  9462. };
  9463. }
  9464. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9465. /** @hidden */
  9466. export var instancesVertex: {
  9467. name: string;
  9468. shader: string;
  9469. };
  9470. }
  9471. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9472. /** @hidden */
  9473. export var bonesVertex: {
  9474. name: string;
  9475. shader: string;
  9476. };
  9477. }
  9478. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9479. /** @hidden */
  9480. export var shadowMapVertexNormalBias: {
  9481. name: string;
  9482. shader: string;
  9483. };
  9484. }
  9485. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9486. /** @hidden */
  9487. export var shadowMapVertexMetric: {
  9488. name: string;
  9489. shader: string;
  9490. };
  9491. }
  9492. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9493. /** @hidden */
  9494. export var clipPlaneVertex: {
  9495. name: string;
  9496. shader: string;
  9497. };
  9498. }
  9499. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9500. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9501. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9502. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9503. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9504. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9505. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9506. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9507. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9508. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9509. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9510. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9511. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9512. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9513. /** @hidden */
  9514. export var shadowMapVertexShader: {
  9515. name: string;
  9516. shader: string;
  9517. };
  9518. }
  9519. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9520. /** @hidden */
  9521. export var depthBoxBlurPixelShader: {
  9522. name: string;
  9523. shader: string;
  9524. };
  9525. }
  9526. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9527. /** @hidden */
  9528. export var shadowMapFragmentSoftTransparentShadow: {
  9529. name: string;
  9530. shader: string;
  9531. };
  9532. }
  9533. declare module "babylonjs/Materials/effectFallbacks" {
  9534. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9535. import { Effect } from "babylonjs/Materials/effect";
  9536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9537. /**
  9538. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9539. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9540. */
  9541. export class EffectFallbacks implements IEffectFallbacks {
  9542. private _defines;
  9543. private _currentRank;
  9544. private _maxRank;
  9545. private _mesh;
  9546. /**
  9547. * Removes the fallback from the bound mesh.
  9548. */
  9549. unBindMesh(): void;
  9550. /**
  9551. * Adds a fallback on the specified property.
  9552. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9553. * @param define The name of the define in the shader
  9554. */
  9555. addFallback(rank: number, define: string): void;
  9556. /**
  9557. * Sets the mesh to use CPU skinning when needing to fallback.
  9558. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9559. * @param mesh The mesh to use the fallbacks.
  9560. */
  9561. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9562. /**
  9563. * Checks to see if more fallbacks are still availible.
  9564. */
  9565. get hasMoreFallbacks(): boolean;
  9566. /**
  9567. * Removes the defines that should be removed when falling back.
  9568. * @param currentDefines defines the current define statements for the shader.
  9569. * @param effect defines the current effect we try to compile
  9570. * @returns The resulting defines with defines of the current rank removed.
  9571. */
  9572. reduce(currentDefines: string, effect: Effect): string;
  9573. }
  9574. }
  9575. declare module "babylonjs/Actions/action" {
  9576. import { Observable } from "babylonjs/Misc/observable";
  9577. import { Condition } from "babylonjs/Actions/condition";
  9578. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9579. import { Nullable } from "babylonjs/types";
  9580. import { Scene } from "babylonjs/scene";
  9581. import { ActionManager } from "babylonjs/Actions/actionManager";
  9582. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9583. import { Node } from "babylonjs/node";
  9584. /**
  9585. * Interface used to define Action
  9586. */
  9587. export interface IAction {
  9588. /**
  9589. * Trigger for the action
  9590. */
  9591. trigger: number;
  9592. /** Options of the trigger */
  9593. triggerOptions: any;
  9594. /**
  9595. * Gets the trigger parameters
  9596. * @returns the trigger parameters
  9597. */
  9598. getTriggerParameter(): any;
  9599. /**
  9600. * Internal only - executes current action event
  9601. * @hidden
  9602. */
  9603. _executeCurrent(evt?: ActionEvent): void;
  9604. /**
  9605. * Serialize placeholder for child classes
  9606. * @param parent of child
  9607. * @returns the serialized object
  9608. */
  9609. serialize(parent: any): any;
  9610. /**
  9611. * Internal only
  9612. * @hidden
  9613. */
  9614. _prepare(): void;
  9615. /**
  9616. * Internal only - manager for action
  9617. * @hidden
  9618. */
  9619. _actionManager: Nullable<AbstractActionManager>;
  9620. /**
  9621. * Adds action to chain of actions, may be a DoNothingAction
  9622. * @param action defines the next action to execute
  9623. * @returns The action passed in
  9624. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9625. */
  9626. then(action: IAction): IAction;
  9627. }
  9628. /**
  9629. * The action to be carried out following a trigger
  9630. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9631. */
  9632. export class Action implements IAction {
  9633. /** the trigger, with or without parameters, for the action */
  9634. triggerOptions: any;
  9635. /**
  9636. * Trigger for the action
  9637. */
  9638. trigger: number;
  9639. /**
  9640. * Internal only - manager for action
  9641. * @hidden
  9642. */
  9643. _actionManager: ActionManager;
  9644. private _nextActiveAction;
  9645. private _child;
  9646. private _condition?;
  9647. private _triggerParameter;
  9648. /**
  9649. * An event triggered prior to action being executed.
  9650. */
  9651. onBeforeExecuteObservable: Observable<Action>;
  9652. /**
  9653. * Creates a new Action
  9654. * @param triggerOptions the trigger, with or without parameters, for the action
  9655. * @param condition an optional determinant of action
  9656. */
  9657. constructor(
  9658. /** the trigger, with or without parameters, for the action */
  9659. triggerOptions: any, condition?: Condition);
  9660. /**
  9661. * Internal only
  9662. * @hidden
  9663. */
  9664. _prepare(): void;
  9665. /**
  9666. * Gets the trigger parameters
  9667. * @returns the trigger parameters
  9668. */
  9669. getTriggerParameter(): any;
  9670. /**
  9671. * Internal only - executes current action event
  9672. * @hidden
  9673. */
  9674. _executeCurrent(evt?: ActionEvent): void;
  9675. /**
  9676. * Execute placeholder for child classes
  9677. * @param evt optional action event
  9678. */
  9679. execute(evt?: ActionEvent): void;
  9680. /**
  9681. * Skips to next active action
  9682. */
  9683. skipToNextActiveAction(): void;
  9684. /**
  9685. * Adds action to chain of actions, may be a DoNothingAction
  9686. * @param action defines the next action to execute
  9687. * @returns The action passed in
  9688. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9689. */
  9690. then(action: Action): Action;
  9691. /**
  9692. * Internal only
  9693. * @hidden
  9694. */
  9695. _getProperty(propertyPath: string): string;
  9696. /**
  9697. * Internal only
  9698. * @hidden
  9699. */
  9700. _getEffectiveTarget(target: any, propertyPath: string): any;
  9701. /**
  9702. * Serialize placeholder for child classes
  9703. * @param parent of child
  9704. * @returns the serialized object
  9705. */
  9706. serialize(parent: any): any;
  9707. /**
  9708. * Internal only called by serialize
  9709. * @hidden
  9710. */
  9711. protected _serialize(serializedAction: any, parent?: any): any;
  9712. /**
  9713. * Internal only
  9714. * @hidden
  9715. */
  9716. static _SerializeValueAsString: (value: any) => string;
  9717. /**
  9718. * Internal only
  9719. * @hidden
  9720. */
  9721. static _GetTargetProperty: (target: Scene | Node) => {
  9722. name: string;
  9723. targetType: string;
  9724. value: string;
  9725. };
  9726. }
  9727. }
  9728. declare module "babylonjs/Actions/condition" {
  9729. import { ActionManager } from "babylonjs/Actions/actionManager";
  9730. /**
  9731. * A Condition applied to an Action
  9732. */
  9733. export class Condition {
  9734. /**
  9735. * Internal only - manager for action
  9736. * @hidden
  9737. */
  9738. _actionManager: ActionManager;
  9739. /**
  9740. * Internal only
  9741. * @hidden
  9742. */
  9743. _evaluationId: number;
  9744. /**
  9745. * Internal only
  9746. * @hidden
  9747. */
  9748. _currentResult: boolean;
  9749. /**
  9750. * Creates a new Condition
  9751. * @param actionManager the manager of the action the condition is applied to
  9752. */
  9753. constructor(actionManager: ActionManager);
  9754. /**
  9755. * Check if the current condition is valid
  9756. * @returns a boolean
  9757. */
  9758. isValid(): boolean;
  9759. /**
  9760. * Internal only
  9761. * @hidden
  9762. */
  9763. _getProperty(propertyPath: string): string;
  9764. /**
  9765. * Internal only
  9766. * @hidden
  9767. */
  9768. _getEffectiveTarget(target: any, propertyPath: string): any;
  9769. /**
  9770. * Serialize placeholder for child classes
  9771. * @returns the serialized object
  9772. */
  9773. serialize(): any;
  9774. /**
  9775. * Internal only
  9776. * @hidden
  9777. */
  9778. protected _serialize(serializedCondition: any): any;
  9779. }
  9780. /**
  9781. * Defines specific conditional operators as extensions of Condition
  9782. */
  9783. export class ValueCondition extends Condition {
  9784. /** path to specify the property of the target the conditional operator uses */
  9785. propertyPath: string;
  9786. /** the value compared by the conditional operator against the current value of the property */
  9787. value: any;
  9788. /** the conditional operator, default ValueCondition.IsEqual */
  9789. operator: number;
  9790. /**
  9791. * Internal only
  9792. * @hidden
  9793. */
  9794. private static _IsEqual;
  9795. /**
  9796. * Internal only
  9797. * @hidden
  9798. */
  9799. private static _IsDifferent;
  9800. /**
  9801. * Internal only
  9802. * @hidden
  9803. */
  9804. private static _IsGreater;
  9805. /**
  9806. * Internal only
  9807. * @hidden
  9808. */
  9809. private static _IsLesser;
  9810. /**
  9811. * returns the number for IsEqual
  9812. */
  9813. static get IsEqual(): number;
  9814. /**
  9815. * Returns the number for IsDifferent
  9816. */
  9817. static get IsDifferent(): number;
  9818. /**
  9819. * Returns the number for IsGreater
  9820. */
  9821. static get IsGreater(): number;
  9822. /**
  9823. * Returns the number for IsLesser
  9824. */
  9825. static get IsLesser(): number;
  9826. /**
  9827. * Internal only The action manager for the condition
  9828. * @hidden
  9829. */
  9830. _actionManager: ActionManager;
  9831. /**
  9832. * Internal only
  9833. * @hidden
  9834. */
  9835. private _target;
  9836. /**
  9837. * Internal only
  9838. * @hidden
  9839. */
  9840. private _effectiveTarget;
  9841. /**
  9842. * Internal only
  9843. * @hidden
  9844. */
  9845. private _property;
  9846. /**
  9847. * Creates a new ValueCondition
  9848. * @param actionManager manager for the action the condition applies to
  9849. * @param target for the action
  9850. * @param propertyPath path to specify the property of the target the conditional operator uses
  9851. * @param value the value compared by the conditional operator against the current value of the property
  9852. * @param operator the conditional operator, default ValueCondition.IsEqual
  9853. */
  9854. constructor(actionManager: ActionManager, target: any,
  9855. /** path to specify the property of the target the conditional operator uses */
  9856. propertyPath: string,
  9857. /** the value compared by the conditional operator against the current value of the property */
  9858. value: any,
  9859. /** the conditional operator, default ValueCondition.IsEqual */
  9860. operator?: number);
  9861. /**
  9862. * Compares the given value with the property value for the specified conditional operator
  9863. * @returns the result of the comparison
  9864. */
  9865. isValid(): boolean;
  9866. /**
  9867. * Serialize the ValueCondition into a JSON compatible object
  9868. * @returns serialization object
  9869. */
  9870. serialize(): any;
  9871. /**
  9872. * Gets the name of the conditional operator for the ValueCondition
  9873. * @param operator the conditional operator
  9874. * @returns the name
  9875. */
  9876. static GetOperatorName(operator: number): string;
  9877. }
  9878. /**
  9879. * Defines a predicate condition as an extension of Condition
  9880. */
  9881. export class PredicateCondition extends Condition {
  9882. /** defines the predicate function used to validate the condition */
  9883. predicate: () => boolean;
  9884. /**
  9885. * Internal only - manager for action
  9886. * @hidden
  9887. */
  9888. _actionManager: ActionManager;
  9889. /**
  9890. * Creates a new PredicateCondition
  9891. * @param actionManager manager for the action the condition applies to
  9892. * @param predicate defines the predicate function used to validate the condition
  9893. */
  9894. constructor(actionManager: ActionManager,
  9895. /** defines the predicate function used to validate the condition */
  9896. predicate: () => boolean);
  9897. /**
  9898. * @returns the validity of the predicate condition
  9899. */
  9900. isValid(): boolean;
  9901. }
  9902. /**
  9903. * Defines a state condition as an extension of Condition
  9904. */
  9905. export class StateCondition extends Condition {
  9906. /** Value to compare with target state */
  9907. value: string;
  9908. /**
  9909. * Internal only - manager for action
  9910. * @hidden
  9911. */
  9912. _actionManager: ActionManager;
  9913. /**
  9914. * Internal only
  9915. * @hidden
  9916. */
  9917. private _target;
  9918. /**
  9919. * Creates a new StateCondition
  9920. * @param actionManager manager for the action the condition applies to
  9921. * @param target of the condition
  9922. * @param value to compare with target state
  9923. */
  9924. constructor(actionManager: ActionManager, target: any,
  9925. /** Value to compare with target state */
  9926. value: string);
  9927. /**
  9928. * Gets a boolean indicating if the current condition is met
  9929. * @returns the validity of the state
  9930. */
  9931. isValid(): boolean;
  9932. /**
  9933. * Serialize the StateCondition into a JSON compatible object
  9934. * @returns serialization object
  9935. */
  9936. serialize(): any;
  9937. }
  9938. }
  9939. declare module "babylonjs/Actions/directActions" {
  9940. import { Action } from "babylonjs/Actions/action";
  9941. import { Condition } from "babylonjs/Actions/condition";
  9942. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9943. /**
  9944. * This defines an action responsible to toggle a boolean once triggered.
  9945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9946. */
  9947. export class SwitchBooleanAction extends Action {
  9948. /**
  9949. * The path to the boolean property in the target object
  9950. */
  9951. propertyPath: string;
  9952. private _target;
  9953. private _effectiveTarget;
  9954. private _property;
  9955. /**
  9956. * Instantiate the action
  9957. * @param triggerOptions defines the trigger options
  9958. * @param target defines the object containing the boolean
  9959. * @param propertyPath defines the path to the boolean property in the target object
  9960. * @param condition defines the trigger related conditions
  9961. */
  9962. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9963. /** @hidden */
  9964. _prepare(): void;
  9965. /**
  9966. * Execute the action toggle the boolean value.
  9967. */
  9968. execute(): void;
  9969. /**
  9970. * Serializes the actions and its related information.
  9971. * @param parent defines the object to serialize in
  9972. * @returns the serialized object
  9973. */
  9974. serialize(parent: any): any;
  9975. }
  9976. /**
  9977. * This defines an action responsible to set a the state field of the target
  9978. * to a desired value once triggered.
  9979. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9980. */
  9981. export class SetStateAction extends Action {
  9982. /**
  9983. * The value to store in the state field.
  9984. */
  9985. value: string;
  9986. private _target;
  9987. /**
  9988. * Instantiate the action
  9989. * @param triggerOptions defines the trigger options
  9990. * @param target defines the object containing the state property
  9991. * @param value defines the value to store in the state field
  9992. * @param condition defines the trigger related conditions
  9993. */
  9994. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9995. /**
  9996. * Execute the action and store the value on the target state property.
  9997. */
  9998. execute(): void;
  9999. /**
  10000. * Serializes the actions and its related information.
  10001. * @param parent defines the object to serialize in
  10002. * @returns the serialized object
  10003. */
  10004. serialize(parent: any): any;
  10005. }
  10006. /**
  10007. * This defines an action responsible to set a property of the target
  10008. * to a desired value once triggered.
  10009. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10010. */
  10011. export class SetValueAction extends Action {
  10012. /**
  10013. * The path of the property to set in the target.
  10014. */
  10015. propertyPath: string;
  10016. /**
  10017. * The value to set in the property
  10018. */
  10019. value: any;
  10020. private _target;
  10021. private _effectiveTarget;
  10022. private _property;
  10023. /**
  10024. * Instantiate the action
  10025. * @param triggerOptions defines the trigger options
  10026. * @param target defines the object containing the property
  10027. * @param propertyPath defines the path of the property to set in the target
  10028. * @param value defines the value to set in the property
  10029. * @param condition defines the trigger related conditions
  10030. */
  10031. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10032. /** @hidden */
  10033. _prepare(): void;
  10034. /**
  10035. * Execute the action and set the targetted property to the desired value.
  10036. */
  10037. execute(): void;
  10038. /**
  10039. * Serializes the actions and its related information.
  10040. * @param parent defines the object to serialize in
  10041. * @returns the serialized object
  10042. */
  10043. serialize(parent: any): any;
  10044. }
  10045. /**
  10046. * This defines an action responsible to increment the target value
  10047. * to a desired value once triggered.
  10048. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10049. */
  10050. export class IncrementValueAction extends Action {
  10051. /**
  10052. * The path of the property to increment in the target.
  10053. */
  10054. propertyPath: string;
  10055. /**
  10056. * The value we should increment the property by.
  10057. */
  10058. value: any;
  10059. private _target;
  10060. private _effectiveTarget;
  10061. private _property;
  10062. /**
  10063. * Instantiate the action
  10064. * @param triggerOptions defines the trigger options
  10065. * @param target defines the object containing the property
  10066. * @param propertyPath defines the path of the property to increment in the target
  10067. * @param value defines the value value we should increment the property by
  10068. * @param condition defines the trigger related conditions
  10069. */
  10070. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10071. /** @hidden */
  10072. _prepare(): void;
  10073. /**
  10074. * Execute the action and increment the target of the value amount.
  10075. */
  10076. execute(): void;
  10077. /**
  10078. * Serializes the actions and its related information.
  10079. * @param parent defines the object to serialize in
  10080. * @returns the serialized object
  10081. */
  10082. serialize(parent: any): any;
  10083. }
  10084. /**
  10085. * This defines an action responsible to start an animation once triggered.
  10086. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10087. */
  10088. export class PlayAnimationAction extends Action {
  10089. /**
  10090. * Where the animation should start (animation frame)
  10091. */
  10092. from: number;
  10093. /**
  10094. * Where the animation should stop (animation frame)
  10095. */
  10096. to: number;
  10097. /**
  10098. * Define if the animation should loop or stop after the first play.
  10099. */
  10100. loop?: boolean;
  10101. private _target;
  10102. /**
  10103. * Instantiate the action
  10104. * @param triggerOptions defines the trigger options
  10105. * @param target defines the target animation or animation name
  10106. * @param from defines from where the animation should start (animation frame)
  10107. * @param end defines where the animation should stop (animation frame)
  10108. * @param loop defines if the animation should loop or stop after the first play
  10109. * @param condition defines the trigger related conditions
  10110. */
  10111. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10112. /** @hidden */
  10113. _prepare(): void;
  10114. /**
  10115. * Execute the action and play the animation.
  10116. */
  10117. execute(): void;
  10118. /**
  10119. * Serializes the actions and its related information.
  10120. * @param parent defines the object to serialize in
  10121. * @returns the serialized object
  10122. */
  10123. serialize(parent: any): any;
  10124. }
  10125. /**
  10126. * This defines an action responsible to stop an animation once triggered.
  10127. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10128. */
  10129. export class StopAnimationAction extends Action {
  10130. private _target;
  10131. /**
  10132. * Instantiate the action
  10133. * @param triggerOptions defines the trigger options
  10134. * @param target defines the target animation or animation name
  10135. * @param condition defines the trigger related conditions
  10136. */
  10137. constructor(triggerOptions: any, target: any, condition?: Condition);
  10138. /** @hidden */
  10139. _prepare(): void;
  10140. /**
  10141. * Execute the action and stop the animation.
  10142. */
  10143. execute(): void;
  10144. /**
  10145. * Serializes the actions and its related information.
  10146. * @param parent defines the object to serialize in
  10147. * @returns the serialized object
  10148. */
  10149. serialize(parent: any): any;
  10150. }
  10151. /**
  10152. * This defines an action responsible that does nothing once triggered.
  10153. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10154. */
  10155. export class DoNothingAction extends Action {
  10156. /**
  10157. * Instantiate the action
  10158. * @param triggerOptions defines the trigger options
  10159. * @param condition defines the trigger related conditions
  10160. */
  10161. constructor(triggerOptions?: any, condition?: Condition);
  10162. /**
  10163. * Execute the action and do nothing.
  10164. */
  10165. execute(): void;
  10166. /**
  10167. * Serializes the actions and its related information.
  10168. * @param parent defines the object to serialize in
  10169. * @returns the serialized object
  10170. */
  10171. serialize(parent: any): any;
  10172. }
  10173. /**
  10174. * This defines an action responsible to trigger several actions once triggered.
  10175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10176. */
  10177. export class CombineAction extends Action {
  10178. /**
  10179. * The list of aggregated animations to run.
  10180. */
  10181. children: Action[];
  10182. /**
  10183. * Instantiate the action
  10184. * @param triggerOptions defines the trigger options
  10185. * @param children defines the list of aggregated animations to run
  10186. * @param condition defines the trigger related conditions
  10187. */
  10188. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10189. /** @hidden */
  10190. _prepare(): void;
  10191. /**
  10192. * Execute the action and executes all the aggregated actions.
  10193. */
  10194. execute(evt: ActionEvent): void;
  10195. /**
  10196. * Serializes the actions and its related information.
  10197. * @param parent defines the object to serialize in
  10198. * @returns the serialized object
  10199. */
  10200. serialize(parent: any): any;
  10201. }
  10202. /**
  10203. * This defines an action responsible to run code (external event) once triggered.
  10204. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10205. */
  10206. export class ExecuteCodeAction extends Action {
  10207. /**
  10208. * The callback function to run.
  10209. */
  10210. func: (evt: ActionEvent) => void;
  10211. /**
  10212. * Instantiate the action
  10213. * @param triggerOptions defines the trigger options
  10214. * @param func defines the callback function to run
  10215. * @param condition defines the trigger related conditions
  10216. */
  10217. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10218. /**
  10219. * Execute the action and run the attached code.
  10220. */
  10221. execute(evt: ActionEvent): void;
  10222. }
  10223. /**
  10224. * This defines an action responsible to set the parent property of the target once triggered.
  10225. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10226. */
  10227. export class SetParentAction extends Action {
  10228. private _parent;
  10229. private _target;
  10230. /**
  10231. * Instantiate the action
  10232. * @param triggerOptions defines the trigger options
  10233. * @param target defines the target containing the parent property
  10234. * @param parent defines from where the animation should start (animation frame)
  10235. * @param condition defines the trigger related conditions
  10236. */
  10237. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10238. /** @hidden */
  10239. _prepare(): void;
  10240. /**
  10241. * Execute the action and set the parent property.
  10242. */
  10243. execute(): void;
  10244. /**
  10245. * Serializes the actions and its related information.
  10246. * @param parent defines the object to serialize in
  10247. * @returns the serialized object
  10248. */
  10249. serialize(parent: any): any;
  10250. }
  10251. }
  10252. declare module "babylonjs/Actions/actionManager" {
  10253. import { Nullable } from "babylonjs/types";
  10254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10255. import { Scene } from "babylonjs/scene";
  10256. import { IAction } from "babylonjs/Actions/action";
  10257. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10258. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10259. /**
  10260. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10261. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10262. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10263. */
  10264. export class ActionManager extends AbstractActionManager {
  10265. /**
  10266. * Nothing
  10267. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10268. */
  10269. static readonly NothingTrigger: number;
  10270. /**
  10271. * On pick
  10272. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10273. */
  10274. static readonly OnPickTrigger: number;
  10275. /**
  10276. * On left pick
  10277. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10278. */
  10279. static readonly OnLeftPickTrigger: number;
  10280. /**
  10281. * On right pick
  10282. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10283. */
  10284. static readonly OnRightPickTrigger: number;
  10285. /**
  10286. * On center pick
  10287. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10288. */
  10289. static readonly OnCenterPickTrigger: number;
  10290. /**
  10291. * On pick down
  10292. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10293. */
  10294. static readonly OnPickDownTrigger: number;
  10295. /**
  10296. * On double pick
  10297. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10298. */
  10299. static readonly OnDoublePickTrigger: number;
  10300. /**
  10301. * On pick up
  10302. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10303. */
  10304. static readonly OnPickUpTrigger: number;
  10305. /**
  10306. * On pick out.
  10307. * This trigger will only be raised if you also declared a OnPickDown
  10308. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10309. */
  10310. static readonly OnPickOutTrigger: number;
  10311. /**
  10312. * On long press
  10313. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10314. */
  10315. static readonly OnLongPressTrigger: number;
  10316. /**
  10317. * On pointer over
  10318. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10319. */
  10320. static readonly OnPointerOverTrigger: number;
  10321. /**
  10322. * On pointer out
  10323. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10324. */
  10325. static readonly OnPointerOutTrigger: number;
  10326. /**
  10327. * On every frame
  10328. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10329. */
  10330. static readonly OnEveryFrameTrigger: number;
  10331. /**
  10332. * On intersection enter
  10333. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10334. */
  10335. static readonly OnIntersectionEnterTrigger: number;
  10336. /**
  10337. * On intersection exit
  10338. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10339. */
  10340. static readonly OnIntersectionExitTrigger: number;
  10341. /**
  10342. * On key down
  10343. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10344. */
  10345. static readonly OnKeyDownTrigger: number;
  10346. /**
  10347. * On key up
  10348. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10349. */
  10350. static readonly OnKeyUpTrigger: number;
  10351. private _scene;
  10352. /**
  10353. * Creates a new action manager
  10354. * @param scene defines the hosting scene
  10355. */
  10356. constructor(scene: Scene);
  10357. /**
  10358. * Releases all associated resources
  10359. */
  10360. dispose(): void;
  10361. /**
  10362. * Gets hosting scene
  10363. * @returns the hosting scene
  10364. */
  10365. getScene(): Scene;
  10366. /**
  10367. * Does this action manager handles actions of any of the given triggers
  10368. * @param triggers defines the triggers to be tested
  10369. * @return a boolean indicating whether one (or more) of the triggers is handled
  10370. */
  10371. hasSpecificTriggers(triggers: number[]): boolean;
  10372. /**
  10373. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10374. * speed.
  10375. * @param triggerA defines the trigger to be tested
  10376. * @param triggerB defines the trigger to be tested
  10377. * @return a boolean indicating whether one (or more) of the triggers is handled
  10378. */
  10379. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10380. /**
  10381. * Does this action manager handles actions of a given trigger
  10382. * @param trigger defines the trigger to be tested
  10383. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10384. * @return whether the trigger is handled
  10385. */
  10386. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10387. /**
  10388. * Does this action manager has pointer triggers
  10389. */
  10390. get hasPointerTriggers(): boolean;
  10391. /**
  10392. * Does this action manager has pick triggers
  10393. */
  10394. get hasPickTriggers(): boolean;
  10395. /**
  10396. * Registers an action to this action manager
  10397. * @param action defines the action to be registered
  10398. * @return the action amended (prepared) after registration
  10399. */
  10400. registerAction(action: IAction): Nullable<IAction>;
  10401. /**
  10402. * Unregisters an action to this action manager
  10403. * @param action defines the action to be unregistered
  10404. * @return a boolean indicating whether the action has been unregistered
  10405. */
  10406. unregisterAction(action: IAction): Boolean;
  10407. /**
  10408. * Process a specific trigger
  10409. * @param trigger defines the trigger to process
  10410. * @param evt defines the event details to be processed
  10411. */
  10412. processTrigger(trigger: number, evt?: IActionEvent): void;
  10413. /** @hidden */
  10414. _getEffectiveTarget(target: any, propertyPath: string): any;
  10415. /** @hidden */
  10416. _getProperty(propertyPath: string): string;
  10417. /**
  10418. * Serialize this manager to a JSON object
  10419. * @param name defines the property name to store this manager
  10420. * @returns a JSON representation of this manager
  10421. */
  10422. serialize(name: string): any;
  10423. /**
  10424. * Creates a new ActionManager from a JSON data
  10425. * @param parsedActions defines the JSON data to read from
  10426. * @param object defines the hosting mesh
  10427. * @param scene defines the hosting scene
  10428. */
  10429. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10430. /**
  10431. * Get a trigger name by index
  10432. * @param trigger defines the trigger index
  10433. * @returns a trigger name
  10434. */
  10435. static GetTriggerName(trigger: number): string;
  10436. }
  10437. }
  10438. declare module "babylonjs/Sprites/sprite" {
  10439. import { Vector3 } from "babylonjs/Maths/math.vector";
  10440. import { Nullable } from "babylonjs/types";
  10441. import { ActionManager } from "babylonjs/Actions/actionManager";
  10442. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10443. import { Color4 } from "babylonjs/Maths/math.color";
  10444. import { Observable } from "babylonjs/Misc/observable";
  10445. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10446. import { Animation } from "babylonjs/Animations/animation";
  10447. /**
  10448. * Class used to represent a sprite
  10449. * @see https://doc.babylonjs.com/babylon101/sprites
  10450. */
  10451. export class Sprite implements IAnimatable {
  10452. /** defines the name */
  10453. name: string;
  10454. /** Gets or sets the current world position */
  10455. position: Vector3;
  10456. /** Gets or sets the main color */
  10457. color: Color4;
  10458. /** Gets or sets the width */
  10459. width: number;
  10460. /** Gets or sets the height */
  10461. height: number;
  10462. /** Gets or sets rotation angle */
  10463. angle: number;
  10464. /** Gets or sets the cell index in the sprite sheet */
  10465. cellIndex: number;
  10466. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10467. cellRef: string;
  10468. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10469. invertU: boolean;
  10470. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10471. invertV: boolean;
  10472. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10473. disposeWhenFinishedAnimating: boolean;
  10474. /** Gets the list of attached animations */
  10475. animations: Nullable<Array<Animation>>;
  10476. /** Gets or sets a boolean indicating if the sprite can be picked */
  10477. isPickable: boolean;
  10478. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10479. useAlphaForPicking: boolean;
  10480. /** @hidden */
  10481. _xOffset: number;
  10482. /** @hidden */
  10483. _yOffset: number;
  10484. /** @hidden */
  10485. _xSize: number;
  10486. /** @hidden */
  10487. _ySize: number;
  10488. /**
  10489. * Gets or sets the associated action manager
  10490. */
  10491. actionManager: Nullable<ActionManager>;
  10492. /**
  10493. * An event triggered when the control has been disposed
  10494. */
  10495. onDisposeObservable: Observable<Sprite>;
  10496. private _animationStarted;
  10497. private _loopAnimation;
  10498. private _fromIndex;
  10499. private _toIndex;
  10500. private _delay;
  10501. private _direction;
  10502. private _manager;
  10503. private _time;
  10504. private _onAnimationEnd;
  10505. /**
  10506. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10507. */
  10508. isVisible: boolean;
  10509. /**
  10510. * Gets or sets the sprite size
  10511. */
  10512. get size(): number;
  10513. set size(value: number);
  10514. /**
  10515. * Returns a boolean indicating if the animation is started
  10516. */
  10517. get animationStarted(): boolean;
  10518. /**
  10519. * Gets or sets the unique id of the sprite
  10520. */
  10521. uniqueId: number;
  10522. /**
  10523. * Gets the manager of this sprite
  10524. */
  10525. get manager(): ISpriteManager;
  10526. /**
  10527. * Creates a new Sprite
  10528. * @param name defines the name
  10529. * @param manager defines the manager
  10530. */
  10531. constructor(
  10532. /** defines the name */
  10533. name: string, manager: ISpriteManager);
  10534. /**
  10535. * Returns the string "Sprite"
  10536. * @returns "Sprite"
  10537. */
  10538. getClassName(): string;
  10539. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10540. get fromIndex(): number;
  10541. set fromIndex(value: number);
  10542. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10543. get toIndex(): number;
  10544. set toIndex(value: number);
  10545. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10546. get loopAnimation(): boolean;
  10547. set loopAnimation(value: boolean);
  10548. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10549. get delay(): number;
  10550. set delay(value: number);
  10551. /**
  10552. * Starts an animation
  10553. * @param from defines the initial key
  10554. * @param to defines the end key
  10555. * @param loop defines if the animation must loop
  10556. * @param delay defines the start delay (in ms)
  10557. * @param onAnimationEnd defines a callback to call when animation ends
  10558. */
  10559. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10560. /** Stops current animation (if any) */
  10561. stopAnimation(): void;
  10562. /** @hidden */
  10563. _animate(deltaTime: number): void;
  10564. /** Release associated resources */
  10565. dispose(): void;
  10566. /**
  10567. * Serializes the sprite to a JSON object
  10568. * @returns the JSON object
  10569. */
  10570. serialize(): any;
  10571. /**
  10572. * Parses a JSON object to create a new sprite
  10573. * @param parsedSprite The JSON object to parse
  10574. * @param manager defines the hosting manager
  10575. * @returns the new sprite
  10576. */
  10577. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10578. }
  10579. }
  10580. declare module "babylonjs/Collisions/pickingInfo" {
  10581. import { Nullable } from "babylonjs/types";
  10582. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10584. import { Sprite } from "babylonjs/Sprites/sprite";
  10585. import { Ray } from "babylonjs/Culling/ray";
  10586. /**
  10587. * Information about the result of picking within a scene
  10588. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10589. */
  10590. export class PickingInfo {
  10591. /** @hidden */
  10592. _pickingUnavailable: boolean;
  10593. /**
  10594. * If the pick collided with an object
  10595. */
  10596. hit: boolean;
  10597. /**
  10598. * Distance away where the pick collided
  10599. */
  10600. distance: number;
  10601. /**
  10602. * The location of pick collision
  10603. */
  10604. pickedPoint: Nullable<Vector3>;
  10605. /**
  10606. * The mesh corresponding the the pick collision
  10607. */
  10608. pickedMesh: Nullable<AbstractMesh>;
  10609. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10610. bu: number;
  10611. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10612. bv: number;
  10613. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10614. faceId: number;
  10615. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10616. subMeshFaceId: number;
  10617. /** Id of the the submesh that was picked */
  10618. subMeshId: number;
  10619. /** If a sprite was picked, this will be the sprite the pick collided with */
  10620. pickedSprite: Nullable<Sprite>;
  10621. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10622. thinInstanceIndex: number;
  10623. /**
  10624. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10625. */
  10626. originMesh: Nullable<AbstractMesh>;
  10627. /**
  10628. * The ray that was used to perform the picking.
  10629. */
  10630. ray: Nullable<Ray>;
  10631. /**
  10632. * Gets the normal correspodning to the face the pick collided with
  10633. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10634. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10635. * @returns The normal correspodning to the face the pick collided with
  10636. */
  10637. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10638. /**
  10639. * Gets the texture coordinates of where the pick occured
  10640. * @returns the vector containing the coordnates of the texture
  10641. */
  10642. getTextureCoordinates(): Nullable<Vector2>;
  10643. }
  10644. }
  10645. declare module "babylonjs/Culling/ray" {
  10646. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10647. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10649. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10650. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10651. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10652. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10653. import { Plane } from "babylonjs/Maths/math.plane";
  10654. /**
  10655. * Class representing a ray with position and direction
  10656. */
  10657. export class Ray {
  10658. /** origin point */
  10659. origin: Vector3;
  10660. /** direction */
  10661. direction: Vector3;
  10662. /** length of the ray */
  10663. length: number;
  10664. private static readonly _TmpVector3;
  10665. private _tmpRay;
  10666. /**
  10667. * Creates a new ray
  10668. * @param origin origin point
  10669. * @param direction direction
  10670. * @param length length of the ray
  10671. */
  10672. constructor(
  10673. /** origin point */
  10674. origin: Vector3,
  10675. /** direction */
  10676. direction: Vector3,
  10677. /** length of the ray */
  10678. length?: number);
  10679. /**
  10680. * Checks if the ray intersects a box
  10681. * This does not account for the ray lenght by design to improve perfs.
  10682. * @param minimum bound of the box
  10683. * @param maximum bound of the box
  10684. * @param intersectionTreshold extra extend to be added to the box in all direction
  10685. * @returns if the box was hit
  10686. */
  10687. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10688. /**
  10689. * Checks if the ray intersects a box
  10690. * This does not account for the ray lenght by design to improve perfs.
  10691. * @param box the bounding box to check
  10692. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10693. * @returns if the box was hit
  10694. */
  10695. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10696. /**
  10697. * If the ray hits a sphere
  10698. * @param sphere the bounding sphere to check
  10699. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10700. * @returns true if it hits the sphere
  10701. */
  10702. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10703. /**
  10704. * If the ray hits a triange
  10705. * @param vertex0 triangle vertex
  10706. * @param vertex1 triangle vertex
  10707. * @param vertex2 triangle vertex
  10708. * @returns intersection information if hit
  10709. */
  10710. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10711. /**
  10712. * Checks if ray intersects a plane
  10713. * @param plane the plane to check
  10714. * @returns the distance away it was hit
  10715. */
  10716. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10717. /**
  10718. * Calculate the intercept of a ray on a given axis
  10719. * @param axis to check 'x' | 'y' | 'z'
  10720. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10721. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10722. */
  10723. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10724. /**
  10725. * Checks if ray intersects a mesh
  10726. * @param mesh the mesh to check
  10727. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10728. * @returns picking info of the intersecton
  10729. */
  10730. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10731. /**
  10732. * Checks if ray intersects a mesh
  10733. * @param meshes the meshes to check
  10734. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10735. * @param results array to store result in
  10736. * @returns Array of picking infos
  10737. */
  10738. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10739. private _comparePickingInfo;
  10740. private static smallnum;
  10741. private static rayl;
  10742. /**
  10743. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10744. * @param sega the first point of the segment to test the intersection against
  10745. * @param segb the second point of the segment to test the intersection against
  10746. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10747. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10748. */
  10749. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10750. /**
  10751. * Update the ray from viewport position
  10752. * @param x position
  10753. * @param y y position
  10754. * @param viewportWidth viewport width
  10755. * @param viewportHeight viewport height
  10756. * @param world world matrix
  10757. * @param view view matrix
  10758. * @param projection projection matrix
  10759. * @returns this ray updated
  10760. */
  10761. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10762. /**
  10763. * Creates a ray with origin and direction of 0,0,0
  10764. * @returns the new ray
  10765. */
  10766. static Zero(): Ray;
  10767. /**
  10768. * Creates a new ray from screen space and viewport
  10769. * @param x position
  10770. * @param y y position
  10771. * @param viewportWidth viewport width
  10772. * @param viewportHeight viewport height
  10773. * @param world world matrix
  10774. * @param view view matrix
  10775. * @param projection projection matrix
  10776. * @returns new ray
  10777. */
  10778. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10779. /**
  10780. * 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
  10781. * transformed to the given world matrix.
  10782. * @param origin The origin point
  10783. * @param end The end point
  10784. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10785. * @returns the new ray
  10786. */
  10787. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10788. /**
  10789. * Transforms a ray by a matrix
  10790. * @param ray ray to transform
  10791. * @param matrix matrix to apply
  10792. * @returns the resulting new ray
  10793. */
  10794. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10795. /**
  10796. * Transforms a ray by a matrix
  10797. * @param ray ray to transform
  10798. * @param matrix matrix to apply
  10799. * @param result ray to store result in
  10800. */
  10801. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10802. /**
  10803. * Unproject a ray from screen space to object space
  10804. * @param sourceX defines the screen space x coordinate to use
  10805. * @param sourceY defines the screen space y coordinate to use
  10806. * @param viewportWidth defines the current width of the viewport
  10807. * @param viewportHeight defines the current height of the viewport
  10808. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10809. * @param view defines the view matrix to use
  10810. * @param projection defines the projection matrix to use
  10811. */
  10812. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10813. }
  10814. /**
  10815. * Type used to define predicate used to select faces when a mesh intersection is detected
  10816. */
  10817. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10818. module "babylonjs/scene" {
  10819. interface Scene {
  10820. /** @hidden */
  10821. _tempPickingRay: Nullable<Ray>;
  10822. /** @hidden */
  10823. _cachedRayForTransform: Ray;
  10824. /** @hidden */
  10825. _pickWithRayInverseMatrix: Matrix;
  10826. /** @hidden */
  10827. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10828. /** @hidden */
  10829. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10830. /** @hidden */
  10831. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10832. }
  10833. }
  10834. }
  10835. declare module "babylonjs/sceneComponent" {
  10836. import { Scene } from "babylonjs/scene";
  10837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10838. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10839. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10840. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10841. import { Nullable } from "babylonjs/types";
  10842. import { Camera } from "babylonjs/Cameras/camera";
  10843. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10844. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10845. import { AbstractScene } from "babylonjs/abstractScene";
  10846. import { Mesh } from "babylonjs/Meshes/mesh";
  10847. /**
  10848. * Groups all the scene component constants in one place to ease maintenance.
  10849. * @hidden
  10850. */
  10851. export class SceneComponentConstants {
  10852. static readonly NAME_EFFECTLAYER: string;
  10853. static readonly NAME_LAYER: string;
  10854. static readonly NAME_LENSFLARESYSTEM: string;
  10855. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10856. static readonly NAME_PARTICLESYSTEM: string;
  10857. static readonly NAME_GAMEPAD: string;
  10858. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10859. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10860. static readonly NAME_PREPASSRENDERER: string;
  10861. static readonly NAME_DEPTHRENDERER: string;
  10862. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10863. static readonly NAME_SPRITE: string;
  10864. static readonly NAME_OUTLINERENDERER: string;
  10865. static readonly NAME_PROCEDURALTEXTURE: string;
  10866. static readonly NAME_SHADOWGENERATOR: string;
  10867. static readonly NAME_OCTREE: string;
  10868. static readonly NAME_PHYSICSENGINE: string;
  10869. static readonly NAME_AUDIO: string;
  10870. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10871. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10872. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10873. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10874. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10875. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10876. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10877. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10878. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10879. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10880. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10881. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10882. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10883. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10884. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10885. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10886. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10887. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10888. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10889. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10890. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10891. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10892. static readonly STEP_AFTERRENDER_AUDIO: number;
  10893. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10894. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10895. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10896. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10897. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10898. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10899. static readonly STEP_POINTERMOVE_SPRITE: number;
  10900. static readonly STEP_POINTERDOWN_SPRITE: number;
  10901. static readonly STEP_POINTERUP_SPRITE: number;
  10902. }
  10903. /**
  10904. * This represents a scene component.
  10905. *
  10906. * This is used to decouple the dependency the scene is having on the different workloads like
  10907. * layers, post processes...
  10908. */
  10909. export interface ISceneComponent {
  10910. /**
  10911. * The name of the component. Each component must have a unique name.
  10912. */
  10913. name: string;
  10914. /**
  10915. * The scene the component belongs to.
  10916. */
  10917. scene: Scene;
  10918. /**
  10919. * Register the component to one instance of a scene.
  10920. */
  10921. register(): void;
  10922. /**
  10923. * Rebuilds the elements related to this component in case of
  10924. * context lost for instance.
  10925. */
  10926. rebuild(): void;
  10927. /**
  10928. * Disposes the component and the associated ressources.
  10929. */
  10930. dispose(): void;
  10931. }
  10932. /**
  10933. * This represents a SERIALIZABLE scene component.
  10934. *
  10935. * This extends Scene Component to add Serialization methods on top.
  10936. */
  10937. export interface ISceneSerializableComponent extends ISceneComponent {
  10938. /**
  10939. * Adds all the elements from the container to the scene
  10940. * @param container the container holding the elements
  10941. */
  10942. addFromContainer(container: AbstractScene): void;
  10943. /**
  10944. * Removes all the elements in the container from the scene
  10945. * @param container contains the elements to remove
  10946. * @param dispose if the removed element should be disposed (default: false)
  10947. */
  10948. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10949. /**
  10950. * Serializes the component data to the specified json object
  10951. * @param serializationObject The object to serialize to
  10952. */
  10953. serialize(serializationObject: any): void;
  10954. }
  10955. /**
  10956. * Strong typing of a Mesh related stage step action
  10957. */
  10958. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10959. /**
  10960. * Strong typing of a Evaluate Sub Mesh related stage step action
  10961. */
  10962. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10963. /**
  10964. * Strong typing of a Active Mesh related stage step action
  10965. */
  10966. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10967. /**
  10968. * Strong typing of a Camera related stage step action
  10969. */
  10970. export type CameraStageAction = (camera: Camera) => void;
  10971. /**
  10972. * Strong typing of a Camera Frame buffer related stage step action
  10973. */
  10974. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10975. /**
  10976. * Strong typing of a Render Target related stage step action
  10977. */
  10978. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10979. /**
  10980. * Strong typing of a RenderingGroup related stage step action
  10981. */
  10982. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10983. /**
  10984. * Strong typing of a Mesh Render related stage step action
  10985. */
  10986. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10987. /**
  10988. * Strong typing of a simple stage step action
  10989. */
  10990. export type SimpleStageAction = () => void;
  10991. /**
  10992. * Strong typing of a render target action.
  10993. */
  10994. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10995. /**
  10996. * Strong typing of a pointer move action.
  10997. */
  10998. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10999. /**
  11000. * Strong typing of a pointer up/down action.
  11001. */
  11002. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11003. /**
  11004. * Representation of a stage in the scene (Basically a list of ordered steps)
  11005. * @hidden
  11006. */
  11007. export class Stage<T extends Function> extends Array<{
  11008. index: number;
  11009. component: ISceneComponent;
  11010. action: T;
  11011. }> {
  11012. /**
  11013. * Hide ctor from the rest of the world.
  11014. * @param items The items to add.
  11015. */
  11016. private constructor();
  11017. /**
  11018. * Creates a new Stage.
  11019. * @returns A new instance of a Stage
  11020. */
  11021. static Create<T extends Function>(): Stage<T>;
  11022. /**
  11023. * Registers a step in an ordered way in the targeted stage.
  11024. * @param index Defines the position to register the step in
  11025. * @param component Defines the component attached to the step
  11026. * @param action Defines the action to launch during the step
  11027. */
  11028. registerStep(index: number, component: ISceneComponent, action: T): void;
  11029. /**
  11030. * Clears all the steps from the stage.
  11031. */
  11032. clear(): void;
  11033. }
  11034. }
  11035. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11036. import { Nullable } from "babylonjs/types";
  11037. import { Observable } from "babylonjs/Misc/observable";
  11038. import { Scene } from "babylonjs/scene";
  11039. import { Sprite } from "babylonjs/Sprites/sprite";
  11040. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11041. import { Ray } from "babylonjs/Culling/ray";
  11042. import { Camera } from "babylonjs/Cameras/camera";
  11043. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11044. import { ISceneComponent } from "babylonjs/sceneComponent";
  11045. module "babylonjs/scene" {
  11046. interface Scene {
  11047. /** @hidden */
  11048. _pointerOverSprite: Nullable<Sprite>;
  11049. /** @hidden */
  11050. _pickedDownSprite: Nullable<Sprite>;
  11051. /** @hidden */
  11052. _tempSpritePickingRay: Nullable<Ray>;
  11053. /**
  11054. * All of the sprite managers added to this scene
  11055. * @see https://doc.babylonjs.com/babylon101/sprites
  11056. */
  11057. spriteManagers: Array<ISpriteManager>;
  11058. /**
  11059. * An event triggered when sprites rendering is about to start
  11060. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11061. */
  11062. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11063. /**
  11064. * An event triggered when sprites rendering is done
  11065. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11066. */
  11067. onAfterSpritesRenderingObservable: Observable<Scene>;
  11068. /** @hidden */
  11069. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11070. /** Launch a ray to try to pick a sprite in the scene
  11071. * @param x position on screen
  11072. * @param y position on screen
  11073. * @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
  11074. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11075. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11076. * @returns a PickingInfo
  11077. */
  11078. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11079. /** Use the given ray to pick a sprite in the scene
  11080. * @param ray The ray (in world space) to use to pick meshes
  11081. * @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
  11082. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11083. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11084. * @returns a PickingInfo
  11085. */
  11086. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11087. /** @hidden */
  11088. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11089. /** Launch a ray to try to pick sprites in the scene
  11090. * @param x position on screen
  11091. * @param y position on screen
  11092. * @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
  11093. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11094. * @returns a PickingInfo array
  11095. */
  11096. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11097. /** Use the given ray to pick sprites in the scene
  11098. * @param ray The ray (in world space) to use to pick meshes
  11099. * @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
  11100. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11101. * @returns a PickingInfo array
  11102. */
  11103. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11104. /**
  11105. * Force the sprite under the pointer
  11106. * @param sprite defines the sprite to use
  11107. */
  11108. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11109. /**
  11110. * Gets the sprite under the pointer
  11111. * @returns a Sprite or null if no sprite is under the pointer
  11112. */
  11113. getPointerOverSprite(): Nullable<Sprite>;
  11114. }
  11115. }
  11116. /**
  11117. * Defines the sprite scene component responsible to manage sprites
  11118. * in a given scene.
  11119. */
  11120. export class SpriteSceneComponent implements ISceneComponent {
  11121. /**
  11122. * The component name helpfull to identify the component in the list of scene components.
  11123. */
  11124. readonly name: string;
  11125. /**
  11126. * The scene the component belongs to.
  11127. */
  11128. scene: Scene;
  11129. /** @hidden */
  11130. private _spritePredicate;
  11131. /**
  11132. * Creates a new instance of the component for the given scene
  11133. * @param scene Defines the scene to register the component in
  11134. */
  11135. constructor(scene: Scene);
  11136. /**
  11137. * Registers the component in a given scene
  11138. */
  11139. register(): void;
  11140. /**
  11141. * Rebuilds the elements related to this component in case of
  11142. * context lost for instance.
  11143. */
  11144. rebuild(): void;
  11145. /**
  11146. * Disposes the component and the associated ressources.
  11147. */
  11148. dispose(): void;
  11149. private _pickSpriteButKeepRay;
  11150. private _pointerMove;
  11151. private _pointerDown;
  11152. private _pointerUp;
  11153. }
  11154. }
  11155. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11156. /** @hidden */
  11157. export var fogFragmentDeclaration: {
  11158. name: string;
  11159. shader: string;
  11160. };
  11161. }
  11162. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11163. /** @hidden */
  11164. export var fogFragment: {
  11165. name: string;
  11166. shader: string;
  11167. };
  11168. }
  11169. declare module "babylonjs/Shaders/sprites.fragment" {
  11170. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11171. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11172. /** @hidden */
  11173. export var spritesPixelShader: {
  11174. name: string;
  11175. shader: string;
  11176. };
  11177. }
  11178. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11179. /** @hidden */
  11180. export var fogVertexDeclaration: {
  11181. name: string;
  11182. shader: string;
  11183. };
  11184. }
  11185. declare module "babylonjs/Shaders/sprites.vertex" {
  11186. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11187. /** @hidden */
  11188. export var spritesVertexShader: {
  11189. name: string;
  11190. shader: string;
  11191. };
  11192. }
  11193. declare module "babylonjs/Sprites/spriteManager" {
  11194. import { IDisposable, Scene } from "babylonjs/scene";
  11195. import { Nullable } from "babylonjs/types";
  11196. import { Observable } from "babylonjs/Misc/observable";
  11197. import { Sprite } from "babylonjs/Sprites/sprite";
  11198. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11199. import { Camera } from "babylonjs/Cameras/camera";
  11200. import { Texture } from "babylonjs/Materials/Textures/texture";
  11201. import "babylonjs/Shaders/sprites.fragment";
  11202. import "babylonjs/Shaders/sprites.vertex";
  11203. import { Ray } from "babylonjs/Culling/ray";
  11204. /**
  11205. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11206. */
  11207. export interface ISpriteManager extends IDisposable {
  11208. /**
  11209. * Gets manager's name
  11210. */
  11211. name: string;
  11212. /**
  11213. * Restricts the camera to viewing objects with the same layerMask.
  11214. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11215. */
  11216. layerMask: number;
  11217. /**
  11218. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11219. */
  11220. isPickable: boolean;
  11221. /**
  11222. * Gets the hosting scene
  11223. */
  11224. scene: Scene;
  11225. /**
  11226. * Specifies the rendering group id for this mesh (0 by default)
  11227. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11228. */
  11229. renderingGroupId: number;
  11230. /**
  11231. * Defines the list of sprites managed by the manager.
  11232. */
  11233. sprites: Array<Sprite>;
  11234. /**
  11235. * Gets or sets the spritesheet texture
  11236. */
  11237. texture: Texture;
  11238. /** Defines the default width of a cell in the spritesheet */
  11239. cellWidth: number;
  11240. /** Defines the default height of a cell in the spritesheet */
  11241. cellHeight: number;
  11242. /**
  11243. * Tests the intersection of a sprite with a specific ray.
  11244. * @param ray The ray we are sending to test the collision
  11245. * @param camera The camera space we are sending rays in
  11246. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11247. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11248. * @returns picking info or null.
  11249. */
  11250. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11251. /**
  11252. * Intersects the sprites with a ray
  11253. * @param ray defines the ray to intersect with
  11254. * @param camera defines the current active camera
  11255. * @param predicate defines a predicate used to select candidate sprites
  11256. * @returns null if no hit or a PickingInfo array
  11257. */
  11258. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11259. /**
  11260. * Renders the list of sprites on screen.
  11261. */
  11262. render(): void;
  11263. }
  11264. /**
  11265. * Class used to manage multiple sprites on the same spritesheet
  11266. * @see https://doc.babylonjs.com/babylon101/sprites
  11267. */
  11268. export class SpriteManager implements ISpriteManager {
  11269. /** defines the manager's name */
  11270. name: string;
  11271. /** Define the Url to load snippets */
  11272. static SnippetUrl: string;
  11273. /** Snippet ID if the manager was created from the snippet server */
  11274. snippetId: string;
  11275. /** Gets the list of sprites */
  11276. sprites: Sprite[];
  11277. /** Gets or sets the rendering group id (0 by default) */
  11278. renderingGroupId: number;
  11279. /** Gets or sets camera layer mask */
  11280. layerMask: number;
  11281. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11282. fogEnabled: boolean;
  11283. /** Gets or sets a boolean indicating if the sprites are pickable */
  11284. isPickable: boolean;
  11285. /** Defines the default width of a cell in the spritesheet */
  11286. cellWidth: number;
  11287. /** Defines the default height of a cell in the spritesheet */
  11288. cellHeight: number;
  11289. /** Associative array from JSON sprite data file */
  11290. private _cellData;
  11291. /** Array of sprite names from JSON sprite data file */
  11292. private _spriteMap;
  11293. /** True when packed cell data from JSON file is ready*/
  11294. private _packedAndReady;
  11295. private _textureContent;
  11296. private _useInstancing;
  11297. /**
  11298. * An event triggered when the manager is disposed.
  11299. */
  11300. onDisposeObservable: Observable<SpriteManager>;
  11301. private _onDisposeObserver;
  11302. /**
  11303. * Callback called when the manager is disposed
  11304. */
  11305. set onDispose(callback: () => void);
  11306. private _capacity;
  11307. private _fromPacked;
  11308. private _spriteTexture;
  11309. private _epsilon;
  11310. private _scene;
  11311. private _vertexData;
  11312. private _buffer;
  11313. private _vertexBuffers;
  11314. private _spriteBuffer;
  11315. private _indexBuffer;
  11316. private _effectBase;
  11317. private _effectFog;
  11318. private _vertexBufferSize;
  11319. /**
  11320. * Gets or sets the unique id of the sprite
  11321. */
  11322. uniqueId: number;
  11323. /**
  11324. * Gets the array of sprites
  11325. */
  11326. get children(): Sprite[];
  11327. /**
  11328. * Gets the hosting scene
  11329. */
  11330. get scene(): Scene;
  11331. /**
  11332. * Gets the capacity of the manager
  11333. */
  11334. get capacity(): number;
  11335. /**
  11336. * Gets or sets the spritesheet texture
  11337. */
  11338. get texture(): Texture;
  11339. set texture(value: Texture);
  11340. private _blendMode;
  11341. /**
  11342. * Blend mode use to render the particle, it can be any of
  11343. * the static Constants.ALPHA_x properties provided in this class.
  11344. * Default value is Constants.ALPHA_COMBINE
  11345. */
  11346. get blendMode(): number;
  11347. set blendMode(blendMode: number);
  11348. /** Disables writing to the depth buffer when rendering the sprites.
  11349. * It can be handy to disable depth writing when using textures without alpha channel
  11350. * and setting some specific blend modes.
  11351. */
  11352. disableDepthWrite: boolean;
  11353. /**
  11354. * Creates a new sprite manager
  11355. * @param name defines the manager's name
  11356. * @param imgUrl defines the sprite sheet url
  11357. * @param capacity defines the maximum allowed number of sprites
  11358. * @param cellSize defines the size of a sprite cell
  11359. * @param scene defines the hosting scene
  11360. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11361. * @param samplingMode defines the smapling mode to use with spritesheet
  11362. * @param fromPacked set to false; do not alter
  11363. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11364. */
  11365. constructor(
  11366. /** defines the manager's name */
  11367. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11368. /**
  11369. * Returns the string "SpriteManager"
  11370. * @returns "SpriteManager"
  11371. */
  11372. getClassName(): string;
  11373. private _makePacked;
  11374. private _appendSpriteVertex;
  11375. private _checkTextureAlpha;
  11376. /**
  11377. * Intersects the sprites with a ray
  11378. * @param ray defines the ray to intersect with
  11379. * @param camera defines the current active camera
  11380. * @param predicate defines a predicate used to select candidate sprites
  11381. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11382. * @returns null if no hit or a PickingInfo
  11383. */
  11384. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11385. /**
  11386. * Intersects the sprites with a ray
  11387. * @param ray defines the ray to intersect with
  11388. * @param camera defines the current active camera
  11389. * @param predicate defines a predicate used to select candidate sprites
  11390. * @returns null if no hit or a PickingInfo array
  11391. */
  11392. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11393. /**
  11394. * Render all child sprites
  11395. */
  11396. render(): void;
  11397. /**
  11398. * Release associated resources
  11399. */
  11400. dispose(): void;
  11401. /**
  11402. * Serializes the sprite manager to a JSON object
  11403. * @param serializeTexture defines if the texture must be serialized as well
  11404. * @returns the JSON object
  11405. */
  11406. serialize(serializeTexture?: boolean): any;
  11407. /**
  11408. * Parses a JSON object to create a new sprite manager.
  11409. * @param parsedManager The JSON object to parse
  11410. * @param scene The scene to create the sprite managerin
  11411. * @param rootUrl The root url to use to load external dependencies like texture
  11412. * @returns the new sprite manager
  11413. */
  11414. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11415. /**
  11416. * Creates a sprite manager from a snippet saved in a remote file
  11417. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11418. * @param url defines the url to load from
  11419. * @param scene defines the hosting scene
  11420. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11421. * @returns a promise that will resolve to the new sprite manager
  11422. */
  11423. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11424. /**
  11425. * Creates a sprite manager from a snippet saved by the sprite editor
  11426. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11427. * @param scene defines the hosting scene
  11428. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11429. * @returns a promise that will resolve to the new sprite manager
  11430. */
  11431. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11432. }
  11433. }
  11434. declare module "babylonjs/Misc/gradients" {
  11435. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11436. /** Interface used by value gradients (color, factor, ...) */
  11437. export interface IValueGradient {
  11438. /**
  11439. * Gets or sets the gradient value (between 0 and 1)
  11440. */
  11441. gradient: number;
  11442. }
  11443. /** Class used to store color4 gradient */
  11444. export class ColorGradient implements IValueGradient {
  11445. /**
  11446. * Gets or sets the gradient value (between 0 and 1)
  11447. */
  11448. gradient: number;
  11449. /**
  11450. * Gets or sets first associated color
  11451. */
  11452. color1: Color4;
  11453. /**
  11454. * Gets or sets second associated color
  11455. */
  11456. color2?: Color4 | undefined;
  11457. /**
  11458. * Creates a new color4 gradient
  11459. * @param gradient gets or sets the gradient value (between 0 and 1)
  11460. * @param color1 gets or sets first associated color
  11461. * @param color2 gets or sets first second color
  11462. */
  11463. constructor(
  11464. /**
  11465. * Gets or sets the gradient value (between 0 and 1)
  11466. */
  11467. gradient: number,
  11468. /**
  11469. * Gets or sets first associated color
  11470. */
  11471. color1: Color4,
  11472. /**
  11473. * Gets or sets second associated color
  11474. */
  11475. color2?: Color4 | undefined);
  11476. /**
  11477. * Will get a color picked randomly between color1 and color2.
  11478. * If color2 is undefined then color1 will be used
  11479. * @param result defines the target Color4 to store the result in
  11480. */
  11481. getColorToRef(result: Color4): void;
  11482. }
  11483. /** Class used to store color 3 gradient */
  11484. export class Color3Gradient implements IValueGradient {
  11485. /**
  11486. * Gets or sets the gradient value (between 0 and 1)
  11487. */
  11488. gradient: number;
  11489. /**
  11490. * Gets or sets the associated color
  11491. */
  11492. color: Color3;
  11493. /**
  11494. * Creates a new color3 gradient
  11495. * @param gradient gets or sets the gradient value (between 0 and 1)
  11496. * @param color gets or sets associated color
  11497. */
  11498. constructor(
  11499. /**
  11500. * Gets or sets the gradient value (between 0 and 1)
  11501. */
  11502. gradient: number,
  11503. /**
  11504. * Gets or sets the associated color
  11505. */
  11506. color: Color3);
  11507. }
  11508. /** Class used to store factor gradient */
  11509. export class FactorGradient implements IValueGradient {
  11510. /**
  11511. * Gets or sets the gradient value (between 0 and 1)
  11512. */
  11513. gradient: number;
  11514. /**
  11515. * Gets or sets first associated factor
  11516. */
  11517. factor1: number;
  11518. /**
  11519. * Gets or sets second associated factor
  11520. */
  11521. factor2?: number | undefined;
  11522. /**
  11523. * Creates a new factor gradient
  11524. * @param gradient gets or sets the gradient value (between 0 and 1)
  11525. * @param factor1 gets or sets first associated factor
  11526. * @param factor2 gets or sets second associated factor
  11527. */
  11528. constructor(
  11529. /**
  11530. * Gets or sets the gradient value (between 0 and 1)
  11531. */
  11532. gradient: number,
  11533. /**
  11534. * Gets or sets first associated factor
  11535. */
  11536. factor1: number,
  11537. /**
  11538. * Gets or sets second associated factor
  11539. */
  11540. factor2?: number | undefined);
  11541. /**
  11542. * Will get a number picked randomly between factor1 and factor2.
  11543. * If factor2 is undefined then factor1 will be used
  11544. * @returns the picked number
  11545. */
  11546. getFactor(): number;
  11547. }
  11548. /**
  11549. * Helper used to simplify some generic gradient tasks
  11550. */
  11551. export class GradientHelper {
  11552. /**
  11553. * Gets the current gradient from an array of IValueGradient
  11554. * @param ratio defines the current ratio to get
  11555. * @param gradients defines the array of IValueGradient
  11556. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11557. */
  11558. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11559. }
  11560. }
  11561. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11562. import { Nullable } from "babylonjs/types";
  11563. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11564. import { Scene } from "babylonjs/scene";
  11565. module "babylonjs/Engines/thinEngine" {
  11566. interface ThinEngine {
  11567. /**
  11568. * Creates a raw texture
  11569. * @param data defines the data to store in the texture
  11570. * @param width defines the width of the texture
  11571. * @param height defines the height of the texture
  11572. * @param format defines the format of the data
  11573. * @param generateMipMaps defines if the engine should generate the mip levels
  11574. * @param invertY defines if data must be stored with Y axis inverted
  11575. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11576. * @param compression defines the compression used (null by default)
  11577. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11578. * @returns the raw texture inside an InternalTexture
  11579. */
  11580. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11581. /**
  11582. * Update a raw texture
  11583. * @param texture defines the texture to update
  11584. * @param data defines the data to store in the texture
  11585. * @param format defines the format of the data
  11586. * @param invertY defines if data must be stored with Y axis inverted
  11587. */
  11588. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11589. /**
  11590. * Update a raw texture
  11591. * @param texture defines the texture to update
  11592. * @param data defines the data to store in the texture
  11593. * @param format defines the format of the data
  11594. * @param invertY defines if data must be stored with Y axis inverted
  11595. * @param compression defines the compression used (null by default)
  11596. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11597. */
  11598. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11599. /**
  11600. * Creates a new raw cube texture
  11601. * @param data defines the array of data to use to create each face
  11602. * @param size defines the size of the textures
  11603. * @param format defines the format of the data
  11604. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11605. * @param generateMipMaps defines if the engine should generate the mip levels
  11606. * @param invertY defines if data must be stored with Y axis inverted
  11607. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11608. * @param compression defines the compression used (null by default)
  11609. * @returns the cube texture as an InternalTexture
  11610. */
  11611. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11612. /**
  11613. * Update a raw cube texture
  11614. * @param texture defines the texture to udpdate
  11615. * @param data defines the data to store
  11616. * @param format defines the data format
  11617. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11618. * @param invertY defines if data must be stored with Y axis inverted
  11619. */
  11620. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11621. /**
  11622. * Update a raw cube texture
  11623. * @param texture defines the texture to udpdate
  11624. * @param data defines the data to store
  11625. * @param format defines the data format
  11626. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11627. * @param invertY defines if data must be stored with Y axis inverted
  11628. * @param compression defines the compression used (null by default)
  11629. */
  11630. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11631. /**
  11632. * Update a raw cube texture
  11633. * @param texture defines the texture to udpdate
  11634. * @param data defines the data to store
  11635. * @param format defines the data format
  11636. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11637. * @param invertY defines if data must be stored with Y axis inverted
  11638. * @param compression defines the compression used (null by default)
  11639. * @param level defines which level of the texture to update
  11640. */
  11641. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11642. /**
  11643. * Creates a new raw cube texture from a specified url
  11644. * @param url defines the url where the data is located
  11645. * @param scene defines the current scene
  11646. * @param size defines the size of the textures
  11647. * @param format defines the format of the data
  11648. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11649. * @param noMipmap defines if the engine should avoid generating the mip levels
  11650. * @param callback defines a callback used to extract texture data from loaded data
  11651. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11652. * @param onLoad defines a callback called when texture is loaded
  11653. * @param onError defines a callback called if there is an error
  11654. * @returns the cube texture as an InternalTexture
  11655. */
  11656. 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;
  11657. /**
  11658. * Creates a new raw cube texture from a specified url
  11659. * @param url defines the url where the data is located
  11660. * @param scene defines the current scene
  11661. * @param size defines the size of the textures
  11662. * @param format defines the format of the data
  11663. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11664. * @param noMipmap defines if the engine should avoid generating the mip levels
  11665. * @param callback defines a callback used to extract texture data from loaded data
  11666. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11667. * @param onLoad defines a callback called when texture is loaded
  11668. * @param onError defines a callback called if there is an error
  11669. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11670. * @param invertY defines if data must be stored with Y axis inverted
  11671. * @returns the cube texture as an InternalTexture
  11672. */
  11673. 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;
  11674. /**
  11675. * Creates a new raw 3D texture
  11676. * @param data defines the data used to create the texture
  11677. * @param width defines the width of the texture
  11678. * @param height defines the height of the texture
  11679. * @param depth defines the depth of the texture
  11680. * @param format defines the format of the texture
  11681. * @param generateMipMaps defines if the engine must generate mip levels
  11682. * @param invertY defines if data must be stored with Y axis inverted
  11683. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11684. * @param compression defines the compressed used (can be null)
  11685. * @param textureType defines the compressed used (can be null)
  11686. * @returns a new raw 3D texture (stored in an InternalTexture)
  11687. */
  11688. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11689. /**
  11690. * Update a raw 3D texture
  11691. * @param texture defines the texture to update
  11692. * @param data defines the data to store
  11693. * @param format defines the data format
  11694. * @param invertY defines if data must be stored with Y axis inverted
  11695. */
  11696. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11697. /**
  11698. * Update a raw 3D texture
  11699. * @param texture defines the texture to update
  11700. * @param data defines the data to store
  11701. * @param format defines the data format
  11702. * @param invertY defines if data must be stored with Y axis inverted
  11703. * @param compression defines the used compression (can be null)
  11704. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11705. */
  11706. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11707. /**
  11708. * Creates a new raw 2D array texture
  11709. * @param data defines the data used to create the texture
  11710. * @param width defines the width of the texture
  11711. * @param height defines the height of the texture
  11712. * @param depth defines the number of layers of the texture
  11713. * @param format defines the format of the texture
  11714. * @param generateMipMaps defines if the engine must generate mip levels
  11715. * @param invertY defines if data must be stored with Y axis inverted
  11716. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11717. * @param compression defines the compressed used (can be null)
  11718. * @param textureType defines the compressed used (can be null)
  11719. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11720. */
  11721. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11722. /**
  11723. * Update a raw 2D array texture
  11724. * @param texture defines the texture to update
  11725. * @param data defines the data to store
  11726. * @param format defines the data format
  11727. * @param invertY defines if data must be stored with Y axis inverted
  11728. */
  11729. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11730. /**
  11731. * Update a raw 2D array texture
  11732. * @param texture defines the texture to update
  11733. * @param data defines the data to store
  11734. * @param format defines the data format
  11735. * @param invertY defines if data must be stored with Y axis inverted
  11736. * @param compression defines the used compression (can be null)
  11737. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11738. */
  11739. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11740. }
  11741. }
  11742. }
  11743. declare module "babylonjs/Materials/Textures/rawTexture" {
  11744. import { Texture } from "babylonjs/Materials/Textures/texture";
  11745. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11746. import { Nullable } from "babylonjs/types";
  11747. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11748. import { Scene } from "babylonjs/scene";
  11749. /**
  11750. * Raw texture can help creating a texture directly from an array of data.
  11751. * This can be super useful if you either get the data from an uncompressed source or
  11752. * if you wish to create your texture pixel by pixel.
  11753. */
  11754. export class RawTexture extends Texture {
  11755. /**
  11756. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11757. */
  11758. format: number;
  11759. /**
  11760. * Instantiates a new RawTexture.
  11761. * Raw texture can help creating a texture directly from an array of data.
  11762. * This can be super useful if you either get the data from an uncompressed source or
  11763. * if you wish to create your texture pixel by pixel.
  11764. * @param data define the array of data to use to create the texture
  11765. * @param width define the width of the texture
  11766. * @param height define the height of the texture
  11767. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11768. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11769. * @param generateMipMaps define whether mip maps should be generated or not
  11770. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11771. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11772. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11773. */
  11774. constructor(data: ArrayBufferView, width: number, height: number,
  11775. /**
  11776. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11777. */
  11778. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11779. /**
  11780. * Updates the texture underlying data.
  11781. * @param data Define the new data of the texture
  11782. */
  11783. update(data: ArrayBufferView): void;
  11784. /**
  11785. * Creates a luminance texture from some data.
  11786. * @param data Define the texture data
  11787. * @param width Define the width of the texture
  11788. * @param height Define the height of the texture
  11789. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11790. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11791. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11792. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11793. * @returns the luminance texture
  11794. */
  11795. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11796. /**
  11797. * Creates a luminance alpha texture from some data.
  11798. * @param data Define the texture data
  11799. * @param width Define the width of the texture
  11800. * @param height Define the height of the texture
  11801. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11802. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11803. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11804. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11805. * @returns the luminance alpha texture
  11806. */
  11807. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11808. /**
  11809. * Creates an alpha texture from some data.
  11810. * @param data Define the texture data
  11811. * @param width Define the width of the texture
  11812. * @param height Define the height of the texture
  11813. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11814. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11815. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11816. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11817. * @returns the alpha texture
  11818. */
  11819. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11820. /**
  11821. * Creates a RGB texture from some data.
  11822. * @param data Define the texture data
  11823. * @param width Define the width of the texture
  11824. * @param height Define the height of the texture
  11825. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11826. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11827. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11828. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11829. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11830. * @returns the RGB alpha texture
  11831. */
  11832. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11833. /**
  11834. * Creates a RGBA texture from some data.
  11835. * @param data Define the texture data
  11836. * @param width Define the width of the texture
  11837. * @param height Define the height of the texture
  11838. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11839. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11840. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11841. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11842. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11843. * @returns the RGBA texture
  11844. */
  11845. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11846. /**
  11847. * Creates a R texture from some data.
  11848. * @param data Define the texture data
  11849. * @param width Define the width of the texture
  11850. * @param height Define the height of the texture
  11851. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11852. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11853. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11854. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11855. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11856. * @returns the R texture
  11857. */
  11858. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11859. }
  11860. }
  11861. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11862. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11863. import { IndicesArray, DataArray } from "babylonjs/types";
  11864. module "babylonjs/Engines/thinEngine" {
  11865. interface ThinEngine {
  11866. /**
  11867. * Update a dynamic index buffer
  11868. * @param indexBuffer defines the target index buffer
  11869. * @param indices defines the data to update
  11870. * @param offset defines the offset in the target index buffer where update should start
  11871. */
  11872. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11873. /**
  11874. * Updates a dynamic vertex buffer.
  11875. * @param vertexBuffer the vertex buffer to update
  11876. * @param data the data used to update the vertex buffer
  11877. * @param byteOffset the byte offset of the data
  11878. * @param byteLength the byte length of the data
  11879. */
  11880. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11881. }
  11882. }
  11883. }
  11884. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11885. import { Scene } from "babylonjs/scene";
  11886. import { ISceneComponent } from "babylonjs/sceneComponent";
  11887. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11888. module "babylonjs/abstractScene" {
  11889. interface AbstractScene {
  11890. /**
  11891. * The list of procedural textures added to the scene
  11892. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11893. */
  11894. proceduralTextures: Array<ProceduralTexture>;
  11895. }
  11896. }
  11897. /**
  11898. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11899. * in a given scene.
  11900. */
  11901. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11902. /**
  11903. * The component name helpfull to identify the component in the list of scene components.
  11904. */
  11905. readonly name: string;
  11906. /**
  11907. * The scene the component belongs to.
  11908. */
  11909. scene: Scene;
  11910. /**
  11911. * Creates a new instance of the component for the given scene
  11912. * @param scene Defines the scene to register the component in
  11913. */
  11914. constructor(scene: Scene);
  11915. /**
  11916. * Registers the component in a given scene
  11917. */
  11918. register(): void;
  11919. /**
  11920. * Rebuilds the elements related to this component in case of
  11921. * context lost for instance.
  11922. */
  11923. rebuild(): void;
  11924. /**
  11925. * Disposes the component and the associated ressources.
  11926. */
  11927. dispose(): void;
  11928. private _beforeClear;
  11929. }
  11930. }
  11931. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11932. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11933. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11934. module "babylonjs/Engines/thinEngine" {
  11935. interface ThinEngine {
  11936. /**
  11937. * Creates a new render target cube texture
  11938. * @param size defines the size of the texture
  11939. * @param options defines the options used to create the texture
  11940. * @returns a new render target cube texture stored in an InternalTexture
  11941. */
  11942. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11943. }
  11944. }
  11945. }
  11946. declare module "babylonjs/Shaders/procedural.vertex" {
  11947. /** @hidden */
  11948. export var proceduralVertexShader: {
  11949. name: string;
  11950. shader: string;
  11951. };
  11952. }
  11953. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11954. import { Observable } from "babylonjs/Misc/observable";
  11955. import { Nullable } from "babylonjs/types";
  11956. import { Scene } from "babylonjs/scene";
  11957. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11958. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11959. import { Effect } from "babylonjs/Materials/effect";
  11960. import { Texture } from "babylonjs/Materials/Textures/texture";
  11961. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11962. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11963. import "babylonjs/Shaders/procedural.vertex";
  11964. /**
  11965. * 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.
  11966. * This is the base class of any Procedural texture and contains most of the shareable code.
  11967. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11968. */
  11969. export class ProceduralTexture extends Texture {
  11970. /**
  11971. * Define if the texture is enabled or not (disabled texture will not render)
  11972. */
  11973. isEnabled: boolean;
  11974. /**
  11975. * Define if the texture must be cleared before rendering (default is true)
  11976. */
  11977. autoClear: boolean;
  11978. /**
  11979. * Callback called when the texture is generated
  11980. */
  11981. onGenerated: () => void;
  11982. /**
  11983. * Event raised when the texture is generated
  11984. */
  11985. onGeneratedObservable: Observable<ProceduralTexture>;
  11986. /** @hidden */
  11987. _generateMipMaps: boolean;
  11988. /** @hidden **/
  11989. _effect: Effect;
  11990. /** @hidden */
  11991. _textures: {
  11992. [key: string]: Texture;
  11993. };
  11994. /** @hidden */
  11995. protected _fallbackTexture: Nullable<Texture>;
  11996. private _size;
  11997. private _currentRefreshId;
  11998. private _frameId;
  11999. private _refreshRate;
  12000. private _vertexBuffers;
  12001. private _indexBuffer;
  12002. private _uniforms;
  12003. private _samplers;
  12004. private _fragment;
  12005. private _floats;
  12006. private _ints;
  12007. private _floatsArrays;
  12008. private _colors3;
  12009. private _colors4;
  12010. private _vectors2;
  12011. private _vectors3;
  12012. private _matrices;
  12013. private _fallbackTextureUsed;
  12014. private _fullEngine;
  12015. private _cachedDefines;
  12016. private _contentUpdateId;
  12017. private _contentData;
  12018. /**
  12019. * Instantiates a new procedural texture.
  12020. * 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.
  12021. * This is the base class of any Procedural texture and contains most of the shareable code.
  12022. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12023. * @param name Define the name of the texture
  12024. * @param size Define the size of the texture to create
  12025. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12026. * @param scene Define the scene the texture belongs to
  12027. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12028. * @param generateMipMaps Define if the texture should creates mip maps or not
  12029. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12030. */
  12031. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  12032. /**
  12033. * The effect that is created when initializing the post process.
  12034. * @returns The created effect corresponding the the postprocess.
  12035. */
  12036. getEffect(): Effect;
  12037. /**
  12038. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12039. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12040. */
  12041. getContent(): Nullable<ArrayBufferView>;
  12042. private _createIndexBuffer;
  12043. /** @hidden */
  12044. _rebuild(): void;
  12045. /**
  12046. * Resets the texture in order to recreate its associated resources.
  12047. * This can be called in case of context loss
  12048. */
  12049. reset(): void;
  12050. protected _getDefines(): string;
  12051. /**
  12052. * Is the texture ready to be used ? (rendered at least once)
  12053. * @returns true if ready, otherwise, false.
  12054. */
  12055. isReady(): boolean;
  12056. /**
  12057. * Resets the refresh counter of the texture and start bak from scratch.
  12058. * Could be useful to regenerate the texture if it is setup to render only once.
  12059. */
  12060. resetRefreshCounter(): void;
  12061. /**
  12062. * Set the fragment shader to use in order to render the texture.
  12063. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12064. */
  12065. setFragment(fragment: any): void;
  12066. /**
  12067. * Define the refresh rate of the texture or the rendering frequency.
  12068. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12069. */
  12070. get refreshRate(): number;
  12071. set refreshRate(value: number);
  12072. /** @hidden */
  12073. _shouldRender(): boolean;
  12074. /**
  12075. * Get the size the texture is rendering at.
  12076. * @returns the size (texture is always squared)
  12077. */
  12078. getRenderSize(): number;
  12079. /**
  12080. * Resize the texture to new value.
  12081. * @param size Define the new size the texture should have
  12082. * @param generateMipMaps Define whether the new texture should create mip maps
  12083. */
  12084. resize(size: number, generateMipMaps: boolean): void;
  12085. private _checkUniform;
  12086. /**
  12087. * Set a texture in the shader program used to render.
  12088. * @param name Define the name of the uniform samplers as defined in the shader
  12089. * @param texture Define the texture to bind to this sampler
  12090. * @return the texture itself allowing "fluent" like uniform updates
  12091. */
  12092. setTexture(name: string, texture: Texture): ProceduralTexture;
  12093. /**
  12094. * Set a float in the shader.
  12095. * @param name Define the name of the uniform as defined in the shader
  12096. * @param value Define the value to give to the uniform
  12097. * @return the texture itself allowing "fluent" like uniform updates
  12098. */
  12099. setFloat(name: string, value: number): ProceduralTexture;
  12100. /**
  12101. * Set a int in the shader.
  12102. * @param name Define the name of the uniform as defined in the shader
  12103. * @param value Define the value to give to the uniform
  12104. * @return the texture itself allowing "fluent" like uniform updates
  12105. */
  12106. setInt(name: string, value: number): ProceduralTexture;
  12107. /**
  12108. * Set an array of floats in the shader.
  12109. * @param name Define the name of the uniform as defined in the shader
  12110. * @param value Define the value to give to the uniform
  12111. * @return the texture itself allowing "fluent" like uniform updates
  12112. */
  12113. setFloats(name: string, value: number[]): ProceduralTexture;
  12114. /**
  12115. * Set a vec3 in the shader from a Color3.
  12116. * @param name Define the name of the uniform as defined in the shader
  12117. * @param value Define the value to give to the uniform
  12118. * @return the texture itself allowing "fluent" like uniform updates
  12119. */
  12120. setColor3(name: string, value: Color3): ProceduralTexture;
  12121. /**
  12122. * Set a vec4 in the shader from a Color4.
  12123. * @param name Define the name of the uniform as defined in the shader
  12124. * @param value Define the value to give to the uniform
  12125. * @return the texture itself allowing "fluent" like uniform updates
  12126. */
  12127. setColor4(name: string, value: Color4): ProceduralTexture;
  12128. /**
  12129. * Set a vec2 in the shader from a Vector2.
  12130. * @param name Define the name of the uniform as defined in the shader
  12131. * @param value Define the value to give to the uniform
  12132. * @return the texture itself allowing "fluent" like uniform updates
  12133. */
  12134. setVector2(name: string, value: Vector2): ProceduralTexture;
  12135. /**
  12136. * Set a vec3 in the shader from a Vector3.
  12137. * @param name Define the name of the uniform as defined in the shader
  12138. * @param value Define the value to give to the uniform
  12139. * @return the texture itself allowing "fluent" like uniform updates
  12140. */
  12141. setVector3(name: string, value: Vector3): ProceduralTexture;
  12142. /**
  12143. * Set a mat4 in the shader from a MAtrix.
  12144. * @param name Define the name of the uniform as defined in the shader
  12145. * @param value Define the value to give to the uniform
  12146. * @return the texture itself allowing "fluent" like uniform updates
  12147. */
  12148. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12149. /**
  12150. * Render the texture to its associated render target.
  12151. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12152. */
  12153. render(useCameraPostProcess?: boolean): void;
  12154. /**
  12155. * Clone the texture.
  12156. * @returns the cloned texture
  12157. */
  12158. clone(): ProceduralTexture;
  12159. /**
  12160. * Dispose the texture and release its asoociated resources.
  12161. */
  12162. dispose(): void;
  12163. }
  12164. }
  12165. declare module "babylonjs/Particles/baseParticleSystem" {
  12166. import { Nullable } from "babylonjs/types";
  12167. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12169. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12170. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12171. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12172. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12173. import { Color4 } from "babylonjs/Maths/math.color";
  12174. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12175. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12176. import { Animation } from "babylonjs/Animations/animation";
  12177. import { Scene } from "babylonjs/scene";
  12178. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12179. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12180. /**
  12181. * This represents the base class for particle system in Babylon.
  12182. * 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.
  12183. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12184. * @example https://doc.babylonjs.com/babylon101/particles
  12185. */
  12186. export class BaseParticleSystem {
  12187. /**
  12188. * Source color is added to the destination color without alpha affecting the result
  12189. */
  12190. static BLENDMODE_ONEONE: number;
  12191. /**
  12192. * Blend current color and particle color using particle’s alpha
  12193. */
  12194. static BLENDMODE_STANDARD: number;
  12195. /**
  12196. * Add current color and particle color multiplied by particle’s alpha
  12197. */
  12198. static BLENDMODE_ADD: number;
  12199. /**
  12200. * Multiply current color with particle color
  12201. */
  12202. static BLENDMODE_MULTIPLY: number;
  12203. /**
  12204. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12205. */
  12206. static BLENDMODE_MULTIPLYADD: number;
  12207. /**
  12208. * List of animations used by the particle system.
  12209. */
  12210. animations: Animation[];
  12211. /**
  12212. * Gets or sets the unique id of the particle system
  12213. */
  12214. uniqueId: number;
  12215. /**
  12216. * The id of the Particle system.
  12217. */
  12218. id: string;
  12219. /**
  12220. * The friendly name of the Particle system.
  12221. */
  12222. name: string;
  12223. /**
  12224. * Snippet ID if the particle system was created from the snippet server
  12225. */
  12226. snippetId: string;
  12227. /**
  12228. * The rendering group used by the Particle system to chose when to render.
  12229. */
  12230. renderingGroupId: number;
  12231. /**
  12232. * The emitter represents the Mesh or position we are attaching the particle system to.
  12233. */
  12234. emitter: Nullable<AbstractMesh | Vector3>;
  12235. /**
  12236. * The maximum number of particles to emit per frame
  12237. */
  12238. emitRate: number;
  12239. /**
  12240. * If you want to launch only a few particles at once, that can be done, as well.
  12241. */
  12242. manualEmitCount: number;
  12243. /**
  12244. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12245. */
  12246. updateSpeed: number;
  12247. /**
  12248. * The amount of time the particle system is running (depends of the overall update speed).
  12249. */
  12250. targetStopDuration: number;
  12251. /**
  12252. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12253. */
  12254. disposeOnStop: boolean;
  12255. /**
  12256. * Minimum power of emitting particles.
  12257. */
  12258. minEmitPower: number;
  12259. /**
  12260. * Maximum power of emitting particles.
  12261. */
  12262. maxEmitPower: number;
  12263. /**
  12264. * Minimum life time of emitting particles.
  12265. */
  12266. minLifeTime: number;
  12267. /**
  12268. * Maximum life time of emitting particles.
  12269. */
  12270. maxLifeTime: number;
  12271. /**
  12272. * Minimum Size of emitting particles.
  12273. */
  12274. minSize: number;
  12275. /**
  12276. * Maximum Size of emitting particles.
  12277. */
  12278. maxSize: number;
  12279. /**
  12280. * Minimum scale of emitting particles on X axis.
  12281. */
  12282. minScaleX: number;
  12283. /**
  12284. * Maximum scale of emitting particles on X axis.
  12285. */
  12286. maxScaleX: number;
  12287. /**
  12288. * Minimum scale of emitting particles on Y axis.
  12289. */
  12290. minScaleY: number;
  12291. /**
  12292. * Maximum scale of emitting particles on Y axis.
  12293. */
  12294. maxScaleY: number;
  12295. /**
  12296. * Gets or sets the minimal initial rotation in radians.
  12297. */
  12298. minInitialRotation: number;
  12299. /**
  12300. * Gets or sets the maximal initial rotation in radians.
  12301. */
  12302. maxInitialRotation: number;
  12303. /**
  12304. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12305. */
  12306. minAngularSpeed: number;
  12307. /**
  12308. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12309. */
  12310. maxAngularSpeed: number;
  12311. /**
  12312. * The texture used to render each particle. (this can be a spritesheet)
  12313. */
  12314. particleTexture: Nullable<BaseTexture>;
  12315. /**
  12316. * The layer mask we are rendering the particles through.
  12317. */
  12318. layerMask: number;
  12319. /**
  12320. * This can help using your own shader to render the particle system.
  12321. * The according effect will be created
  12322. */
  12323. customShader: any;
  12324. /**
  12325. * By default particle system starts as soon as they are created. This prevents the
  12326. * automatic start to happen and let you decide when to start emitting particles.
  12327. */
  12328. preventAutoStart: boolean;
  12329. private _noiseTexture;
  12330. /**
  12331. * Gets or sets a texture used to add random noise to particle positions
  12332. */
  12333. get noiseTexture(): Nullable<ProceduralTexture>;
  12334. set noiseTexture(value: Nullable<ProceduralTexture>);
  12335. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12336. noiseStrength: Vector3;
  12337. /**
  12338. * Callback triggered when the particle animation is ending.
  12339. */
  12340. onAnimationEnd: Nullable<() => void>;
  12341. /**
  12342. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12343. */
  12344. blendMode: number;
  12345. /**
  12346. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12347. * to override the particles.
  12348. */
  12349. forceDepthWrite: boolean;
  12350. /** 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 */
  12351. preWarmCycles: number;
  12352. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12353. preWarmStepOffset: number;
  12354. /**
  12355. * 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)
  12356. */
  12357. spriteCellChangeSpeed: number;
  12358. /**
  12359. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12360. */
  12361. startSpriteCellID: number;
  12362. /**
  12363. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12364. */
  12365. endSpriteCellID: number;
  12366. /**
  12367. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12368. */
  12369. spriteCellWidth: number;
  12370. /**
  12371. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12372. */
  12373. spriteCellHeight: number;
  12374. /**
  12375. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12376. */
  12377. spriteRandomStartCell: boolean;
  12378. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12379. translationPivot: Vector2;
  12380. /** @hidden */
  12381. protected _isAnimationSheetEnabled: boolean;
  12382. /**
  12383. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12384. */
  12385. beginAnimationOnStart: boolean;
  12386. /**
  12387. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12388. */
  12389. beginAnimationFrom: number;
  12390. /**
  12391. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12392. */
  12393. beginAnimationTo: number;
  12394. /**
  12395. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12396. */
  12397. beginAnimationLoop: boolean;
  12398. /**
  12399. * Gets or sets a world offset applied to all particles
  12400. */
  12401. worldOffset: Vector3;
  12402. /**
  12403. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12404. */
  12405. get isAnimationSheetEnabled(): boolean;
  12406. set isAnimationSheetEnabled(value: boolean);
  12407. /**
  12408. * Get hosting scene
  12409. * @returns the scene
  12410. */
  12411. getScene(): Nullable<Scene>;
  12412. /**
  12413. * You can use gravity if you want to give an orientation to your particles.
  12414. */
  12415. gravity: Vector3;
  12416. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12417. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12418. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12419. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12420. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12421. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12422. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12423. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12424. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12425. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12426. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12427. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12428. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12429. /**
  12430. * Defines the delay in milliseconds before starting the system (0 by default)
  12431. */
  12432. startDelay: number;
  12433. /**
  12434. * Gets the current list of drag gradients.
  12435. * You must use addDragGradient and removeDragGradient to udpate this list
  12436. * @returns the list of drag gradients
  12437. */
  12438. getDragGradients(): Nullable<Array<FactorGradient>>;
  12439. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12440. limitVelocityDamping: number;
  12441. /**
  12442. * Gets the current list of limit velocity gradients.
  12443. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12444. * @returns the list of limit velocity gradients
  12445. */
  12446. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12447. /**
  12448. * Gets the current list of color gradients.
  12449. * You must use addColorGradient and removeColorGradient to udpate this list
  12450. * @returns the list of color gradients
  12451. */
  12452. getColorGradients(): Nullable<Array<ColorGradient>>;
  12453. /**
  12454. * Gets the current list of size gradients.
  12455. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12456. * @returns the list of size gradients
  12457. */
  12458. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12459. /**
  12460. * Gets the current list of color remap gradients.
  12461. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12462. * @returns the list of color remap gradients
  12463. */
  12464. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12465. /**
  12466. * Gets the current list of alpha remap gradients.
  12467. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12468. * @returns the list of alpha remap gradients
  12469. */
  12470. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12471. /**
  12472. * Gets the current list of life time gradients.
  12473. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12474. * @returns the list of life time gradients
  12475. */
  12476. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12477. /**
  12478. * Gets the current list of angular speed gradients.
  12479. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12480. * @returns the list of angular speed gradients
  12481. */
  12482. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12483. /**
  12484. * Gets the current list of velocity gradients.
  12485. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12486. * @returns the list of velocity gradients
  12487. */
  12488. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12489. /**
  12490. * Gets the current list of start size gradients.
  12491. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12492. * @returns the list of start size gradients
  12493. */
  12494. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12495. /**
  12496. * Gets the current list of emit rate gradients.
  12497. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12498. * @returns the list of emit rate gradients
  12499. */
  12500. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12501. /**
  12502. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12503. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12504. */
  12505. get direction1(): Vector3;
  12506. set direction1(value: Vector3);
  12507. /**
  12508. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12509. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12510. */
  12511. get direction2(): Vector3;
  12512. set direction2(value: Vector3);
  12513. /**
  12514. * 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.
  12515. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12516. */
  12517. get minEmitBox(): Vector3;
  12518. set minEmitBox(value: Vector3);
  12519. /**
  12520. * 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.
  12521. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12522. */
  12523. get maxEmitBox(): Vector3;
  12524. set maxEmitBox(value: Vector3);
  12525. /**
  12526. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12527. */
  12528. color1: Color4;
  12529. /**
  12530. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12531. */
  12532. color2: Color4;
  12533. /**
  12534. * Color the particle will have at the end of its lifetime
  12535. */
  12536. colorDead: Color4;
  12537. /**
  12538. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12539. */
  12540. textureMask: Color4;
  12541. /**
  12542. * The particle emitter type defines the emitter used by the particle system.
  12543. * It can be for example box, sphere, or cone...
  12544. */
  12545. particleEmitterType: IParticleEmitterType;
  12546. /** @hidden */
  12547. _isSubEmitter: boolean;
  12548. /**
  12549. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12550. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12551. */
  12552. billboardMode: number;
  12553. protected _isBillboardBased: boolean;
  12554. /**
  12555. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12556. */
  12557. get isBillboardBased(): boolean;
  12558. set isBillboardBased(value: boolean);
  12559. /**
  12560. * The scene the particle system belongs to.
  12561. */
  12562. protected _scene: Nullable<Scene>;
  12563. /**
  12564. * The engine the particle system belongs to.
  12565. */
  12566. protected _engine: ThinEngine;
  12567. /**
  12568. * Local cache of defines for image processing.
  12569. */
  12570. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12571. /**
  12572. * Default configuration related to image processing available in the standard Material.
  12573. */
  12574. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12575. /**
  12576. * Gets the image processing configuration used either in this material.
  12577. */
  12578. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12579. /**
  12580. * Sets the Default image processing configuration used either in the this material.
  12581. *
  12582. * If sets to null, the scene one is in use.
  12583. */
  12584. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12585. /**
  12586. * Attaches a new image processing configuration to the Standard Material.
  12587. * @param configuration
  12588. */
  12589. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12590. /** @hidden */
  12591. protected _reset(): void;
  12592. /** @hidden */
  12593. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12594. /**
  12595. * Instantiates a particle system.
  12596. * 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.
  12597. * @param name The name of the particle system
  12598. */
  12599. constructor(name: string);
  12600. /**
  12601. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12602. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12603. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12604. * @returns the emitter
  12605. */
  12606. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12607. /**
  12608. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12609. * @param radius The radius of the hemisphere to emit from
  12610. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12611. * @returns the emitter
  12612. */
  12613. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12614. /**
  12615. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12616. * @param radius The radius of the sphere to emit from
  12617. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12618. * @returns the emitter
  12619. */
  12620. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12621. /**
  12622. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12623. * @param radius The radius of the sphere to emit from
  12624. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12625. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12626. * @returns the emitter
  12627. */
  12628. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12629. /**
  12630. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12631. * @param radius The radius of the emission cylinder
  12632. * @param height The height of the emission cylinder
  12633. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12634. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12635. * @returns the emitter
  12636. */
  12637. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12638. /**
  12639. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12640. * @param radius The radius of the cylinder to emit from
  12641. * @param height The height of the emission cylinder
  12642. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12643. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12644. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12645. * @returns the emitter
  12646. */
  12647. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12648. /**
  12649. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12650. * @param radius The radius of the cone to emit from
  12651. * @param angle The base angle of the cone
  12652. * @returns the emitter
  12653. */
  12654. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12655. /**
  12656. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12657. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12658. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12659. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12660. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12661. * @returns the emitter
  12662. */
  12663. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12664. }
  12665. }
  12666. declare module "babylonjs/Particles/subEmitter" {
  12667. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12668. import { Scene } from "babylonjs/scene";
  12669. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12670. /**
  12671. * Type of sub emitter
  12672. */
  12673. export enum SubEmitterType {
  12674. /**
  12675. * Attached to the particle over it's lifetime
  12676. */
  12677. ATTACHED = 0,
  12678. /**
  12679. * Created when the particle dies
  12680. */
  12681. END = 1
  12682. }
  12683. /**
  12684. * Sub emitter class used to emit particles from an existing particle
  12685. */
  12686. export class SubEmitter {
  12687. /**
  12688. * the particle system to be used by the sub emitter
  12689. */
  12690. particleSystem: ParticleSystem;
  12691. /**
  12692. * Type of the submitter (Default: END)
  12693. */
  12694. type: SubEmitterType;
  12695. /**
  12696. * 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)
  12697. * Note: This only is supported when using an emitter of type Mesh
  12698. */
  12699. inheritDirection: boolean;
  12700. /**
  12701. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12702. */
  12703. inheritedVelocityAmount: number;
  12704. /**
  12705. * Creates a sub emitter
  12706. * @param particleSystem the particle system to be used by the sub emitter
  12707. */
  12708. constructor(
  12709. /**
  12710. * the particle system to be used by the sub emitter
  12711. */
  12712. particleSystem: ParticleSystem);
  12713. /**
  12714. * Clones the sub emitter
  12715. * @returns the cloned sub emitter
  12716. */
  12717. clone(): SubEmitter;
  12718. /**
  12719. * Serialize current object to a JSON object
  12720. * @returns the serialized object
  12721. */
  12722. serialize(): any;
  12723. /** @hidden */
  12724. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12725. /**
  12726. * Creates a new SubEmitter from a serialized JSON version
  12727. * @param serializationObject defines the JSON object to read from
  12728. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12729. * @param rootUrl defines the rootUrl for data loading
  12730. * @returns a new SubEmitter
  12731. */
  12732. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12733. /** Release associated resources */
  12734. dispose(): void;
  12735. }
  12736. }
  12737. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12738. /** @hidden */
  12739. export var imageProcessingDeclaration: {
  12740. name: string;
  12741. shader: string;
  12742. };
  12743. }
  12744. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12745. /** @hidden */
  12746. export var imageProcessingFunctions: {
  12747. name: string;
  12748. shader: string;
  12749. };
  12750. }
  12751. declare module "babylonjs/Shaders/particles.fragment" {
  12752. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12753. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12754. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12755. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12756. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12757. /** @hidden */
  12758. export var particlesPixelShader: {
  12759. name: string;
  12760. shader: string;
  12761. };
  12762. }
  12763. declare module "babylonjs/Shaders/particles.vertex" {
  12764. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12765. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12766. /** @hidden */
  12767. export var particlesVertexShader: {
  12768. name: string;
  12769. shader: string;
  12770. };
  12771. }
  12772. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12773. import { Nullable } from "babylonjs/types";
  12774. import { Plane } from "babylonjs/Maths/math";
  12775. /**
  12776. * Interface used to define entities containing multiple clip planes
  12777. */
  12778. export interface IClipPlanesHolder {
  12779. /**
  12780. * Gets or sets the active clipplane 1
  12781. */
  12782. clipPlane: Nullable<Plane>;
  12783. /**
  12784. * Gets or sets the active clipplane 2
  12785. */
  12786. clipPlane2: Nullable<Plane>;
  12787. /**
  12788. * Gets or sets the active clipplane 3
  12789. */
  12790. clipPlane3: Nullable<Plane>;
  12791. /**
  12792. * Gets or sets the active clipplane 4
  12793. */
  12794. clipPlane4: Nullable<Plane>;
  12795. /**
  12796. * Gets or sets the active clipplane 5
  12797. */
  12798. clipPlane5: Nullable<Plane>;
  12799. /**
  12800. * Gets or sets the active clipplane 6
  12801. */
  12802. clipPlane6: Nullable<Plane>;
  12803. }
  12804. }
  12805. declare module "babylonjs/Materials/thinMaterialHelper" {
  12806. import { Effect } from "babylonjs/Materials/effect";
  12807. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12808. /**
  12809. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12810. *
  12811. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12812. *
  12813. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12814. */
  12815. export class ThinMaterialHelper {
  12816. /**
  12817. * Binds the clip plane information from the holder to the effect.
  12818. * @param effect The effect we are binding the data to
  12819. * @param holder The entity containing the clip plane information
  12820. */
  12821. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12822. }
  12823. }
  12824. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12825. module "babylonjs/Engines/thinEngine" {
  12826. interface ThinEngine {
  12827. /**
  12828. * Sets alpha constants used by some alpha blending modes
  12829. * @param r defines the red component
  12830. * @param g defines the green component
  12831. * @param b defines the blue component
  12832. * @param a defines the alpha component
  12833. */
  12834. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12835. /**
  12836. * Sets the current alpha mode
  12837. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12838. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12839. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12840. */
  12841. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12842. /**
  12843. * Gets the current alpha mode
  12844. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12845. * @returns the current alpha mode
  12846. */
  12847. getAlphaMode(): number;
  12848. /**
  12849. * Sets the current alpha equation
  12850. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12851. */
  12852. setAlphaEquation(equation: number): void;
  12853. /**
  12854. * Gets the current alpha equation.
  12855. * @returns the current alpha equation
  12856. */
  12857. getAlphaEquation(): number;
  12858. }
  12859. }
  12860. }
  12861. declare module "babylonjs/Particles/particleSystem" {
  12862. import { Nullable } from "babylonjs/types";
  12863. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12864. import { Observable } from "babylonjs/Misc/observable";
  12865. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12866. import { Effect } from "babylonjs/Materials/effect";
  12867. import { IDisposable } from "babylonjs/scene";
  12868. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12869. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12870. import { Particle } from "babylonjs/Particles/particle";
  12871. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12872. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12873. import "babylonjs/Shaders/particles.fragment";
  12874. import "babylonjs/Shaders/particles.vertex";
  12875. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12876. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12877. import "babylonjs/Engines/Extensions/engine.alpha";
  12878. import { Scene } from "babylonjs/scene";
  12879. /**
  12880. * This represents a particle system in Babylon.
  12881. * 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.
  12882. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12883. * @example https://doc.babylonjs.com/babylon101/particles
  12884. */
  12885. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12886. /**
  12887. * Billboard mode will only apply to Y axis
  12888. */
  12889. static readonly BILLBOARDMODE_Y: number;
  12890. /**
  12891. * Billboard mode will apply to all axes
  12892. */
  12893. static readonly BILLBOARDMODE_ALL: number;
  12894. /**
  12895. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12896. */
  12897. static readonly BILLBOARDMODE_STRETCHED: number;
  12898. /**
  12899. * This function can be defined to provide custom update for active particles.
  12900. * This function will be called instead of regular update (age, position, color, etc.).
  12901. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12902. */
  12903. updateFunction: (particles: Particle[]) => void;
  12904. private _emitterWorldMatrix;
  12905. /**
  12906. * This function can be defined to specify initial direction for every new particle.
  12907. * It by default use the emitterType defined function
  12908. */
  12909. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12910. /**
  12911. * This function can be defined to specify initial position for every new particle.
  12912. * It by default use the emitterType defined function
  12913. */
  12914. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12915. /**
  12916. * @hidden
  12917. */
  12918. _inheritedVelocityOffset: Vector3;
  12919. /**
  12920. * An event triggered when the system is disposed
  12921. */
  12922. onDisposeObservable: Observable<IParticleSystem>;
  12923. private _onDisposeObserver;
  12924. /**
  12925. * Sets a callback that will be triggered when the system is disposed
  12926. */
  12927. set onDispose(callback: () => void);
  12928. private _particles;
  12929. private _epsilon;
  12930. private _capacity;
  12931. private _stockParticles;
  12932. private _newPartsExcess;
  12933. private _vertexData;
  12934. private _vertexBuffer;
  12935. private _vertexBuffers;
  12936. private _spriteBuffer;
  12937. private _indexBuffer;
  12938. private _effect;
  12939. private _customEffect;
  12940. private _cachedDefines;
  12941. private _scaledColorStep;
  12942. private _colorDiff;
  12943. private _scaledDirection;
  12944. private _scaledGravity;
  12945. private _currentRenderId;
  12946. private _alive;
  12947. private _useInstancing;
  12948. private _started;
  12949. private _stopped;
  12950. private _actualFrame;
  12951. private _scaledUpdateSpeed;
  12952. private _vertexBufferSize;
  12953. /** @hidden */
  12954. _currentEmitRateGradient: Nullable<FactorGradient>;
  12955. /** @hidden */
  12956. _currentEmitRate1: number;
  12957. /** @hidden */
  12958. _currentEmitRate2: number;
  12959. /** @hidden */
  12960. _currentStartSizeGradient: Nullable<FactorGradient>;
  12961. /** @hidden */
  12962. _currentStartSize1: number;
  12963. /** @hidden */
  12964. _currentStartSize2: number;
  12965. private readonly _rawTextureWidth;
  12966. private _rampGradientsTexture;
  12967. private _useRampGradients;
  12968. /** Gets or sets a matrix to use to compute projection */
  12969. defaultProjectionMatrix: Matrix;
  12970. /** Gets or sets a matrix to use to compute view */
  12971. defaultViewMatrix: Matrix;
  12972. /** Gets or sets a boolean indicating that ramp gradients must be used
  12973. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12974. */
  12975. get useRampGradients(): boolean;
  12976. set useRampGradients(value: boolean);
  12977. /**
  12978. * 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.
  12979. * 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: [])
  12980. */
  12981. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12982. private _subEmitters;
  12983. /**
  12984. * @hidden
  12985. * If the particle systems emitter should be disposed when the particle system is disposed
  12986. */
  12987. _disposeEmitterOnDispose: boolean;
  12988. /**
  12989. * The current active Sub-systems, this property is used by the root particle system only.
  12990. */
  12991. activeSubSystems: Array<ParticleSystem>;
  12992. /**
  12993. * Specifies if the particles are updated in emitter local space or world space
  12994. */
  12995. isLocal: boolean;
  12996. private _rootParticleSystem;
  12997. /**
  12998. * Gets the current list of active particles
  12999. */
  13000. get particles(): Particle[];
  13001. /**
  13002. * Gets the number of particles active at the same time.
  13003. * @returns The number of active particles.
  13004. */
  13005. getActiveCount(): number;
  13006. /**
  13007. * Returns the string "ParticleSystem"
  13008. * @returns a string containing the class name
  13009. */
  13010. getClassName(): string;
  13011. /**
  13012. * Gets a boolean indicating that the system is stopping
  13013. * @returns true if the system is currently stopping
  13014. */
  13015. isStopping(): boolean;
  13016. /**
  13017. * Gets the custom effect used to render the particles
  13018. * @param blendMode Blend mode for which the effect should be retrieved
  13019. * @returns The effect
  13020. */
  13021. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13022. /**
  13023. * Sets the custom effect used to render the particles
  13024. * @param effect The effect to set
  13025. * @param blendMode Blend mode for which the effect should be set
  13026. */
  13027. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13028. /** @hidden */
  13029. private _onBeforeDrawParticlesObservable;
  13030. /**
  13031. * Observable that will be called just before the particles are drawn
  13032. */
  13033. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13034. /**
  13035. * Gets the name of the particle vertex shader
  13036. */
  13037. get vertexShaderName(): string;
  13038. /**
  13039. * Instantiates a particle system.
  13040. * 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.
  13041. * @param name The name of the particle system
  13042. * @param capacity The max number of particles alive at the same time
  13043. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13044. * @param customEffect a custom effect used to change the way particles are rendered by default
  13045. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13046. * @param epsilon Offset used to render the particles
  13047. */
  13048. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13049. private _addFactorGradient;
  13050. private _removeFactorGradient;
  13051. /**
  13052. * Adds a new life time gradient
  13053. * @param gradient defines the gradient to use (between 0 and 1)
  13054. * @param factor defines the life time factor to affect to the specified gradient
  13055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13056. * @returns the current particle system
  13057. */
  13058. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13059. /**
  13060. * Remove a specific life time gradient
  13061. * @param gradient defines the gradient to remove
  13062. * @returns the current particle system
  13063. */
  13064. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13065. /**
  13066. * Adds a new size gradient
  13067. * @param gradient defines the gradient to use (between 0 and 1)
  13068. * @param factor defines the size factor to affect to the specified gradient
  13069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13070. * @returns the current particle system
  13071. */
  13072. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13073. /**
  13074. * Remove a specific size gradient
  13075. * @param gradient defines the gradient to remove
  13076. * @returns the current particle system
  13077. */
  13078. removeSizeGradient(gradient: number): IParticleSystem;
  13079. /**
  13080. * Adds a new color remap gradient
  13081. * @param gradient defines the gradient to use (between 0 and 1)
  13082. * @param min defines the color remap minimal range
  13083. * @param max defines the color remap maximal range
  13084. * @returns the current particle system
  13085. */
  13086. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13087. /**
  13088. * Remove a specific color remap gradient
  13089. * @param gradient defines the gradient to remove
  13090. * @returns the current particle system
  13091. */
  13092. removeColorRemapGradient(gradient: number): IParticleSystem;
  13093. /**
  13094. * Adds a new alpha remap gradient
  13095. * @param gradient defines the gradient to use (between 0 and 1)
  13096. * @param min defines the alpha remap minimal range
  13097. * @param max defines the alpha remap maximal range
  13098. * @returns the current particle system
  13099. */
  13100. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13101. /**
  13102. * Remove a specific alpha remap gradient
  13103. * @param gradient defines the gradient to remove
  13104. * @returns the current particle system
  13105. */
  13106. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13107. /**
  13108. * Adds a new angular speed gradient
  13109. * @param gradient defines the gradient to use (between 0 and 1)
  13110. * @param factor defines the angular speed to affect to the specified gradient
  13111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13112. * @returns the current particle system
  13113. */
  13114. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13115. /**
  13116. * Remove a specific angular speed gradient
  13117. * @param gradient defines the gradient to remove
  13118. * @returns the current particle system
  13119. */
  13120. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13121. /**
  13122. * Adds a new velocity gradient
  13123. * @param gradient defines the gradient to use (between 0 and 1)
  13124. * @param factor defines the velocity to affect to the specified gradient
  13125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13126. * @returns the current particle system
  13127. */
  13128. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13129. /**
  13130. * Remove a specific velocity gradient
  13131. * @param gradient defines the gradient to remove
  13132. * @returns the current particle system
  13133. */
  13134. removeVelocityGradient(gradient: number): IParticleSystem;
  13135. /**
  13136. * Adds a new limit velocity gradient
  13137. * @param gradient defines the gradient to use (between 0 and 1)
  13138. * @param factor defines the limit velocity value to affect to the specified gradient
  13139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13140. * @returns the current particle system
  13141. */
  13142. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13143. /**
  13144. * Remove a specific limit velocity gradient
  13145. * @param gradient defines the gradient to remove
  13146. * @returns the current particle system
  13147. */
  13148. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13149. /**
  13150. * Adds a new drag gradient
  13151. * @param gradient defines the gradient to use (between 0 and 1)
  13152. * @param factor defines the drag value 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. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13157. /**
  13158. * Remove a specific drag gradient
  13159. * @param gradient defines the gradient to remove
  13160. * @returns the current particle system
  13161. */
  13162. removeDragGradient(gradient: number): IParticleSystem;
  13163. /**
  13164. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13165. * @param gradient defines the gradient to use (between 0 and 1)
  13166. * @param factor defines the emit rate value 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. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13171. /**
  13172. * Remove a specific emit rate gradient
  13173. * @param gradient defines the gradient to remove
  13174. * @returns the current particle system
  13175. */
  13176. removeEmitRateGradient(gradient: number): IParticleSystem;
  13177. /**
  13178. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13179. * @param gradient defines the gradient to use (between 0 and 1)
  13180. * @param factor defines the start size value to affect to the specified gradient
  13181. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13182. * @returns the current particle system
  13183. */
  13184. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13185. /**
  13186. * Remove a specific start size gradient
  13187. * @param gradient defines the gradient to remove
  13188. * @returns the current particle system
  13189. */
  13190. removeStartSizeGradient(gradient: number): IParticleSystem;
  13191. private _createRampGradientTexture;
  13192. /**
  13193. * Gets the current list of ramp gradients.
  13194. * You must use addRampGradient and removeRampGradient to udpate this list
  13195. * @returns the list of ramp gradients
  13196. */
  13197. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13198. /** Force the system to rebuild all gradients that need to be resync */
  13199. forceRefreshGradients(): void;
  13200. private _syncRampGradientTexture;
  13201. /**
  13202. * Adds a new ramp gradient used to remap particle colors
  13203. * @param gradient defines the gradient to use (between 0 and 1)
  13204. * @param color defines the color to affect to the specified gradient
  13205. * @returns the current particle system
  13206. */
  13207. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13208. /**
  13209. * Remove a specific ramp gradient
  13210. * @param gradient defines the gradient to remove
  13211. * @returns the current particle system
  13212. */
  13213. removeRampGradient(gradient: number): ParticleSystem;
  13214. /**
  13215. * Adds a new color gradient
  13216. * @param gradient defines the gradient to use (between 0 and 1)
  13217. * @param color1 defines the color to affect to the specified gradient
  13218. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13219. * @returns this particle system
  13220. */
  13221. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13222. /**
  13223. * Remove a specific color gradient
  13224. * @param gradient defines the gradient to remove
  13225. * @returns this particle system
  13226. */
  13227. removeColorGradient(gradient: number): IParticleSystem;
  13228. private _fetchR;
  13229. protected _reset(): void;
  13230. private _resetEffect;
  13231. private _createVertexBuffers;
  13232. private _createIndexBuffer;
  13233. /**
  13234. * Gets the maximum number of particles active at the same time.
  13235. * @returns The max number of active particles.
  13236. */
  13237. getCapacity(): number;
  13238. /**
  13239. * Gets whether there are still active particles in the system.
  13240. * @returns True if it is alive, otherwise false.
  13241. */
  13242. isAlive(): boolean;
  13243. /**
  13244. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13245. * @returns True if it has been started, otherwise false.
  13246. */
  13247. isStarted(): boolean;
  13248. private _prepareSubEmitterInternalArray;
  13249. /**
  13250. * Starts the particle system and begins to emit
  13251. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13252. */
  13253. start(delay?: number): void;
  13254. /**
  13255. * Stops the particle system.
  13256. * @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.
  13257. */
  13258. stop(stopSubEmitters?: boolean): void;
  13259. /**
  13260. * Remove all active particles
  13261. */
  13262. reset(): void;
  13263. /**
  13264. * @hidden (for internal use only)
  13265. */
  13266. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13267. /**
  13268. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13269. * Its lifetime will start back at 0.
  13270. */
  13271. recycleParticle: (particle: Particle) => void;
  13272. private _stopSubEmitters;
  13273. private _createParticle;
  13274. private _removeFromRoot;
  13275. private _emitFromParticle;
  13276. private _update;
  13277. /** @hidden */
  13278. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13279. /** @hidden */
  13280. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13281. /**
  13282. * Fill the defines array according to the current settings of the particle system
  13283. * @param defines Array to be updated
  13284. * @param blendMode blend mode to take into account when updating the array
  13285. */
  13286. fillDefines(defines: Array<string>, blendMode: number): void;
  13287. /**
  13288. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13289. * @param uniforms Uniforms array to fill
  13290. * @param attributes Attributes array to fill
  13291. * @param samplers Samplers array to fill
  13292. */
  13293. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13294. /** @hidden */
  13295. private _getEffect;
  13296. /**
  13297. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13298. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13299. */
  13300. animate(preWarmOnly?: boolean): void;
  13301. private _appendParticleVertices;
  13302. /**
  13303. * Rebuilds the particle system.
  13304. */
  13305. rebuild(): void;
  13306. /**
  13307. * Is this system ready to be used/rendered
  13308. * @return true if the system is ready
  13309. */
  13310. isReady(): boolean;
  13311. private _render;
  13312. /**
  13313. * Renders the particle system in its current state.
  13314. * @returns the current number of particles
  13315. */
  13316. render(): number;
  13317. /**
  13318. * Disposes the particle system and free the associated resources
  13319. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13320. */
  13321. dispose(disposeTexture?: boolean): void;
  13322. /**
  13323. * Clones the particle system.
  13324. * @param name The name of the cloned object
  13325. * @param newEmitter The new emitter to use
  13326. * @returns the cloned particle system
  13327. */
  13328. clone(name: string, newEmitter: any): ParticleSystem;
  13329. /**
  13330. * Serializes the particle system to a JSON object
  13331. * @param serializeTexture defines if the texture must be serialized as well
  13332. * @returns the JSON object
  13333. */
  13334. serialize(serializeTexture?: boolean): any;
  13335. /** @hidden */
  13336. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13337. /** @hidden */
  13338. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13339. /**
  13340. * Parses a JSON object to create a particle system.
  13341. * @param parsedParticleSystem The JSON object to parse
  13342. * @param sceneOrEngine The scene or the engine to create the particle system in
  13343. * @param rootUrl The root url to use to load external dependencies like texture
  13344. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13345. * @returns the Parsed particle system
  13346. */
  13347. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13348. }
  13349. }
  13350. declare module "babylonjs/Particles/particle" {
  13351. import { Nullable } from "babylonjs/types";
  13352. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13353. import { Color4 } from "babylonjs/Maths/math.color";
  13354. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13355. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13356. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13357. /**
  13358. * A particle represents one of the element emitted by a particle system.
  13359. * This is mainly define by its coordinates, direction, velocity and age.
  13360. */
  13361. export class Particle {
  13362. /**
  13363. * The particle system the particle belongs to.
  13364. */
  13365. particleSystem: ParticleSystem;
  13366. private static _Count;
  13367. /**
  13368. * Unique ID of the particle
  13369. */
  13370. id: number;
  13371. /**
  13372. * The world position of the particle in the scene.
  13373. */
  13374. position: Vector3;
  13375. /**
  13376. * The world direction of the particle in the scene.
  13377. */
  13378. direction: Vector3;
  13379. /**
  13380. * The color of the particle.
  13381. */
  13382. color: Color4;
  13383. /**
  13384. * The color change of the particle per step.
  13385. */
  13386. colorStep: Color4;
  13387. /**
  13388. * Defines how long will the life of the particle be.
  13389. */
  13390. lifeTime: number;
  13391. /**
  13392. * The current age of the particle.
  13393. */
  13394. age: number;
  13395. /**
  13396. * The current size of the particle.
  13397. */
  13398. size: number;
  13399. /**
  13400. * The current scale of the particle.
  13401. */
  13402. scale: Vector2;
  13403. /**
  13404. * The current angle of the particle.
  13405. */
  13406. angle: number;
  13407. /**
  13408. * Defines how fast is the angle changing.
  13409. */
  13410. angularSpeed: number;
  13411. /**
  13412. * Defines the cell index used by the particle to be rendered from a sprite.
  13413. */
  13414. cellIndex: number;
  13415. /**
  13416. * The information required to support color remapping
  13417. */
  13418. remapData: Vector4;
  13419. /** @hidden */
  13420. _randomCellOffset?: number;
  13421. /** @hidden */
  13422. _initialDirection: Nullable<Vector3>;
  13423. /** @hidden */
  13424. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13425. /** @hidden */
  13426. _initialStartSpriteCellID: number;
  13427. /** @hidden */
  13428. _initialEndSpriteCellID: number;
  13429. /** @hidden */
  13430. _currentColorGradient: Nullable<ColorGradient>;
  13431. /** @hidden */
  13432. _currentColor1: Color4;
  13433. /** @hidden */
  13434. _currentColor2: Color4;
  13435. /** @hidden */
  13436. _currentSizeGradient: Nullable<FactorGradient>;
  13437. /** @hidden */
  13438. _currentSize1: number;
  13439. /** @hidden */
  13440. _currentSize2: number;
  13441. /** @hidden */
  13442. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13443. /** @hidden */
  13444. _currentAngularSpeed1: number;
  13445. /** @hidden */
  13446. _currentAngularSpeed2: number;
  13447. /** @hidden */
  13448. _currentVelocityGradient: Nullable<FactorGradient>;
  13449. /** @hidden */
  13450. _currentVelocity1: number;
  13451. /** @hidden */
  13452. _currentVelocity2: number;
  13453. /** @hidden */
  13454. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13455. /** @hidden */
  13456. _currentLimitVelocity1: number;
  13457. /** @hidden */
  13458. _currentLimitVelocity2: number;
  13459. /** @hidden */
  13460. _currentDragGradient: Nullable<FactorGradient>;
  13461. /** @hidden */
  13462. _currentDrag1: number;
  13463. /** @hidden */
  13464. _currentDrag2: number;
  13465. /** @hidden */
  13466. _randomNoiseCoordinates1: Vector3;
  13467. /** @hidden */
  13468. _randomNoiseCoordinates2: Vector3;
  13469. /** @hidden */
  13470. _localPosition?: Vector3;
  13471. /**
  13472. * Creates a new instance Particle
  13473. * @param particleSystem the particle system the particle belongs to
  13474. */
  13475. constructor(
  13476. /**
  13477. * The particle system the particle belongs to.
  13478. */
  13479. particleSystem: ParticleSystem);
  13480. private updateCellInfoFromSystem;
  13481. /**
  13482. * Defines how the sprite cell index is updated for the particle
  13483. */
  13484. updateCellIndex(): void;
  13485. /** @hidden */
  13486. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13487. /** @hidden */
  13488. _inheritParticleInfoToSubEmitters(): void;
  13489. /** @hidden */
  13490. _reset(): void;
  13491. /**
  13492. * Copy the properties of particle to another one.
  13493. * @param other the particle to copy the information to.
  13494. */
  13495. copyTo(other: Particle): void;
  13496. }
  13497. }
  13498. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13499. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13500. import { Effect } from "babylonjs/Materials/effect";
  13501. import { Particle } from "babylonjs/Particles/particle";
  13502. import { Nullable } from "babylonjs/types";
  13503. import { Scene } from "babylonjs/scene";
  13504. /**
  13505. * Particle emitter represents a volume emitting particles.
  13506. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13507. */
  13508. export interface IParticleEmitterType {
  13509. /**
  13510. * Called by the particle System when the direction is computed for the created particle.
  13511. * @param worldMatrix is the world matrix of the particle system
  13512. * @param directionToUpdate is the direction vector to update with the result
  13513. * @param particle is the particle we are computed the direction for
  13514. * @param isLocal defines if the direction should be set in local space
  13515. */
  13516. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13517. /**
  13518. * Called by the particle System when the position is computed for the created particle.
  13519. * @param worldMatrix is the world matrix of the particle system
  13520. * @param positionToUpdate is the position vector to update with the result
  13521. * @param particle is the particle we are computed the position for
  13522. * @param isLocal defines if the position should be set in local space
  13523. */
  13524. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13525. /**
  13526. * Clones the current emitter and returns a copy of it
  13527. * @returns the new emitter
  13528. */
  13529. clone(): IParticleEmitterType;
  13530. /**
  13531. * Called by the GPUParticleSystem to setup the update shader
  13532. * @param effect defines the update shader
  13533. */
  13534. applyToShader(effect: Effect): void;
  13535. /**
  13536. * Returns a string to use to update the GPU particles update shader
  13537. * @returns the effect defines string
  13538. */
  13539. getEffectDefines(): string;
  13540. /**
  13541. * Returns a string representing the class name
  13542. * @returns a string containing the class name
  13543. */
  13544. getClassName(): string;
  13545. /**
  13546. * Serializes the particle system to a JSON object.
  13547. * @returns the JSON object
  13548. */
  13549. serialize(): any;
  13550. /**
  13551. * Parse properties from a JSON object
  13552. * @param serializationObject defines the JSON object
  13553. * @param scene defines the hosting scene
  13554. */
  13555. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13556. }
  13557. }
  13558. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13559. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13560. import { Effect } from "babylonjs/Materials/effect";
  13561. import { Particle } from "babylonjs/Particles/particle";
  13562. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13563. /**
  13564. * Particle emitter emitting particles from the inside of a box.
  13565. * It emits the particles randomly between 2 given directions.
  13566. */
  13567. export class BoxParticleEmitter implements IParticleEmitterType {
  13568. /**
  13569. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13570. */
  13571. direction1: Vector3;
  13572. /**
  13573. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13574. */
  13575. direction2: Vector3;
  13576. /**
  13577. * 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.
  13578. */
  13579. minEmitBox: Vector3;
  13580. /**
  13581. * 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.
  13582. */
  13583. maxEmitBox: Vector3;
  13584. /**
  13585. * Creates a new instance BoxParticleEmitter
  13586. */
  13587. constructor();
  13588. /**
  13589. * Called by the particle System when the direction is computed for the created particle.
  13590. * @param worldMatrix is the world matrix of the particle system
  13591. * @param directionToUpdate is the direction vector to update with the result
  13592. * @param particle is the particle we are computed the direction for
  13593. * @param isLocal defines if the direction should be set in local space
  13594. */
  13595. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13596. /**
  13597. * Called by the particle System when the position is computed for the created particle.
  13598. * @param worldMatrix is the world matrix of the particle system
  13599. * @param positionToUpdate is the position vector to update with the result
  13600. * @param particle is the particle we are computed the position for
  13601. * @param isLocal defines if the position should be set in local space
  13602. */
  13603. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13604. /**
  13605. * Clones the current emitter and returns a copy of it
  13606. * @returns the new emitter
  13607. */
  13608. clone(): BoxParticleEmitter;
  13609. /**
  13610. * Called by the GPUParticleSystem to setup the update shader
  13611. * @param effect defines the update shader
  13612. */
  13613. applyToShader(effect: Effect): void;
  13614. /**
  13615. * Returns a string to use to update the GPU particles update shader
  13616. * @returns a string containng the defines string
  13617. */
  13618. getEffectDefines(): string;
  13619. /**
  13620. * Returns the string "BoxParticleEmitter"
  13621. * @returns a string containing the class name
  13622. */
  13623. getClassName(): string;
  13624. /**
  13625. * Serializes the particle system to a JSON object.
  13626. * @returns the JSON object
  13627. */
  13628. serialize(): any;
  13629. /**
  13630. * Parse properties from a JSON object
  13631. * @param serializationObject defines the JSON object
  13632. */
  13633. parse(serializationObject: any): void;
  13634. }
  13635. }
  13636. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13637. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13638. import { Effect } from "babylonjs/Materials/effect";
  13639. import { Particle } from "babylonjs/Particles/particle";
  13640. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13641. /**
  13642. * Particle emitter emitting particles from the inside of a cone.
  13643. * It emits the particles alongside the cone volume from the base to the particle.
  13644. * The emission direction might be randomized.
  13645. */
  13646. export class ConeParticleEmitter implements IParticleEmitterType {
  13647. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13648. directionRandomizer: number;
  13649. private _radius;
  13650. private _angle;
  13651. private _height;
  13652. /**
  13653. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13654. */
  13655. radiusRange: number;
  13656. /**
  13657. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13658. */
  13659. heightRange: number;
  13660. /**
  13661. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13662. */
  13663. emitFromSpawnPointOnly: boolean;
  13664. /**
  13665. * Gets or sets the radius of the emission cone
  13666. */
  13667. get radius(): number;
  13668. set radius(value: number);
  13669. /**
  13670. * Gets or sets the angle of the emission cone
  13671. */
  13672. get angle(): number;
  13673. set angle(value: number);
  13674. private _buildHeight;
  13675. /**
  13676. * Creates a new instance ConeParticleEmitter
  13677. * @param radius the radius of the emission cone (1 by default)
  13678. * @param angle the cone base angle (PI by default)
  13679. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13680. */
  13681. constructor(radius?: number, angle?: number,
  13682. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13683. directionRandomizer?: number);
  13684. /**
  13685. * Called by the particle System when the direction is computed for the created particle.
  13686. * @param worldMatrix is the world matrix of the particle system
  13687. * @param directionToUpdate is the direction vector to update with the result
  13688. * @param particle is the particle we are computed the direction for
  13689. * @param isLocal defines if the direction should be set in local space
  13690. */
  13691. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13692. /**
  13693. * Called by the particle System when the position is computed for the created particle.
  13694. * @param worldMatrix is the world matrix of the particle system
  13695. * @param positionToUpdate is the position vector to update with the result
  13696. * @param particle is the particle we are computed the position for
  13697. * @param isLocal defines if the position should be set in local space
  13698. */
  13699. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13700. /**
  13701. * Clones the current emitter and returns a copy of it
  13702. * @returns the new emitter
  13703. */
  13704. clone(): ConeParticleEmitter;
  13705. /**
  13706. * Called by the GPUParticleSystem to setup the update shader
  13707. * @param effect defines the update shader
  13708. */
  13709. applyToShader(effect: Effect): void;
  13710. /**
  13711. * Returns a string to use to update the GPU particles update shader
  13712. * @returns a string containng the defines string
  13713. */
  13714. getEffectDefines(): string;
  13715. /**
  13716. * Returns the string "ConeParticleEmitter"
  13717. * @returns a string containing the class name
  13718. */
  13719. getClassName(): string;
  13720. /**
  13721. * Serializes the particle system to a JSON object.
  13722. * @returns the JSON object
  13723. */
  13724. serialize(): any;
  13725. /**
  13726. * Parse properties from a JSON object
  13727. * @param serializationObject defines the JSON object
  13728. */
  13729. parse(serializationObject: any): void;
  13730. }
  13731. }
  13732. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13733. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13734. import { Effect } from "babylonjs/Materials/effect";
  13735. import { Particle } from "babylonjs/Particles/particle";
  13736. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13737. /**
  13738. * Particle emitter emitting particles from the inside of a cylinder.
  13739. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13740. */
  13741. export class CylinderParticleEmitter implements IParticleEmitterType {
  13742. /**
  13743. * The radius of the emission cylinder.
  13744. */
  13745. radius: number;
  13746. /**
  13747. * The height of the emission cylinder.
  13748. */
  13749. height: number;
  13750. /**
  13751. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13752. */
  13753. radiusRange: number;
  13754. /**
  13755. * How much to randomize the particle direction [0-1].
  13756. */
  13757. directionRandomizer: number;
  13758. /**
  13759. * Creates a new instance CylinderParticleEmitter
  13760. * @param radius the radius of the emission cylinder (1 by default)
  13761. * @param height the height of the emission cylinder (1 by default)
  13762. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13763. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13764. */
  13765. constructor(
  13766. /**
  13767. * The radius of the emission cylinder.
  13768. */
  13769. radius?: number,
  13770. /**
  13771. * The height of the emission cylinder.
  13772. */
  13773. height?: number,
  13774. /**
  13775. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13776. */
  13777. radiusRange?: number,
  13778. /**
  13779. * How much to randomize the particle direction [0-1].
  13780. */
  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(): CylinderParticleEmitter;
  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 "CylinderParticleEmitter"
  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. * Particle emitter emitting particles from the inside of a cylinder.
  13831. * It emits the particles randomly between two vectors.
  13832. */
  13833. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13834. /**
  13835. * The min limit of the emission direction.
  13836. */
  13837. direction1: Vector3;
  13838. /**
  13839. * The max limit of the emission direction.
  13840. */
  13841. direction2: Vector3;
  13842. /**
  13843. * Creates a new instance CylinderDirectedParticleEmitter
  13844. * @param radius the radius of the emission cylinder (1 by default)
  13845. * @param height the height of the emission cylinder (1 by default)
  13846. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13847. * @param direction1 the min limit of the emission direction (up vector by default)
  13848. * @param direction2 the max limit of the emission direction (up vector by default)
  13849. */
  13850. constructor(radius?: number, height?: number, radiusRange?: number,
  13851. /**
  13852. * The min limit of the emission direction.
  13853. */
  13854. direction1?: Vector3,
  13855. /**
  13856. * The max limit of the emission direction.
  13857. */
  13858. direction2?: Vector3);
  13859. /**
  13860. * Called by the particle System when the direction is computed for the created particle.
  13861. * @param worldMatrix is the world matrix of the particle system
  13862. * @param directionToUpdate is the direction vector to update with the result
  13863. * @param particle is the particle we are computed the direction for
  13864. */
  13865. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13866. /**
  13867. * Clones the current emitter and returns a copy of it
  13868. * @returns the new emitter
  13869. */
  13870. clone(): CylinderDirectedParticleEmitter;
  13871. /**
  13872. * Called by the GPUParticleSystem to setup the update shader
  13873. * @param effect defines the update shader
  13874. */
  13875. applyToShader(effect: Effect): void;
  13876. /**
  13877. * Returns a string to use to update the GPU particles update shader
  13878. * @returns a string containng the defines string
  13879. */
  13880. getEffectDefines(): string;
  13881. /**
  13882. * Returns the string "CylinderDirectedParticleEmitter"
  13883. * @returns a string containing the class name
  13884. */
  13885. getClassName(): string;
  13886. /**
  13887. * Serializes the particle system to a JSON object.
  13888. * @returns the JSON object
  13889. */
  13890. serialize(): any;
  13891. /**
  13892. * Parse properties from a JSON object
  13893. * @param serializationObject defines the JSON object
  13894. */
  13895. parse(serializationObject: any): void;
  13896. }
  13897. }
  13898. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13899. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13900. import { Effect } from "babylonjs/Materials/effect";
  13901. import { Particle } from "babylonjs/Particles/particle";
  13902. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13903. /**
  13904. * Particle emitter emitting particles from the inside of a hemisphere.
  13905. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13906. */
  13907. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13908. /**
  13909. * The radius of the emission hemisphere.
  13910. */
  13911. radius: number;
  13912. /**
  13913. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13914. */
  13915. radiusRange: number;
  13916. /**
  13917. * How much to randomize the particle direction [0-1].
  13918. */
  13919. directionRandomizer: number;
  13920. /**
  13921. * Creates a new instance HemisphericParticleEmitter
  13922. * @param radius the radius of the emission hemisphere (1 by default)
  13923. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13924. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13925. */
  13926. constructor(
  13927. /**
  13928. * The radius of the emission hemisphere.
  13929. */
  13930. radius?: number,
  13931. /**
  13932. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13933. */
  13934. radiusRange?: number,
  13935. /**
  13936. * How much to randomize the particle direction [0-1].
  13937. */
  13938. directionRandomizer?: number);
  13939. /**
  13940. * Called by the particle System when the direction is computed for the created particle.
  13941. * @param worldMatrix is the world matrix of the particle system
  13942. * @param directionToUpdate is the direction vector to update with the result
  13943. * @param particle is the particle we are computed the direction for
  13944. * @param isLocal defines if the direction should be set in local space
  13945. */
  13946. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13947. /**
  13948. * Called by the particle System when the position is computed for the created particle.
  13949. * @param worldMatrix is the world matrix of the particle system
  13950. * @param positionToUpdate is the position vector to update with the result
  13951. * @param particle is the particle we are computed the position for
  13952. * @param isLocal defines if the position should be set in local space
  13953. */
  13954. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13955. /**
  13956. * Clones the current emitter and returns a copy of it
  13957. * @returns the new emitter
  13958. */
  13959. clone(): HemisphericParticleEmitter;
  13960. /**
  13961. * Called by the GPUParticleSystem to setup the update shader
  13962. * @param effect defines the update shader
  13963. */
  13964. applyToShader(effect: Effect): void;
  13965. /**
  13966. * Returns a string to use to update the GPU particles update shader
  13967. * @returns a string containng the defines string
  13968. */
  13969. getEffectDefines(): string;
  13970. /**
  13971. * Returns the string "HemisphericParticleEmitter"
  13972. * @returns a string containing the class name
  13973. */
  13974. getClassName(): string;
  13975. /**
  13976. * Serializes the particle system to a JSON object.
  13977. * @returns the JSON object
  13978. */
  13979. serialize(): any;
  13980. /**
  13981. * Parse properties from a JSON object
  13982. * @param serializationObject defines the JSON object
  13983. */
  13984. parse(serializationObject: any): void;
  13985. }
  13986. }
  13987. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13988. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13989. import { Effect } from "babylonjs/Materials/effect";
  13990. import { Particle } from "babylonjs/Particles/particle";
  13991. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13992. /**
  13993. * Particle emitter emitting particles from a point.
  13994. * It emits the particles randomly between 2 given directions.
  13995. */
  13996. export class PointParticleEmitter implements IParticleEmitterType {
  13997. /**
  13998. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13999. */
  14000. direction1: Vector3;
  14001. /**
  14002. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14003. */
  14004. direction2: Vector3;
  14005. /**
  14006. * Creates a new instance PointParticleEmitter
  14007. */
  14008. constructor();
  14009. /**
  14010. * Called by the particle System when the direction is computed for the created particle.
  14011. * @param worldMatrix is the world matrix of the particle system
  14012. * @param directionToUpdate is the direction vector to update with the result
  14013. * @param particle is the particle we are computed the direction for
  14014. * @param isLocal defines if the direction should be set in local space
  14015. */
  14016. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14017. /**
  14018. * Called by the particle System when the position is computed for the created particle.
  14019. * @param worldMatrix is the world matrix of the particle system
  14020. * @param positionToUpdate is the position vector to update with the result
  14021. * @param particle is the particle we are computed the position for
  14022. * @param isLocal defines if the position should be set in local space
  14023. */
  14024. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14025. /**
  14026. * Clones the current emitter and returns a copy of it
  14027. * @returns the new emitter
  14028. */
  14029. clone(): PointParticleEmitter;
  14030. /**
  14031. * Called by the GPUParticleSystem to setup the update shader
  14032. * @param effect defines the update shader
  14033. */
  14034. applyToShader(effect: Effect): void;
  14035. /**
  14036. * Returns a string to use to update the GPU particles update shader
  14037. * @returns a string containng the defines string
  14038. */
  14039. getEffectDefines(): string;
  14040. /**
  14041. * Returns the string "PointParticleEmitter"
  14042. * @returns a string containing the class name
  14043. */
  14044. getClassName(): string;
  14045. /**
  14046. * Serializes the particle system to a JSON object.
  14047. * @returns the JSON object
  14048. */
  14049. serialize(): any;
  14050. /**
  14051. * Parse properties from a JSON object
  14052. * @param serializationObject defines the JSON object
  14053. */
  14054. parse(serializationObject: any): void;
  14055. }
  14056. }
  14057. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14058. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14059. import { Effect } from "babylonjs/Materials/effect";
  14060. import { Particle } from "babylonjs/Particles/particle";
  14061. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14062. /**
  14063. * Particle emitter emitting particles from the inside of a sphere.
  14064. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14065. */
  14066. export class SphereParticleEmitter implements IParticleEmitterType {
  14067. /**
  14068. * The radius of the emission sphere.
  14069. */
  14070. radius: number;
  14071. /**
  14072. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14073. */
  14074. radiusRange: number;
  14075. /**
  14076. * How much to randomize the particle direction [0-1].
  14077. */
  14078. directionRandomizer: number;
  14079. /**
  14080. * Creates a new instance SphereParticleEmitter
  14081. * @param radius the radius of the emission sphere (1 by default)
  14082. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14083. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14084. */
  14085. constructor(
  14086. /**
  14087. * The radius of the emission sphere.
  14088. */
  14089. radius?: number,
  14090. /**
  14091. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14092. */
  14093. radiusRange?: number,
  14094. /**
  14095. * How much to randomize the particle direction [0-1].
  14096. */
  14097. directionRandomizer?: number);
  14098. /**
  14099. * Called by the particle System when the direction is computed for the created particle.
  14100. * @param worldMatrix is the world matrix of the particle system
  14101. * @param directionToUpdate is the direction vector to update with the result
  14102. * @param particle is the particle we are computed the direction for
  14103. * @param isLocal defines if the direction should be set in local space
  14104. */
  14105. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14106. /**
  14107. * Called by the particle System when the position is computed for the created particle.
  14108. * @param worldMatrix is the world matrix of the particle system
  14109. * @param positionToUpdate is the position vector to update with the result
  14110. * @param particle is the particle we are computed the position for
  14111. * @param isLocal defines if the position should be set in local space
  14112. */
  14113. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14114. /**
  14115. * Clones the current emitter and returns a copy of it
  14116. * @returns the new emitter
  14117. */
  14118. clone(): SphereParticleEmitter;
  14119. /**
  14120. * Called by the GPUParticleSystem to setup the update shader
  14121. * @param effect defines the update shader
  14122. */
  14123. applyToShader(effect: Effect): void;
  14124. /**
  14125. * Returns a string to use to update the GPU particles update shader
  14126. * @returns a string containng the defines string
  14127. */
  14128. getEffectDefines(): string;
  14129. /**
  14130. * Returns the string "SphereParticleEmitter"
  14131. * @returns a string containing the class name
  14132. */
  14133. getClassName(): string;
  14134. /**
  14135. * Serializes the particle system to a JSON object.
  14136. * @returns the JSON object
  14137. */
  14138. serialize(): any;
  14139. /**
  14140. * Parse properties from a JSON object
  14141. * @param serializationObject defines the JSON object
  14142. */
  14143. parse(serializationObject: any): void;
  14144. }
  14145. /**
  14146. * Particle emitter emitting particles from the inside of a sphere.
  14147. * It emits the particles randomly between two vectors.
  14148. */
  14149. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14150. /**
  14151. * The min limit of the emission direction.
  14152. */
  14153. direction1: Vector3;
  14154. /**
  14155. * The max limit of the emission direction.
  14156. */
  14157. direction2: Vector3;
  14158. /**
  14159. * Creates a new instance SphereDirectedParticleEmitter
  14160. * @param radius the radius of the emission sphere (1 by default)
  14161. * @param direction1 the min limit of the emission direction (up vector by default)
  14162. * @param direction2 the max limit of the emission direction (up vector by default)
  14163. */
  14164. constructor(radius?: number,
  14165. /**
  14166. * The min limit of the emission direction.
  14167. */
  14168. direction1?: Vector3,
  14169. /**
  14170. * The max limit of the emission direction.
  14171. */
  14172. direction2?: Vector3);
  14173. /**
  14174. * Called by the particle System when the direction is computed for the created particle.
  14175. * @param worldMatrix is the world matrix of the particle system
  14176. * @param directionToUpdate is the direction vector to update with the result
  14177. * @param particle is the particle we are computed the direction for
  14178. */
  14179. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14180. /**
  14181. * Clones the current emitter and returns a copy of it
  14182. * @returns the new emitter
  14183. */
  14184. clone(): SphereDirectedParticleEmitter;
  14185. /**
  14186. * Called by the GPUParticleSystem to setup the update shader
  14187. * @param effect defines the update shader
  14188. */
  14189. applyToShader(effect: Effect): void;
  14190. /**
  14191. * Returns a string to use to update the GPU particles update shader
  14192. * @returns a string containng the defines string
  14193. */
  14194. getEffectDefines(): string;
  14195. /**
  14196. * Returns the string "SphereDirectedParticleEmitter"
  14197. * @returns a string containing the class name
  14198. */
  14199. getClassName(): string;
  14200. /**
  14201. * Serializes the particle system to a JSON object.
  14202. * @returns the JSON object
  14203. */
  14204. serialize(): any;
  14205. /**
  14206. * Parse properties from a JSON object
  14207. * @param serializationObject defines the JSON object
  14208. */
  14209. parse(serializationObject: any): void;
  14210. }
  14211. }
  14212. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14213. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14214. import { Effect } from "babylonjs/Materials/effect";
  14215. import { Particle } from "babylonjs/Particles/particle";
  14216. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14217. import { Nullable } from "babylonjs/types";
  14218. /**
  14219. * Particle emitter emitting particles from a custom list of positions.
  14220. */
  14221. export class CustomParticleEmitter implements IParticleEmitterType {
  14222. /**
  14223. * Gets or sets the position generator that will create the inital position of each particle.
  14224. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14225. */
  14226. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14227. /**
  14228. * Gets or sets the destination generator that will create the final destination of each particle.
  14229. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14230. */
  14231. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14232. /**
  14233. * Creates a new instance CustomParticleEmitter
  14234. */
  14235. constructor();
  14236. /**
  14237. * Called by the particle System when the direction is computed for the created particle.
  14238. * @param worldMatrix is the world matrix of the particle system
  14239. * @param directionToUpdate is the direction vector to update with the result
  14240. * @param particle is the particle we are computed the direction for
  14241. * @param isLocal defines if the direction should be set in local space
  14242. */
  14243. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14244. /**
  14245. * Called by the particle System when the position is computed for the created particle.
  14246. * @param worldMatrix is the world matrix of the particle system
  14247. * @param positionToUpdate is the position vector to update with the result
  14248. * @param particle is the particle we are computed the position for
  14249. * @param isLocal defines if the position should be set in local space
  14250. */
  14251. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14252. /**
  14253. * Clones the current emitter and returns a copy of it
  14254. * @returns the new emitter
  14255. */
  14256. clone(): CustomParticleEmitter;
  14257. /**
  14258. * Called by the GPUParticleSystem to setup the update shader
  14259. * @param effect defines the update shader
  14260. */
  14261. applyToShader(effect: Effect): void;
  14262. /**
  14263. * Returns a string to use to update the GPU particles update shader
  14264. * @returns a string containng the defines string
  14265. */
  14266. getEffectDefines(): string;
  14267. /**
  14268. * Returns the string "PointParticleEmitter"
  14269. * @returns a string containing the class name
  14270. */
  14271. getClassName(): string;
  14272. /**
  14273. * Serializes the particle system to a JSON object.
  14274. * @returns the JSON object
  14275. */
  14276. serialize(): any;
  14277. /**
  14278. * Parse properties from a JSON object
  14279. * @param serializationObject defines the JSON object
  14280. */
  14281. parse(serializationObject: any): void;
  14282. }
  14283. }
  14284. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14285. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14286. import { Effect } from "babylonjs/Materials/effect";
  14287. import { Particle } from "babylonjs/Particles/particle";
  14288. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14289. import { Nullable } from "babylonjs/types";
  14290. import { Scene } from "babylonjs/scene";
  14291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14292. /**
  14293. * Particle emitter emitting particles from the inside of a box.
  14294. * It emits the particles randomly between 2 given directions.
  14295. */
  14296. export class MeshParticleEmitter implements IParticleEmitterType {
  14297. private _indices;
  14298. private _positions;
  14299. private _normals;
  14300. private _storedNormal;
  14301. private _mesh;
  14302. /**
  14303. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14304. */
  14305. direction1: Vector3;
  14306. /**
  14307. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14308. */
  14309. direction2: Vector3;
  14310. /**
  14311. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14312. */
  14313. useMeshNormalsForDirection: boolean;
  14314. /** Defines the mesh to use as source */
  14315. get mesh(): Nullable<AbstractMesh>;
  14316. set mesh(value: Nullable<AbstractMesh>);
  14317. /**
  14318. * Creates a new instance MeshParticleEmitter
  14319. * @param mesh defines the mesh to use as source
  14320. */
  14321. constructor(mesh?: Nullable<AbstractMesh>);
  14322. /**
  14323. * Called by the particle System when the direction is computed for the created particle.
  14324. * @param worldMatrix is the world matrix of the particle system
  14325. * @param directionToUpdate is the direction vector to update with the result
  14326. * @param particle is the particle we are computed the direction for
  14327. * @param isLocal defines if the direction should be set in local space
  14328. */
  14329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14330. /**
  14331. * Called by the particle System when the position is computed for the created particle.
  14332. * @param worldMatrix is the world matrix of the particle system
  14333. * @param positionToUpdate is the position vector to update with the result
  14334. * @param particle is the particle we are computed the position for
  14335. * @param isLocal defines if the position should be set in local space
  14336. */
  14337. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14338. /**
  14339. * Clones the current emitter and returns a copy of it
  14340. * @returns the new emitter
  14341. */
  14342. clone(): MeshParticleEmitter;
  14343. /**
  14344. * Called by the GPUParticleSystem to setup the update shader
  14345. * @param effect defines the update shader
  14346. */
  14347. applyToShader(effect: Effect): void;
  14348. /**
  14349. * Returns a string to use to update the GPU particles update shader
  14350. * @returns a string containng the defines string
  14351. */
  14352. getEffectDefines(): string;
  14353. /**
  14354. * Returns the string "BoxParticleEmitter"
  14355. * @returns a string containing the class name
  14356. */
  14357. getClassName(): string;
  14358. /**
  14359. * Serializes the particle system to a JSON object.
  14360. * @returns the JSON object
  14361. */
  14362. serialize(): any;
  14363. /**
  14364. * Parse properties from a JSON object
  14365. * @param serializationObject defines the JSON object
  14366. * @param scene defines the hosting scene
  14367. */
  14368. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14369. }
  14370. }
  14371. declare module "babylonjs/Particles/EmitterTypes/index" {
  14372. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14373. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14374. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14375. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14376. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14377. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14378. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14379. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14380. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14381. }
  14382. declare module "babylonjs/Particles/IParticleSystem" {
  14383. import { Nullable } from "babylonjs/types";
  14384. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14385. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14386. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14387. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14388. import { Scene } from "babylonjs/scene";
  14389. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14390. import { Effect } from "babylonjs/Materials/effect";
  14391. import { Observable } from "babylonjs/Misc/observable";
  14392. import { Animation } from "babylonjs/Animations/animation";
  14393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14394. /**
  14395. * Interface representing a particle system in Babylon.js.
  14396. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14397. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14398. */
  14399. export interface IParticleSystem {
  14400. /**
  14401. * List of animations used by the particle system.
  14402. */
  14403. animations: Animation[];
  14404. /**
  14405. * The id of the Particle system.
  14406. */
  14407. id: string;
  14408. /**
  14409. * The name of the Particle system.
  14410. */
  14411. name: string;
  14412. /**
  14413. * The emitter represents the Mesh or position we are attaching the particle system to.
  14414. */
  14415. emitter: Nullable<AbstractMesh | Vector3>;
  14416. /**
  14417. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14418. */
  14419. isBillboardBased: boolean;
  14420. /**
  14421. * The rendering group used by the Particle system to chose when to render.
  14422. */
  14423. renderingGroupId: number;
  14424. /**
  14425. * The layer mask we are rendering the particles through.
  14426. */
  14427. layerMask: number;
  14428. /**
  14429. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14430. */
  14431. updateSpeed: number;
  14432. /**
  14433. * The amount of time the particle system is running (depends of the overall update speed).
  14434. */
  14435. targetStopDuration: number;
  14436. /**
  14437. * The texture used to render each particle. (this can be a spritesheet)
  14438. */
  14439. particleTexture: Nullable<BaseTexture>;
  14440. /**
  14441. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14442. */
  14443. blendMode: number;
  14444. /**
  14445. * Minimum life time of emitting particles.
  14446. */
  14447. minLifeTime: number;
  14448. /**
  14449. * Maximum life time of emitting particles.
  14450. */
  14451. maxLifeTime: number;
  14452. /**
  14453. * Minimum Size of emitting particles.
  14454. */
  14455. minSize: number;
  14456. /**
  14457. * Maximum Size of emitting particles.
  14458. */
  14459. maxSize: number;
  14460. /**
  14461. * Minimum scale of emitting particles on X axis.
  14462. */
  14463. minScaleX: number;
  14464. /**
  14465. * Maximum scale of emitting particles on X axis.
  14466. */
  14467. maxScaleX: number;
  14468. /**
  14469. * Minimum scale of emitting particles on Y axis.
  14470. */
  14471. minScaleY: number;
  14472. /**
  14473. * Maximum scale of emitting particles on Y axis.
  14474. */
  14475. maxScaleY: number;
  14476. /**
  14477. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14478. */
  14479. color1: Color4;
  14480. /**
  14481. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14482. */
  14483. color2: Color4;
  14484. /**
  14485. * Color the particle will have at the end of its lifetime.
  14486. */
  14487. colorDead: Color4;
  14488. /**
  14489. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14490. */
  14491. emitRate: number;
  14492. /**
  14493. * You can use gravity if you want to give an orientation to your particles.
  14494. */
  14495. gravity: Vector3;
  14496. /**
  14497. * Minimum power of emitting particles.
  14498. */
  14499. minEmitPower: number;
  14500. /**
  14501. * Maximum power of emitting particles.
  14502. */
  14503. maxEmitPower: number;
  14504. /**
  14505. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14506. */
  14507. minAngularSpeed: number;
  14508. /**
  14509. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14510. */
  14511. maxAngularSpeed: number;
  14512. /**
  14513. * Gets or sets the minimal initial rotation in radians.
  14514. */
  14515. minInitialRotation: number;
  14516. /**
  14517. * Gets or sets the maximal initial rotation in radians.
  14518. */
  14519. maxInitialRotation: number;
  14520. /**
  14521. * The particle emitter type defines the emitter used by the particle system.
  14522. * It can be for example box, sphere, or cone...
  14523. */
  14524. particleEmitterType: Nullable<IParticleEmitterType>;
  14525. /**
  14526. * Defines the delay in milliseconds before starting the system (0 by default)
  14527. */
  14528. startDelay: number;
  14529. /**
  14530. * 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
  14531. */
  14532. preWarmCycles: number;
  14533. /**
  14534. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14535. */
  14536. preWarmStepOffset: number;
  14537. /**
  14538. * 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)
  14539. */
  14540. spriteCellChangeSpeed: number;
  14541. /**
  14542. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14543. */
  14544. startSpriteCellID: number;
  14545. /**
  14546. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14547. */
  14548. endSpriteCellID: number;
  14549. /**
  14550. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14551. */
  14552. spriteCellWidth: number;
  14553. /**
  14554. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14555. */
  14556. spriteCellHeight: number;
  14557. /**
  14558. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14559. */
  14560. spriteRandomStartCell: boolean;
  14561. /**
  14562. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14563. */
  14564. isAnimationSheetEnabled: boolean;
  14565. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14566. translationPivot: Vector2;
  14567. /**
  14568. * Gets or sets a texture used to add random noise to particle positions
  14569. */
  14570. noiseTexture: Nullable<BaseTexture>;
  14571. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14572. noiseStrength: Vector3;
  14573. /**
  14574. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14575. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14576. */
  14577. billboardMode: number;
  14578. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14579. limitVelocityDamping: number;
  14580. /**
  14581. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14582. */
  14583. beginAnimationOnStart: boolean;
  14584. /**
  14585. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14586. */
  14587. beginAnimationFrom: number;
  14588. /**
  14589. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14590. */
  14591. beginAnimationTo: number;
  14592. /**
  14593. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14594. */
  14595. beginAnimationLoop: boolean;
  14596. /**
  14597. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14598. */
  14599. disposeOnStop: boolean;
  14600. /**
  14601. * Specifies if the particles are updated in emitter local space or world space
  14602. */
  14603. isLocal: boolean;
  14604. /** Snippet ID if the particle system was created from the snippet server */
  14605. snippetId: string;
  14606. /** Gets or sets a matrix to use to compute projection */
  14607. defaultProjectionMatrix: Matrix;
  14608. /**
  14609. * Gets the maximum number of particles active at the same time.
  14610. * @returns The max number of active particles.
  14611. */
  14612. getCapacity(): number;
  14613. /**
  14614. * Gets the number of particles active at the same time.
  14615. * @returns The number of active particles.
  14616. */
  14617. getActiveCount(): number;
  14618. /**
  14619. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14620. * @returns True if it has been started, otherwise false.
  14621. */
  14622. isStarted(): boolean;
  14623. /**
  14624. * Animates the particle system for this frame.
  14625. */
  14626. animate(): void;
  14627. /**
  14628. * Renders the particle system in its current state.
  14629. * @returns the current number of particles
  14630. */
  14631. render(): number;
  14632. /**
  14633. * Dispose the particle system and frees its associated resources.
  14634. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14635. */
  14636. dispose(disposeTexture?: boolean): void;
  14637. /**
  14638. * An event triggered when the system is disposed
  14639. */
  14640. onDisposeObservable: Observable<IParticleSystem>;
  14641. /**
  14642. * Clones the particle system.
  14643. * @param name The name of the cloned object
  14644. * @param newEmitter The new emitter to use
  14645. * @returns the cloned particle system
  14646. */
  14647. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14648. /**
  14649. * Serializes the particle system to a JSON object
  14650. * @param serializeTexture defines if the texture must be serialized as well
  14651. * @returns the JSON object
  14652. */
  14653. serialize(serializeTexture: boolean): any;
  14654. /**
  14655. * Rebuild the particle system
  14656. */
  14657. rebuild(): void;
  14658. /** Force the system to rebuild all gradients that need to be resync */
  14659. forceRefreshGradients(): void;
  14660. /**
  14661. * Starts the particle system and begins to emit
  14662. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14663. */
  14664. start(delay?: number): void;
  14665. /**
  14666. * Stops the particle system.
  14667. */
  14668. stop(): void;
  14669. /**
  14670. * Remove all active particles
  14671. */
  14672. reset(): void;
  14673. /**
  14674. * Gets a boolean indicating that the system is stopping
  14675. * @returns true if the system is currently stopping
  14676. */
  14677. isStopping(): boolean;
  14678. /**
  14679. * Is this system ready to be used/rendered
  14680. * @return true if the system is ready
  14681. */
  14682. isReady(): boolean;
  14683. /**
  14684. * Returns the string "ParticleSystem"
  14685. * @returns a string containing the class name
  14686. */
  14687. getClassName(): string;
  14688. /**
  14689. * Gets the custom effect used to render the particles
  14690. * @param blendMode Blend mode for which the effect should be retrieved
  14691. * @returns The effect
  14692. */
  14693. getCustomEffect(blendMode: number): Nullable<Effect>;
  14694. /**
  14695. * Sets the custom effect used to render the particles
  14696. * @param effect The effect to set
  14697. * @param blendMode Blend mode for which the effect should be set
  14698. */
  14699. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14700. /**
  14701. * Fill the defines array according to the current settings of the particle system
  14702. * @param defines Array to be updated
  14703. * @param blendMode blend mode to take into account when updating the array
  14704. */
  14705. fillDefines(defines: Array<string>, blendMode: number): void;
  14706. /**
  14707. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14708. * @param uniforms Uniforms array to fill
  14709. * @param attributes Attributes array to fill
  14710. * @param samplers Samplers array to fill
  14711. */
  14712. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14713. /**
  14714. * Observable that will be called just before the particles are drawn
  14715. */
  14716. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14717. /**
  14718. * Gets the name of the particle vertex shader
  14719. */
  14720. vertexShaderName: string;
  14721. /**
  14722. * Adds a new color gradient
  14723. * @param gradient defines the gradient to use (between 0 and 1)
  14724. * @param color1 defines the color to affect to the specified gradient
  14725. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14726. * @returns the current particle system
  14727. */
  14728. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14729. /**
  14730. * Remove a specific color gradient
  14731. * @param gradient defines the gradient to remove
  14732. * @returns the current particle system
  14733. */
  14734. removeColorGradient(gradient: number): IParticleSystem;
  14735. /**
  14736. * Adds a new size gradient
  14737. * @param gradient defines the gradient to use (between 0 and 1)
  14738. * @param factor defines the size factor to affect to the specified gradient
  14739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14740. * @returns the current particle system
  14741. */
  14742. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14743. /**
  14744. * Remove a specific size gradient
  14745. * @param gradient defines the gradient to remove
  14746. * @returns the current particle system
  14747. */
  14748. removeSizeGradient(gradient: number): IParticleSystem;
  14749. /**
  14750. * Gets the current list of color gradients.
  14751. * You must use addColorGradient and removeColorGradient to udpate this list
  14752. * @returns the list of color gradients
  14753. */
  14754. getColorGradients(): Nullable<Array<ColorGradient>>;
  14755. /**
  14756. * Gets the current list of size gradients.
  14757. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14758. * @returns the list of size gradients
  14759. */
  14760. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14761. /**
  14762. * Gets the current list of angular speed gradients.
  14763. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14764. * @returns the list of angular speed gradients
  14765. */
  14766. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14767. /**
  14768. * Adds a new angular speed gradient
  14769. * @param gradient defines the gradient to use (between 0 and 1)
  14770. * @param factor defines the angular speed to affect to the specified gradient
  14771. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14772. * @returns the current particle system
  14773. */
  14774. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14775. /**
  14776. * Remove a specific angular speed gradient
  14777. * @param gradient defines the gradient to remove
  14778. * @returns the current particle system
  14779. */
  14780. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14781. /**
  14782. * Gets the current list of velocity gradients.
  14783. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14784. * @returns the list of velocity gradients
  14785. */
  14786. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14787. /**
  14788. * Adds a new velocity gradient
  14789. * @param gradient defines the gradient to use (between 0 and 1)
  14790. * @param factor defines the velocity to affect to the specified gradient
  14791. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14792. * @returns the current particle system
  14793. */
  14794. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14795. /**
  14796. * Remove a specific velocity gradient
  14797. * @param gradient defines the gradient to remove
  14798. * @returns the current particle system
  14799. */
  14800. removeVelocityGradient(gradient: number): IParticleSystem;
  14801. /**
  14802. * Gets the current list of limit velocity gradients.
  14803. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14804. * @returns the list of limit velocity gradients
  14805. */
  14806. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14807. /**
  14808. * Adds a new limit velocity gradient
  14809. * @param gradient defines the gradient to use (between 0 and 1)
  14810. * @param factor defines the limit velocity to affect to the specified gradient
  14811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14812. * @returns the current particle system
  14813. */
  14814. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14815. /**
  14816. * Remove a specific limit velocity gradient
  14817. * @param gradient defines the gradient to remove
  14818. * @returns the current particle system
  14819. */
  14820. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14821. /**
  14822. * Adds a new drag gradient
  14823. * @param gradient defines the gradient to use (between 0 and 1)
  14824. * @param factor defines the drag to affect to the specified gradient
  14825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14826. * @returns the current particle system
  14827. */
  14828. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14829. /**
  14830. * Remove a specific drag gradient
  14831. * @param gradient defines the gradient to remove
  14832. * @returns the current particle system
  14833. */
  14834. removeDragGradient(gradient: number): IParticleSystem;
  14835. /**
  14836. * Gets the current list of drag gradients.
  14837. * You must use addDragGradient and removeDragGradient to udpate this list
  14838. * @returns the list of drag gradients
  14839. */
  14840. getDragGradients(): Nullable<Array<FactorGradient>>;
  14841. /**
  14842. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14843. * @param gradient defines the gradient to use (between 0 and 1)
  14844. * @param factor defines the emit rate to affect to the specified gradient
  14845. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14846. * @returns the current particle system
  14847. */
  14848. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14849. /**
  14850. * Remove a specific emit rate gradient
  14851. * @param gradient defines the gradient to remove
  14852. * @returns the current particle system
  14853. */
  14854. removeEmitRateGradient(gradient: number): IParticleSystem;
  14855. /**
  14856. * Gets the current list of emit rate gradients.
  14857. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14858. * @returns the list of emit rate gradients
  14859. */
  14860. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14861. /**
  14862. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14863. * @param gradient defines the gradient to use (between 0 and 1)
  14864. * @param factor defines the start size to affect to the specified gradient
  14865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14866. * @returns the current particle system
  14867. */
  14868. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14869. /**
  14870. * Remove a specific start size gradient
  14871. * @param gradient defines the gradient to remove
  14872. * @returns the current particle system
  14873. */
  14874. removeStartSizeGradient(gradient: number): IParticleSystem;
  14875. /**
  14876. * Gets the current list of start size gradients.
  14877. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14878. * @returns the list of start size gradients
  14879. */
  14880. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14881. /**
  14882. * Adds a new life time gradient
  14883. * @param gradient defines the gradient to use (between 0 and 1)
  14884. * @param factor defines the life time factor to affect to the specified gradient
  14885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14886. * @returns the current particle system
  14887. */
  14888. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14889. /**
  14890. * Remove a specific life time gradient
  14891. * @param gradient defines the gradient to remove
  14892. * @returns the current particle system
  14893. */
  14894. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14895. /**
  14896. * Gets the current list of life time gradients.
  14897. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14898. * @returns the list of life time gradients
  14899. */
  14900. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14901. /**
  14902. * Gets the current list of color gradients.
  14903. * You must use addColorGradient and removeColorGradient to udpate this list
  14904. * @returns the list of color gradients
  14905. */
  14906. getColorGradients(): Nullable<Array<ColorGradient>>;
  14907. /**
  14908. * Adds a new ramp gradient used to remap particle colors
  14909. * @param gradient defines the gradient to use (between 0 and 1)
  14910. * @param color defines the color to affect to the specified gradient
  14911. * @returns the current particle system
  14912. */
  14913. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14914. /**
  14915. * Gets the current list of ramp gradients.
  14916. * You must use addRampGradient and removeRampGradient to udpate this list
  14917. * @returns the list of ramp gradients
  14918. */
  14919. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14920. /** Gets or sets a boolean indicating that ramp gradients must be used
  14921. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14922. */
  14923. useRampGradients: boolean;
  14924. /**
  14925. * Adds a new color remap gradient
  14926. * @param gradient defines the gradient to use (between 0 and 1)
  14927. * @param min defines the color remap minimal range
  14928. * @param max defines the color remap maximal range
  14929. * @returns the current particle system
  14930. */
  14931. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14932. /**
  14933. * Gets the current list of color remap gradients.
  14934. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14935. * @returns the list of color remap gradients
  14936. */
  14937. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14938. /**
  14939. * Adds a new alpha remap gradient
  14940. * @param gradient defines the gradient to use (between 0 and 1)
  14941. * @param min defines the alpha remap minimal range
  14942. * @param max defines the alpha remap maximal range
  14943. * @returns the current particle system
  14944. */
  14945. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14946. /**
  14947. * Gets the current list of alpha remap gradients.
  14948. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14949. * @returns the list of alpha remap gradients
  14950. */
  14951. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14952. /**
  14953. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14954. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14955. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14956. * @returns the emitter
  14957. */
  14958. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14959. /**
  14960. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14961. * @param radius The radius of the hemisphere to emit from
  14962. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14963. * @returns the emitter
  14964. */
  14965. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14966. /**
  14967. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14968. * @param radius The radius of the sphere to emit from
  14969. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14970. * @returns the emitter
  14971. */
  14972. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14973. /**
  14974. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14975. * @param radius The radius of the sphere to emit from
  14976. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14977. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14978. * @returns the emitter
  14979. */
  14980. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14981. /**
  14982. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14983. * @param radius The radius of the emission cylinder
  14984. * @param height The height of the emission cylinder
  14985. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14986. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14987. * @returns the emitter
  14988. */
  14989. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14990. /**
  14991. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14992. * @param radius The radius of the cylinder to emit from
  14993. * @param height The height of the emission cylinder
  14994. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14995. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14996. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14997. * @returns the emitter
  14998. */
  14999. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15000. /**
  15001. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15002. * @param radius The radius of the cone to emit from
  15003. * @param angle The base angle of the cone
  15004. * @returns the emitter
  15005. */
  15006. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15007. /**
  15008. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15009. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15010. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15011. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15012. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15013. * @returns the emitter
  15014. */
  15015. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15016. /**
  15017. * Get hosting scene
  15018. * @returns the scene
  15019. */
  15020. getScene(): Nullable<Scene>;
  15021. }
  15022. }
  15023. declare module "babylonjs/Meshes/transformNode" {
  15024. import { DeepImmutable } from "babylonjs/types";
  15025. import { Observable } from "babylonjs/Misc/observable";
  15026. import { Nullable } from "babylonjs/types";
  15027. import { Camera } from "babylonjs/Cameras/camera";
  15028. import { Scene } from "babylonjs/scene";
  15029. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15030. import { Node } from "babylonjs/node";
  15031. import { Bone } from "babylonjs/Bones/bone";
  15032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15033. import { Space } from "babylonjs/Maths/math.axis";
  15034. /**
  15035. * 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.
  15036. * @see https://doc.babylonjs.com/how_to/transformnode
  15037. */
  15038. export class TransformNode extends Node {
  15039. /**
  15040. * Object will not rotate to face the camera
  15041. */
  15042. static BILLBOARDMODE_NONE: number;
  15043. /**
  15044. * Object will rotate to face the camera but only on the x axis
  15045. */
  15046. static BILLBOARDMODE_X: number;
  15047. /**
  15048. * Object will rotate to face the camera but only on the y axis
  15049. */
  15050. static BILLBOARDMODE_Y: number;
  15051. /**
  15052. * Object will rotate to face the camera but only on the z axis
  15053. */
  15054. static BILLBOARDMODE_Z: number;
  15055. /**
  15056. * Object will rotate to face the camera
  15057. */
  15058. static BILLBOARDMODE_ALL: number;
  15059. /**
  15060. * Object will rotate to face the camera's position instead of orientation
  15061. */
  15062. static BILLBOARDMODE_USE_POSITION: number;
  15063. private static _TmpRotation;
  15064. private static _TmpScaling;
  15065. private static _TmpTranslation;
  15066. private _forward;
  15067. private _forwardInverted;
  15068. private _up;
  15069. private _right;
  15070. private _rightInverted;
  15071. private _position;
  15072. private _rotation;
  15073. private _rotationQuaternion;
  15074. protected _scaling: Vector3;
  15075. protected _isDirty: boolean;
  15076. private _transformToBoneReferal;
  15077. private _isAbsoluteSynced;
  15078. private _billboardMode;
  15079. /**
  15080. * Gets or sets the billboard mode. Default is 0.
  15081. *
  15082. * | Value | Type | Description |
  15083. * | --- | --- | --- |
  15084. * | 0 | BILLBOARDMODE_NONE | |
  15085. * | 1 | BILLBOARDMODE_X | |
  15086. * | 2 | BILLBOARDMODE_Y | |
  15087. * | 4 | BILLBOARDMODE_Z | |
  15088. * | 7 | BILLBOARDMODE_ALL | |
  15089. *
  15090. */
  15091. get billboardMode(): number;
  15092. set billboardMode(value: number);
  15093. private _preserveParentRotationForBillboard;
  15094. /**
  15095. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15096. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15097. */
  15098. get preserveParentRotationForBillboard(): boolean;
  15099. set preserveParentRotationForBillboard(value: boolean);
  15100. /**
  15101. * 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
  15102. */
  15103. scalingDeterminant: number;
  15104. private _infiniteDistance;
  15105. /**
  15106. * Gets or sets the distance of the object to max, often used by skybox
  15107. */
  15108. get infiniteDistance(): boolean;
  15109. set infiniteDistance(value: boolean);
  15110. /**
  15111. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15112. * By default the system will update normals to compensate
  15113. */
  15114. ignoreNonUniformScaling: boolean;
  15115. /**
  15116. * 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
  15117. */
  15118. reIntegrateRotationIntoRotationQuaternion: boolean;
  15119. /** @hidden */
  15120. _poseMatrix: Nullable<Matrix>;
  15121. /** @hidden */
  15122. _localMatrix: Matrix;
  15123. private _usePivotMatrix;
  15124. private _absolutePosition;
  15125. private _absoluteScaling;
  15126. private _absoluteRotationQuaternion;
  15127. private _pivotMatrix;
  15128. private _pivotMatrixInverse;
  15129. /** @hidden */
  15130. _postMultiplyPivotMatrix: boolean;
  15131. protected _isWorldMatrixFrozen: boolean;
  15132. /** @hidden */
  15133. _indexInSceneTransformNodesArray: number;
  15134. /**
  15135. * An event triggered after the world matrix is updated
  15136. */
  15137. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15138. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15139. /**
  15140. * Gets a string identifying the name of the class
  15141. * @returns "TransformNode" string
  15142. */
  15143. getClassName(): string;
  15144. /**
  15145. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15146. */
  15147. get position(): Vector3;
  15148. set position(newPosition: Vector3);
  15149. /**
  15150. * 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)).
  15151. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15152. */
  15153. get rotation(): Vector3;
  15154. set rotation(newRotation: Vector3);
  15155. /**
  15156. * 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)).
  15157. */
  15158. get scaling(): Vector3;
  15159. set scaling(newScaling: Vector3);
  15160. /**
  15161. * 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).
  15162. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15163. */
  15164. get rotationQuaternion(): Nullable<Quaternion>;
  15165. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15166. /**
  15167. * The forward direction of that transform in world space.
  15168. */
  15169. get forward(): Vector3;
  15170. /**
  15171. * The up direction of that transform in world space.
  15172. */
  15173. get up(): Vector3;
  15174. /**
  15175. * The right direction of that transform in world space.
  15176. */
  15177. get right(): Vector3;
  15178. /**
  15179. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15180. * @param matrix the matrix to copy the pose from
  15181. * @returns this TransformNode.
  15182. */
  15183. updatePoseMatrix(matrix: Matrix): TransformNode;
  15184. /**
  15185. * Returns the mesh Pose matrix.
  15186. * @returns the pose matrix
  15187. */
  15188. getPoseMatrix(): Matrix;
  15189. /** @hidden */
  15190. _isSynchronized(): boolean;
  15191. /** @hidden */
  15192. _initCache(): void;
  15193. /**
  15194. * Flag the transform node as dirty (Forcing it to update everything)
  15195. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15196. * @returns this transform node
  15197. */
  15198. markAsDirty(property: string): TransformNode;
  15199. /**
  15200. * Returns the current mesh absolute position.
  15201. * Returns a Vector3.
  15202. */
  15203. get absolutePosition(): Vector3;
  15204. /**
  15205. * Returns the current mesh absolute scaling.
  15206. * Returns a Vector3.
  15207. */
  15208. get absoluteScaling(): Vector3;
  15209. /**
  15210. * Returns the current mesh absolute rotation.
  15211. * Returns a Quaternion.
  15212. */
  15213. get absoluteRotationQuaternion(): Quaternion;
  15214. /**
  15215. * Sets a new matrix to apply before all other transformation
  15216. * @param matrix defines the transform matrix
  15217. * @returns the current TransformNode
  15218. */
  15219. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15220. /**
  15221. * Sets a new pivot matrix to the current node
  15222. * @param matrix defines the new pivot matrix to use
  15223. * @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
  15224. * @returns the current TransformNode
  15225. */
  15226. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15227. /**
  15228. * Returns the mesh pivot matrix.
  15229. * Default : Identity.
  15230. * @returns the matrix
  15231. */
  15232. getPivotMatrix(): Matrix;
  15233. /**
  15234. * Instantiate (when possible) or clone that node with its hierarchy
  15235. * @param newParent defines the new parent to use for the instance (or clone)
  15236. * @param options defines options to configure how copy is done
  15237. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15238. * @returns an instance (or a clone) of the current node with its hiearchy
  15239. */
  15240. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15241. doNotInstantiate: boolean;
  15242. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15243. /**
  15244. * Prevents the World matrix to be computed any longer
  15245. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15246. * @returns the TransformNode.
  15247. */
  15248. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15249. /**
  15250. * Allows back the World matrix computation.
  15251. * @returns the TransformNode.
  15252. */
  15253. unfreezeWorldMatrix(): this;
  15254. /**
  15255. * True if the World matrix has been frozen.
  15256. */
  15257. get isWorldMatrixFrozen(): boolean;
  15258. /**
  15259. * Retuns the mesh absolute position in the World.
  15260. * @returns a Vector3.
  15261. */
  15262. getAbsolutePosition(): Vector3;
  15263. /**
  15264. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15265. * @param absolutePosition the absolute position to set
  15266. * @returns the TransformNode.
  15267. */
  15268. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15269. /**
  15270. * Sets the mesh position in its local space.
  15271. * @param vector3 the position to set in localspace
  15272. * @returns the TransformNode.
  15273. */
  15274. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15275. /**
  15276. * Returns the mesh position in the local space from the current World matrix values.
  15277. * @returns a new Vector3.
  15278. */
  15279. getPositionExpressedInLocalSpace(): Vector3;
  15280. /**
  15281. * Translates the mesh along the passed Vector3 in its local space.
  15282. * @param vector3 the distance to translate in localspace
  15283. * @returns the TransformNode.
  15284. */
  15285. locallyTranslate(vector3: Vector3): TransformNode;
  15286. private static _lookAtVectorCache;
  15287. /**
  15288. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15289. * @param targetPoint the position (must be in same space as current mesh) to look at
  15290. * @param yawCor optional yaw (y-axis) correction in radians
  15291. * @param pitchCor optional pitch (x-axis) correction in radians
  15292. * @param rollCor optional roll (z-axis) correction in radians
  15293. * @param space the choosen space of the target
  15294. * @returns the TransformNode.
  15295. */
  15296. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15297. /**
  15298. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15299. * This Vector3 is expressed in the World space.
  15300. * @param localAxis axis to rotate
  15301. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15302. */
  15303. getDirection(localAxis: Vector3): Vector3;
  15304. /**
  15305. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15306. * localAxis is expressed in the mesh local space.
  15307. * result is computed in the Wordl space from the mesh World matrix.
  15308. * @param localAxis axis to rotate
  15309. * @param result the resulting transformnode
  15310. * @returns this TransformNode.
  15311. */
  15312. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15313. /**
  15314. * Sets this transform node rotation to the given local axis.
  15315. * @param localAxis the axis in local space
  15316. * @param yawCor optional yaw (y-axis) correction in radians
  15317. * @param pitchCor optional pitch (x-axis) correction in radians
  15318. * @param rollCor optional roll (z-axis) correction in radians
  15319. * @returns this TransformNode
  15320. */
  15321. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15322. /**
  15323. * Sets a new pivot point to the current node
  15324. * @param point defines the new pivot point to use
  15325. * @param space defines if the point is in world or local space (local by default)
  15326. * @returns the current TransformNode
  15327. */
  15328. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15329. /**
  15330. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15331. * @returns the pivot point
  15332. */
  15333. getPivotPoint(): Vector3;
  15334. /**
  15335. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15336. * @param result the vector3 to store the result
  15337. * @returns this TransformNode.
  15338. */
  15339. getPivotPointToRef(result: Vector3): TransformNode;
  15340. /**
  15341. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15342. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15343. */
  15344. getAbsolutePivotPoint(): Vector3;
  15345. /**
  15346. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15347. * @param result vector3 to store the result
  15348. * @returns this TransformNode.
  15349. */
  15350. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15351. /**
  15352. * Defines the passed node as the parent of the current node.
  15353. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15354. * @see https://doc.babylonjs.com/how_to/parenting
  15355. * @param node the node ot set as the parent
  15356. * @returns this TransformNode.
  15357. */
  15358. setParent(node: Nullable<Node>): TransformNode;
  15359. private _nonUniformScaling;
  15360. /**
  15361. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15362. */
  15363. get nonUniformScaling(): boolean;
  15364. /** @hidden */
  15365. _updateNonUniformScalingState(value: boolean): boolean;
  15366. /**
  15367. * Attach the current TransformNode to another TransformNode associated with a bone
  15368. * @param bone Bone affecting the TransformNode
  15369. * @param affectedTransformNode TransformNode associated with the bone
  15370. * @returns this object
  15371. */
  15372. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15373. /**
  15374. * Detach the transform node if its associated with a bone
  15375. * @returns this object
  15376. */
  15377. detachFromBone(): TransformNode;
  15378. private static _rotationAxisCache;
  15379. /**
  15380. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15381. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15382. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15383. * The passed axis is also normalized.
  15384. * @param axis the axis to rotate around
  15385. * @param amount the amount to rotate in radians
  15386. * @param space Space to rotate in (Default: local)
  15387. * @returns the TransformNode.
  15388. */
  15389. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15390. /**
  15391. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15392. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15393. * The passed axis is also normalized. .
  15394. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15395. * @param point the point to rotate around
  15396. * @param axis the axis to rotate around
  15397. * @param amount the amount to rotate in radians
  15398. * @returns the TransformNode
  15399. */
  15400. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15401. /**
  15402. * Translates the mesh along the axis vector for the passed distance in the given space.
  15403. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15404. * @param axis the axis to translate in
  15405. * @param distance the distance to translate
  15406. * @param space Space to rotate in (Default: local)
  15407. * @returns the TransformNode.
  15408. */
  15409. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15410. /**
  15411. * Adds a rotation step to the mesh current rotation.
  15412. * x, y, z are Euler angles expressed in radians.
  15413. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15414. * This means this rotation is made in the mesh local space only.
  15415. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15416. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15417. * ```javascript
  15418. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15419. * ```
  15420. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15421. * 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.
  15422. * @param x Rotation to add
  15423. * @param y Rotation to add
  15424. * @param z Rotation to add
  15425. * @returns the TransformNode.
  15426. */
  15427. addRotation(x: number, y: number, z: number): TransformNode;
  15428. /**
  15429. * @hidden
  15430. */
  15431. protected _getEffectiveParent(): Nullable<Node>;
  15432. /**
  15433. * Computes the world matrix of the node
  15434. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15435. * @returns the world matrix
  15436. */
  15437. computeWorldMatrix(force?: boolean): Matrix;
  15438. /**
  15439. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15440. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15441. */
  15442. resetLocalMatrix(independentOfChildren?: boolean): void;
  15443. protected _afterComputeWorldMatrix(): void;
  15444. /**
  15445. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15446. * @param func callback function to add
  15447. *
  15448. * @returns the TransformNode.
  15449. */
  15450. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15451. /**
  15452. * Removes a registered callback function.
  15453. * @param func callback function to remove
  15454. * @returns the TransformNode.
  15455. */
  15456. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15457. /**
  15458. * Gets the position of the current mesh in camera space
  15459. * @param camera defines the camera to use
  15460. * @returns a position
  15461. */
  15462. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15463. /**
  15464. * Returns the distance from the mesh to the active camera
  15465. * @param camera defines the camera to use
  15466. * @returns the distance
  15467. */
  15468. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15469. /**
  15470. * Clone the current transform node
  15471. * @param name Name of the new clone
  15472. * @param newParent New parent for the clone
  15473. * @param doNotCloneChildren Do not clone children hierarchy
  15474. * @returns the new transform node
  15475. */
  15476. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15477. /**
  15478. * Serializes the objects information.
  15479. * @param currentSerializationObject defines the object to serialize in
  15480. * @returns the serialized object
  15481. */
  15482. serialize(currentSerializationObject?: any): any;
  15483. /**
  15484. * Returns a new TransformNode object parsed from the source provided.
  15485. * @param parsedTransformNode is the source.
  15486. * @param scene the scne the object belongs to
  15487. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15488. * @returns a new TransformNode object parsed from the source provided.
  15489. */
  15490. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15491. /**
  15492. * Get all child-transformNodes of this node
  15493. * @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
  15494. * @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
  15495. * @returns an array of TransformNode
  15496. */
  15497. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15498. /**
  15499. * Releases resources associated with this transform node.
  15500. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15501. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15502. */
  15503. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15504. /**
  15505. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15506. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15507. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15508. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15509. * @returns the current mesh
  15510. */
  15511. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15512. private _syncAbsoluteScalingAndRotation;
  15513. }
  15514. }
  15515. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15516. /**
  15517. * Class used to override all child animations of a given target
  15518. */
  15519. export class AnimationPropertiesOverride {
  15520. /**
  15521. * Gets or sets a value indicating if animation blending must be used
  15522. */
  15523. enableBlending: boolean;
  15524. /**
  15525. * Gets or sets the blending speed to use when enableBlending is true
  15526. */
  15527. blendingSpeed: number;
  15528. /**
  15529. * Gets or sets the default loop mode to use
  15530. */
  15531. loopMode: number;
  15532. }
  15533. }
  15534. declare module "babylonjs/Bones/bone" {
  15535. import { Skeleton } from "babylonjs/Bones/skeleton";
  15536. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15537. import { Nullable } from "babylonjs/types";
  15538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15539. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15540. import { Node } from "babylonjs/node";
  15541. import { Space } from "babylonjs/Maths/math.axis";
  15542. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15543. /**
  15544. * Class used to store bone information
  15545. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15546. */
  15547. export class Bone extends Node {
  15548. /**
  15549. * defines the bone name
  15550. */
  15551. name: string;
  15552. private static _tmpVecs;
  15553. private static _tmpQuat;
  15554. private static _tmpMats;
  15555. /**
  15556. * Gets the list of child bones
  15557. */
  15558. children: Bone[];
  15559. /** Gets the animations associated with this bone */
  15560. animations: import("babylonjs/Animations/animation").Animation[];
  15561. /**
  15562. * Gets or sets bone length
  15563. */
  15564. length: number;
  15565. /**
  15566. * @hidden Internal only
  15567. * Set this value to map this bone to a different index in the transform matrices
  15568. * Set this value to -1 to exclude the bone from the transform matrices
  15569. */
  15570. _index: Nullable<number>;
  15571. private _skeleton;
  15572. private _localMatrix;
  15573. private _restPose;
  15574. private _bindPose;
  15575. private _baseMatrix;
  15576. private _absoluteTransform;
  15577. private _invertedAbsoluteTransform;
  15578. private _parent;
  15579. private _scalingDeterminant;
  15580. private _worldTransform;
  15581. private _localScaling;
  15582. private _localRotation;
  15583. private _localPosition;
  15584. private _needToDecompose;
  15585. private _needToCompose;
  15586. /** @hidden */
  15587. _linkedTransformNode: Nullable<TransformNode>;
  15588. /** @hidden */
  15589. _waitingTransformNodeId: Nullable<string>;
  15590. /** @hidden */
  15591. get _matrix(): Matrix;
  15592. /** @hidden */
  15593. set _matrix(value: Matrix);
  15594. /**
  15595. * Create a new bone
  15596. * @param name defines the bone name
  15597. * @param skeleton defines the parent skeleton
  15598. * @param parentBone defines the parent (can be null if the bone is the root)
  15599. * @param localMatrix defines the local matrix
  15600. * @param restPose defines the rest pose matrix
  15601. * @param baseMatrix defines the base matrix
  15602. * @param index defines index of the bone in the hiearchy
  15603. */
  15604. constructor(
  15605. /**
  15606. * defines the bone name
  15607. */
  15608. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15609. /**
  15610. * Gets the current object class name.
  15611. * @return the class name
  15612. */
  15613. getClassName(): string;
  15614. /**
  15615. * Gets the parent skeleton
  15616. * @returns a skeleton
  15617. */
  15618. getSkeleton(): Skeleton;
  15619. /**
  15620. * Gets parent bone
  15621. * @returns a bone or null if the bone is the root of the bone hierarchy
  15622. */
  15623. getParent(): Nullable<Bone>;
  15624. /**
  15625. * Returns an array containing the root bones
  15626. * @returns an array containing the root bones
  15627. */
  15628. getChildren(): Array<Bone>;
  15629. /**
  15630. * Gets the node index in matrix array generated for rendering
  15631. * @returns the node index
  15632. */
  15633. getIndex(): number;
  15634. /**
  15635. * Sets the parent bone
  15636. * @param parent defines the parent (can be null if the bone is the root)
  15637. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15638. */
  15639. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15640. /**
  15641. * Gets the local matrix
  15642. * @returns a matrix
  15643. */
  15644. getLocalMatrix(): Matrix;
  15645. /**
  15646. * Gets the base matrix (initial matrix which remains unchanged)
  15647. * @returns a matrix
  15648. */
  15649. getBaseMatrix(): Matrix;
  15650. /**
  15651. * Gets the rest pose matrix
  15652. * @returns a matrix
  15653. */
  15654. getRestPose(): Matrix;
  15655. /**
  15656. * Sets the rest pose matrix
  15657. * @param matrix the local-space rest pose to set for this bone
  15658. */
  15659. setRestPose(matrix: Matrix): void;
  15660. /**
  15661. * Gets the bind pose matrix
  15662. * @returns the bind pose matrix
  15663. */
  15664. getBindPose(): Matrix;
  15665. /**
  15666. * Sets the bind pose matrix
  15667. * @param matrix the local-space bind pose to set for this bone
  15668. */
  15669. setBindPose(matrix: Matrix): void;
  15670. /**
  15671. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15672. */
  15673. getWorldMatrix(): Matrix;
  15674. /**
  15675. * Sets the local matrix to rest pose matrix
  15676. */
  15677. returnToRest(): void;
  15678. /**
  15679. * Gets the inverse of the absolute transform matrix.
  15680. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15681. * @returns a matrix
  15682. */
  15683. getInvertedAbsoluteTransform(): Matrix;
  15684. /**
  15685. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15686. * @returns a matrix
  15687. */
  15688. getAbsoluteTransform(): Matrix;
  15689. /**
  15690. * Links with the given transform node.
  15691. * The local matrix of this bone is copied from the transform node every frame.
  15692. * @param transformNode defines the transform node to link to
  15693. */
  15694. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15695. /**
  15696. * Gets the node used to drive the bone's transformation
  15697. * @returns a transform node or null
  15698. */
  15699. getTransformNode(): Nullable<TransformNode>;
  15700. /** Gets or sets current position (in local space) */
  15701. get position(): Vector3;
  15702. set position(newPosition: Vector3);
  15703. /** Gets or sets current rotation (in local space) */
  15704. get rotation(): Vector3;
  15705. set rotation(newRotation: Vector3);
  15706. /** Gets or sets current rotation quaternion (in local space) */
  15707. get rotationQuaternion(): Quaternion;
  15708. set rotationQuaternion(newRotation: Quaternion);
  15709. /** Gets or sets current scaling (in local space) */
  15710. get scaling(): Vector3;
  15711. set scaling(newScaling: Vector3);
  15712. /**
  15713. * Gets the animation properties override
  15714. */
  15715. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15716. private _decompose;
  15717. private _compose;
  15718. /**
  15719. * Update the base and local matrices
  15720. * @param matrix defines the new base or local matrix
  15721. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15722. * @param updateLocalMatrix defines if the local matrix should be updated
  15723. */
  15724. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15725. /** @hidden */
  15726. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15727. /**
  15728. * Flag the bone as dirty (Forcing it to update everything)
  15729. */
  15730. markAsDirty(): void;
  15731. /** @hidden */
  15732. _markAsDirtyAndCompose(): void;
  15733. private _markAsDirtyAndDecompose;
  15734. /**
  15735. * Translate the bone in local or world space
  15736. * @param vec The amount to translate the bone
  15737. * @param space The space that the translation is in
  15738. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15739. */
  15740. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15741. /**
  15742. * Set the postion of the bone in local or world space
  15743. * @param position The position to set the bone
  15744. * @param space The space that the position is in
  15745. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15746. */
  15747. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15748. /**
  15749. * Set the absolute position of the bone (world space)
  15750. * @param position The position to set the bone
  15751. * @param mesh The mesh that this bone is attached to
  15752. */
  15753. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15754. /**
  15755. * Scale the bone on the x, y and z axes (in local space)
  15756. * @param x The amount to scale the bone on the x axis
  15757. * @param y The amount to scale the bone on the y axis
  15758. * @param z The amount to scale the bone on the z axis
  15759. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15760. */
  15761. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15762. /**
  15763. * Set the bone scaling in local space
  15764. * @param scale defines the scaling vector
  15765. */
  15766. setScale(scale: Vector3): void;
  15767. /**
  15768. * Gets the current scaling in local space
  15769. * @returns the current scaling vector
  15770. */
  15771. getScale(): Vector3;
  15772. /**
  15773. * Gets the current scaling in local space and stores it in a target vector
  15774. * @param result defines the target vector
  15775. */
  15776. getScaleToRef(result: Vector3): void;
  15777. /**
  15778. * Set the yaw, pitch, and roll of the bone in local or world space
  15779. * @param yaw The rotation of the bone on the y axis
  15780. * @param pitch The rotation of the bone on the x axis
  15781. * @param roll The rotation of the bone on the z axis
  15782. * @param space The space that the axes of rotation are in
  15783. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15784. */
  15785. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15786. /**
  15787. * Add a rotation to the bone on an axis in local or world space
  15788. * @param axis The axis to rotate the bone on
  15789. * @param amount The amount to rotate the bone
  15790. * @param space The space that the axis is in
  15791. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15792. */
  15793. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15794. /**
  15795. * Set the rotation of the bone to a particular axis angle in local or world space
  15796. * @param axis The axis to rotate the bone on
  15797. * @param angle The angle that the bone should be rotated to
  15798. * @param space The space that the axis is in
  15799. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15800. */
  15801. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15802. /**
  15803. * Set the euler rotation of the bone in local of world space
  15804. * @param rotation The euler rotation that the bone should be set to
  15805. * @param space The space that the rotation is in
  15806. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15807. */
  15808. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15809. /**
  15810. * Set the quaternion rotation of the bone in local of world space
  15811. * @param quat The quaternion rotation that the bone should be set to
  15812. * @param space The space that the rotation is in
  15813. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15814. */
  15815. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15816. /**
  15817. * Set the rotation matrix of the bone in local of world space
  15818. * @param rotMat The rotation matrix that the bone should be set to
  15819. * @param space The space that the rotation is in
  15820. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15821. */
  15822. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15823. private _rotateWithMatrix;
  15824. private _getNegativeRotationToRef;
  15825. /**
  15826. * Get the position of the bone in local or world space
  15827. * @param space The space that the returned position is in
  15828. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15829. * @returns The position of the bone
  15830. */
  15831. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15832. /**
  15833. * Copy the position of the bone to a vector3 in local or world space
  15834. * @param space The space that the returned position is in
  15835. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15836. * @param result The vector3 to copy the position to
  15837. */
  15838. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15839. /**
  15840. * Get the absolute position of the bone (world space)
  15841. * @param mesh The mesh that this bone is attached to
  15842. * @returns The absolute position of the bone
  15843. */
  15844. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15845. /**
  15846. * Copy the absolute position of the bone (world space) to the result param
  15847. * @param mesh The mesh that this bone is attached to
  15848. * @param result The vector3 to copy the absolute position to
  15849. */
  15850. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15851. /**
  15852. * Compute the absolute transforms of this bone and its children
  15853. */
  15854. computeAbsoluteTransforms(): void;
  15855. /**
  15856. * Get the world direction from an axis that is in the local space of the bone
  15857. * @param localAxis The local direction that is used to compute the world direction
  15858. * @param mesh The mesh that this bone is attached to
  15859. * @returns The world direction
  15860. */
  15861. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15862. /**
  15863. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15864. * @param localAxis The local direction that is used to compute the world direction
  15865. * @param mesh The mesh that this bone is attached to
  15866. * @param result The vector3 that the world direction will be copied to
  15867. */
  15868. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15869. /**
  15870. * Get the euler rotation of the bone in local or world space
  15871. * @param space The space that the rotation should be in
  15872. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15873. * @returns The euler rotation
  15874. */
  15875. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15876. /**
  15877. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15878. * @param space The space that the rotation should be in
  15879. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15880. * @param result The vector3 that the rotation should be copied to
  15881. */
  15882. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15883. /**
  15884. * Get the quaternion rotation of the bone in either local or world space
  15885. * @param space The space that the rotation should be in
  15886. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15887. * @returns The quaternion rotation
  15888. */
  15889. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15890. /**
  15891. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15892. * @param space The space that the rotation should be in
  15893. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15894. * @param result The quaternion that the rotation should be copied to
  15895. */
  15896. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15897. /**
  15898. * Get the rotation matrix of the bone in local or world space
  15899. * @param space The space that the rotation should be in
  15900. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15901. * @returns The rotation matrix
  15902. */
  15903. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15904. /**
  15905. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15906. * @param space The space that the rotation should be in
  15907. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15908. * @param result The quaternion that the rotation should be copied to
  15909. */
  15910. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15911. /**
  15912. * Get the world position of a point that is in the local space of the bone
  15913. * @param position The local position
  15914. * @param mesh The mesh that this bone is attached to
  15915. * @returns The world position
  15916. */
  15917. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15918. /**
  15919. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15920. * @param position The local position
  15921. * @param mesh The mesh that this bone is attached to
  15922. * @param result The vector3 that the world position should be copied to
  15923. */
  15924. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15925. /**
  15926. * Get the local position of a point that is in world space
  15927. * @param position The world position
  15928. * @param mesh The mesh that this bone is attached to
  15929. * @returns The local position
  15930. */
  15931. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15932. /**
  15933. * Get the local position of a point that is in world space and copy it to the result param
  15934. * @param position The world position
  15935. * @param mesh The mesh that this bone is attached to
  15936. * @param result The vector3 that the local position should be copied to
  15937. */
  15938. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15939. }
  15940. }
  15941. declare module "babylonjs/Animations/runtimeAnimation" {
  15942. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15943. import { Animatable } from "babylonjs/Animations/animatable";
  15944. import { Scene } from "babylonjs/scene";
  15945. /**
  15946. * Defines a runtime animation
  15947. */
  15948. export class RuntimeAnimation {
  15949. private _events;
  15950. /**
  15951. * The current frame of the runtime animation
  15952. */
  15953. private _currentFrame;
  15954. /**
  15955. * The animation used by the runtime animation
  15956. */
  15957. private _animation;
  15958. /**
  15959. * The target of the runtime animation
  15960. */
  15961. private _target;
  15962. /**
  15963. * The initiating animatable
  15964. */
  15965. private _host;
  15966. /**
  15967. * The original value of the runtime animation
  15968. */
  15969. private _originalValue;
  15970. /**
  15971. * The original blend value of the runtime animation
  15972. */
  15973. private _originalBlendValue;
  15974. /**
  15975. * The offsets cache of the runtime animation
  15976. */
  15977. private _offsetsCache;
  15978. /**
  15979. * The high limits cache of the runtime animation
  15980. */
  15981. private _highLimitsCache;
  15982. /**
  15983. * Specifies if the runtime animation has been stopped
  15984. */
  15985. private _stopped;
  15986. /**
  15987. * The blending factor of the runtime animation
  15988. */
  15989. private _blendingFactor;
  15990. /**
  15991. * The BabylonJS scene
  15992. */
  15993. private _scene;
  15994. /**
  15995. * The current value of the runtime animation
  15996. */
  15997. private _currentValue;
  15998. /** @hidden */
  15999. _animationState: _IAnimationState;
  16000. /**
  16001. * The active target of the runtime animation
  16002. */
  16003. private _activeTargets;
  16004. private _currentActiveTarget;
  16005. private _directTarget;
  16006. /**
  16007. * The target path of the runtime animation
  16008. */
  16009. private _targetPath;
  16010. /**
  16011. * The weight of the runtime animation
  16012. */
  16013. private _weight;
  16014. /**
  16015. * The ratio offset of the runtime animation
  16016. */
  16017. private _ratioOffset;
  16018. /**
  16019. * The previous delay of the runtime animation
  16020. */
  16021. private _previousDelay;
  16022. /**
  16023. * The previous ratio of the runtime animation
  16024. */
  16025. private _previousRatio;
  16026. private _enableBlending;
  16027. private _keys;
  16028. private _minFrame;
  16029. private _maxFrame;
  16030. private _minValue;
  16031. private _maxValue;
  16032. private _targetIsArray;
  16033. /**
  16034. * Gets the current frame of the runtime animation
  16035. */
  16036. get currentFrame(): number;
  16037. /**
  16038. * Gets the weight of the runtime animation
  16039. */
  16040. get weight(): number;
  16041. /**
  16042. * Gets the current value of the runtime animation
  16043. */
  16044. get currentValue(): any;
  16045. /**
  16046. * Gets the target path of the runtime animation
  16047. */
  16048. get targetPath(): string;
  16049. /**
  16050. * Gets the actual target of the runtime animation
  16051. */
  16052. get target(): any;
  16053. /**
  16054. * Gets the additive state of the runtime animation
  16055. */
  16056. get isAdditive(): boolean;
  16057. /** @hidden */
  16058. _onLoop: () => void;
  16059. /**
  16060. * Create a new RuntimeAnimation object
  16061. * @param target defines the target of the animation
  16062. * @param animation defines the source animation object
  16063. * @param scene defines the hosting scene
  16064. * @param host defines the initiating Animatable
  16065. */
  16066. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16067. private _preparePath;
  16068. /**
  16069. * Gets the animation from the runtime animation
  16070. */
  16071. get animation(): Animation;
  16072. /**
  16073. * Resets the runtime animation to the beginning
  16074. * @param restoreOriginal defines whether to restore the target property to the original value
  16075. */
  16076. reset(restoreOriginal?: boolean): void;
  16077. /**
  16078. * Specifies if the runtime animation is stopped
  16079. * @returns Boolean specifying if the runtime animation is stopped
  16080. */
  16081. isStopped(): boolean;
  16082. /**
  16083. * Disposes of the runtime animation
  16084. */
  16085. dispose(): void;
  16086. /**
  16087. * Apply the interpolated value to the target
  16088. * @param currentValue defines the value computed by the animation
  16089. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16090. */
  16091. setValue(currentValue: any, weight: number): void;
  16092. private _getOriginalValues;
  16093. private _setValue;
  16094. /**
  16095. * Gets the loop pmode of the runtime animation
  16096. * @returns Loop Mode
  16097. */
  16098. private _getCorrectLoopMode;
  16099. /**
  16100. * Move the current animation to a given frame
  16101. * @param frame defines the frame to move to
  16102. */
  16103. goToFrame(frame: number): void;
  16104. /**
  16105. * @hidden Internal use only
  16106. */
  16107. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16108. /**
  16109. * Execute the current animation
  16110. * @param delay defines the delay to add to the current frame
  16111. * @param from defines the lower bound of the animation range
  16112. * @param to defines the upper bound of the animation range
  16113. * @param loop defines if the current animation must loop
  16114. * @param speedRatio defines the current speed ratio
  16115. * @param weight defines the weight of the animation (default is -1 so no weight)
  16116. * @param onLoop optional callback called when animation loops
  16117. * @returns a boolean indicating if the animation is running
  16118. */
  16119. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16120. }
  16121. }
  16122. declare module "babylonjs/Animations/animatable" {
  16123. import { Animation } from "babylonjs/Animations/animation";
  16124. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16125. import { Nullable } from "babylonjs/types";
  16126. import { Observable } from "babylonjs/Misc/observable";
  16127. import { Scene } from "babylonjs/scene";
  16128. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16129. import { Node } from "babylonjs/node";
  16130. /**
  16131. * Class used to store an actual running animation
  16132. */
  16133. export class Animatable {
  16134. /** defines the target object */
  16135. target: any;
  16136. /** defines the starting frame number (default is 0) */
  16137. fromFrame: number;
  16138. /** defines the ending frame number (default is 100) */
  16139. toFrame: number;
  16140. /** defines if the animation must loop (default is false) */
  16141. loopAnimation: boolean;
  16142. /** defines a callback to call when animation ends if it is not looping */
  16143. onAnimationEnd?: (() => void) | null | undefined;
  16144. /** defines a callback to call when animation loops */
  16145. onAnimationLoop?: (() => void) | null | undefined;
  16146. /** defines whether the animation should be evaluated additively */
  16147. isAdditive: boolean;
  16148. private _localDelayOffset;
  16149. private _pausedDelay;
  16150. private _runtimeAnimations;
  16151. private _paused;
  16152. private _scene;
  16153. private _speedRatio;
  16154. private _weight;
  16155. private _syncRoot;
  16156. /**
  16157. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16158. * This will only apply for non looping animation (default is true)
  16159. */
  16160. disposeOnEnd: boolean;
  16161. /**
  16162. * Gets a boolean indicating if the animation has started
  16163. */
  16164. animationStarted: boolean;
  16165. /**
  16166. * Observer raised when the animation ends
  16167. */
  16168. onAnimationEndObservable: Observable<Animatable>;
  16169. /**
  16170. * Observer raised when the animation loops
  16171. */
  16172. onAnimationLoopObservable: Observable<Animatable>;
  16173. /**
  16174. * Gets the root Animatable used to synchronize and normalize animations
  16175. */
  16176. get syncRoot(): Nullable<Animatable>;
  16177. /**
  16178. * Gets the current frame of the first RuntimeAnimation
  16179. * Used to synchronize Animatables
  16180. */
  16181. get masterFrame(): number;
  16182. /**
  16183. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16184. */
  16185. get weight(): number;
  16186. set weight(value: number);
  16187. /**
  16188. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16189. */
  16190. get speedRatio(): number;
  16191. set speedRatio(value: number);
  16192. /**
  16193. * Creates a new Animatable
  16194. * @param scene defines the hosting scene
  16195. * @param target defines the target object
  16196. * @param fromFrame defines the starting frame number (default is 0)
  16197. * @param toFrame defines the ending frame number (default is 100)
  16198. * @param loopAnimation defines if the animation must loop (default is false)
  16199. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16200. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16201. * @param animations defines a group of animation to add to the new Animatable
  16202. * @param onAnimationLoop defines a callback to call when animation loops
  16203. * @param isAdditive defines whether the animation should be evaluated additively
  16204. */
  16205. constructor(scene: Scene,
  16206. /** defines the target object */
  16207. target: any,
  16208. /** defines the starting frame number (default is 0) */
  16209. fromFrame?: number,
  16210. /** defines the ending frame number (default is 100) */
  16211. toFrame?: number,
  16212. /** defines if the animation must loop (default is false) */
  16213. loopAnimation?: boolean, speedRatio?: number,
  16214. /** defines a callback to call when animation ends if it is not looping */
  16215. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16216. /** defines a callback to call when animation loops */
  16217. onAnimationLoop?: (() => void) | null | undefined,
  16218. /** defines whether the animation should be evaluated additively */
  16219. isAdditive?: boolean);
  16220. /**
  16221. * Synchronize and normalize current Animatable with a source Animatable
  16222. * This is useful when using animation weights and when animations are not of the same length
  16223. * @param root defines the root Animatable to synchronize with
  16224. * @returns the current Animatable
  16225. */
  16226. syncWith(root: Animatable): Animatable;
  16227. /**
  16228. * Gets the list of runtime animations
  16229. * @returns an array of RuntimeAnimation
  16230. */
  16231. getAnimations(): RuntimeAnimation[];
  16232. /**
  16233. * Adds more animations to the current animatable
  16234. * @param target defines the target of the animations
  16235. * @param animations defines the new animations to add
  16236. */
  16237. appendAnimations(target: any, animations: Animation[]): void;
  16238. /**
  16239. * Gets the source animation for a specific property
  16240. * @param property defines the propertyu to look for
  16241. * @returns null or the source animation for the given property
  16242. */
  16243. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16244. /**
  16245. * Gets the runtime animation for a specific property
  16246. * @param property defines the propertyu to look for
  16247. * @returns null or the runtime animation for the given property
  16248. */
  16249. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16250. /**
  16251. * Resets the animatable to its original state
  16252. */
  16253. reset(): void;
  16254. /**
  16255. * Allows the animatable to blend with current running animations
  16256. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16257. * @param blendingSpeed defines the blending speed to use
  16258. */
  16259. enableBlending(blendingSpeed: number): void;
  16260. /**
  16261. * Disable animation blending
  16262. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16263. */
  16264. disableBlending(): void;
  16265. /**
  16266. * Jump directly to a given frame
  16267. * @param frame defines the frame to jump to
  16268. */
  16269. goToFrame(frame: number): void;
  16270. /**
  16271. * Pause the animation
  16272. */
  16273. pause(): void;
  16274. /**
  16275. * Restart the animation
  16276. */
  16277. restart(): void;
  16278. private _raiseOnAnimationEnd;
  16279. /**
  16280. * Stop and delete the current animation
  16281. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16282. * @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)
  16283. */
  16284. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16285. /**
  16286. * Wait asynchronously for the animation to end
  16287. * @returns a promise which will be fullfilled when the animation ends
  16288. */
  16289. waitAsync(): Promise<Animatable>;
  16290. /** @hidden */
  16291. _animate(delay: number): boolean;
  16292. }
  16293. module "babylonjs/scene" {
  16294. interface Scene {
  16295. /** @hidden */
  16296. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16297. /** @hidden */
  16298. _processLateAnimationBindingsForMatrices(holder: {
  16299. totalWeight: number;
  16300. totalAdditiveWeight: number;
  16301. animations: RuntimeAnimation[];
  16302. additiveAnimations: RuntimeAnimation[];
  16303. originalValue: Matrix;
  16304. }): any;
  16305. /** @hidden */
  16306. _processLateAnimationBindingsForQuaternions(holder: {
  16307. totalWeight: number;
  16308. totalAdditiveWeight: number;
  16309. animations: RuntimeAnimation[];
  16310. additiveAnimations: RuntimeAnimation[];
  16311. originalValue: Quaternion;
  16312. }, refQuaternion: Quaternion): Quaternion;
  16313. /** @hidden */
  16314. _processLateAnimationBindings(): void;
  16315. /**
  16316. * Will start the animation sequence of a given target
  16317. * @param target defines the target
  16318. * @param from defines from which frame should animation start
  16319. * @param to defines until which frame should animation run.
  16320. * @param weight defines the weight to apply to the animation (1.0 by default)
  16321. * @param loop defines if the animation loops
  16322. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16323. * @param onAnimationEnd defines the function to be executed when the animation ends
  16324. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16325. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16326. * @param onAnimationLoop defines the callback to call when an animation loops
  16327. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16328. * @returns the animatable object created for this animation
  16329. */
  16330. 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;
  16331. /**
  16332. * Will start the animation sequence of a given target
  16333. * @param target defines the target
  16334. * @param from defines from which frame should animation start
  16335. * @param to defines until which frame should animation run.
  16336. * @param loop defines if the animation loops
  16337. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16338. * @param onAnimationEnd defines the function to be executed when the animation ends
  16339. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16340. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16341. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16342. * @param onAnimationLoop defines the callback to call when an animation loops
  16343. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16344. * @returns the animatable object created for this animation
  16345. */
  16346. 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;
  16347. /**
  16348. * Will start the animation sequence of a given target and its hierarchy
  16349. * @param target defines the target
  16350. * @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.
  16351. * @param from defines from which frame should animation start
  16352. * @param to defines until which frame should animation run.
  16353. * @param loop defines if the animation loops
  16354. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16355. * @param onAnimationEnd defines the function to be executed when the animation ends
  16356. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16357. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16358. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16359. * @param onAnimationLoop defines the callback to call when an animation loops
  16360. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16361. * @returns the list of created animatables
  16362. */
  16363. 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[];
  16364. /**
  16365. * Begin a new animation on a given node
  16366. * @param target defines the target where the animation will take place
  16367. * @param animations defines the list of animations to start
  16368. * @param from defines the initial value
  16369. * @param to defines the final value
  16370. * @param loop defines if you want animation to loop (off by default)
  16371. * @param speedRatio defines the speed ratio to apply to all animations
  16372. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16373. * @param onAnimationLoop defines the callback to call when an animation loops
  16374. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16375. * @returns the list of created animatables
  16376. */
  16377. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16378. /**
  16379. * Begin a new animation on a given node and its hierarchy
  16380. * @param target defines the root node where the animation will take place
  16381. * @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.
  16382. * @param animations defines the list of animations to start
  16383. * @param from defines the initial value
  16384. * @param to defines the final value
  16385. * @param loop defines if you want animation to loop (off by default)
  16386. * @param speedRatio defines the speed ratio to apply to all animations
  16387. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16388. * @param onAnimationLoop defines the callback to call when an animation loops
  16389. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16390. * @returns the list of animatables created for all nodes
  16391. */
  16392. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16393. /**
  16394. * Gets the animatable associated with a specific target
  16395. * @param target defines the target of the animatable
  16396. * @returns the required animatable if found
  16397. */
  16398. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16399. /**
  16400. * Gets all animatables associated with a given target
  16401. * @param target defines the target to look animatables for
  16402. * @returns an array of Animatables
  16403. */
  16404. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16405. /**
  16406. * Stops and removes all animations that have been applied to the scene
  16407. */
  16408. stopAllAnimations(): void;
  16409. /**
  16410. * Gets the current delta time used by animation engine
  16411. */
  16412. deltaTime: number;
  16413. }
  16414. }
  16415. module "babylonjs/Bones/bone" {
  16416. interface Bone {
  16417. /**
  16418. * Copy an animation range from another bone
  16419. * @param source defines the source bone
  16420. * @param rangeName defines the range name to copy
  16421. * @param frameOffset defines the frame offset
  16422. * @param rescaleAsRequired defines if rescaling must be applied if required
  16423. * @param skelDimensionsRatio defines the scaling ratio
  16424. * @returns true if operation was successful
  16425. */
  16426. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16427. }
  16428. }
  16429. }
  16430. declare module "babylonjs/Bones/skeleton" {
  16431. import { Bone } from "babylonjs/Bones/bone";
  16432. import { Observable } from "babylonjs/Misc/observable";
  16433. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16434. import { Scene } from "babylonjs/scene";
  16435. import { Nullable } from "babylonjs/types";
  16436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16437. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16438. import { Animatable } from "babylonjs/Animations/animatable";
  16439. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16440. import { Animation } from "babylonjs/Animations/animation";
  16441. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16442. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16443. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16444. /**
  16445. * Class used to handle skinning animations
  16446. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16447. */
  16448. export class Skeleton implements IAnimatable {
  16449. /** defines the skeleton name */
  16450. name: string;
  16451. /** defines the skeleton Id */
  16452. id: string;
  16453. /**
  16454. * Defines the list of child bones
  16455. */
  16456. bones: Bone[];
  16457. /**
  16458. * Defines an estimate of the dimension of the skeleton at rest
  16459. */
  16460. dimensionsAtRest: Vector3;
  16461. /**
  16462. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16463. */
  16464. needInitialSkinMatrix: boolean;
  16465. /**
  16466. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16467. */
  16468. overrideMesh: Nullable<AbstractMesh>;
  16469. /**
  16470. * Gets the list of animations attached to this skeleton
  16471. */
  16472. animations: Array<Animation>;
  16473. private _scene;
  16474. private _isDirty;
  16475. private _transformMatrices;
  16476. private _transformMatrixTexture;
  16477. private _meshesWithPoseMatrix;
  16478. private _animatables;
  16479. private _identity;
  16480. private _synchronizedWithMesh;
  16481. private _ranges;
  16482. private _lastAbsoluteTransformsUpdateId;
  16483. private _canUseTextureForBones;
  16484. private _uniqueId;
  16485. /** @hidden */
  16486. _numBonesWithLinkedTransformNode: number;
  16487. /** @hidden */
  16488. _hasWaitingData: Nullable<boolean>;
  16489. /** @hidden */
  16490. _waitingOverrideMeshId: Nullable<string>;
  16491. /**
  16492. * Specifies if the skeleton should be serialized
  16493. */
  16494. doNotSerialize: boolean;
  16495. private _useTextureToStoreBoneMatrices;
  16496. /**
  16497. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16498. * Please note that this option is not available if the hardware does not support it
  16499. */
  16500. get useTextureToStoreBoneMatrices(): boolean;
  16501. set useTextureToStoreBoneMatrices(value: boolean);
  16502. private _animationPropertiesOverride;
  16503. /**
  16504. * Gets or sets the animation properties override
  16505. */
  16506. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16507. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16508. /**
  16509. * List of inspectable custom properties (used by the Inspector)
  16510. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16511. */
  16512. inspectableCustomProperties: IInspectable[];
  16513. /**
  16514. * An observable triggered before computing the skeleton's matrices
  16515. */
  16516. onBeforeComputeObservable: Observable<Skeleton>;
  16517. /**
  16518. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16519. */
  16520. get isUsingTextureForMatrices(): boolean;
  16521. /**
  16522. * Gets the unique ID of this skeleton
  16523. */
  16524. get uniqueId(): number;
  16525. /**
  16526. * Creates a new skeleton
  16527. * @param name defines the skeleton name
  16528. * @param id defines the skeleton Id
  16529. * @param scene defines the hosting scene
  16530. */
  16531. constructor(
  16532. /** defines the skeleton name */
  16533. name: string,
  16534. /** defines the skeleton Id */
  16535. id: string, scene: Scene);
  16536. /**
  16537. * Gets the current object class name.
  16538. * @return the class name
  16539. */
  16540. getClassName(): string;
  16541. /**
  16542. * Returns an array containing the root bones
  16543. * @returns an array containing the root bones
  16544. */
  16545. getChildren(): Array<Bone>;
  16546. /**
  16547. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16548. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16549. * @returns a Float32Array containing matrices data
  16550. */
  16551. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16552. /**
  16553. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16554. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16555. * @returns a raw texture containing the data
  16556. */
  16557. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16558. /**
  16559. * Gets the current hosting scene
  16560. * @returns a scene object
  16561. */
  16562. getScene(): Scene;
  16563. /**
  16564. * Gets a string representing the current skeleton data
  16565. * @param fullDetails defines a boolean indicating if we want a verbose version
  16566. * @returns a string representing the current skeleton data
  16567. */
  16568. toString(fullDetails?: boolean): string;
  16569. /**
  16570. * Get bone's index searching by name
  16571. * @param name defines bone's name to search for
  16572. * @return the indice of the bone. Returns -1 if not found
  16573. */
  16574. getBoneIndexByName(name: string): number;
  16575. /**
  16576. * Creater a new animation range
  16577. * @param name defines the name of the range
  16578. * @param from defines the start key
  16579. * @param to defines the end key
  16580. */
  16581. createAnimationRange(name: string, from: number, to: number): void;
  16582. /**
  16583. * Delete a specific animation range
  16584. * @param name defines the name of the range
  16585. * @param deleteFrames defines if frames must be removed as well
  16586. */
  16587. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16588. /**
  16589. * Gets a specific animation range
  16590. * @param name defines the name of the range to look for
  16591. * @returns the requested animation range or null if not found
  16592. */
  16593. getAnimationRange(name: string): Nullable<AnimationRange>;
  16594. /**
  16595. * Gets the list of all animation ranges defined on this skeleton
  16596. * @returns an array
  16597. */
  16598. getAnimationRanges(): Nullable<AnimationRange>[];
  16599. /**
  16600. * Copy animation range from a source skeleton.
  16601. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16602. * @param source defines the source skeleton
  16603. * @param name defines the name of the range to copy
  16604. * @param rescaleAsRequired defines if rescaling must be applied if required
  16605. * @returns true if operation was successful
  16606. */
  16607. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16608. /**
  16609. * Forces the skeleton to go to rest pose
  16610. */
  16611. returnToRest(): void;
  16612. private _getHighestAnimationFrame;
  16613. /**
  16614. * Begin a specific animation range
  16615. * @param name defines the name of the range to start
  16616. * @param loop defines if looping must be turned on (false by default)
  16617. * @param speedRatio defines the speed ratio to apply (1 by default)
  16618. * @param onAnimationEnd defines a callback which will be called when animation will end
  16619. * @returns a new animatable
  16620. */
  16621. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16622. /**
  16623. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16624. * @param skeleton defines the Skeleton containing the animation range to convert
  16625. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16626. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16627. * @returns the original skeleton
  16628. */
  16629. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16630. /** @hidden */
  16631. _markAsDirty(): void;
  16632. /** @hidden */
  16633. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16634. /** @hidden */
  16635. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16636. private _computeTransformMatrices;
  16637. /**
  16638. * Build all resources required to render a skeleton
  16639. */
  16640. prepare(): void;
  16641. /**
  16642. * Gets the list of animatables currently running for this skeleton
  16643. * @returns an array of animatables
  16644. */
  16645. getAnimatables(): IAnimatable[];
  16646. /**
  16647. * Clone the current skeleton
  16648. * @param name defines the name of the new skeleton
  16649. * @param id defines the id of the new skeleton
  16650. * @returns the new skeleton
  16651. */
  16652. clone(name: string, id?: string): Skeleton;
  16653. /**
  16654. * Enable animation blending for this skeleton
  16655. * @param blendingSpeed defines the blending speed to apply
  16656. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16657. */
  16658. enableBlending(blendingSpeed?: number): void;
  16659. /**
  16660. * Releases all resources associated with the current skeleton
  16661. */
  16662. dispose(): void;
  16663. /**
  16664. * Serialize the skeleton in a JSON object
  16665. * @returns a JSON object
  16666. */
  16667. serialize(): any;
  16668. /**
  16669. * Creates a new skeleton from serialized data
  16670. * @param parsedSkeleton defines the serialized data
  16671. * @param scene defines the hosting scene
  16672. * @returns a new skeleton
  16673. */
  16674. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16675. /**
  16676. * Compute all node absolute transforms
  16677. * @param forceUpdate defines if computation must be done even if cache is up to date
  16678. */
  16679. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16680. /**
  16681. * Gets the root pose matrix
  16682. * @returns a matrix
  16683. */
  16684. getPoseMatrix(): Nullable<Matrix>;
  16685. /**
  16686. * Sorts bones per internal index
  16687. */
  16688. sortBones(): void;
  16689. private _sortBones;
  16690. }
  16691. }
  16692. declare module "babylonjs/Meshes/instancedMesh" {
  16693. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16694. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16695. import { Camera } from "babylonjs/Cameras/camera";
  16696. import { Node } from "babylonjs/node";
  16697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16698. import { Mesh } from "babylonjs/Meshes/mesh";
  16699. import { Material } from "babylonjs/Materials/material";
  16700. import { Skeleton } from "babylonjs/Bones/skeleton";
  16701. import { Light } from "babylonjs/Lights/light";
  16702. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16703. /**
  16704. * Creates an instance based on a source mesh.
  16705. */
  16706. export class InstancedMesh extends AbstractMesh {
  16707. private _sourceMesh;
  16708. private _currentLOD;
  16709. /** @hidden */
  16710. _indexInSourceMeshInstanceArray: number;
  16711. constructor(name: string, source: Mesh);
  16712. /**
  16713. * Returns the string "InstancedMesh".
  16714. */
  16715. getClassName(): string;
  16716. /** Gets the list of lights affecting that mesh */
  16717. get lightSources(): Light[];
  16718. _resyncLightSources(): void;
  16719. _resyncLightSource(light: Light): void;
  16720. _removeLightSource(light: Light, dispose: boolean): void;
  16721. /**
  16722. * If the source mesh receives shadows
  16723. */
  16724. get receiveShadows(): boolean;
  16725. /**
  16726. * The material of the source mesh
  16727. */
  16728. get material(): Nullable<Material>;
  16729. /**
  16730. * Visibility of the source mesh
  16731. */
  16732. get visibility(): number;
  16733. /**
  16734. * Skeleton of the source mesh
  16735. */
  16736. get skeleton(): Nullable<Skeleton>;
  16737. /**
  16738. * Rendering ground id of the source mesh
  16739. */
  16740. get renderingGroupId(): number;
  16741. set renderingGroupId(value: number);
  16742. /**
  16743. * Returns the total number of vertices (integer).
  16744. */
  16745. getTotalVertices(): number;
  16746. /**
  16747. * Returns a positive integer : the total number of indices in this mesh geometry.
  16748. * @returns the numner of indices or zero if the mesh has no geometry.
  16749. */
  16750. getTotalIndices(): number;
  16751. /**
  16752. * The source mesh of the instance
  16753. */
  16754. get sourceMesh(): Mesh;
  16755. /**
  16756. * Creates a new InstancedMesh object from the mesh model.
  16757. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16758. * @param name defines the name of the new instance
  16759. * @returns a new InstancedMesh
  16760. */
  16761. createInstance(name: string): InstancedMesh;
  16762. /**
  16763. * Is this node ready to be used/rendered
  16764. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16765. * @return {boolean} is it ready
  16766. */
  16767. isReady(completeCheck?: boolean): boolean;
  16768. /**
  16769. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16770. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16771. * @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.
  16772. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16773. */
  16774. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16775. /**
  16776. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16777. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16778. * The `data` are either a numeric array either a Float32Array.
  16779. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16780. * 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).
  16781. * Note that a new underlying VertexBuffer object is created each call.
  16782. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16783. *
  16784. * Possible `kind` values :
  16785. * - VertexBuffer.PositionKind
  16786. * - VertexBuffer.UVKind
  16787. * - VertexBuffer.UV2Kind
  16788. * - VertexBuffer.UV3Kind
  16789. * - VertexBuffer.UV4Kind
  16790. * - VertexBuffer.UV5Kind
  16791. * - VertexBuffer.UV6Kind
  16792. * - VertexBuffer.ColorKind
  16793. * - VertexBuffer.MatricesIndicesKind
  16794. * - VertexBuffer.MatricesIndicesExtraKind
  16795. * - VertexBuffer.MatricesWeightsKind
  16796. * - VertexBuffer.MatricesWeightsExtraKind
  16797. *
  16798. * Returns the Mesh.
  16799. */
  16800. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16801. /**
  16802. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16803. * If the mesh has no geometry, it is simply returned as it is.
  16804. * The `data` are either a numeric array either a Float32Array.
  16805. * No new underlying VertexBuffer object is created.
  16806. * 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.
  16807. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16808. *
  16809. * Possible `kind` values :
  16810. * - VertexBuffer.PositionKind
  16811. * - VertexBuffer.UVKind
  16812. * - VertexBuffer.UV2Kind
  16813. * - VertexBuffer.UV3Kind
  16814. * - VertexBuffer.UV4Kind
  16815. * - VertexBuffer.UV5Kind
  16816. * - VertexBuffer.UV6Kind
  16817. * - VertexBuffer.ColorKind
  16818. * - VertexBuffer.MatricesIndicesKind
  16819. * - VertexBuffer.MatricesIndicesExtraKind
  16820. * - VertexBuffer.MatricesWeightsKind
  16821. * - VertexBuffer.MatricesWeightsExtraKind
  16822. *
  16823. * Returns the Mesh.
  16824. */
  16825. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16826. /**
  16827. * Sets the mesh indices.
  16828. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16829. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16830. * This method creates a new index buffer each call.
  16831. * Returns the Mesh.
  16832. */
  16833. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16834. /**
  16835. * Boolean : True if the mesh owns the requested kind of data.
  16836. */
  16837. isVerticesDataPresent(kind: string): boolean;
  16838. /**
  16839. * Returns an array of indices (IndicesArray).
  16840. */
  16841. getIndices(): Nullable<IndicesArray>;
  16842. get _positions(): Nullable<Vector3[]>;
  16843. /**
  16844. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16845. * This means the mesh underlying bounding box and sphere are recomputed.
  16846. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16847. * @returns the current mesh
  16848. */
  16849. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16850. /** @hidden */
  16851. _preActivate(): InstancedMesh;
  16852. /** @hidden */
  16853. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16854. /** @hidden */
  16855. _postActivate(): void;
  16856. getWorldMatrix(): Matrix;
  16857. get isAnInstance(): boolean;
  16858. /**
  16859. * Returns the current associated LOD AbstractMesh.
  16860. */
  16861. getLOD(camera: Camera): AbstractMesh;
  16862. /** @hidden */
  16863. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16864. /** @hidden */
  16865. _syncSubMeshes(): InstancedMesh;
  16866. /** @hidden */
  16867. _generatePointsArray(): boolean;
  16868. /** @hidden */
  16869. _updateBoundingInfo(): AbstractMesh;
  16870. /**
  16871. * Creates a new InstancedMesh from the current mesh.
  16872. * - name (string) : the cloned mesh name
  16873. * - newParent (optional Node) : the optional Node to parent the clone to.
  16874. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16875. *
  16876. * Returns the clone.
  16877. */
  16878. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16879. /**
  16880. * Disposes the InstancedMesh.
  16881. * Returns nothing.
  16882. */
  16883. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16884. }
  16885. module "babylonjs/Meshes/mesh" {
  16886. interface Mesh {
  16887. /**
  16888. * Register a custom buffer that will be instanced
  16889. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16890. * @param kind defines the buffer kind
  16891. * @param stride defines the stride in floats
  16892. */
  16893. registerInstancedBuffer(kind: string, stride: number): void;
  16894. /**
  16895. * true to use the edge renderer for all instances of this mesh
  16896. */
  16897. edgesShareWithInstances: boolean;
  16898. /** @hidden */
  16899. _userInstancedBuffersStorage: {
  16900. data: {
  16901. [key: string]: Float32Array;
  16902. };
  16903. sizes: {
  16904. [key: string]: number;
  16905. };
  16906. vertexBuffers: {
  16907. [key: string]: Nullable<VertexBuffer>;
  16908. };
  16909. strides: {
  16910. [key: string]: number;
  16911. };
  16912. };
  16913. }
  16914. }
  16915. module "babylonjs/Meshes/abstractMesh" {
  16916. interface AbstractMesh {
  16917. /**
  16918. * Object used to store instanced buffers defined by user
  16919. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16920. */
  16921. instancedBuffers: {
  16922. [key: string]: any;
  16923. };
  16924. }
  16925. }
  16926. }
  16927. declare module "babylonjs/Materials/shaderMaterial" {
  16928. import { Nullable } from "babylonjs/types";
  16929. import { Scene } from "babylonjs/scene";
  16930. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16932. import { Mesh } from "babylonjs/Meshes/mesh";
  16933. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16934. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16935. import { Effect } from "babylonjs/Materials/effect";
  16936. import { Material } from "babylonjs/Materials/material";
  16937. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16938. /**
  16939. * Defines the options associated with the creation of a shader material.
  16940. */
  16941. export interface IShaderMaterialOptions {
  16942. /**
  16943. * Does the material work in alpha blend mode
  16944. */
  16945. needAlphaBlending: boolean;
  16946. /**
  16947. * Does the material work in alpha test mode
  16948. */
  16949. needAlphaTesting: boolean;
  16950. /**
  16951. * The list of attribute names used in the shader
  16952. */
  16953. attributes: string[];
  16954. /**
  16955. * The list of unifrom names used in the shader
  16956. */
  16957. uniforms: string[];
  16958. /**
  16959. * The list of UBO names used in the shader
  16960. */
  16961. uniformBuffers: string[];
  16962. /**
  16963. * The list of sampler names used in the shader
  16964. */
  16965. samplers: string[];
  16966. /**
  16967. * The list of defines used in the shader
  16968. */
  16969. defines: string[];
  16970. }
  16971. /**
  16972. * 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.
  16973. *
  16974. * This returned material effects how the mesh will look based on the code in the shaders.
  16975. *
  16976. * @see https://doc.babylonjs.com/how_to/shader_material
  16977. */
  16978. export class ShaderMaterial extends Material {
  16979. private _shaderPath;
  16980. private _options;
  16981. private _textures;
  16982. private _textureArrays;
  16983. private _floats;
  16984. private _ints;
  16985. private _floatsArrays;
  16986. private _colors3;
  16987. private _colors3Arrays;
  16988. private _colors4;
  16989. private _colors4Arrays;
  16990. private _vectors2;
  16991. private _vectors3;
  16992. private _vectors4;
  16993. private _matrices;
  16994. private _matrixArrays;
  16995. private _matrices3x3;
  16996. private _matrices2x2;
  16997. private _vectors2Arrays;
  16998. private _vectors3Arrays;
  16999. private _vectors4Arrays;
  17000. private _cachedWorldViewMatrix;
  17001. private _cachedWorldViewProjectionMatrix;
  17002. private _renderId;
  17003. private _multiview;
  17004. private _cachedDefines;
  17005. /** Define the Url to load snippets */
  17006. static SnippetUrl: string;
  17007. /** Snippet ID if the material was created from the snippet server */
  17008. snippetId: string;
  17009. /**
  17010. * Instantiate a new shader material.
  17011. * 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.
  17012. * This returned material effects how the mesh will look based on the code in the shaders.
  17013. * @see https://doc.babylonjs.com/how_to/shader_material
  17014. * @param name Define the name of the material in the scene
  17015. * @param scene Define the scene the material belongs to
  17016. * @param shaderPath Defines the route to the shader code in one of three ways:
  17017. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17018. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17019. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17020. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17021. * @param options Define the options used to create the shader
  17022. */
  17023. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17024. /**
  17025. * Gets the shader path used to define the shader code
  17026. * It can be modified to trigger a new compilation
  17027. */
  17028. get shaderPath(): any;
  17029. /**
  17030. * Sets the shader path used to define the shader code
  17031. * It can be modified to trigger a new compilation
  17032. */
  17033. set shaderPath(shaderPath: any);
  17034. /**
  17035. * Gets the options used to compile the shader.
  17036. * They can be modified to trigger a new compilation
  17037. */
  17038. get options(): IShaderMaterialOptions;
  17039. /**
  17040. * Gets the current class name of the material e.g. "ShaderMaterial"
  17041. * Mainly use in serialization.
  17042. * @returns the class name
  17043. */
  17044. getClassName(): string;
  17045. /**
  17046. * Specifies if the material will require alpha blending
  17047. * @returns a boolean specifying if alpha blending is needed
  17048. */
  17049. needAlphaBlending(): boolean;
  17050. /**
  17051. * Specifies if this material should be rendered in alpha test mode
  17052. * @returns a boolean specifying if an alpha test is needed.
  17053. */
  17054. needAlphaTesting(): boolean;
  17055. private _checkUniform;
  17056. /**
  17057. * Set a texture in the shader.
  17058. * @param name Define the name of the uniform samplers as defined in the shader
  17059. * @param texture Define the texture to bind to this sampler
  17060. * @return the material itself allowing "fluent" like uniform updates
  17061. */
  17062. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17063. /**
  17064. * Set a texture array in the shader.
  17065. * @param name Define the name of the uniform sampler array as defined in the shader
  17066. * @param textures Define the list of textures to bind to this sampler
  17067. * @return the material itself allowing "fluent" like uniform updates
  17068. */
  17069. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17070. /**
  17071. * Set a float in the shader.
  17072. * @param name Define the name of the uniform as defined in the shader
  17073. * @param value Define the value to give to the uniform
  17074. * @return the material itself allowing "fluent" like uniform updates
  17075. */
  17076. setFloat(name: string, value: number): ShaderMaterial;
  17077. /**
  17078. * Set a int in the shader.
  17079. * @param name Define the name of the uniform as defined in the shader
  17080. * @param value Define the value to give to the uniform
  17081. * @return the material itself allowing "fluent" like uniform updates
  17082. */
  17083. setInt(name: string, value: number): ShaderMaterial;
  17084. /**
  17085. * Set an array of floats in the shader.
  17086. * @param name Define the name of the uniform as defined in the shader
  17087. * @param value Define the value to give to the uniform
  17088. * @return the material itself allowing "fluent" like uniform updates
  17089. */
  17090. setFloats(name: string, value: number[]): ShaderMaterial;
  17091. /**
  17092. * Set a vec3 in the shader from a Color3.
  17093. * @param name Define the name of the uniform as defined in the shader
  17094. * @param value Define the value to give to the uniform
  17095. * @return the material itself allowing "fluent" like uniform updates
  17096. */
  17097. setColor3(name: string, value: Color3): ShaderMaterial;
  17098. /**
  17099. * Set a vec3 array in the shader from a Color3 array.
  17100. * @param name Define the name of the uniform as defined in the shader
  17101. * @param value Define the value to give to the uniform
  17102. * @return the material itself allowing "fluent" like uniform updates
  17103. */
  17104. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17105. /**
  17106. * Set a vec4 in the shader from a Color4.
  17107. * @param name Define the name of the uniform as defined in the shader
  17108. * @param value Define the value to give to the uniform
  17109. * @return the material itself allowing "fluent" like uniform updates
  17110. */
  17111. setColor4(name: string, value: Color4): ShaderMaterial;
  17112. /**
  17113. * Set a vec4 array in the shader from a Color4 array.
  17114. * @param name Define the name of the uniform as defined in the shader
  17115. * @param value Define the value to give to the uniform
  17116. * @return the material itself allowing "fluent" like uniform updates
  17117. */
  17118. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17119. /**
  17120. * Set a vec2 in the shader from a Vector2.
  17121. * @param name Define the name of the uniform as defined in the shader
  17122. * @param value Define the value to give to the uniform
  17123. * @return the material itself allowing "fluent" like uniform updates
  17124. */
  17125. setVector2(name: string, value: Vector2): ShaderMaterial;
  17126. /**
  17127. * Set a vec3 in the shader from a Vector3.
  17128. * @param name Define the name of the uniform as defined in the shader
  17129. * @param value Define the value to give to the uniform
  17130. * @return the material itself allowing "fluent" like uniform updates
  17131. */
  17132. setVector3(name: string, value: Vector3): ShaderMaterial;
  17133. /**
  17134. * Set a vec4 in the shader from a Vector4.
  17135. * @param name Define the name of the uniform as defined in the shader
  17136. * @param value Define the value to give to the uniform
  17137. * @return the material itself allowing "fluent" like uniform updates
  17138. */
  17139. setVector4(name: string, value: Vector4): ShaderMaterial;
  17140. /**
  17141. * Set a mat4 in the shader from a Matrix.
  17142. * @param name Define the name of the uniform as defined in the shader
  17143. * @param value Define the value to give to the uniform
  17144. * @return the material itself allowing "fluent" like uniform updates
  17145. */
  17146. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17147. /**
  17148. * Set a float32Array in the shader from a matrix array.
  17149. * @param name Define the name of the uniform as defined in the shader
  17150. * @param value Define the value to give to the uniform
  17151. * @return the material itself allowing "fluent" like uniform updates
  17152. */
  17153. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17154. /**
  17155. * Set a mat3 in the shader from a Float32Array.
  17156. * @param name Define the name of the uniform as defined in the shader
  17157. * @param value Define the value to give to the uniform
  17158. * @return the material itself allowing "fluent" like uniform updates
  17159. */
  17160. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17161. /**
  17162. * Set a mat2 in the shader from a Float32Array.
  17163. * @param name Define the name of the uniform as defined in the shader
  17164. * @param value Define the value to give to the uniform
  17165. * @return the material itself allowing "fluent" like uniform updates
  17166. */
  17167. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17168. /**
  17169. * Set a vec2 array in the shader from a number array.
  17170. * @param name Define the name of the uniform as defined in the shader
  17171. * @param value Define the value to give to the uniform
  17172. * @return the material itself allowing "fluent" like uniform updates
  17173. */
  17174. setArray2(name: string, value: number[]): ShaderMaterial;
  17175. /**
  17176. * Set a vec3 array in the shader from a number array.
  17177. * @param name Define the name of the uniform as defined in the shader
  17178. * @param value Define the value to give to the uniform
  17179. * @return the material itself allowing "fluent" like uniform updates
  17180. */
  17181. setArray3(name: string, value: number[]): ShaderMaterial;
  17182. /**
  17183. * Set a vec4 array in the shader from a number array.
  17184. * @param name Define the name of the uniform as defined in the shader
  17185. * @param value Define the value to give to the uniform
  17186. * @return the material itself allowing "fluent" like uniform updates
  17187. */
  17188. setArray4(name: string, value: number[]): ShaderMaterial;
  17189. private _checkCache;
  17190. /**
  17191. * Specifies that the submesh is ready to be used
  17192. * @param mesh defines the mesh to check
  17193. * @param subMesh defines which submesh to check
  17194. * @param useInstances specifies that instances should be used
  17195. * @returns a boolean indicating that the submesh is ready or not
  17196. */
  17197. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17198. /**
  17199. * Checks if the material is ready to render the requested mesh
  17200. * @param mesh Define the mesh to render
  17201. * @param useInstances Define whether or not the material is used with instances
  17202. * @returns true if ready, otherwise false
  17203. */
  17204. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17205. /**
  17206. * Binds the world matrix to the material
  17207. * @param world defines the world transformation matrix
  17208. * @param effectOverride - If provided, use this effect instead of internal effect
  17209. */
  17210. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17211. /**
  17212. * Binds the submesh to this material by preparing the effect and shader to draw
  17213. * @param world defines the world transformation matrix
  17214. * @param mesh defines the mesh containing the submesh
  17215. * @param subMesh defines the submesh to bind the material to
  17216. */
  17217. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17218. /**
  17219. * Binds the material to the mesh
  17220. * @param world defines the world transformation matrix
  17221. * @param mesh defines the mesh to bind the material to
  17222. * @param effectOverride - If provided, use this effect instead of internal effect
  17223. */
  17224. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17225. protected _afterBind(mesh?: Mesh): void;
  17226. /**
  17227. * Gets the active textures from the material
  17228. * @returns an array of textures
  17229. */
  17230. getActiveTextures(): BaseTexture[];
  17231. /**
  17232. * Specifies if the material uses a texture
  17233. * @param texture defines the texture to check against the material
  17234. * @returns a boolean specifying if the material uses the texture
  17235. */
  17236. hasTexture(texture: BaseTexture): boolean;
  17237. /**
  17238. * Makes a duplicate of the material, and gives it a new name
  17239. * @param name defines the new name for the duplicated material
  17240. * @returns the cloned material
  17241. */
  17242. clone(name: string): ShaderMaterial;
  17243. /**
  17244. * Disposes the material
  17245. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17246. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17247. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17248. */
  17249. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17250. /**
  17251. * Serializes this material in a JSON representation
  17252. * @returns the serialized material object
  17253. */
  17254. serialize(): any;
  17255. /**
  17256. * Creates a shader material from parsed shader material data
  17257. * @param source defines the JSON represnetation of the material
  17258. * @param scene defines the hosting scene
  17259. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17260. * @returns a new material
  17261. */
  17262. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17263. /**
  17264. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17265. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17266. * @param url defines the url to load from
  17267. * @param scene defines the hosting scene
  17268. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17269. * @returns a promise that will resolve to the new ShaderMaterial
  17270. */
  17271. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17272. /**
  17273. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17274. * @param snippetId defines the snippet to load
  17275. * @param scene defines the hosting scene
  17276. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17277. * @returns a promise that will resolve to the new ShaderMaterial
  17278. */
  17279. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17280. }
  17281. }
  17282. declare module "babylonjs/Shaders/color.fragment" {
  17283. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17284. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17285. /** @hidden */
  17286. export var colorPixelShader: {
  17287. name: string;
  17288. shader: string;
  17289. };
  17290. }
  17291. declare module "babylonjs/Shaders/color.vertex" {
  17292. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17293. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17294. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17295. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17296. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17297. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17298. /** @hidden */
  17299. export var colorVertexShader: {
  17300. name: string;
  17301. shader: string;
  17302. };
  17303. }
  17304. declare module "babylonjs/Meshes/linesMesh" {
  17305. import { Nullable } from "babylonjs/types";
  17306. import { Scene } from "babylonjs/scene";
  17307. import { Color3 } from "babylonjs/Maths/math.color";
  17308. import { Node } from "babylonjs/node";
  17309. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17310. import { Mesh } from "babylonjs/Meshes/mesh";
  17311. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17312. import { Effect } from "babylonjs/Materials/effect";
  17313. import { Material } from "babylonjs/Materials/material";
  17314. import "babylonjs/Shaders/color.fragment";
  17315. import "babylonjs/Shaders/color.vertex";
  17316. /**
  17317. * Line mesh
  17318. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17319. */
  17320. export class LinesMesh extends Mesh {
  17321. /**
  17322. * If vertex color should be applied to the mesh
  17323. */
  17324. readonly useVertexColor?: boolean | undefined;
  17325. /**
  17326. * If vertex alpha should be applied to the mesh
  17327. */
  17328. readonly useVertexAlpha?: boolean | undefined;
  17329. /**
  17330. * Color of the line (Default: White)
  17331. */
  17332. color: Color3;
  17333. /**
  17334. * Alpha of the line (Default: 1)
  17335. */
  17336. alpha: number;
  17337. /**
  17338. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17339. * This margin is expressed in world space coordinates, so its value may vary.
  17340. * Default value is 0.1
  17341. */
  17342. intersectionThreshold: number;
  17343. private _colorShader;
  17344. private color4;
  17345. /**
  17346. * Creates a new LinesMesh
  17347. * @param name defines the name
  17348. * @param scene defines the hosting scene
  17349. * @param parent defines the parent mesh if any
  17350. * @param source defines the optional source LinesMesh used to clone data from
  17351. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17352. * When false, achieved by calling a clone(), also passing False.
  17353. * This will make creation of children, recursive.
  17354. * @param useVertexColor defines if this LinesMesh supports vertex color
  17355. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17356. */
  17357. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17358. /**
  17359. * If vertex color should be applied to the mesh
  17360. */
  17361. useVertexColor?: boolean | undefined,
  17362. /**
  17363. * If vertex alpha should be applied to the mesh
  17364. */
  17365. useVertexAlpha?: boolean | undefined);
  17366. private _addClipPlaneDefine;
  17367. private _removeClipPlaneDefine;
  17368. isReady(): boolean;
  17369. /**
  17370. * Returns the string "LineMesh"
  17371. */
  17372. getClassName(): string;
  17373. /**
  17374. * @hidden
  17375. */
  17376. get material(): Material;
  17377. /**
  17378. * @hidden
  17379. */
  17380. set material(value: Material);
  17381. /**
  17382. * @hidden
  17383. */
  17384. get checkCollisions(): boolean;
  17385. /** @hidden */
  17386. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17387. /** @hidden */
  17388. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17389. /**
  17390. * Disposes of the line mesh
  17391. * @param doNotRecurse If children should be disposed
  17392. */
  17393. dispose(doNotRecurse?: boolean): void;
  17394. /**
  17395. * Returns a new LineMesh object cloned from the current one.
  17396. */
  17397. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17398. /**
  17399. * Creates a new InstancedLinesMesh object from the mesh model.
  17400. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17401. * @param name defines the name of the new instance
  17402. * @returns a new InstancedLinesMesh
  17403. */
  17404. createInstance(name: string): InstancedLinesMesh;
  17405. }
  17406. /**
  17407. * Creates an instance based on a source LinesMesh
  17408. */
  17409. export class InstancedLinesMesh extends InstancedMesh {
  17410. /**
  17411. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17412. * This margin is expressed in world space coordinates, so its value may vary.
  17413. * Initilized with the intersectionThreshold value of the source LinesMesh
  17414. */
  17415. intersectionThreshold: number;
  17416. constructor(name: string, source: LinesMesh);
  17417. /**
  17418. * Returns the string "InstancedLinesMesh".
  17419. */
  17420. getClassName(): string;
  17421. }
  17422. }
  17423. declare module "babylonjs/Shaders/line.fragment" {
  17424. /** @hidden */
  17425. export var linePixelShader: {
  17426. name: string;
  17427. shader: string;
  17428. };
  17429. }
  17430. declare module "babylonjs/Shaders/line.vertex" {
  17431. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17432. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17433. /** @hidden */
  17434. export var lineVertexShader: {
  17435. name: string;
  17436. shader: string;
  17437. };
  17438. }
  17439. declare module "babylonjs/Rendering/edgesRenderer" {
  17440. import { Nullable } from "babylonjs/types";
  17441. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17443. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17444. import { IDisposable } from "babylonjs/scene";
  17445. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17446. import "babylonjs/Shaders/line.fragment";
  17447. import "babylonjs/Shaders/line.vertex";
  17448. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17449. import { SmartArray } from "babylonjs/Misc/smartArray";
  17450. module "babylonjs/scene" {
  17451. interface Scene {
  17452. /** @hidden */
  17453. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17454. }
  17455. }
  17456. module "babylonjs/Meshes/abstractMesh" {
  17457. interface AbstractMesh {
  17458. /**
  17459. * Gets the edgesRenderer associated with the mesh
  17460. */
  17461. edgesRenderer: Nullable<EdgesRenderer>;
  17462. }
  17463. }
  17464. module "babylonjs/Meshes/linesMesh" {
  17465. interface LinesMesh {
  17466. /**
  17467. * Enables the edge rendering mode on the mesh.
  17468. * This mode makes the mesh edges visible
  17469. * @param epsilon defines the maximal distance between two angles to detect a face
  17470. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17471. * @returns the currentAbstractMesh
  17472. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17473. */
  17474. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17475. }
  17476. }
  17477. module "babylonjs/Meshes/linesMesh" {
  17478. interface InstancedLinesMesh {
  17479. /**
  17480. * Enables the edge rendering mode on the mesh.
  17481. * This mode makes the mesh edges visible
  17482. * @param epsilon defines the maximal distance between two angles to detect a face
  17483. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17484. * @returns the current InstancedLinesMesh
  17485. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17486. */
  17487. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17488. }
  17489. }
  17490. /**
  17491. * Defines the minimum contract an Edges renderer should follow.
  17492. */
  17493. export interface IEdgesRenderer extends IDisposable {
  17494. /**
  17495. * Gets or sets a boolean indicating if the edgesRenderer is active
  17496. */
  17497. isEnabled: boolean;
  17498. /**
  17499. * Renders the edges of the attached mesh,
  17500. */
  17501. render(): void;
  17502. /**
  17503. * Checks wether or not the edges renderer is ready to render.
  17504. * @return true if ready, otherwise false.
  17505. */
  17506. isReady(): boolean;
  17507. /**
  17508. * List of instances to render in case the source mesh has instances
  17509. */
  17510. customInstances: SmartArray<Matrix>;
  17511. }
  17512. /**
  17513. * Defines the additional options of the edges renderer
  17514. */
  17515. export interface IEdgesRendererOptions {
  17516. /**
  17517. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17518. * If not defined, the default value is true
  17519. */
  17520. useAlternateEdgeFinder?: boolean;
  17521. /**
  17522. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17523. * If not defined, the default value is true.
  17524. * 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)
  17525. * This option is used only if useAlternateEdgeFinder = true
  17526. */
  17527. useFastVertexMerger?: boolean;
  17528. /**
  17529. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17530. * The default value is 1e-6
  17531. * This option is used only if useAlternateEdgeFinder = true
  17532. */
  17533. epsilonVertexMerge?: number;
  17534. /**
  17535. * 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
  17536. * 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.
  17537. * This option is used only if useAlternateEdgeFinder = true
  17538. */
  17539. applyTessellation?: boolean;
  17540. /**
  17541. * 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
  17542. * The default value is 1e-6
  17543. * This option is used only if useAlternateEdgeFinder = true
  17544. */
  17545. epsilonVertexAligned?: number;
  17546. }
  17547. /**
  17548. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17549. */
  17550. export class EdgesRenderer implements IEdgesRenderer {
  17551. /**
  17552. * Define the size of the edges with an orthographic camera
  17553. */
  17554. edgesWidthScalerForOrthographic: number;
  17555. /**
  17556. * Define the size of the edges with a perspective camera
  17557. */
  17558. edgesWidthScalerForPerspective: number;
  17559. protected _source: AbstractMesh;
  17560. protected _linesPositions: number[];
  17561. protected _linesNormals: number[];
  17562. protected _linesIndices: number[];
  17563. protected _epsilon: number;
  17564. protected _indicesCount: number;
  17565. protected _lineShader: ShaderMaterial;
  17566. protected _ib: DataBuffer;
  17567. protected _buffers: {
  17568. [key: string]: Nullable<VertexBuffer>;
  17569. };
  17570. protected _buffersForInstances: {
  17571. [key: string]: Nullable<VertexBuffer>;
  17572. };
  17573. protected _checkVerticesInsteadOfIndices: boolean;
  17574. protected _options: Nullable<IEdgesRendererOptions>;
  17575. private _meshRebuildObserver;
  17576. private _meshDisposeObserver;
  17577. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17578. isEnabled: boolean;
  17579. /**
  17580. * List of instances to render in case the source mesh has instances
  17581. */
  17582. customInstances: SmartArray<Matrix>;
  17583. private static GetShader;
  17584. /**
  17585. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17586. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17587. * @param source Mesh used to create edges
  17588. * @param epsilon sum of angles in adjacency to check for edge
  17589. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17590. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17591. * @param options The options to apply when generating the edges
  17592. */
  17593. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17594. protected _prepareRessources(): void;
  17595. /** @hidden */
  17596. _rebuild(): void;
  17597. /**
  17598. * Releases the required resources for the edges renderer
  17599. */
  17600. dispose(): void;
  17601. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17602. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17603. /**
  17604. * Checks if the pair of p0 and p1 is en edge
  17605. * @param faceIndex
  17606. * @param edge
  17607. * @param faceNormals
  17608. * @param p0
  17609. * @param p1
  17610. * @private
  17611. */
  17612. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17613. /**
  17614. * push line into the position, normal and index buffer
  17615. * @protected
  17616. */
  17617. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17618. /**
  17619. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17620. */
  17621. private _tessellateTriangle;
  17622. private _generateEdgesLinesAlternate;
  17623. /**
  17624. * Generates lines edges from adjacencjes
  17625. * @private
  17626. */
  17627. _generateEdgesLines(): void;
  17628. /**
  17629. * Checks wether or not the edges renderer is ready to render.
  17630. * @return true if ready, otherwise false.
  17631. */
  17632. isReady(): boolean;
  17633. /**
  17634. * Renders the edges of the attached mesh,
  17635. */
  17636. render(): void;
  17637. }
  17638. /**
  17639. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17640. */
  17641. export class LineEdgesRenderer extends EdgesRenderer {
  17642. /**
  17643. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17644. * @param source LineMesh used to generate edges
  17645. * @param epsilon not important (specified angle for edge detection)
  17646. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17647. */
  17648. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17649. /**
  17650. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17651. */
  17652. _generateEdgesLines(): void;
  17653. }
  17654. }
  17655. declare module "babylonjs/Rendering/renderingGroup" {
  17656. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17657. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17659. import { Nullable } from "babylonjs/types";
  17660. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17661. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17662. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17663. import { Material } from "babylonjs/Materials/material";
  17664. import { Scene } from "babylonjs/scene";
  17665. /**
  17666. * This represents the object necessary to create a rendering group.
  17667. * This is exclusively used and created by the rendering manager.
  17668. * To modify the behavior, you use the available helpers in your scene or meshes.
  17669. * @hidden
  17670. */
  17671. export class RenderingGroup {
  17672. index: number;
  17673. private static _zeroVector;
  17674. private _scene;
  17675. private _opaqueSubMeshes;
  17676. private _transparentSubMeshes;
  17677. private _alphaTestSubMeshes;
  17678. private _depthOnlySubMeshes;
  17679. private _particleSystems;
  17680. private _spriteManagers;
  17681. private _opaqueSortCompareFn;
  17682. private _alphaTestSortCompareFn;
  17683. private _transparentSortCompareFn;
  17684. private _renderOpaque;
  17685. private _renderAlphaTest;
  17686. private _renderTransparent;
  17687. /** @hidden */
  17688. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17689. onBeforeTransparentRendering: () => void;
  17690. /**
  17691. * Set the opaque sort comparison function.
  17692. * If null the sub meshes will be render in the order they were created
  17693. */
  17694. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17695. /**
  17696. * Set the alpha test sort comparison function.
  17697. * If null the sub meshes will be render in the order they were created
  17698. */
  17699. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17700. /**
  17701. * Set the transparent sort comparison function.
  17702. * If null the sub meshes will be render in the order they were created
  17703. */
  17704. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17705. /**
  17706. * Creates a new rendering group.
  17707. * @param index The rendering group index
  17708. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17709. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17710. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17711. */
  17712. 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>);
  17713. /**
  17714. * Render all the sub meshes contained in the group.
  17715. * @param customRenderFunction Used to override the default render behaviour of the group.
  17716. * @returns true if rendered some submeshes.
  17717. */
  17718. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17719. /**
  17720. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17721. * @param subMeshes The submeshes to render
  17722. */
  17723. private renderOpaqueSorted;
  17724. /**
  17725. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17726. * @param subMeshes The submeshes to render
  17727. */
  17728. private renderAlphaTestSorted;
  17729. /**
  17730. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17731. * @param subMeshes The submeshes to render
  17732. */
  17733. private renderTransparentSorted;
  17734. /**
  17735. * Renders the submeshes in a specified order.
  17736. * @param subMeshes The submeshes to sort before render
  17737. * @param sortCompareFn The comparison function use to sort
  17738. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17739. * @param transparent Specifies to activate blending if true
  17740. */
  17741. private static renderSorted;
  17742. /**
  17743. * Renders the submeshes in the order they were dispatched (no sort applied).
  17744. * @param subMeshes The submeshes to render
  17745. */
  17746. private static renderUnsorted;
  17747. /**
  17748. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17749. * are rendered back to front if in the same alpha index.
  17750. *
  17751. * @param a The first submesh
  17752. * @param b The second submesh
  17753. * @returns The result of the comparison
  17754. */
  17755. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17756. /**
  17757. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17758. * are rendered back to front.
  17759. *
  17760. * @param a The first submesh
  17761. * @param b The second submesh
  17762. * @returns The result of the comparison
  17763. */
  17764. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17765. /**
  17766. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17767. * are rendered front to back (prevent overdraw).
  17768. *
  17769. * @param a The first submesh
  17770. * @param b The second submesh
  17771. * @returns The result of the comparison
  17772. */
  17773. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17774. /**
  17775. * Resets the different lists of submeshes to prepare a new frame.
  17776. */
  17777. prepare(): void;
  17778. dispose(): void;
  17779. /**
  17780. * Inserts the submesh in its correct queue depending on its material.
  17781. * @param subMesh The submesh to dispatch
  17782. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17783. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17784. */
  17785. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17786. dispatchSprites(spriteManager: ISpriteManager): void;
  17787. dispatchParticles(particleSystem: IParticleSystem): void;
  17788. private _renderParticles;
  17789. private _renderSprites;
  17790. }
  17791. }
  17792. declare module "babylonjs/Rendering/renderingManager" {
  17793. import { Nullable } from "babylonjs/types";
  17794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17795. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17796. import { SmartArray } from "babylonjs/Misc/smartArray";
  17797. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17798. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17799. import { Material } from "babylonjs/Materials/material";
  17800. import { Scene } from "babylonjs/scene";
  17801. import { Camera } from "babylonjs/Cameras/camera";
  17802. /**
  17803. * Interface describing the different options available in the rendering manager
  17804. * regarding Auto Clear between groups.
  17805. */
  17806. export interface IRenderingManagerAutoClearSetup {
  17807. /**
  17808. * Defines whether or not autoclear is enable.
  17809. */
  17810. autoClear: boolean;
  17811. /**
  17812. * Defines whether or not to autoclear the depth buffer.
  17813. */
  17814. depth: boolean;
  17815. /**
  17816. * Defines whether or not to autoclear the stencil buffer.
  17817. */
  17818. stencil: boolean;
  17819. }
  17820. /**
  17821. * This class is used by the onRenderingGroupObservable
  17822. */
  17823. export class RenderingGroupInfo {
  17824. /**
  17825. * The Scene that being rendered
  17826. */
  17827. scene: Scene;
  17828. /**
  17829. * The camera currently used for the rendering pass
  17830. */
  17831. camera: Nullable<Camera>;
  17832. /**
  17833. * The ID of the renderingGroup being processed
  17834. */
  17835. renderingGroupId: number;
  17836. }
  17837. /**
  17838. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17839. * It is enable to manage the different groups as well as the different necessary sort functions.
  17840. * This should not be used directly aside of the few static configurations
  17841. */
  17842. export class RenderingManager {
  17843. /**
  17844. * The max id used for rendering groups (not included)
  17845. */
  17846. static MAX_RENDERINGGROUPS: number;
  17847. /**
  17848. * The min id used for rendering groups (included)
  17849. */
  17850. static MIN_RENDERINGGROUPS: number;
  17851. /**
  17852. * Used to globally prevent autoclearing scenes.
  17853. */
  17854. static AUTOCLEAR: boolean;
  17855. /**
  17856. * @hidden
  17857. */
  17858. _useSceneAutoClearSetup: boolean;
  17859. private _scene;
  17860. private _renderingGroups;
  17861. private _depthStencilBufferAlreadyCleaned;
  17862. private _autoClearDepthStencil;
  17863. private _customOpaqueSortCompareFn;
  17864. private _customAlphaTestSortCompareFn;
  17865. private _customTransparentSortCompareFn;
  17866. private _renderingGroupInfo;
  17867. /**
  17868. * Instantiates a new rendering group for a particular scene
  17869. * @param scene Defines the scene the groups belongs to
  17870. */
  17871. constructor(scene: Scene);
  17872. private _clearDepthStencilBuffer;
  17873. /**
  17874. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17875. * @hidden
  17876. */
  17877. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17878. /**
  17879. * Resets the different information of the group to prepare a new frame
  17880. * @hidden
  17881. */
  17882. reset(): void;
  17883. /**
  17884. * Dispose and release the group and its associated resources.
  17885. * @hidden
  17886. */
  17887. dispose(): void;
  17888. /**
  17889. * Clear the info related to rendering groups preventing retention points during dispose.
  17890. */
  17891. freeRenderingGroups(): void;
  17892. private _prepareRenderingGroup;
  17893. /**
  17894. * Add a sprite manager to the rendering manager in order to render it this frame.
  17895. * @param spriteManager Define the sprite manager to render
  17896. */
  17897. dispatchSprites(spriteManager: ISpriteManager): void;
  17898. /**
  17899. * Add a particle system to the rendering manager in order to render it this frame.
  17900. * @param particleSystem Define the particle system to render
  17901. */
  17902. dispatchParticles(particleSystem: IParticleSystem): void;
  17903. /**
  17904. * Add a submesh to the manager in order to render it this frame
  17905. * @param subMesh The submesh to dispatch
  17906. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17907. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17908. */
  17909. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17910. /**
  17911. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17912. * This allowed control for front to back rendering or reversly depending of the special needs.
  17913. *
  17914. * @param renderingGroupId The rendering group id corresponding to its index
  17915. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17916. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17917. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17918. */
  17919. 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;
  17920. /**
  17921. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17922. *
  17923. * @param renderingGroupId The rendering group id corresponding to its index
  17924. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17925. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17926. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17927. */
  17928. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17929. /**
  17930. * Gets the current auto clear configuration for one rendering group of the rendering
  17931. * manager.
  17932. * @param index the rendering group index to get the information for
  17933. * @returns The auto clear setup for the requested rendering group
  17934. */
  17935. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17936. }
  17937. }
  17938. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17939. import { SmartArray } from "babylonjs/Misc/smartArray";
  17940. import { Nullable } from "babylonjs/types";
  17941. import { Scene } from "babylonjs/scene";
  17942. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17943. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17945. import { Mesh } from "babylonjs/Meshes/mesh";
  17946. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17947. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17948. import { Effect } from "babylonjs/Materials/effect";
  17949. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17950. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17951. import "babylonjs/Shaders/shadowMap.fragment";
  17952. import "babylonjs/Shaders/shadowMap.vertex";
  17953. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17954. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17955. import { Observable } from "babylonjs/Misc/observable";
  17956. /**
  17957. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17958. */
  17959. export interface ICustomShaderOptions {
  17960. /**
  17961. * Gets or sets the custom shader name to use
  17962. */
  17963. shaderName: string;
  17964. /**
  17965. * The list of attribute names used in the shader
  17966. */
  17967. attributes?: string[];
  17968. /**
  17969. * The list of unifrom names used in the shader
  17970. */
  17971. uniforms?: string[];
  17972. /**
  17973. * The list of sampler names used in the shader
  17974. */
  17975. samplers?: string[];
  17976. /**
  17977. * The list of defines used in the shader
  17978. */
  17979. defines?: string[];
  17980. }
  17981. /**
  17982. * Interface to implement to create a shadow generator compatible with BJS.
  17983. */
  17984. export interface IShadowGenerator {
  17985. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17986. id: string;
  17987. /**
  17988. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17989. * @returns The render target texture if present otherwise, null
  17990. */
  17991. getShadowMap(): Nullable<RenderTargetTexture>;
  17992. /**
  17993. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17994. * @param subMesh The submesh we want to render in the shadow map
  17995. * @param useInstances Defines wether will draw in the map using instances
  17996. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17997. * @returns true if ready otherwise, false
  17998. */
  17999. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18000. /**
  18001. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18002. * @param defines Defines of the material we want to update
  18003. * @param lightIndex Index of the light in the enabled light list of the material
  18004. */
  18005. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18006. /**
  18007. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18008. * defined in the generator but impacting the effect).
  18009. * It implies the unifroms available on the materials are the standard BJS ones.
  18010. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18011. * @param effect The effect we are binfing the information for
  18012. */
  18013. bindShadowLight(lightIndex: string, effect: Effect): void;
  18014. /**
  18015. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18016. * (eq to shadow prjection matrix * light transform matrix)
  18017. * @returns The transform matrix used to create the shadow map
  18018. */
  18019. getTransformMatrix(): Matrix;
  18020. /**
  18021. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18022. * Cube and 2D textures for instance.
  18023. */
  18024. recreateShadowMap(): void;
  18025. /**
  18026. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18027. * @param onCompiled Callback triggered at the and of the effects compilation
  18028. * @param options Sets of optional options forcing the compilation with different modes
  18029. */
  18030. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18031. useInstances: boolean;
  18032. }>): void;
  18033. /**
  18034. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18035. * @param options Sets of optional options forcing the compilation with different modes
  18036. * @returns A promise that resolves when the compilation completes
  18037. */
  18038. forceCompilationAsync(options?: Partial<{
  18039. useInstances: boolean;
  18040. }>): Promise<void>;
  18041. /**
  18042. * Serializes the shadow generator setup to a json object.
  18043. * @returns The serialized JSON object
  18044. */
  18045. serialize(): any;
  18046. /**
  18047. * Disposes the Shadow map and related Textures and effects.
  18048. */
  18049. dispose(): void;
  18050. }
  18051. /**
  18052. * Default implementation IShadowGenerator.
  18053. * This is the main object responsible of generating shadows in the framework.
  18054. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18055. */
  18056. export class ShadowGenerator implements IShadowGenerator {
  18057. /**
  18058. * Name of the shadow generator class
  18059. */
  18060. static CLASSNAME: string;
  18061. /**
  18062. * Shadow generator mode None: no filtering applied.
  18063. */
  18064. static readonly FILTER_NONE: number;
  18065. /**
  18066. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18067. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18068. */
  18069. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18070. /**
  18071. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18072. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18073. */
  18074. static readonly FILTER_POISSONSAMPLING: number;
  18075. /**
  18076. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18077. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18078. */
  18079. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18080. /**
  18081. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18082. * edge artifacts on steep falloff.
  18083. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18084. */
  18085. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18086. /**
  18087. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18088. * edge artifacts on steep falloff.
  18089. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18090. */
  18091. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18092. /**
  18093. * Shadow generator mode PCF: Percentage Closer Filtering
  18094. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18095. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18096. */
  18097. static readonly FILTER_PCF: number;
  18098. /**
  18099. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18100. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18101. * Contact Hardening
  18102. */
  18103. static readonly FILTER_PCSS: number;
  18104. /**
  18105. * Reserved for PCF and PCSS
  18106. * Highest Quality.
  18107. *
  18108. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18109. *
  18110. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18111. */
  18112. static readonly QUALITY_HIGH: number;
  18113. /**
  18114. * Reserved for PCF and PCSS
  18115. * Good tradeoff for quality/perf cross devices
  18116. *
  18117. * Execute PCF on a 3*3 kernel.
  18118. *
  18119. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18120. */
  18121. static readonly QUALITY_MEDIUM: number;
  18122. /**
  18123. * Reserved for PCF and PCSS
  18124. * The lowest quality but the fastest.
  18125. *
  18126. * Execute PCF on a 1*1 kernel.
  18127. *
  18128. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18129. */
  18130. static readonly QUALITY_LOW: number;
  18131. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18132. id: string;
  18133. /** Gets or sets the custom shader name to use */
  18134. customShaderOptions: ICustomShaderOptions;
  18135. /**
  18136. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18137. */
  18138. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18139. /**
  18140. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18141. */
  18142. onAfterShadowMapRenderObservable: Observable<Effect>;
  18143. /**
  18144. * Observable triggered before a mesh is rendered in the shadow map.
  18145. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18146. */
  18147. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18148. /**
  18149. * Observable triggered after a mesh is rendered in the shadow map.
  18150. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18151. */
  18152. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18153. protected _bias: number;
  18154. /**
  18155. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18156. */
  18157. get bias(): number;
  18158. /**
  18159. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18160. */
  18161. set bias(bias: number);
  18162. protected _normalBias: number;
  18163. /**
  18164. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18165. */
  18166. get normalBias(): number;
  18167. /**
  18168. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18169. */
  18170. set normalBias(normalBias: number);
  18171. protected _blurBoxOffset: number;
  18172. /**
  18173. * Gets the blur box offset: offset applied during the blur pass.
  18174. * Only useful if useKernelBlur = false
  18175. */
  18176. get blurBoxOffset(): number;
  18177. /**
  18178. * Sets the blur box offset: offset applied during the blur pass.
  18179. * Only useful if useKernelBlur = false
  18180. */
  18181. set blurBoxOffset(value: number);
  18182. protected _blurScale: number;
  18183. /**
  18184. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18185. * 2 means half of the size.
  18186. */
  18187. get blurScale(): number;
  18188. /**
  18189. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18190. * 2 means half of the size.
  18191. */
  18192. set blurScale(value: number);
  18193. protected _blurKernel: number;
  18194. /**
  18195. * Gets the blur kernel: kernel size of the blur pass.
  18196. * Only useful if useKernelBlur = true
  18197. */
  18198. get blurKernel(): number;
  18199. /**
  18200. * Sets the blur kernel: kernel size of the blur pass.
  18201. * Only useful if useKernelBlur = true
  18202. */
  18203. set blurKernel(value: number);
  18204. protected _useKernelBlur: boolean;
  18205. /**
  18206. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18207. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18208. */
  18209. get useKernelBlur(): boolean;
  18210. /**
  18211. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18212. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18213. */
  18214. set useKernelBlur(value: boolean);
  18215. protected _depthScale: number;
  18216. /**
  18217. * Gets the depth scale used in ESM mode.
  18218. */
  18219. get depthScale(): number;
  18220. /**
  18221. * Sets the depth scale used in ESM mode.
  18222. * This can override the scale stored on the light.
  18223. */
  18224. set depthScale(value: number);
  18225. protected _validateFilter(filter: number): number;
  18226. protected _filter: number;
  18227. /**
  18228. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18229. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18230. */
  18231. get filter(): number;
  18232. /**
  18233. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18234. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18235. */
  18236. set filter(value: number);
  18237. /**
  18238. * Gets if the current filter is set to Poisson Sampling.
  18239. */
  18240. get usePoissonSampling(): boolean;
  18241. /**
  18242. * Sets the current filter to Poisson Sampling.
  18243. */
  18244. set usePoissonSampling(value: boolean);
  18245. /**
  18246. * Gets if the current filter is set to ESM.
  18247. */
  18248. get useExponentialShadowMap(): boolean;
  18249. /**
  18250. * Sets the current filter is to ESM.
  18251. */
  18252. set useExponentialShadowMap(value: boolean);
  18253. /**
  18254. * Gets if the current filter is set to filtered ESM.
  18255. */
  18256. get useBlurExponentialShadowMap(): boolean;
  18257. /**
  18258. * Gets if the current filter is set to filtered ESM.
  18259. */
  18260. set useBlurExponentialShadowMap(value: boolean);
  18261. /**
  18262. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18263. * exponential to prevent steep falloff artifacts).
  18264. */
  18265. get useCloseExponentialShadowMap(): boolean;
  18266. /**
  18267. * Sets the current filter to "close ESM" (using the inverse of the
  18268. * exponential to prevent steep falloff artifacts).
  18269. */
  18270. set useCloseExponentialShadowMap(value: boolean);
  18271. /**
  18272. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18273. * exponential to prevent steep falloff artifacts).
  18274. */
  18275. get useBlurCloseExponentialShadowMap(): boolean;
  18276. /**
  18277. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18278. * exponential to prevent steep falloff artifacts).
  18279. */
  18280. set useBlurCloseExponentialShadowMap(value: boolean);
  18281. /**
  18282. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18283. */
  18284. get usePercentageCloserFiltering(): boolean;
  18285. /**
  18286. * Sets the current filter to "PCF" (percentage closer filtering).
  18287. */
  18288. set usePercentageCloserFiltering(value: boolean);
  18289. protected _filteringQuality: number;
  18290. /**
  18291. * Gets the PCF or PCSS Quality.
  18292. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18293. */
  18294. get filteringQuality(): number;
  18295. /**
  18296. * Sets the PCF or PCSS Quality.
  18297. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18298. */
  18299. set filteringQuality(filteringQuality: number);
  18300. /**
  18301. * Gets if the current filter is set to "PCSS" (contact hardening).
  18302. */
  18303. get useContactHardeningShadow(): boolean;
  18304. /**
  18305. * Sets the current filter to "PCSS" (contact hardening).
  18306. */
  18307. set useContactHardeningShadow(value: boolean);
  18308. protected _contactHardeningLightSizeUVRatio: number;
  18309. /**
  18310. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18311. * Using a ratio helps keeping shape stability independently of the map size.
  18312. *
  18313. * It does not account for the light projection as it was having too much
  18314. * instability during the light setup or during light position changes.
  18315. *
  18316. * Only valid if useContactHardeningShadow is true.
  18317. */
  18318. get contactHardeningLightSizeUVRatio(): number;
  18319. /**
  18320. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18321. * Using a ratio helps keeping shape stability independently of the map size.
  18322. *
  18323. * It does not account for the light projection as it was having too much
  18324. * instability during the light setup or during light position changes.
  18325. *
  18326. * Only valid if useContactHardeningShadow is true.
  18327. */
  18328. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18329. protected _darkness: number;
  18330. /** Gets or sets the actual darkness of a shadow */
  18331. get darkness(): number;
  18332. set darkness(value: number);
  18333. /**
  18334. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18335. * 0 means strongest and 1 would means no shadow.
  18336. * @returns the darkness.
  18337. */
  18338. getDarkness(): number;
  18339. /**
  18340. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18341. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18342. * @returns the shadow generator allowing fluent coding.
  18343. */
  18344. setDarkness(darkness: number): ShadowGenerator;
  18345. protected _transparencyShadow: boolean;
  18346. /** Gets or sets the ability to have transparent shadow */
  18347. get transparencyShadow(): boolean;
  18348. set transparencyShadow(value: boolean);
  18349. /**
  18350. * Sets the ability to have transparent shadow (boolean).
  18351. * @param transparent True if transparent else False
  18352. * @returns the shadow generator allowing fluent coding
  18353. */
  18354. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18355. /**
  18356. * Enables or disables shadows with varying strength based on the transparency
  18357. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18358. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18359. * mesh.visibility * alphaTexture.a
  18360. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18361. */
  18362. enableSoftTransparentShadow: boolean;
  18363. protected _shadowMap: Nullable<RenderTargetTexture>;
  18364. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18365. /**
  18366. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18367. * @returns The render target texture if present otherwise, null
  18368. */
  18369. getShadowMap(): Nullable<RenderTargetTexture>;
  18370. /**
  18371. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18372. * @returns The render target texture if the shadow map is present otherwise, null
  18373. */
  18374. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18375. /**
  18376. * Gets the class name of that object
  18377. * @returns "ShadowGenerator"
  18378. */
  18379. getClassName(): string;
  18380. /**
  18381. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18382. * @param mesh Mesh to add
  18383. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18384. * @returns the Shadow Generator itself
  18385. */
  18386. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18387. /**
  18388. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18389. * @param mesh Mesh to remove
  18390. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18391. * @returns the Shadow Generator itself
  18392. */
  18393. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18394. /**
  18395. * Controls the extent to which the shadows fade out at the edge of the frustum
  18396. */
  18397. frustumEdgeFalloff: number;
  18398. protected _light: IShadowLight;
  18399. /**
  18400. * Returns the associated light object.
  18401. * @returns the light generating the shadow
  18402. */
  18403. getLight(): IShadowLight;
  18404. /**
  18405. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18406. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18407. * It might on the other hand introduce peter panning.
  18408. */
  18409. forceBackFacesOnly: boolean;
  18410. protected _scene: Scene;
  18411. protected _lightDirection: Vector3;
  18412. protected _effect: Effect;
  18413. protected _viewMatrix: Matrix;
  18414. protected _projectionMatrix: Matrix;
  18415. protected _transformMatrix: Matrix;
  18416. protected _cachedPosition: Vector3;
  18417. protected _cachedDirection: Vector3;
  18418. protected _cachedDefines: string;
  18419. protected _currentRenderID: number;
  18420. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18421. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18422. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18423. protected _blurPostProcesses: PostProcess[];
  18424. protected _mapSize: number;
  18425. protected _currentFaceIndex: number;
  18426. protected _currentFaceIndexCache: number;
  18427. protected _textureType: number;
  18428. protected _defaultTextureMatrix: Matrix;
  18429. protected _storedUniqueId: Nullable<number>;
  18430. /** @hidden */
  18431. static _SceneComponentInitialization: (scene: Scene) => void;
  18432. /**
  18433. * Creates a ShadowGenerator object.
  18434. * A ShadowGenerator is the required tool to use the shadows.
  18435. * Each light casting shadows needs to use its own ShadowGenerator.
  18436. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18437. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18438. * @param light The light object generating the shadows.
  18439. * @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.
  18440. */
  18441. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18442. protected _initializeGenerator(): void;
  18443. protected _createTargetRenderTexture(): void;
  18444. protected _initializeShadowMap(): void;
  18445. protected _initializeBlurRTTAndPostProcesses(): void;
  18446. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18447. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18448. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18449. protected _applyFilterValues(): void;
  18450. /**
  18451. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18452. * @param onCompiled Callback triggered at the and of the effects compilation
  18453. * @param options Sets of optional options forcing the compilation with different modes
  18454. */
  18455. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18456. useInstances: boolean;
  18457. }>): void;
  18458. /**
  18459. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18460. * @param options Sets of optional options forcing the compilation with different modes
  18461. * @returns A promise that resolves when the compilation completes
  18462. */
  18463. forceCompilationAsync(options?: Partial<{
  18464. useInstances: boolean;
  18465. }>): Promise<void>;
  18466. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18467. private _prepareShadowDefines;
  18468. /**
  18469. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18470. * @param subMesh The submesh we want to render in the shadow map
  18471. * @param useInstances Defines wether will draw in the map using instances
  18472. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18473. * @returns true if ready otherwise, false
  18474. */
  18475. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18476. /**
  18477. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18478. * @param defines Defines of the material we want to update
  18479. * @param lightIndex Index of the light in the enabled light list of the material
  18480. */
  18481. prepareDefines(defines: any, lightIndex: number): void;
  18482. /**
  18483. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18484. * defined in the generator but impacting the effect).
  18485. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18486. * @param effect The effect we are binfing the information for
  18487. */
  18488. bindShadowLight(lightIndex: string, effect: Effect): void;
  18489. /**
  18490. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18491. * (eq to shadow prjection matrix * light transform matrix)
  18492. * @returns The transform matrix used to create the shadow map
  18493. */
  18494. getTransformMatrix(): Matrix;
  18495. /**
  18496. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18497. * Cube and 2D textures for instance.
  18498. */
  18499. recreateShadowMap(): void;
  18500. protected _disposeBlurPostProcesses(): void;
  18501. protected _disposeRTTandPostProcesses(): void;
  18502. /**
  18503. * Disposes the ShadowGenerator.
  18504. * Returns nothing.
  18505. */
  18506. dispose(): void;
  18507. /**
  18508. * Serializes the shadow generator setup to a json object.
  18509. * @returns The serialized JSON object
  18510. */
  18511. serialize(): any;
  18512. /**
  18513. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18514. * @param parsedShadowGenerator The JSON object to parse
  18515. * @param scene The scene to create the shadow map for
  18516. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18517. * @returns The parsed shadow generator
  18518. */
  18519. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18520. }
  18521. }
  18522. declare module "babylonjs/Lights/light" {
  18523. import { Nullable } from "babylonjs/types";
  18524. import { Scene } from "babylonjs/scene";
  18525. import { Vector3 } from "babylonjs/Maths/math.vector";
  18526. import { Color3 } from "babylonjs/Maths/math.color";
  18527. import { Node } from "babylonjs/node";
  18528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18529. import { Effect } from "babylonjs/Materials/effect";
  18530. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18531. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18532. /**
  18533. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18534. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18535. * 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.
  18536. */
  18537. export abstract class Light extends Node {
  18538. /**
  18539. * Falloff Default: light is falling off following the material specification:
  18540. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18541. */
  18542. static readonly FALLOFF_DEFAULT: number;
  18543. /**
  18544. * Falloff Physical: light is falling off following the inverse squared distance law.
  18545. */
  18546. static readonly FALLOFF_PHYSICAL: number;
  18547. /**
  18548. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18549. * to enhance interoperability with other engines.
  18550. */
  18551. static readonly FALLOFF_GLTF: number;
  18552. /**
  18553. * Falloff Standard: light is falling off like in the standard material
  18554. * to enhance interoperability with other materials.
  18555. */
  18556. static readonly FALLOFF_STANDARD: number;
  18557. /**
  18558. * If every light affecting the material is in this lightmapMode,
  18559. * material.lightmapTexture adds or multiplies
  18560. * (depends on material.useLightmapAsShadowmap)
  18561. * after every other light calculations.
  18562. */
  18563. static readonly LIGHTMAP_DEFAULT: number;
  18564. /**
  18565. * material.lightmapTexture as only diffuse lighting from this light
  18566. * adds only specular lighting from this light
  18567. * adds dynamic shadows
  18568. */
  18569. static readonly LIGHTMAP_SPECULAR: number;
  18570. /**
  18571. * material.lightmapTexture as only lighting
  18572. * no light calculation from this light
  18573. * only adds dynamic shadows from this light
  18574. */
  18575. static readonly LIGHTMAP_SHADOWSONLY: number;
  18576. /**
  18577. * Each light type uses the default quantity according to its type:
  18578. * point/spot lights use luminous intensity
  18579. * directional lights use illuminance
  18580. */
  18581. static readonly INTENSITYMODE_AUTOMATIC: number;
  18582. /**
  18583. * lumen (lm)
  18584. */
  18585. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18586. /**
  18587. * candela (lm/sr)
  18588. */
  18589. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18590. /**
  18591. * lux (lm/m^2)
  18592. */
  18593. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18594. /**
  18595. * nit (cd/m^2)
  18596. */
  18597. static readonly INTENSITYMODE_LUMINANCE: number;
  18598. /**
  18599. * Light type const id of the point light.
  18600. */
  18601. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18602. /**
  18603. * Light type const id of the directional light.
  18604. */
  18605. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18606. /**
  18607. * Light type const id of the spot light.
  18608. */
  18609. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18610. /**
  18611. * Light type const id of the hemispheric light.
  18612. */
  18613. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18614. /**
  18615. * Diffuse gives the basic color to an object.
  18616. */
  18617. diffuse: Color3;
  18618. /**
  18619. * Specular produces a highlight color on an object.
  18620. * Note: This is note affecting PBR materials.
  18621. */
  18622. specular: Color3;
  18623. /**
  18624. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18625. * falling off base on range or angle.
  18626. * This can be set to any values in Light.FALLOFF_x.
  18627. *
  18628. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18629. * other types of materials.
  18630. */
  18631. falloffType: number;
  18632. /**
  18633. * Strength of the light.
  18634. * Note: By default it is define in the framework own unit.
  18635. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18636. */
  18637. intensity: number;
  18638. private _range;
  18639. protected _inverseSquaredRange: number;
  18640. /**
  18641. * Defines how far from the source the light is impacting in scene units.
  18642. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18643. */
  18644. get range(): number;
  18645. /**
  18646. * Defines how far from the source the light is impacting in scene units.
  18647. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18648. */
  18649. set range(value: number);
  18650. /**
  18651. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18652. * of light.
  18653. */
  18654. private _photometricScale;
  18655. private _intensityMode;
  18656. /**
  18657. * Gets the photometric scale used to interpret the intensity.
  18658. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18659. */
  18660. get intensityMode(): number;
  18661. /**
  18662. * Sets the photometric scale used to interpret the intensity.
  18663. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18664. */
  18665. set intensityMode(value: number);
  18666. private _radius;
  18667. /**
  18668. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18669. */
  18670. get radius(): number;
  18671. /**
  18672. * sets the light radius used by PBR Materials to simulate soft area lights.
  18673. */
  18674. set radius(value: number);
  18675. private _renderPriority;
  18676. /**
  18677. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18678. * exceeding the number allowed of the materials.
  18679. */
  18680. renderPriority: number;
  18681. private _shadowEnabled;
  18682. /**
  18683. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18684. * the current shadow generator.
  18685. */
  18686. get shadowEnabled(): boolean;
  18687. /**
  18688. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18689. * the current shadow generator.
  18690. */
  18691. set shadowEnabled(value: boolean);
  18692. private _includedOnlyMeshes;
  18693. /**
  18694. * Gets the only meshes impacted by this light.
  18695. */
  18696. get includedOnlyMeshes(): AbstractMesh[];
  18697. /**
  18698. * Sets the only meshes impacted by this light.
  18699. */
  18700. set includedOnlyMeshes(value: AbstractMesh[]);
  18701. private _excludedMeshes;
  18702. /**
  18703. * Gets the meshes not impacted by this light.
  18704. */
  18705. get excludedMeshes(): AbstractMesh[];
  18706. /**
  18707. * Sets the meshes not impacted by this light.
  18708. */
  18709. set excludedMeshes(value: AbstractMesh[]);
  18710. private _excludeWithLayerMask;
  18711. /**
  18712. * Gets the layer id use to find what meshes are not impacted by the light.
  18713. * Inactive if 0
  18714. */
  18715. get excludeWithLayerMask(): number;
  18716. /**
  18717. * Sets the layer id use to find what meshes are not impacted by the light.
  18718. * Inactive if 0
  18719. */
  18720. set excludeWithLayerMask(value: number);
  18721. private _includeOnlyWithLayerMask;
  18722. /**
  18723. * Gets the layer id use to find what meshes are impacted by the light.
  18724. * Inactive if 0
  18725. */
  18726. get includeOnlyWithLayerMask(): number;
  18727. /**
  18728. * Sets the layer id use to find what meshes are impacted by the light.
  18729. * Inactive if 0
  18730. */
  18731. set includeOnlyWithLayerMask(value: number);
  18732. private _lightmapMode;
  18733. /**
  18734. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18735. */
  18736. get lightmapMode(): number;
  18737. /**
  18738. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18739. */
  18740. set lightmapMode(value: number);
  18741. /**
  18742. * Shadow generator associted to the light.
  18743. * @hidden Internal use only.
  18744. */
  18745. _shadowGenerator: Nullable<IShadowGenerator>;
  18746. /**
  18747. * @hidden Internal use only.
  18748. */
  18749. _excludedMeshesIds: string[];
  18750. /**
  18751. * @hidden Internal use only.
  18752. */
  18753. _includedOnlyMeshesIds: string[];
  18754. /**
  18755. * The current light unifom buffer.
  18756. * @hidden Internal use only.
  18757. */
  18758. _uniformBuffer: UniformBuffer;
  18759. /** @hidden */
  18760. _renderId: number;
  18761. /**
  18762. * Creates a Light object in the scene.
  18763. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18764. * @param name The firendly name of the light
  18765. * @param scene The scene the light belongs too
  18766. */
  18767. constructor(name: string, scene: Scene);
  18768. protected abstract _buildUniformLayout(): void;
  18769. /**
  18770. * Sets the passed Effect "effect" with the Light information.
  18771. * @param effect The effect to update
  18772. * @param lightIndex The index of the light in the effect to update
  18773. * @returns The light
  18774. */
  18775. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18776. /**
  18777. * Sets the passed Effect "effect" with the Light textures.
  18778. * @param effect The effect to update
  18779. * @param lightIndex The index of the light in the effect to update
  18780. * @returns The light
  18781. */
  18782. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18783. /**
  18784. * Binds the lights information from the scene to the effect for the given mesh.
  18785. * @param lightIndex Light index
  18786. * @param scene The scene where the light belongs to
  18787. * @param effect The effect we are binding the data to
  18788. * @param useSpecular Defines if specular is supported
  18789. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18790. */
  18791. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18792. /**
  18793. * Sets the passed Effect "effect" with the Light information.
  18794. * @param effect The effect to update
  18795. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18796. * @returns The light
  18797. */
  18798. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18799. /**
  18800. * Returns the string "Light".
  18801. * @returns the class name
  18802. */
  18803. getClassName(): string;
  18804. /** @hidden */
  18805. readonly _isLight: boolean;
  18806. /**
  18807. * Converts the light information to a readable string for debug purpose.
  18808. * @param fullDetails Supports for multiple levels of logging within scene loading
  18809. * @returns the human readable light info
  18810. */
  18811. toString(fullDetails?: boolean): string;
  18812. /** @hidden */
  18813. protected _syncParentEnabledState(): void;
  18814. /**
  18815. * Set the enabled state of this node.
  18816. * @param value - the new enabled state
  18817. */
  18818. setEnabled(value: boolean): void;
  18819. /**
  18820. * Returns the Light associated shadow generator if any.
  18821. * @return the associated shadow generator.
  18822. */
  18823. getShadowGenerator(): Nullable<IShadowGenerator>;
  18824. /**
  18825. * Returns a Vector3, the absolute light position in the World.
  18826. * @returns the world space position of the light
  18827. */
  18828. getAbsolutePosition(): Vector3;
  18829. /**
  18830. * Specifies if the light will affect the passed mesh.
  18831. * @param mesh The mesh to test against the light
  18832. * @return true the mesh is affected otherwise, false.
  18833. */
  18834. canAffectMesh(mesh: AbstractMesh): boolean;
  18835. /**
  18836. * Sort function to order lights for rendering.
  18837. * @param a First Light object to compare to second.
  18838. * @param b Second Light object to compare first.
  18839. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18840. */
  18841. static CompareLightsPriority(a: Light, b: Light): number;
  18842. /**
  18843. * Releases resources associated with this node.
  18844. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18845. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18846. */
  18847. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18848. /**
  18849. * Returns the light type ID (integer).
  18850. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18851. */
  18852. getTypeID(): number;
  18853. /**
  18854. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18855. * @returns the scaled intensity in intensity mode unit
  18856. */
  18857. getScaledIntensity(): number;
  18858. /**
  18859. * Returns a new Light object, named "name", from the current one.
  18860. * @param name The name of the cloned light
  18861. * @param newParent The parent of this light, if it has one
  18862. * @returns the new created light
  18863. */
  18864. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18865. /**
  18866. * Serializes the current light into a Serialization object.
  18867. * @returns the serialized object.
  18868. */
  18869. serialize(): any;
  18870. /**
  18871. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18872. * This new light is named "name" and added to the passed scene.
  18873. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18874. * @param name The friendly name of the light
  18875. * @param scene The scene the new light will belong to
  18876. * @returns the constructor function
  18877. */
  18878. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18879. /**
  18880. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18881. * @param parsedLight The JSON representation of the light
  18882. * @param scene The scene to create the parsed light in
  18883. * @returns the created light after parsing
  18884. */
  18885. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18886. private _hookArrayForExcluded;
  18887. private _hookArrayForIncludedOnly;
  18888. private _resyncMeshes;
  18889. /**
  18890. * Forces the meshes to update their light related information in their rendering used effects
  18891. * @hidden Internal Use Only
  18892. */
  18893. _markMeshesAsLightDirty(): void;
  18894. /**
  18895. * Recomputes the cached photometric scale if needed.
  18896. */
  18897. private _computePhotometricScale;
  18898. /**
  18899. * Returns the Photometric Scale according to the light type and intensity mode.
  18900. */
  18901. private _getPhotometricScale;
  18902. /**
  18903. * Reorder the light in the scene according to their defined priority.
  18904. * @hidden Internal Use Only
  18905. */
  18906. _reorderLightsInScene(): void;
  18907. /**
  18908. * Prepares the list of defines specific to the light type.
  18909. * @param defines the list of defines
  18910. * @param lightIndex defines the index of the light for the effect
  18911. */
  18912. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18913. }
  18914. }
  18915. declare module "babylonjs/Cameras/targetCamera" {
  18916. import { Nullable } from "babylonjs/types";
  18917. import { Camera } from "babylonjs/Cameras/camera";
  18918. import { Scene } from "babylonjs/scene";
  18919. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18920. /**
  18921. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18922. * This is the base of the follow, arc rotate cameras and Free camera
  18923. * @see https://doc.babylonjs.com/features/cameras
  18924. */
  18925. export class TargetCamera extends Camera {
  18926. private static _RigCamTransformMatrix;
  18927. private static _TargetTransformMatrix;
  18928. private static _TargetFocalPoint;
  18929. private _tmpUpVector;
  18930. private _tmpTargetVector;
  18931. /**
  18932. * Define the current direction the camera is moving to
  18933. */
  18934. cameraDirection: Vector3;
  18935. /**
  18936. * Define the current rotation the camera is rotating to
  18937. */
  18938. cameraRotation: Vector2;
  18939. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18940. ignoreParentScaling: boolean;
  18941. /**
  18942. * When set, the up vector of the camera will be updated by the rotation of the camera
  18943. */
  18944. updateUpVectorFromRotation: boolean;
  18945. private _tmpQuaternion;
  18946. /**
  18947. * Define the current rotation of the camera
  18948. */
  18949. rotation: Vector3;
  18950. /**
  18951. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18952. */
  18953. rotationQuaternion: Quaternion;
  18954. /**
  18955. * Define the current speed of the camera
  18956. */
  18957. speed: number;
  18958. /**
  18959. * Add constraint to the camera to prevent it to move freely in all directions and
  18960. * around all axis.
  18961. */
  18962. noRotationConstraint: boolean;
  18963. /**
  18964. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18965. * panning
  18966. */
  18967. invertRotation: boolean;
  18968. /**
  18969. * Speed multiplier for inverse camera panning
  18970. */
  18971. inverseRotationSpeed: number;
  18972. /**
  18973. * Define the current target of the camera as an object or a position.
  18974. */
  18975. lockedTarget: any;
  18976. /** @hidden */
  18977. _currentTarget: Vector3;
  18978. /** @hidden */
  18979. _initialFocalDistance: number;
  18980. /** @hidden */
  18981. _viewMatrix: Matrix;
  18982. /** @hidden */
  18983. _camMatrix: Matrix;
  18984. /** @hidden */
  18985. _cameraTransformMatrix: Matrix;
  18986. /** @hidden */
  18987. _cameraRotationMatrix: Matrix;
  18988. /** @hidden */
  18989. _referencePoint: Vector3;
  18990. /** @hidden */
  18991. _transformedReferencePoint: Vector3;
  18992. /** @hidden */
  18993. _reset: () => void;
  18994. private _defaultUp;
  18995. /**
  18996. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18997. * This is the base of the follow, arc rotate cameras and Free camera
  18998. * @see https://doc.babylonjs.com/features/cameras
  18999. * @param name Defines the name of the camera in the scene
  19000. * @param position Defines the start position of the camera in the scene
  19001. * @param scene Defines the scene the camera belongs to
  19002. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19003. */
  19004. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19005. /**
  19006. * Gets the position in front of the camera at a given distance.
  19007. * @param distance The distance from the camera we want the position to be
  19008. * @returns the position
  19009. */
  19010. getFrontPosition(distance: number): Vector3;
  19011. /** @hidden */
  19012. _getLockedTargetPosition(): Nullable<Vector3>;
  19013. private _storedPosition;
  19014. private _storedRotation;
  19015. private _storedRotationQuaternion;
  19016. /**
  19017. * Store current camera state of the camera (fov, position, rotation, etc..)
  19018. * @returns the camera
  19019. */
  19020. storeState(): Camera;
  19021. /**
  19022. * Restored camera state. You must call storeState() first
  19023. * @returns whether it was successful or not
  19024. * @hidden
  19025. */
  19026. _restoreStateValues(): boolean;
  19027. /** @hidden */
  19028. _initCache(): void;
  19029. /** @hidden */
  19030. _updateCache(ignoreParentClass?: boolean): void;
  19031. /** @hidden */
  19032. _isSynchronizedViewMatrix(): boolean;
  19033. /** @hidden */
  19034. _computeLocalCameraSpeed(): number;
  19035. /**
  19036. * Defines the target the camera should look at.
  19037. * @param target Defines the new target as a Vector or a mesh
  19038. */
  19039. setTarget(target: Vector3): void;
  19040. /**
  19041. * Defines the target point of the camera.
  19042. * The camera looks towards it form the radius distance.
  19043. */
  19044. get target(): Vector3;
  19045. set target(value: Vector3);
  19046. /**
  19047. * Return the current target position of the camera. This value is expressed in local space.
  19048. * @returns the target position
  19049. */
  19050. getTarget(): Vector3;
  19051. /** @hidden */
  19052. _decideIfNeedsToMove(): boolean;
  19053. /** @hidden */
  19054. _updatePosition(): void;
  19055. /** @hidden */
  19056. _checkInputs(): void;
  19057. protected _updateCameraRotationMatrix(): void;
  19058. /**
  19059. * 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)
  19060. * @returns the current camera
  19061. */
  19062. private _rotateUpVectorWithCameraRotationMatrix;
  19063. private _cachedRotationZ;
  19064. private _cachedQuaternionRotationZ;
  19065. /** @hidden */
  19066. _getViewMatrix(): Matrix;
  19067. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19068. /**
  19069. * @hidden
  19070. */
  19071. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19072. /**
  19073. * @hidden
  19074. */
  19075. _updateRigCameras(): void;
  19076. private _getRigCamPositionAndTarget;
  19077. /**
  19078. * Gets the current object class name.
  19079. * @return the class name
  19080. */
  19081. getClassName(): string;
  19082. }
  19083. }
  19084. declare module "babylonjs/Events/keyboardEvents" {
  19085. /**
  19086. * Gather the list of keyboard event types as constants.
  19087. */
  19088. export class KeyboardEventTypes {
  19089. /**
  19090. * The keydown event is fired when a key becomes active (pressed).
  19091. */
  19092. static readonly KEYDOWN: number;
  19093. /**
  19094. * The keyup event is fired when a key has been released.
  19095. */
  19096. static readonly KEYUP: number;
  19097. }
  19098. /**
  19099. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19100. */
  19101. export class KeyboardInfo {
  19102. /**
  19103. * Defines the type of event (KeyboardEventTypes)
  19104. */
  19105. type: number;
  19106. /**
  19107. * Defines the related dom event
  19108. */
  19109. event: KeyboardEvent;
  19110. /**
  19111. * Instantiates a new keyboard info.
  19112. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19113. * @param type Defines the type of event (KeyboardEventTypes)
  19114. * @param event Defines the related dom event
  19115. */
  19116. constructor(
  19117. /**
  19118. * Defines the type of event (KeyboardEventTypes)
  19119. */
  19120. type: number,
  19121. /**
  19122. * Defines the related dom event
  19123. */
  19124. event: KeyboardEvent);
  19125. }
  19126. /**
  19127. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19128. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19129. */
  19130. export class KeyboardInfoPre extends KeyboardInfo {
  19131. /**
  19132. * Defines the type of event (KeyboardEventTypes)
  19133. */
  19134. type: number;
  19135. /**
  19136. * Defines the related dom event
  19137. */
  19138. event: KeyboardEvent;
  19139. /**
  19140. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19141. */
  19142. skipOnPointerObservable: boolean;
  19143. /**
  19144. * Instantiates a new keyboard pre info.
  19145. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19146. * @param type Defines the type of event (KeyboardEventTypes)
  19147. * @param event Defines the related dom event
  19148. */
  19149. constructor(
  19150. /**
  19151. * Defines the type of event (KeyboardEventTypes)
  19152. */
  19153. type: number,
  19154. /**
  19155. * Defines the related dom event
  19156. */
  19157. event: KeyboardEvent);
  19158. }
  19159. }
  19160. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19161. import { Nullable } from "babylonjs/types";
  19162. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19163. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19164. /**
  19165. * Manage the keyboard inputs to control the movement of a free camera.
  19166. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19167. */
  19168. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19169. /**
  19170. * Defines the camera the input is attached to.
  19171. */
  19172. camera: FreeCamera;
  19173. /**
  19174. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19175. */
  19176. keysUp: number[];
  19177. /**
  19178. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19179. */
  19180. keysUpward: number[];
  19181. /**
  19182. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19183. */
  19184. keysDown: number[];
  19185. /**
  19186. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19187. */
  19188. keysDownward: number[];
  19189. /**
  19190. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19191. */
  19192. keysLeft: number[];
  19193. /**
  19194. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19195. */
  19196. keysRight: number[];
  19197. private _keys;
  19198. private _onCanvasBlurObserver;
  19199. private _onKeyboardObserver;
  19200. private _engine;
  19201. private _scene;
  19202. /**
  19203. * Attach the input controls to a specific dom element to get the input from.
  19204. * @param element Defines the element the controls should be listened from
  19205. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19206. */
  19207. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19208. /**
  19209. * Detach the current controls from the specified dom element.
  19210. * @param element Defines the element to stop listening the inputs from
  19211. */
  19212. detachControl(element: Nullable<HTMLElement>): void;
  19213. /**
  19214. * Update the current camera state depending on the inputs that have been used this frame.
  19215. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19216. */
  19217. checkInputs(): void;
  19218. /**
  19219. * Gets the class name of the current intput.
  19220. * @returns the class name
  19221. */
  19222. getClassName(): string;
  19223. /** @hidden */
  19224. _onLostFocus(): void;
  19225. /**
  19226. * Get the friendly name associated with the input class.
  19227. * @returns the input friendly name
  19228. */
  19229. getSimpleName(): string;
  19230. }
  19231. }
  19232. declare module "babylonjs/Events/pointerEvents" {
  19233. import { Nullable } from "babylonjs/types";
  19234. import { Vector2 } from "babylonjs/Maths/math.vector";
  19235. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19236. import { Ray } from "babylonjs/Culling/ray";
  19237. /**
  19238. * Gather the list of pointer event types as constants.
  19239. */
  19240. export class PointerEventTypes {
  19241. /**
  19242. * 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.
  19243. */
  19244. static readonly POINTERDOWN: number;
  19245. /**
  19246. * The pointerup event is fired when a pointer is no longer active.
  19247. */
  19248. static readonly POINTERUP: number;
  19249. /**
  19250. * The pointermove event is fired when a pointer changes coordinates.
  19251. */
  19252. static readonly POINTERMOVE: number;
  19253. /**
  19254. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19255. */
  19256. static readonly POINTERWHEEL: number;
  19257. /**
  19258. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19259. */
  19260. static readonly POINTERPICK: number;
  19261. /**
  19262. * The pointertap event is fired when a the object has been touched and released without drag.
  19263. */
  19264. static readonly POINTERTAP: number;
  19265. /**
  19266. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19267. */
  19268. static readonly POINTERDOUBLETAP: number;
  19269. }
  19270. /**
  19271. * Base class of pointer info types.
  19272. */
  19273. export class PointerInfoBase {
  19274. /**
  19275. * Defines the type of event (PointerEventTypes)
  19276. */
  19277. type: number;
  19278. /**
  19279. * Defines the related dom event
  19280. */
  19281. event: PointerEvent | MouseWheelEvent;
  19282. /**
  19283. * Instantiates the base class of pointers info.
  19284. * @param type Defines the type of event (PointerEventTypes)
  19285. * @param event Defines the related dom event
  19286. */
  19287. constructor(
  19288. /**
  19289. * Defines the type of event (PointerEventTypes)
  19290. */
  19291. type: number,
  19292. /**
  19293. * Defines the related dom event
  19294. */
  19295. event: PointerEvent | MouseWheelEvent);
  19296. }
  19297. /**
  19298. * This class is used to store pointer related info for the onPrePointerObservable event.
  19299. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19300. */
  19301. export class PointerInfoPre extends PointerInfoBase {
  19302. /**
  19303. * Ray from a pointer if availible (eg. 6dof controller)
  19304. */
  19305. ray: Nullable<Ray>;
  19306. /**
  19307. * Defines the local position of the pointer on the canvas.
  19308. */
  19309. localPosition: Vector2;
  19310. /**
  19311. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19312. */
  19313. skipOnPointerObservable: boolean;
  19314. /**
  19315. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19316. * @param type Defines the type of event (PointerEventTypes)
  19317. * @param event Defines the related dom event
  19318. * @param localX Defines the local x coordinates of the pointer when the event occured
  19319. * @param localY Defines the local y coordinates of the pointer when the event occured
  19320. */
  19321. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19322. }
  19323. /**
  19324. * This type contains all the data related to a pointer event in Babylon.js.
  19325. * 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.
  19326. */
  19327. export class PointerInfo extends PointerInfoBase {
  19328. /**
  19329. * Defines the picking info associated to the info (if any)\
  19330. */
  19331. pickInfo: Nullable<PickingInfo>;
  19332. /**
  19333. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19334. * @param type Defines the type of event (PointerEventTypes)
  19335. * @param event Defines the related dom event
  19336. * @param pickInfo Defines the picking info associated to the info (if any)\
  19337. */
  19338. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19339. /**
  19340. * Defines the picking info associated to the info (if any)\
  19341. */
  19342. pickInfo: Nullable<PickingInfo>);
  19343. }
  19344. /**
  19345. * Data relating to a touch event on the screen.
  19346. */
  19347. export interface PointerTouch {
  19348. /**
  19349. * X coordinate of touch.
  19350. */
  19351. x: number;
  19352. /**
  19353. * Y coordinate of touch.
  19354. */
  19355. y: number;
  19356. /**
  19357. * Id of touch. Unique for each finger.
  19358. */
  19359. pointerId: number;
  19360. /**
  19361. * Event type passed from DOM.
  19362. */
  19363. type: any;
  19364. }
  19365. }
  19366. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19367. import { Observable } from "babylonjs/Misc/observable";
  19368. import { Nullable } from "babylonjs/types";
  19369. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19370. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19371. /**
  19372. * Manage the mouse inputs to control the movement of a free camera.
  19373. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19374. */
  19375. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19376. /**
  19377. * Define if touch is enabled in the mouse input
  19378. */
  19379. touchEnabled: boolean;
  19380. /**
  19381. * Defines the camera the input is attached to.
  19382. */
  19383. camera: FreeCamera;
  19384. /**
  19385. * Defines the buttons associated with the input to handle camera move.
  19386. */
  19387. buttons: number[];
  19388. /**
  19389. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19390. */
  19391. angularSensibility: number;
  19392. private _pointerInput;
  19393. private _onMouseMove;
  19394. private _observer;
  19395. private previousPosition;
  19396. /**
  19397. * Observable for when a pointer move event occurs containing the move offset
  19398. */
  19399. onPointerMovedObservable: Observable<{
  19400. offsetX: number;
  19401. offsetY: number;
  19402. }>;
  19403. /**
  19404. * @hidden
  19405. * If the camera should be rotated automatically based on pointer movement
  19406. */
  19407. _allowCameraRotation: boolean;
  19408. /**
  19409. * Manage the mouse inputs to control the movement of a free camera.
  19410. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19411. * @param touchEnabled Defines if touch is enabled or not
  19412. */
  19413. constructor(
  19414. /**
  19415. * Define if touch is enabled in the mouse input
  19416. */
  19417. touchEnabled?: boolean);
  19418. /**
  19419. * Attach the input controls to a specific dom element to get the input from.
  19420. * @param element Defines the element the controls should be listened from
  19421. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19422. */
  19423. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19424. /**
  19425. * Called on JS contextmenu event.
  19426. * Override this method to provide functionality.
  19427. */
  19428. protected onContextMenu(evt: PointerEvent): void;
  19429. /**
  19430. * Detach the current controls from the specified dom element.
  19431. * @param element Defines the element to stop listening the inputs from
  19432. */
  19433. detachControl(element: Nullable<HTMLElement>): void;
  19434. /**
  19435. * Gets the class name of the current intput.
  19436. * @returns the class name
  19437. */
  19438. getClassName(): string;
  19439. /**
  19440. * Get the friendly name associated with the input class.
  19441. * @returns the input friendly name
  19442. */
  19443. getSimpleName(): string;
  19444. }
  19445. }
  19446. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19447. import { Nullable } from "babylonjs/types";
  19448. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19449. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19450. /**
  19451. * Manage the touch inputs to control the movement of a free camera.
  19452. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19453. */
  19454. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19455. /**
  19456. * Define if mouse events can be treated as touch events
  19457. */
  19458. allowMouse: boolean;
  19459. /**
  19460. * Defines the camera the input is attached to.
  19461. */
  19462. camera: FreeCamera;
  19463. /**
  19464. * Defines the touch sensibility for rotation.
  19465. * The higher the faster.
  19466. */
  19467. touchAngularSensibility: number;
  19468. /**
  19469. * Defines the touch sensibility for move.
  19470. * The higher the faster.
  19471. */
  19472. touchMoveSensibility: number;
  19473. private _offsetX;
  19474. private _offsetY;
  19475. private _pointerPressed;
  19476. private _pointerInput;
  19477. private _observer;
  19478. private _onLostFocus;
  19479. /**
  19480. * Manage the touch inputs to control the movement of a free camera.
  19481. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19482. * @param allowMouse Defines if mouse events can be treated as touch events
  19483. */
  19484. constructor(
  19485. /**
  19486. * Define if mouse events can be treated as touch events
  19487. */
  19488. allowMouse?: boolean);
  19489. /**
  19490. * Attach the input controls to a specific dom element to get the input from.
  19491. * @param element Defines the element the controls should be listened from
  19492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19493. */
  19494. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19495. /**
  19496. * Detach the current controls from the specified dom element.
  19497. * @param element Defines the element to stop listening the inputs from
  19498. */
  19499. detachControl(element: Nullable<HTMLElement>): void;
  19500. /**
  19501. * Update the current camera state depending on the inputs that have been used this frame.
  19502. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19503. */
  19504. checkInputs(): void;
  19505. /**
  19506. * Gets the class name of the current intput.
  19507. * @returns the class name
  19508. */
  19509. getClassName(): string;
  19510. /**
  19511. * Get the friendly name associated with the input class.
  19512. * @returns the input friendly name
  19513. */
  19514. getSimpleName(): string;
  19515. }
  19516. }
  19517. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19518. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19519. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19520. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19521. import { Nullable } from "babylonjs/types";
  19522. /**
  19523. * Default Inputs manager for the FreeCamera.
  19524. * It groups all the default supported inputs for ease of use.
  19525. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19526. */
  19527. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19528. /**
  19529. * @hidden
  19530. */
  19531. _mouseInput: Nullable<FreeCameraMouseInput>;
  19532. /**
  19533. * Instantiates a new FreeCameraInputsManager.
  19534. * @param camera Defines the camera the inputs belong to
  19535. */
  19536. constructor(camera: FreeCamera);
  19537. /**
  19538. * Add keyboard input support to the input manager.
  19539. * @returns the current input manager
  19540. */
  19541. addKeyboard(): FreeCameraInputsManager;
  19542. /**
  19543. * Add mouse input support to the input manager.
  19544. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19545. * @returns the current input manager
  19546. */
  19547. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19548. /**
  19549. * Removes the mouse input support from the manager
  19550. * @returns the current input manager
  19551. */
  19552. removeMouse(): FreeCameraInputsManager;
  19553. /**
  19554. * Add touch input support to the input manager.
  19555. * @returns the current input manager
  19556. */
  19557. addTouch(): FreeCameraInputsManager;
  19558. /**
  19559. * Remove all attached input methods from a camera
  19560. */
  19561. clear(): void;
  19562. }
  19563. }
  19564. declare module "babylonjs/Cameras/freeCamera" {
  19565. import { Vector3 } from "babylonjs/Maths/math.vector";
  19566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19567. import { Scene } from "babylonjs/scene";
  19568. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19569. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19570. /**
  19571. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19572. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19573. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19574. */
  19575. export class FreeCamera extends TargetCamera {
  19576. /**
  19577. * Define the collision ellipsoid of the camera.
  19578. * This is helpful to simulate a camera body like the player body around the camera
  19579. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19580. */
  19581. ellipsoid: Vector3;
  19582. /**
  19583. * Define an offset for the position of the ellipsoid around the camera.
  19584. * This can be helpful to determine the center of the body near the gravity center of the body
  19585. * instead of its head.
  19586. */
  19587. ellipsoidOffset: Vector3;
  19588. /**
  19589. * Enable or disable collisions of the camera with the rest of the scene objects.
  19590. */
  19591. checkCollisions: boolean;
  19592. /**
  19593. * Enable or disable gravity on the camera.
  19594. */
  19595. applyGravity: boolean;
  19596. /**
  19597. * Define the input manager associated to the camera.
  19598. */
  19599. inputs: FreeCameraInputsManager;
  19600. /**
  19601. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19602. * Higher values reduce sensitivity.
  19603. */
  19604. get angularSensibility(): number;
  19605. /**
  19606. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19607. * Higher values reduce sensitivity.
  19608. */
  19609. set angularSensibility(value: number);
  19610. /**
  19611. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19612. */
  19613. get keysUp(): number[];
  19614. set keysUp(value: number[]);
  19615. /**
  19616. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19617. */
  19618. get keysUpward(): number[];
  19619. set keysUpward(value: number[]);
  19620. /**
  19621. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19622. */
  19623. get keysDown(): number[];
  19624. set keysDown(value: number[]);
  19625. /**
  19626. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19627. */
  19628. get keysDownward(): number[];
  19629. set keysDownward(value: number[]);
  19630. /**
  19631. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19632. */
  19633. get keysLeft(): number[];
  19634. set keysLeft(value: number[]);
  19635. /**
  19636. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19637. */
  19638. get keysRight(): number[];
  19639. set keysRight(value: number[]);
  19640. /**
  19641. * Event raised when the camera collide with a mesh in the scene.
  19642. */
  19643. onCollide: (collidedMesh: AbstractMesh) => void;
  19644. private _collider;
  19645. private _needMoveForGravity;
  19646. private _oldPosition;
  19647. private _diffPosition;
  19648. private _newPosition;
  19649. /** @hidden */
  19650. _localDirection: Vector3;
  19651. /** @hidden */
  19652. _transformedDirection: Vector3;
  19653. /**
  19654. * Instantiates a Free Camera.
  19655. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19656. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19657. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19658. * @param name Define the name of the camera in the scene
  19659. * @param position Define the start position of the camera in the scene
  19660. * @param scene Define the scene the camera belongs to
  19661. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19662. */
  19663. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19664. /**
  19665. * Attached controls to the current camera.
  19666. * @param element Defines the element the controls should be listened from
  19667. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19668. */
  19669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19670. /**
  19671. * Detach the current controls from the camera.
  19672. * The camera will stop reacting to inputs.
  19673. * @param element Defines the element to stop listening the inputs from
  19674. */
  19675. detachControl(element: HTMLElement): void;
  19676. private _collisionMask;
  19677. /**
  19678. * Define a collision mask to limit the list of object the camera can collide with
  19679. */
  19680. get collisionMask(): number;
  19681. set collisionMask(mask: number);
  19682. /** @hidden */
  19683. _collideWithWorld(displacement: Vector3): void;
  19684. private _onCollisionPositionChange;
  19685. /** @hidden */
  19686. _checkInputs(): void;
  19687. /** @hidden */
  19688. _decideIfNeedsToMove(): boolean;
  19689. /** @hidden */
  19690. _updatePosition(): void;
  19691. /**
  19692. * Destroy the camera and release the current resources hold by it.
  19693. */
  19694. dispose(): void;
  19695. /**
  19696. * Gets the current object class name.
  19697. * @return the class name
  19698. */
  19699. getClassName(): string;
  19700. }
  19701. }
  19702. declare module "babylonjs/Gamepads/gamepad" {
  19703. import { Observable } from "babylonjs/Misc/observable";
  19704. /**
  19705. * Represents a gamepad control stick position
  19706. */
  19707. export class StickValues {
  19708. /**
  19709. * The x component of the control stick
  19710. */
  19711. x: number;
  19712. /**
  19713. * The y component of the control stick
  19714. */
  19715. y: number;
  19716. /**
  19717. * Initializes the gamepad x and y control stick values
  19718. * @param x The x component of the gamepad control stick value
  19719. * @param y The y component of the gamepad control stick value
  19720. */
  19721. constructor(
  19722. /**
  19723. * The x component of the control stick
  19724. */
  19725. x: number,
  19726. /**
  19727. * The y component of the control stick
  19728. */
  19729. y: number);
  19730. }
  19731. /**
  19732. * An interface which manages callbacks for gamepad button changes
  19733. */
  19734. export interface GamepadButtonChanges {
  19735. /**
  19736. * Called when a gamepad has been changed
  19737. */
  19738. changed: boolean;
  19739. /**
  19740. * Called when a gamepad press event has been triggered
  19741. */
  19742. pressChanged: boolean;
  19743. /**
  19744. * Called when a touch event has been triggered
  19745. */
  19746. touchChanged: boolean;
  19747. /**
  19748. * Called when a value has changed
  19749. */
  19750. valueChanged: boolean;
  19751. }
  19752. /**
  19753. * Represents a gamepad
  19754. */
  19755. export class Gamepad {
  19756. /**
  19757. * The id of the gamepad
  19758. */
  19759. id: string;
  19760. /**
  19761. * The index of the gamepad
  19762. */
  19763. index: number;
  19764. /**
  19765. * The browser gamepad
  19766. */
  19767. browserGamepad: any;
  19768. /**
  19769. * Specifies what type of gamepad this represents
  19770. */
  19771. type: number;
  19772. private _leftStick;
  19773. private _rightStick;
  19774. /** @hidden */
  19775. _isConnected: boolean;
  19776. private _leftStickAxisX;
  19777. private _leftStickAxisY;
  19778. private _rightStickAxisX;
  19779. private _rightStickAxisY;
  19780. /**
  19781. * Triggered when the left control stick has been changed
  19782. */
  19783. private _onleftstickchanged;
  19784. /**
  19785. * Triggered when the right control stick has been changed
  19786. */
  19787. private _onrightstickchanged;
  19788. /**
  19789. * Represents a gamepad controller
  19790. */
  19791. static GAMEPAD: number;
  19792. /**
  19793. * Represents a generic controller
  19794. */
  19795. static GENERIC: number;
  19796. /**
  19797. * Represents an XBox controller
  19798. */
  19799. static XBOX: number;
  19800. /**
  19801. * Represents a pose-enabled controller
  19802. */
  19803. static POSE_ENABLED: number;
  19804. /**
  19805. * Represents an Dual Shock controller
  19806. */
  19807. static DUALSHOCK: number;
  19808. /**
  19809. * Specifies whether the left control stick should be Y-inverted
  19810. */
  19811. protected _invertLeftStickY: boolean;
  19812. /**
  19813. * Specifies if the gamepad has been connected
  19814. */
  19815. get isConnected(): boolean;
  19816. /**
  19817. * Initializes the gamepad
  19818. * @param id The id of the gamepad
  19819. * @param index The index of the gamepad
  19820. * @param browserGamepad The browser gamepad
  19821. * @param leftStickX The x component of the left joystick
  19822. * @param leftStickY The y component of the left joystick
  19823. * @param rightStickX The x component of the right joystick
  19824. * @param rightStickY The y component of the right joystick
  19825. */
  19826. constructor(
  19827. /**
  19828. * The id of the gamepad
  19829. */
  19830. id: string,
  19831. /**
  19832. * The index of the gamepad
  19833. */
  19834. index: number,
  19835. /**
  19836. * The browser gamepad
  19837. */
  19838. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19839. /**
  19840. * Callback triggered when the left joystick has changed
  19841. * @param callback
  19842. */
  19843. onleftstickchanged(callback: (values: StickValues) => void): void;
  19844. /**
  19845. * Callback triggered when the right joystick has changed
  19846. * @param callback
  19847. */
  19848. onrightstickchanged(callback: (values: StickValues) => void): void;
  19849. /**
  19850. * Gets the left joystick
  19851. */
  19852. get leftStick(): StickValues;
  19853. /**
  19854. * Sets the left joystick values
  19855. */
  19856. set leftStick(newValues: StickValues);
  19857. /**
  19858. * Gets the right joystick
  19859. */
  19860. get rightStick(): StickValues;
  19861. /**
  19862. * Sets the right joystick value
  19863. */
  19864. set rightStick(newValues: StickValues);
  19865. /**
  19866. * Updates the gamepad joystick positions
  19867. */
  19868. update(): void;
  19869. /**
  19870. * Disposes the gamepad
  19871. */
  19872. dispose(): void;
  19873. }
  19874. /**
  19875. * Represents a generic gamepad
  19876. */
  19877. export class GenericPad extends Gamepad {
  19878. private _buttons;
  19879. private _onbuttondown;
  19880. private _onbuttonup;
  19881. /**
  19882. * Observable triggered when a button has been pressed
  19883. */
  19884. onButtonDownObservable: Observable<number>;
  19885. /**
  19886. * Observable triggered when a button has been released
  19887. */
  19888. onButtonUpObservable: Observable<number>;
  19889. /**
  19890. * Callback triggered when a button has been pressed
  19891. * @param callback Called when a button has been pressed
  19892. */
  19893. onbuttondown(callback: (buttonPressed: number) => void): void;
  19894. /**
  19895. * Callback triggered when a button has been released
  19896. * @param callback Called when a button has been released
  19897. */
  19898. onbuttonup(callback: (buttonReleased: number) => void): void;
  19899. /**
  19900. * Initializes the generic gamepad
  19901. * @param id The id of the generic gamepad
  19902. * @param index The index of the generic gamepad
  19903. * @param browserGamepad The browser gamepad
  19904. */
  19905. constructor(id: string, index: number, browserGamepad: any);
  19906. private _setButtonValue;
  19907. /**
  19908. * Updates the generic gamepad
  19909. */
  19910. update(): void;
  19911. /**
  19912. * Disposes the generic gamepad
  19913. */
  19914. dispose(): void;
  19915. }
  19916. }
  19917. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19918. import { Observable } from "babylonjs/Misc/observable";
  19919. import { Nullable } from "babylonjs/types";
  19920. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19921. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19923. import { Ray } from "babylonjs/Culling/ray";
  19924. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19925. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19926. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19927. /**
  19928. * Defines the types of pose enabled controllers that are supported
  19929. */
  19930. export enum PoseEnabledControllerType {
  19931. /**
  19932. * HTC Vive
  19933. */
  19934. VIVE = 0,
  19935. /**
  19936. * Oculus Rift
  19937. */
  19938. OCULUS = 1,
  19939. /**
  19940. * Windows mixed reality
  19941. */
  19942. WINDOWS = 2,
  19943. /**
  19944. * Samsung gear VR
  19945. */
  19946. GEAR_VR = 3,
  19947. /**
  19948. * Google Daydream
  19949. */
  19950. DAYDREAM = 4,
  19951. /**
  19952. * Generic
  19953. */
  19954. GENERIC = 5
  19955. }
  19956. /**
  19957. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19958. */
  19959. export interface MutableGamepadButton {
  19960. /**
  19961. * Value of the button/trigger
  19962. */
  19963. value: number;
  19964. /**
  19965. * If the button/trigger is currently touched
  19966. */
  19967. touched: boolean;
  19968. /**
  19969. * If the button/trigger is currently pressed
  19970. */
  19971. pressed: boolean;
  19972. }
  19973. /**
  19974. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19975. * @hidden
  19976. */
  19977. export interface ExtendedGamepadButton extends GamepadButton {
  19978. /**
  19979. * If the button/trigger is currently pressed
  19980. */
  19981. readonly pressed: boolean;
  19982. /**
  19983. * If the button/trigger is currently touched
  19984. */
  19985. readonly touched: boolean;
  19986. /**
  19987. * Value of the button/trigger
  19988. */
  19989. readonly value: number;
  19990. }
  19991. /** @hidden */
  19992. export interface _GamePadFactory {
  19993. /**
  19994. * Returns whether or not the current gamepad can be created for this type of controller.
  19995. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19996. * @returns true if it can be created, otherwise false
  19997. */
  19998. canCreate(gamepadInfo: any): boolean;
  19999. /**
  20000. * Creates a new instance of the Gamepad.
  20001. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20002. * @returns the new gamepad instance
  20003. */
  20004. create(gamepadInfo: any): Gamepad;
  20005. }
  20006. /**
  20007. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20008. */
  20009. export class PoseEnabledControllerHelper {
  20010. /** @hidden */
  20011. static _ControllerFactories: _GamePadFactory[];
  20012. /** @hidden */
  20013. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20014. /**
  20015. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20016. * @param vrGamepad the gamepad to initialized
  20017. * @returns a vr controller of the type the gamepad identified as
  20018. */
  20019. static InitiateController(vrGamepad: any): Gamepad;
  20020. }
  20021. /**
  20022. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20023. */
  20024. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20025. /**
  20026. * If the controller is used in a webXR session
  20027. */
  20028. isXR: boolean;
  20029. private _deviceRoomPosition;
  20030. private _deviceRoomRotationQuaternion;
  20031. /**
  20032. * The device position in babylon space
  20033. */
  20034. devicePosition: Vector3;
  20035. /**
  20036. * The device rotation in babylon space
  20037. */
  20038. deviceRotationQuaternion: Quaternion;
  20039. /**
  20040. * The scale factor of the device in babylon space
  20041. */
  20042. deviceScaleFactor: number;
  20043. /**
  20044. * (Likely devicePosition should be used instead) The device position in its room space
  20045. */
  20046. position: Vector3;
  20047. /**
  20048. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20049. */
  20050. rotationQuaternion: Quaternion;
  20051. /**
  20052. * The type of controller (Eg. Windows mixed reality)
  20053. */
  20054. controllerType: PoseEnabledControllerType;
  20055. protected _calculatedPosition: Vector3;
  20056. private _calculatedRotation;
  20057. /**
  20058. * The raw pose from the device
  20059. */
  20060. rawPose: DevicePose;
  20061. private _trackPosition;
  20062. private _maxRotationDistFromHeadset;
  20063. private _draggedRoomRotation;
  20064. /**
  20065. * @hidden
  20066. */
  20067. _disableTrackPosition(fixedPosition: Vector3): void;
  20068. /**
  20069. * Internal, the mesh attached to the controller
  20070. * @hidden
  20071. */
  20072. _mesh: Nullable<AbstractMesh>;
  20073. private _poseControlledCamera;
  20074. private _leftHandSystemQuaternion;
  20075. /**
  20076. * Internal, matrix used to convert room space to babylon space
  20077. * @hidden
  20078. */
  20079. _deviceToWorld: Matrix;
  20080. /**
  20081. * Node to be used when casting a ray from the controller
  20082. * @hidden
  20083. */
  20084. _pointingPoseNode: Nullable<TransformNode>;
  20085. /**
  20086. * Name of the child mesh that can be used to cast a ray from the controller
  20087. */
  20088. static readonly POINTING_POSE: string;
  20089. /**
  20090. * Creates a new PoseEnabledController from a gamepad
  20091. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20092. */
  20093. constructor(browserGamepad: any);
  20094. private _workingMatrix;
  20095. /**
  20096. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20097. */
  20098. update(): void;
  20099. /**
  20100. * Updates only the pose device and mesh without doing any button event checking
  20101. */
  20102. protected _updatePoseAndMesh(): void;
  20103. /**
  20104. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20105. * @param poseData raw pose fromthe device
  20106. */
  20107. updateFromDevice(poseData: DevicePose): void;
  20108. /**
  20109. * @hidden
  20110. */
  20111. _meshAttachedObservable: Observable<AbstractMesh>;
  20112. /**
  20113. * Attaches a mesh to the controller
  20114. * @param mesh the mesh to be attached
  20115. */
  20116. attachToMesh(mesh: AbstractMesh): void;
  20117. /**
  20118. * Attaches the controllers mesh to a camera
  20119. * @param camera the camera the mesh should be attached to
  20120. */
  20121. attachToPoseControlledCamera(camera: TargetCamera): void;
  20122. /**
  20123. * Disposes of the controller
  20124. */
  20125. dispose(): void;
  20126. /**
  20127. * The mesh that is attached to the controller
  20128. */
  20129. get mesh(): Nullable<AbstractMesh>;
  20130. /**
  20131. * Gets the ray of the controller in the direction the controller is pointing
  20132. * @param length the length the resulting ray should be
  20133. * @returns a ray in the direction the controller is pointing
  20134. */
  20135. getForwardRay(length?: number): Ray;
  20136. }
  20137. }
  20138. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20139. import { Observable } from "babylonjs/Misc/observable";
  20140. import { Scene } from "babylonjs/scene";
  20141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20142. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20143. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20144. import { Nullable } from "babylonjs/types";
  20145. /**
  20146. * Defines the WebVRController object that represents controllers tracked in 3D space
  20147. */
  20148. export abstract class WebVRController extends PoseEnabledController {
  20149. /**
  20150. * Internal, the default controller model for the controller
  20151. */
  20152. protected _defaultModel: Nullable<AbstractMesh>;
  20153. /**
  20154. * Fired when the trigger state has changed
  20155. */
  20156. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20157. /**
  20158. * Fired when the main button state has changed
  20159. */
  20160. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20161. /**
  20162. * Fired when the secondary button state has changed
  20163. */
  20164. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20165. /**
  20166. * Fired when the pad state has changed
  20167. */
  20168. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20169. /**
  20170. * Fired when controllers stick values have changed
  20171. */
  20172. onPadValuesChangedObservable: Observable<StickValues>;
  20173. /**
  20174. * Array of button availible on the controller
  20175. */
  20176. protected _buttons: Array<MutableGamepadButton>;
  20177. private _onButtonStateChange;
  20178. /**
  20179. * Fired when a controller button's state has changed
  20180. * @param callback the callback containing the button that was modified
  20181. */
  20182. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20183. /**
  20184. * X and Y axis corresponding to the controllers joystick
  20185. */
  20186. pad: StickValues;
  20187. /**
  20188. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20189. */
  20190. hand: string;
  20191. /**
  20192. * The default controller model for the controller
  20193. */
  20194. get defaultModel(): Nullable<AbstractMesh>;
  20195. /**
  20196. * Creates a new WebVRController from a gamepad
  20197. * @param vrGamepad the gamepad that the WebVRController should be created from
  20198. */
  20199. constructor(vrGamepad: any);
  20200. /**
  20201. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20202. */
  20203. update(): void;
  20204. /**
  20205. * Function to be called when a button is modified
  20206. */
  20207. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20208. /**
  20209. * Loads a mesh and attaches it to the controller
  20210. * @param scene the scene the mesh should be added to
  20211. * @param meshLoaded callback for when the mesh has been loaded
  20212. */
  20213. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20214. private _setButtonValue;
  20215. private _changes;
  20216. private _checkChanges;
  20217. /**
  20218. * Disposes of th webVRCOntroller
  20219. */
  20220. dispose(): void;
  20221. }
  20222. }
  20223. declare module "babylonjs/Lights/hemisphericLight" {
  20224. import { Nullable } from "babylonjs/types";
  20225. import { Scene } from "babylonjs/scene";
  20226. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20227. import { Color3 } from "babylonjs/Maths/math.color";
  20228. import { Effect } from "babylonjs/Materials/effect";
  20229. import { Light } from "babylonjs/Lights/light";
  20230. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20231. /**
  20232. * The HemisphericLight simulates the ambient environment light,
  20233. * so the passed direction is the light reflection direction, not the incoming direction.
  20234. */
  20235. export class HemisphericLight extends Light {
  20236. /**
  20237. * The groundColor is the light in the opposite direction to the one specified during creation.
  20238. * 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.
  20239. */
  20240. groundColor: Color3;
  20241. /**
  20242. * The light reflection direction, not the incoming direction.
  20243. */
  20244. direction: Vector3;
  20245. /**
  20246. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20247. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20248. * The HemisphericLight can't cast shadows.
  20249. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20250. * @param name The friendly name of the light
  20251. * @param direction The direction of the light reflection
  20252. * @param scene The scene the light belongs to
  20253. */
  20254. constructor(name: string, direction: Vector3, scene: Scene);
  20255. protected _buildUniformLayout(): void;
  20256. /**
  20257. * Returns the string "HemisphericLight".
  20258. * @return The class name
  20259. */
  20260. getClassName(): string;
  20261. /**
  20262. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20263. * Returns the updated direction.
  20264. * @param target The target the direction should point to
  20265. * @return The computed direction
  20266. */
  20267. setDirectionToTarget(target: Vector3): Vector3;
  20268. /**
  20269. * Returns the shadow generator associated to the light.
  20270. * @returns Always null for hemispheric lights because it does not support shadows.
  20271. */
  20272. getShadowGenerator(): Nullable<IShadowGenerator>;
  20273. /**
  20274. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20275. * @param effect The effect to update
  20276. * @param lightIndex The index of the light in the effect to update
  20277. * @returns The hemispheric light
  20278. */
  20279. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20280. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20281. /**
  20282. * Computes the world matrix of the node
  20283. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20284. * @param useWasUpdatedFlag defines a reserved property
  20285. * @returns the world matrix
  20286. */
  20287. computeWorldMatrix(): Matrix;
  20288. /**
  20289. * Returns the integer 3.
  20290. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20291. */
  20292. getTypeID(): number;
  20293. /**
  20294. * Prepares the list of defines specific to the light type.
  20295. * @param defines the list of defines
  20296. * @param lightIndex defines the index of the light for the effect
  20297. */
  20298. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20299. }
  20300. }
  20301. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20302. /** @hidden */
  20303. export var vrMultiviewToSingleviewPixelShader: {
  20304. name: string;
  20305. shader: string;
  20306. };
  20307. }
  20308. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20309. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20310. import { Scene } from "babylonjs/scene";
  20311. /**
  20312. * Renders to multiple views with a single draw call
  20313. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20314. */
  20315. export class MultiviewRenderTarget extends RenderTargetTexture {
  20316. /**
  20317. * Creates a multiview render target
  20318. * @param scene scene used with the render target
  20319. * @param size the size of the render target (used for each view)
  20320. */
  20321. constructor(scene: Scene, size?: number | {
  20322. width: number;
  20323. height: number;
  20324. } | {
  20325. ratio: number;
  20326. });
  20327. /**
  20328. * @hidden
  20329. * @param faceIndex the face index, if its a cube texture
  20330. */
  20331. _bindFrameBuffer(faceIndex?: number): void;
  20332. /**
  20333. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20334. * @returns the view count
  20335. */
  20336. getViewCount(): number;
  20337. }
  20338. }
  20339. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20340. import { Camera } from "babylonjs/Cameras/camera";
  20341. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20342. import { Nullable } from "babylonjs/types";
  20343. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20344. import { Matrix } from "babylonjs/Maths/math.vector";
  20345. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20346. module "babylonjs/Engines/engine" {
  20347. interface Engine {
  20348. /**
  20349. * Creates a new multiview render target
  20350. * @param width defines the width of the texture
  20351. * @param height defines the height of the texture
  20352. * @returns the created multiview texture
  20353. */
  20354. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20355. /**
  20356. * Binds a multiview framebuffer to be drawn to
  20357. * @param multiviewTexture texture to bind
  20358. */
  20359. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20360. }
  20361. }
  20362. module "babylonjs/Cameras/camera" {
  20363. interface Camera {
  20364. /**
  20365. * @hidden
  20366. * 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)
  20367. */
  20368. _useMultiviewToSingleView: boolean;
  20369. /**
  20370. * @hidden
  20371. * 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)
  20372. */
  20373. _multiviewTexture: Nullable<RenderTargetTexture>;
  20374. /**
  20375. * @hidden
  20376. * ensures the multiview texture of the camera exists and has the specified width/height
  20377. * @param width height to set on the multiview texture
  20378. * @param height width to set on the multiview texture
  20379. */
  20380. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20381. }
  20382. }
  20383. module "babylonjs/scene" {
  20384. interface Scene {
  20385. /** @hidden */
  20386. _transformMatrixR: Matrix;
  20387. /** @hidden */
  20388. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20389. /** @hidden */
  20390. _createMultiviewUbo(): void;
  20391. /** @hidden */
  20392. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20393. /** @hidden */
  20394. _renderMultiviewToSingleView(camera: Camera): void;
  20395. }
  20396. }
  20397. }
  20398. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20399. import { Camera } from "babylonjs/Cameras/camera";
  20400. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20401. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20402. import "babylonjs/Engines/Extensions/engine.multiview";
  20403. /**
  20404. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20405. * This will not be used for webXR as it supports displaying texture arrays directly
  20406. */
  20407. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20408. /**
  20409. * Gets a string identifying the name of the class
  20410. * @returns "VRMultiviewToSingleviewPostProcess" string
  20411. */
  20412. getClassName(): string;
  20413. /**
  20414. * Initializes a VRMultiviewToSingleview
  20415. * @param name name of the post process
  20416. * @param camera camera to be applied to
  20417. * @param scaleFactor scaling factor to the size of the output texture
  20418. */
  20419. constructor(name: string, camera: Camera, scaleFactor: number);
  20420. }
  20421. }
  20422. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20423. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20424. import { Nullable } from "babylonjs/types";
  20425. import { Size } from "babylonjs/Maths/math.size";
  20426. import { Observable } from "babylonjs/Misc/observable";
  20427. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20428. /**
  20429. * Interface used to define additional presentation attributes
  20430. */
  20431. export interface IVRPresentationAttributes {
  20432. /**
  20433. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20434. */
  20435. highRefreshRate: boolean;
  20436. /**
  20437. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20438. */
  20439. foveationLevel: number;
  20440. }
  20441. module "babylonjs/Engines/engine" {
  20442. interface Engine {
  20443. /** @hidden */
  20444. _vrDisplay: any;
  20445. /** @hidden */
  20446. _vrSupported: boolean;
  20447. /** @hidden */
  20448. _oldSize: Size;
  20449. /** @hidden */
  20450. _oldHardwareScaleFactor: number;
  20451. /** @hidden */
  20452. _vrExclusivePointerMode: boolean;
  20453. /** @hidden */
  20454. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20455. /** @hidden */
  20456. _onVRDisplayPointerRestricted: () => void;
  20457. /** @hidden */
  20458. _onVRDisplayPointerUnrestricted: () => void;
  20459. /** @hidden */
  20460. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20461. /** @hidden */
  20462. _onVrDisplayDisconnect: Nullable<() => void>;
  20463. /** @hidden */
  20464. _onVrDisplayPresentChange: Nullable<() => void>;
  20465. /**
  20466. * Observable signaled when VR display mode changes
  20467. */
  20468. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20469. /**
  20470. * Observable signaled when VR request present is complete
  20471. */
  20472. onVRRequestPresentComplete: Observable<boolean>;
  20473. /**
  20474. * Observable signaled when VR request present starts
  20475. */
  20476. onVRRequestPresentStart: Observable<Engine>;
  20477. /**
  20478. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20479. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20480. */
  20481. isInVRExclusivePointerMode: boolean;
  20482. /**
  20483. * Gets a boolean indicating if a webVR device was detected
  20484. * @returns true if a webVR device was detected
  20485. */
  20486. isVRDevicePresent(): boolean;
  20487. /**
  20488. * Gets the current webVR device
  20489. * @returns the current webVR device (or null)
  20490. */
  20491. getVRDevice(): any;
  20492. /**
  20493. * Initializes a webVR display and starts listening to display change events
  20494. * The onVRDisplayChangedObservable will be notified upon these changes
  20495. * @returns A promise containing a VRDisplay and if vr is supported
  20496. */
  20497. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20498. /** @hidden */
  20499. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20500. /**
  20501. * Gets or sets the presentation attributes used to configure VR rendering
  20502. */
  20503. vrPresentationAttributes?: IVRPresentationAttributes;
  20504. /**
  20505. * Call this function to switch to webVR mode
  20506. * Will do nothing if webVR is not supported or if there is no webVR device
  20507. * @param options the webvr options provided to the camera. mainly used for multiview
  20508. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20509. */
  20510. enableVR(options: WebVROptions): void;
  20511. /** @hidden */
  20512. _onVRFullScreenTriggered(): void;
  20513. }
  20514. }
  20515. }
  20516. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20517. import { Nullable } from "babylonjs/types";
  20518. import { Observable } from "babylonjs/Misc/observable";
  20519. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20520. import { Scene } from "babylonjs/scene";
  20521. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20522. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20523. import { Node } from "babylonjs/node";
  20524. import { Ray } from "babylonjs/Culling/ray";
  20525. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20526. import "babylonjs/Engines/Extensions/engine.webVR";
  20527. /**
  20528. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20529. * IMPORTANT!! The data is right-hand data.
  20530. * @export
  20531. * @interface DevicePose
  20532. */
  20533. export interface DevicePose {
  20534. /**
  20535. * The position of the device, values in array are [x,y,z].
  20536. */
  20537. readonly position: Nullable<Float32Array>;
  20538. /**
  20539. * The linearVelocity of the device, values in array are [x,y,z].
  20540. */
  20541. readonly linearVelocity: Nullable<Float32Array>;
  20542. /**
  20543. * The linearAcceleration of the device, values in array are [x,y,z].
  20544. */
  20545. readonly linearAcceleration: Nullable<Float32Array>;
  20546. /**
  20547. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20548. */
  20549. readonly orientation: Nullable<Float32Array>;
  20550. /**
  20551. * The angularVelocity of the device, values in array are [x,y,z].
  20552. */
  20553. readonly angularVelocity: Nullable<Float32Array>;
  20554. /**
  20555. * The angularAcceleration of the device, values in array are [x,y,z].
  20556. */
  20557. readonly angularAcceleration: Nullable<Float32Array>;
  20558. }
  20559. /**
  20560. * Interface representing a pose controlled object in Babylon.
  20561. * A pose controlled object has both regular pose values as well as pose values
  20562. * from an external device such as a VR head mounted display
  20563. */
  20564. export interface PoseControlled {
  20565. /**
  20566. * The position of the object in babylon space.
  20567. */
  20568. position: Vector3;
  20569. /**
  20570. * The rotation quaternion of the object in babylon space.
  20571. */
  20572. rotationQuaternion: Quaternion;
  20573. /**
  20574. * The position of the device in babylon space.
  20575. */
  20576. devicePosition?: Vector3;
  20577. /**
  20578. * The rotation quaternion of the device in babylon space.
  20579. */
  20580. deviceRotationQuaternion: Quaternion;
  20581. /**
  20582. * The raw pose coming from the device.
  20583. */
  20584. rawPose: Nullable<DevicePose>;
  20585. /**
  20586. * The scale of the device to be used when translating from device space to babylon space.
  20587. */
  20588. deviceScaleFactor: number;
  20589. /**
  20590. * Updates the poseControlled values based on the input device pose.
  20591. * @param poseData the pose data to update the object with
  20592. */
  20593. updateFromDevice(poseData: DevicePose): void;
  20594. }
  20595. /**
  20596. * Set of options to customize the webVRCamera
  20597. */
  20598. export interface WebVROptions {
  20599. /**
  20600. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20601. */
  20602. trackPosition?: boolean;
  20603. /**
  20604. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20605. */
  20606. positionScale?: number;
  20607. /**
  20608. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20609. */
  20610. displayName?: string;
  20611. /**
  20612. * Should the native controller meshes be initialized. (default: true)
  20613. */
  20614. controllerMeshes?: boolean;
  20615. /**
  20616. * Creating a default HemiLight only on controllers. (default: true)
  20617. */
  20618. defaultLightingOnControllers?: boolean;
  20619. /**
  20620. * If you don't want to use the default VR button of the helper. (default: false)
  20621. */
  20622. useCustomVRButton?: boolean;
  20623. /**
  20624. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20625. */
  20626. customVRButton?: HTMLButtonElement;
  20627. /**
  20628. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20629. */
  20630. rayLength?: number;
  20631. /**
  20632. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20633. */
  20634. defaultHeight?: number;
  20635. /**
  20636. * If multiview should be used if availible (default: false)
  20637. */
  20638. useMultiview?: boolean;
  20639. }
  20640. /**
  20641. * This represents a WebVR camera.
  20642. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20643. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20644. */
  20645. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20646. private webVROptions;
  20647. /**
  20648. * @hidden
  20649. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20650. */
  20651. _vrDevice: any;
  20652. /**
  20653. * The rawPose of the vrDevice.
  20654. */
  20655. rawPose: Nullable<DevicePose>;
  20656. private _onVREnabled;
  20657. private _specsVersion;
  20658. private _attached;
  20659. private _frameData;
  20660. protected _descendants: Array<Node>;
  20661. private _deviceRoomPosition;
  20662. /** @hidden */
  20663. _deviceRoomRotationQuaternion: Quaternion;
  20664. private _standingMatrix;
  20665. /**
  20666. * Represents device position in babylon space.
  20667. */
  20668. devicePosition: Vector3;
  20669. /**
  20670. * Represents device rotation in babylon space.
  20671. */
  20672. deviceRotationQuaternion: Quaternion;
  20673. /**
  20674. * The scale of the device to be used when translating from device space to babylon space.
  20675. */
  20676. deviceScaleFactor: number;
  20677. private _deviceToWorld;
  20678. private _worldToDevice;
  20679. /**
  20680. * References to the webVR controllers for the vrDevice.
  20681. */
  20682. controllers: Array<WebVRController>;
  20683. /**
  20684. * Emits an event when a controller is attached.
  20685. */
  20686. onControllersAttachedObservable: Observable<WebVRController[]>;
  20687. /**
  20688. * Emits an event when a controller's mesh has been loaded;
  20689. */
  20690. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20691. /**
  20692. * Emits an event when the HMD's pose has been updated.
  20693. */
  20694. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20695. private _poseSet;
  20696. /**
  20697. * If the rig cameras be used as parent instead of this camera.
  20698. */
  20699. rigParenting: boolean;
  20700. private _lightOnControllers;
  20701. private _defaultHeight?;
  20702. /**
  20703. * Instantiates a WebVRFreeCamera.
  20704. * @param name The name of the WebVRFreeCamera
  20705. * @param position The starting anchor position for the camera
  20706. * @param scene The scene the camera belongs to
  20707. * @param webVROptions a set of customizable options for the webVRCamera
  20708. */
  20709. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20710. /**
  20711. * Gets the device distance from the ground in meters.
  20712. * @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.
  20713. */
  20714. deviceDistanceToRoomGround(): number;
  20715. /**
  20716. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20717. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20718. */
  20719. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20720. /**
  20721. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20722. * @returns A promise with a boolean set to if the standing matrix is supported.
  20723. */
  20724. useStandingMatrixAsync(): Promise<boolean>;
  20725. /**
  20726. * Disposes the camera
  20727. */
  20728. dispose(): void;
  20729. /**
  20730. * Gets a vrController by name.
  20731. * @param name The name of the controller to retreive
  20732. * @returns the controller matching the name specified or null if not found
  20733. */
  20734. getControllerByName(name: string): Nullable<WebVRController>;
  20735. private _leftController;
  20736. /**
  20737. * The controller corresponding to the users left hand.
  20738. */
  20739. get leftController(): Nullable<WebVRController>;
  20740. private _rightController;
  20741. /**
  20742. * The controller corresponding to the users right hand.
  20743. */
  20744. get rightController(): Nullable<WebVRController>;
  20745. /**
  20746. * Casts a ray forward from the vrCamera's gaze.
  20747. * @param length Length of the ray (default: 100)
  20748. * @returns the ray corresponding to the gaze
  20749. */
  20750. getForwardRay(length?: number): Ray;
  20751. /**
  20752. * @hidden
  20753. * Updates the camera based on device's frame data
  20754. */
  20755. _checkInputs(): void;
  20756. /**
  20757. * Updates the poseControlled values based on the input device pose.
  20758. * @param poseData Pose coming from the device
  20759. */
  20760. updateFromDevice(poseData: DevicePose): void;
  20761. private _htmlElementAttached;
  20762. private _detachIfAttached;
  20763. /**
  20764. * WebVR's attach control will start broadcasting frames to the device.
  20765. * Note that in certain browsers (chrome for example) this function must be called
  20766. * within a user-interaction callback. Example:
  20767. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20768. *
  20769. * @param element html element to attach the vrDevice to
  20770. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20771. */
  20772. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20773. /**
  20774. * Detaches the camera from the html element and disables VR
  20775. *
  20776. * @param element html element to detach from
  20777. */
  20778. detachControl(element: HTMLElement): void;
  20779. /**
  20780. * @returns the name of this class
  20781. */
  20782. getClassName(): string;
  20783. /**
  20784. * Calls resetPose on the vrDisplay
  20785. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20786. */
  20787. resetToCurrentRotation(): void;
  20788. /**
  20789. * @hidden
  20790. * Updates the rig cameras (left and right eye)
  20791. */
  20792. _updateRigCameras(): void;
  20793. private _workingVector;
  20794. private _oneVector;
  20795. private _workingMatrix;
  20796. private updateCacheCalled;
  20797. private _correctPositionIfNotTrackPosition;
  20798. /**
  20799. * @hidden
  20800. * Updates the cached values of the camera
  20801. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20802. */
  20803. _updateCache(ignoreParentClass?: boolean): void;
  20804. /**
  20805. * @hidden
  20806. * Get current device position in babylon world
  20807. */
  20808. _computeDevicePosition(): void;
  20809. /**
  20810. * Updates the current device position and rotation in the babylon world
  20811. */
  20812. update(): void;
  20813. /**
  20814. * @hidden
  20815. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20816. * @returns an identity matrix
  20817. */
  20818. _getViewMatrix(): Matrix;
  20819. private _tmpMatrix;
  20820. /**
  20821. * This function is called by the two RIG cameras.
  20822. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20823. * @hidden
  20824. */
  20825. _getWebVRViewMatrix(): Matrix;
  20826. /** @hidden */
  20827. _getWebVRProjectionMatrix(): Matrix;
  20828. private _onGamepadConnectedObserver;
  20829. private _onGamepadDisconnectedObserver;
  20830. private _updateCacheWhenTrackingDisabledObserver;
  20831. /**
  20832. * Initializes the controllers and their meshes
  20833. */
  20834. initControllers(): void;
  20835. }
  20836. }
  20837. declare module "babylonjs/Materials/materialHelper" {
  20838. import { Nullable } from "babylonjs/types";
  20839. import { Scene } from "babylonjs/scene";
  20840. import { Engine } from "babylonjs/Engines/engine";
  20841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20842. import { Light } from "babylonjs/Lights/light";
  20843. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20844. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20845. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20846. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20847. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20848. /**
  20849. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20850. *
  20851. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20852. *
  20853. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20854. */
  20855. export class MaterialHelper {
  20856. /**
  20857. * Bind the current view position to an effect.
  20858. * @param effect The effect to be bound
  20859. * @param scene The scene the eyes position is used from
  20860. * @param variableName name of the shader variable that will hold the eye position
  20861. */
  20862. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20863. /**
  20864. * Helps preparing the defines values about the UVs in used in the effect.
  20865. * UVs are shared as much as we can accross channels in the shaders.
  20866. * @param texture The texture we are preparing the UVs for
  20867. * @param defines The defines to update
  20868. * @param key The channel key "diffuse", "specular"... used in the shader
  20869. */
  20870. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20871. /**
  20872. * Binds a texture matrix value to its corrsponding uniform
  20873. * @param texture The texture to bind the matrix for
  20874. * @param uniformBuffer The uniform buffer receivin the data
  20875. * @param key The channel key "diffuse", "specular"... used in the shader
  20876. */
  20877. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20878. /**
  20879. * Gets the current status of the fog (should it be enabled?)
  20880. * @param mesh defines the mesh to evaluate for fog support
  20881. * @param scene defines the hosting scene
  20882. * @returns true if fog must be enabled
  20883. */
  20884. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20885. /**
  20886. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20887. * @param mesh defines the current mesh
  20888. * @param scene defines the current scene
  20889. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20890. * @param pointsCloud defines if point cloud rendering has to be turned on
  20891. * @param fogEnabled defines if fog has to be turned on
  20892. * @param alphaTest defines if alpha testing has to be turned on
  20893. * @param defines defines the current list of defines
  20894. */
  20895. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20896. /**
  20897. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20898. * @param scene defines the current scene
  20899. * @param engine defines the current engine
  20900. * @param defines specifies the list of active defines
  20901. * @param useInstances defines if instances have to be turned on
  20902. * @param useClipPlane defines if clip plane have to be turned on
  20903. * @param useInstances defines if instances have to be turned on
  20904. * @param useThinInstances defines if thin instances have to be turned on
  20905. */
  20906. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20907. /**
  20908. * Prepares the defines for bones
  20909. * @param mesh The mesh containing the geometry data we will draw
  20910. * @param defines The defines to update
  20911. */
  20912. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20913. /**
  20914. * Prepares the defines for morph targets
  20915. * @param mesh The mesh containing the geometry data we will draw
  20916. * @param defines The defines to update
  20917. */
  20918. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20919. /**
  20920. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20921. * @param mesh The mesh containing the geometry data we will draw
  20922. * @param defines The defines to update
  20923. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20924. * @param useBones Precise whether bones should be used or not (override mesh info)
  20925. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20926. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20927. * @returns false if defines are considered not dirty and have not been checked
  20928. */
  20929. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20930. /**
  20931. * Prepares the defines related to multiview
  20932. * @param scene The scene we are intending to draw
  20933. * @param defines The defines to update
  20934. */
  20935. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20936. /**
  20937. * Prepares the defines related to the prepass
  20938. * @param scene The scene we are intending to draw
  20939. * @param defines The defines to update
  20940. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20941. */
  20942. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20943. /**
  20944. * Prepares the defines related to the light information passed in parameter
  20945. * @param scene The scene we are intending to draw
  20946. * @param mesh The mesh the effect is compiling for
  20947. * @param light The light the effect is compiling for
  20948. * @param lightIndex The index of the light
  20949. * @param defines The defines to update
  20950. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20951. * @param state Defines the current state regarding what is needed (normals, etc...)
  20952. */
  20953. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20954. needNormals: boolean;
  20955. needRebuild: boolean;
  20956. shadowEnabled: boolean;
  20957. specularEnabled: boolean;
  20958. lightmapMode: boolean;
  20959. }): void;
  20960. /**
  20961. * Prepares the defines related to the light information passed in parameter
  20962. * @param scene The scene we are intending to draw
  20963. * @param mesh The mesh the effect is compiling for
  20964. * @param defines The defines to update
  20965. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20966. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20967. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20968. * @returns true if normals will be required for the rest of the effect
  20969. */
  20970. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20971. /**
  20972. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20973. * @param lightIndex defines the light index
  20974. * @param uniformsList The uniform list
  20975. * @param samplersList The sampler list
  20976. * @param projectedLightTexture defines if projected texture must be used
  20977. * @param uniformBuffersList defines an optional list of uniform buffers
  20978. */
  20979. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20980. /**
  20981. * Prepares the uniforms and samplers list to be used in the effect
  20982. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20983. * @param samplersList The sampler list
  20984. * @param defines The defines helping in the list generation
  20985. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20986. */
  20987. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20988. /**
  20989. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20990. * @param defines The defines to update while falling back
  20991. * @param fallbacks The authorized effect fallbacks
  20992. * @param maxSimultaneousLights The maximum number of lights allowed
  20993. * @param rank the current rank of the Effect
  20994. * @returns The newly affected rank
  20995. */
  20996. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20997. private static _TmpMorphInfluencers;
  20998. /**
  20999. * Prepares the list of attributes required for morph targets according to the effect defines.
  21000. * @param attribs The current list of supported attribs
  21001. * @param mesh The mesh to prepare the morph targets attributes for
  21002. * @param influencers The number of influencers
  21003. */
  21004. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21005. /**
  21006. * Prepares the list of attributes required for morph targets according to the effect defines.
  21007. * @param attribs The current list of supported attribs
  21008. * @param mesh The mesh to prepare the morph targets attributes for
  21009. * @param defines The current Defines of the effect
  21010. */
  21011. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21012. /**
  21013. * Prepares the list of attributes required for bones according to the effect defines.
  21014. * @param attribs The current list of supported attribs
  21015. * @param mesh The mesh to prepare the bones attributes for
  21016. * @param defines The current Defines of the effect
  21017. * @param fallbacks The current efffect fallback strategy
  21018. */
  21019. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21020. /**
  21021. * Check and prepare the list of attributes required for instances according to the effect defines.
  21022. * @param attribs The current list of supported attribs
  21023. * @param defines The current MaterialDefines of the effect
  21024. */
  21025. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21026. /**
  21027. * Add the list of attributes required for instances to the attribs array.
  21028. * @param attribs The current list of supported attribs
  21029. */
  21030. static PushAttributesForInstances(attribs: string[]): void;
  21031. /**
  21032. * Binds the light information to the effect.
  21033. * @param light The light containing the generator
  21034. * @param effect The effect we are binding the data to
  21035. * @param lightIndex The light index in the effect used to render
  21036. */
  21037. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21038. /**
  21039. * Binds the lights information from the scene to the effect for the given mesh.
  21040. * @param light Light to bind
  21041. * @param lightIndex Light index
  21042. * @param scene The scene where the light belongs to
  21043. * @param effect The effect we are binding the data to
  21044. * @param useSpecular Defines if specular is supported
  21045. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21046. */
  21047. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21048. /**
  21049. * Binds the lights information from the scene to the effect for the given mesh.
  21050. * @param scene The scene the lights belongs to
  21051. * @param mesh The mesh we are binding the information to render
  21052. * @param effect The effect we are binding the data to
  21053. * @param defines The generated defines for the effect
  21054. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21055. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21056. */
  21057. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21058. private static _tempFogColor;
  21059. /**
  21060. * Binds the fog information from the scene to the effect for the given mesh.
  21061. * @param scene The scene the lights belongs to
  21062. * @param mesh The mesh we are binding the information to render
  21063. * @param effect The effect we are binding the data to
  21064. * @param linearSpace Defines if the fog effect is applied in linear space
  21065. */
  21066. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21067. /**
  21068. * Binds the bones information from the mesh to the effect.
  21069. * @param mesh The mesh we are binding the information to render
  21070. * @param effect The effect we are binding the data to
  21071. */
  21072. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  21073. /**
  21074. * Binds the morph targets information from the mesh to the effect.
  21075. * @param abstractMesh The mesh we are binding the information to render
  21076. * @param effect The effect we are binding the data to
  21077. */
  21078. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21079. /**
  21080. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21081. * @param defines The generated defines used in the effect
  21082. * @param effect The effect we are binding the data to
  21083. * @param scene The scene we are willing to render with logarithmic scale for
  21084. */
  21085. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21086. /**
  21087. * Binds the clip plane information from the scene to the effect.
  21088. * @param scene The scene the clip plane information are extracted from
  21089. * @param effect The effect we are binding the data to
  21090. */
  21091. static BindClipPlane(effect: Effect, scene: Scene): void;
  21092. }
  21093. }
  21094. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21095. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21096. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21097. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21098. import { Nullable } from "babylonjs/types";
  21099. import { Effect } from "babylonjs/Materials/effect";
  21100. import { Matrix } from "babylonjs/Maths/math.vector";
  21101. import { Scene } from "babylonjs/scene";
  21102. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21103. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21104. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21105. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21106. import { Observable } from "babylonjs/Misc/observable";
  21107. /**
  21108. * Block used to expose an input value
  21109. */
  21110. export class InputBlock extends NodeMaterialBlock {
  21111. private _mode;
  21112. private _associatedVariableName;
  21113. private _storedValue;
  21114. private _valueCallback;
  21115. private _type;
  21116. private _animationType;
  21117. /** Gets or set a value used to limit the range of float values */
  21118. min: number;
  21119. /** Gets or set a value used to limit the range of float values */
  21120. max: number;
  21121. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21122. isBoolean: boolean;
  21123. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21124. matrixMode: number;
  21125. /** @hidden */
  21126. _systemValue: Nullable<NodeMaterialSystemValues>;
  21127. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21128. isConstant: boolean;
  21129. /** Gets or sets the group to use to display this block in the Inspector */
  21130. groupInInspector: string;
  21131. /** Gets an observable raised when the value is changed */
  21132. onValueChangedObservable: Observable<InputBlock>;
  21133. /**
  21134. * Gets or sets the connection point type (default is float)
  21135. */
  21136. get type(): NodeMaterialBlockConnectionPointTypes;
  21137. /**
  21138. * Creates a new InputBlock
  21139. * @param name defines the block name
  21140. * @param target defines the target of that block (Vertex by default)
  21141. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21142. */
  21143. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21144. /**
  21145. * Validates if a name is a reserve word.
  21146. * @param newName the new name to be given to the node.
  21147. * @returns false if the name is a reserve word, else true.
  21148. */
  21149. validateBlockName(newName: string): boolean;
  21150. /**
  21151. * Gets the output component
  21152. */
  21153. get output(): NodeMaterialConnectionPoint;
  21154. /**
  21155. * Set the source of this connection point to a vertex attribute
  21156. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21157. * @returns the current connection point
  21158. */
  21159. setAsAttribute(attributeName?: string): InputBlock;
  21160. /**
  21161. * Set the source of this connection point to a system value
  21162. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21163. * @returns the current connection point
  21164. */
  21165. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21166. /**
  21167. * Gets or sets the value of that point.
  21168. * Please note that this value will be ignored if valueCallback is defined
  21169. */
  21170. get value(): any;
  21171. set value(value: any);
  21172. /**
  21173. * Gets or sets a callback used to get the value of that point.
  21174. * Please note that setting this value will force the connection point to ignore the value property
  21175. */
  21176. get valueCallback(): () => any;
  21177. set valueCallback(value: () => any);
  21178. /**
  21179. * Gets or sets the associated variable name in the shader
  21180. */
  21181. get associatedVariableName(): string;
  21182. set associatedVariableName(value: string);
  21183. /** Gets or sets the type of animation applied to the input */
  21184. get animationType(): AnimatedInputBlockTypes;
  21185. set animationType(value: AnimatedInputBlockTypes);
  21186. /**
  21187. * Gets a boolean indicating that this connection point not defined yet
  21188. */
  21189. get isUndefined(): boolean;
  21190. /**
  21191. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21192. * In this case the connection point name must be the name of the uniform to use.
  21193. * Can only be set on inputs
  21194. */
  21195. get isUniform(): boolean;
  21196. set isUniform(value: boolean);
  21197. /**
  21198. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21199. * In this case the connection point name must be the name of the attribute to use
  21200. * Can only be set on inputs
  21201. */
  21202. get isAttribute(): boolean;
  21203. set isAttribute(value: boolean);
  21204. /**
  21205. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21206. * Can only be set on exit points
  21207. */
  21208. get isVarying(): boolean;
  21209. set isVarying(value: boolean);
  21210. /**
  21211. * Gets a boolean indicating that the current connection point is a system value
  21212. */
  21213. get isSystemValue(): boolean;
  21214. /**
  21215. * Gets or sets the current well known value or null if not defined as a system value
  21216. */
  21217. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21218. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21219. /**
  21220. * Gets the current class name
  21221. * @returns the class name
  21222. */
  21223. getClassName(): string;
  21224. /**
  21225. * Animate the input if animationType !== None
  21226. * @param scene defines the rendering scene
  21227. */
  21228. animate(scene: Scene): void;
  21229. private _emitDefine;
  21230. initialize(state: NodeMaterialBuildState): void;
  21231. /**
  21232. * Set the input block to its default value (based on its type)
  21233. */
  21234. setDefaultValue(): void;
  21235. private _emitConstant;
  21236. /** @hidden */
  21237. get _noContextSwitch(): boolean;
  21238. private _emit;
  21239. /** @hidden */
  21240. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21241. /** @hidden */
  21242. _transmit(effect: Effect, scene: Scene): void;
  21243. protected _buildBlock(state: NodeMaterialBuildState): void;
  21244. protected _dumpPropertiesCode(): string;
  21245. dispose(): void;
  21246. serialize(): any;
  21247. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21248. }
  21249. }
  21250. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21251. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21252. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21253. import { Nullable } from "babylonjs/types";
  21254. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21255. import { Observable } from "babylonjs/Misc/observable";
  21256. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21257. /**
  21258. * Enum used to define the compatibility state between two connection points
  21259. */
  21260. export enum NodeMaterialConnectionPointCompatibilityStates {
  21261. /** Points are compatibles */
  21262. Compatible = 0,
  21263. /** Points are incompatible because of their types */
  21264. TypeIncompatible = 1,
  21265. /** Points are incompatible because of their targets (vertex vs fragment) */
  21266. TargetIncompatible = 2
  21267. }
  21268. /**
  21269. * Defines the direction of a connection point
  21270. */
  21271. export enum NodeMaterialConnectionPointDirection {
  21272. /** Input */
  21273. Input = 0,
  21274. /** Output */
  21275. Output = 1
  21276. }
  21277. /**
  21278. * Defines a connection point for a block
  21279. */
  21280. export class NodeMaterialConnectionPoint {
  21281. /** @hidden */
  21282. _ownerBlock: NodeMaterialBlock;
  21283. /** @hidden */
  21284. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21285. private _endpoints;
  21286. private _associatedVariableName;
  21287. private _direction;
  21288. /** @hidden */
  21289. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21290. /** @hidden */
  21291. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21292. private _type;
  21293. /** @hidden */
  21294. _enforceAssociatedVariableName: boolean;
  21295. /** Gets the direction of the point */
  21296. get direction(): NodeMaterialConnectionPointDirection;
  21297. /** Indicates that this connection point needs dual validation before being connected to another point */
  21298. needDualDirectionValidation: boolean;
  21299. /**
  21300. * Gets or sets the additional types supported by this connection point
  21301. */
  21302. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21303. /**
  21304. * Gets or sets the additional types excluded by this connection point
  21305. */
  21306. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21307. /**
  21308. * Observable triggered when this point is connected
  21309. */
  21310. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21311. /**
  21312. * Gets or sets the associated variable name in the shader
  21313. */
  21314. get associatedVariableName(): string;
  21315. set associatedVariableName(value: string);
  21316. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21317. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21318. /**
  21319. * Gets or sets the connection point type (default is float)
  21320. */
  21321. get type(): NodeMaterialBlockConnectionPointTypes;
  21322. set type(value: NodeMaterialBlockConnectionPointTypes);
  21323. /**
  21324. * Gets or sets the connection point name
  21325. */
  21326. name: string;
  21327. /**
  21328. * Gets or sets the connection point name
  21329. */
  21330. displayName: string;
  21331. /**
  21332. * Gets or sets a boolean indicating that this connection point can be omitted
  21333. */
  21334. isOptional: boolean;
  21335. /**
  21336. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21337. */
  21338. isExposedOnFrame: boolean;
  21339. /**
  21340. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21341. */
  21342. define: string;
  21343. /** @hidden */
  21344. _prioritizeVertex: boolean;
  21345. private _target;
  21346. /** Gets or sets the target of that connection point */
  21347. get target(): NodeMaterialBlockTargets;
  21348. set target(value: NodeMaterialBlockTargets);
  21349. /**
  21350. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21351. */
  21352. get isConnected(): boolean;
  21353. /**
  21354. * Gets a boolean indicating that the current point is connected to an input block
  21355. */
  21356. get isConnectedToInputBlock(): boolean;
  21357. /**
  21358. * Gets a the connected input block (if any)
  21359. */
  21360. get connectInputBlock(): Nullable<InputBlock>;
  21361. /** Get the other side of the connection (if any) */
  21362. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21363. /** Get the block that owns this connection point */
  21364. get ownerBlock(): NodeMaterialBlock;
  21365. /** Get the block connected on the other side of this connection (if any) */
  21366. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21367. /** Get the block connected on the endpoints of this connection (if any) */
  21368. get connectedBlocks(): Array<NodeMaterialBlock>;
  21369. /** Gets the list of connected endpoints */
  21370. get endpoints(): NodeMaterialConnectionPoint[];
  21371. /** Gets a boolean indicating if that output point is connected to at least one input */
  21372. get hasEndpoints(): boolean;
  21373. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21374. get isConnectedInVertexShader(): boolean;
  21375. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21376. get isConnectedInFragmentShader(): boolean;
  21377. /**
  21378. * Creates a block suitable to be used as an input for this input point.
  21379. * If null is returned, a block based on the point type will be created.
  21380. * @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
  21381. */
  21382. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21383. /**
  21384. * Creates a new connection point
  21385. * @param name defines the connection point name
  21386. * @param ownerBlock defines the block hosting this connection point
  21387. * @param direction defines the direction of the connection point
  21388. */
  21389. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21390. /**
  21391. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21392. * @returns the class name
  21393. */
  21394. getClassName(): string;
  21395. /**
  21396. * Gets a boolean indicating if the current point can be connected to another point
  21397. * @param connectionPoint defines the other connection point
  21398. * @returns a boolean
  21399. */
  21400. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21401. /**
  21402. * Gets a number indicating if the current point can be connected to another point
  21403. * @param connectionPoint defines the other connection point
  21404. * @returns a number defining the compatibility state
  21405. */
  21406. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21407. /**
  21408. * Connect this point to another connection point
  21409. * @param connectionPoint defines the other connection point
  21410. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21411. * @returns the current connection point
  21412. */
  21413. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21414. /**
  21415. * Disconnect this point from one of his endpoint
  21416. * @param endpoint defines the other connection point
  21417. * @returns the current connection point
  21418. */
  21419. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21420. /**
  21421. * Serializes this point in a JSON representation
  21422. * @param isInput defines if the connection point is an input (default is true)
  21423. * @returns the serialized point object
  21424. */
  21425. serialize(isInput?: boolean): any;
  21426. /**
  21427. * Release resources
  21428. */
  21429. dispose(): void;
  21430. }
  21431. }
  21432. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21433. /**
  21434. * Enum used to define the material modes
  21435. */
  21436. export enum NodeMaterialModes {
  21437. /** Regular material */
  21438. Material = 0,
  21439. /** For post process */
  21440. PostProcess = 1,
  21441. /** For particle system */
  21442. Particle = 2
  21443. }
  21444. }
  21445. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21448. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21449. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21451. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21452. import { Effect } from "babylonjs/Materials/effect";
  21453. import { Mesh } from "babylonjs/Meshes/mesh";
  21454. import { Nullable } from "babylonjs/types";
  21455. import { Texture } from "babylonjs/Materials/Textures/texture";
  21456. import { Scene } from "babylonjs/scene";
  21457. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21458. /**
  21459. * Block used to read a texture from a sampler
  21460. */
  21461. export class TextureBlock extends NodeMaterialBlock {
  21462. private _defineName;
  21463. private _linearDefineName;
  21464. private _gammaDefineName;
  21465. private _tempTextureRead;
  21466. private _samplerName;
  21467. private _transformedUVName;
  21468. private _textureTransformName;
  21469. private _textureInfoName;
  21470. private _mainUVName;
  21471. private _mainUVDefineName;
  21472. private _fragmentOnly;
  21473. /**
  21474. * Gets or sets the texture associated with the node
  21475. */
  21476. texture: Nullable<Texture>;
  21477. /**
  21478. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21479. */
  21480. convertToGammaSpace: boolean;
  21481. /**
  21482. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21483. */
  21484. convertToLinearSpace: boolean;
  21485. /**
  21486. * Create a new TextureBlock
  21487. * @param name defines the block name
  21488. */
  21489. constructor(name: string, fragmentOnly?: boolean);
  21490. /**
  21491. * Gets the current class name
  21492. * @returns the class name
  21493. */
  21494. getClassName(): string;
  21495. /**
  21496. * Gets the uv input component
  21497. */
  21498. get uv(): NodeMaterialConnectionPoint;
  21499. /**
  21500. * Gets the rgba output component
  21501. */
  21502. get rgba(): NodeMaterialConnectionPoint;
  21503. /**
  21504. * Gets the rgb output component
  21505. */
  21506. get rgb(): NodeMaterialConnectionPoint;
  21507. /**
  21508. * Gets the r output component
  21509. */
  21510. get r(): NodeMaterialConnectionPoint;
  21511. /**
  21512. * Gets the g output component
  21513. */
  21514. get g(): NodeMaterialConnectionPoint;
  21515. /**
  21516. * Gets the b output component
  21517. */
  21518. get b(): NodeMaterialConnectionPoint;
  21519. /**
  21520. * Gets the a output component
  21521. */
  21522. get a(): NodeMaterialConnectionPoint;
  21523. get target(): NodeMaterialBlockTargets;
  21524. autoConfigure(material: NodeMaterial): void;
  21525. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21526. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21527. isReady(): boolean;
  21528. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21529. private get _isMixed();
  21530. private _injectVertexCode;
  21531. private _writeTextureRead;
  21532. private _writeOutput;
  21533. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21534. protected _dumpPropertiesCode(): string;
  21535. serialize(): any;
  21536. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21537. }
  21538. }
  21539. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21540. /** @hidden */
  21541. export var reflectionFunction: {
  21542. name: string;
  21543. shader: string;
  21544. };
  21545. }
  21546. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21547. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21548. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21549. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21550. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21552. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21553. import { Effect } from "babylonjs/Materials/effect";
  21554. import { Mesh } from "babylonjs/Meshes/mesh";
  21555. import { Nullable } from "babylonjs/types";
  21556. import { Scene } from "babylonjs/scene";
  21557. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21558. /**
  21559. * Base block used to read a reflection texture from a sampler
  21560. */
  21561. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21562. /** @hidden */
  21563. _define3DName: string;
  21564. /** @hidden */
  21565. _defineCubicName: string;
  21566. /** @hidden */
  21567. _defineExplicitName: string;
  21568. /** @hidden */
  21569. _defineProjectionName: string;
  21570. /** @hidden */
  21571. _defineLocalCubicName: string;
  21572. /** @hidden */
  21573. _defineSphericalName: string;
  21574. /** @hidden */
  21575. _definePlanarName: string;
  21576. /** @hidden */
  21577. _defineEquirectangularName: string;
  21578. /** @hidden */
  21579. _defineMirroredEquirectangularFixedName: string;
  21580. /** @hidden */
  21581. _defineEquirectangularFixedName: string;
  21582. /** @hidden */
  21583. _defineSkyboxName: string;
  21584. /** @hidden */
  21585. _defineOppositeZ: string;
  21586. /** @hidden */
  21587. _cubeSamplerName: string;
  21588. /** @hidden */
  21589. _2DSamplerName: string;
  21590. protected _positionUVWName: string;
  21591. protected _directionWName: string;
  21592. protected _reflectionVectorName: string;
  21593. /** @hidden */
  21594. _reflectionCoordsName: string;
  21595. /** @hidden */
  21596. _reflectionMatrixName: string;
  21597. protected _reflectionColorName: string;
  21598. /**
  21599. * Gets or sets the texture associated with the node
  21600. */
  21601. texture: Nullable<BaseTexture>;
  21602. /**
  21603. * Create a new ReflectionTextureBaseBlock
  21604. * @param name defines the block name
  21605. */
  21606. constructor(name: string);
  21607. /**
  21608. * Gets the current class name
  21609. * @returns the class name
  21610. */
  21611. getClassName(): string;
  21612. /**
  21613. * Gets the world position input component
  21614. */
  21615. abstract get position(): NodeMaterialConnectionPoint;
  21616. /**
  21617. * Gets the world position input component
  21618. */
  21619. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21620. /**
  21621. * Gets the world normal input component
  21622. */
  21623. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21624. /**
  21625. * Gets the world input component
  21626. */
  21627. abstract get world(): NodeMaterialConnectionPoint;
  21628. /**
  21629. * Gets the camera (or eye) position component
  21630. */
  21631. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21632. /**
  21633. * Gets the view input component
  21634. */
  21635. abstract get view(): NodeMaterialConnectionPoint;
  21636. protected _getTexture(): Nullable<BaseTexture>;
  21637. autoConfigure(material: NodeMaterial): void;
  21638. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21639. isReady(): boolean;
  21640. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21641. /**
  21642. * Gets the code to inject in the vertex shader
  21643. * @param state current state of the node material building
  21644. * @returns the shader code
  21645. */
  21646. handleVertexSide(state: NodeMaterialBuildState): string;
  21647. /**
  21648. * Handles the inits for the fragment code path
  21649. * @param state node material build state
  21650. */
  21651. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21652. /**
  21653. * Generates the reflection coords code for the fragment code path
  21654. * @param worldNormalVarName name of the world normal variable
  21655. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21656. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21657. * @returns the shader code
  21658. */
  21659. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21660. /**
  21661. * Generates the reflection color code for the fragment code path
  21662. * @param lodVarName name of the lod variable
  21663. * @param swizzleLookupTexture swizzle to use for the final color variable
  21664. * @returns the shader code
  21665. */
  21666. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21667. /**
  21668. * Generates the code corresponding to the connected output points
  21669. * @param state node material build state
  21670. * @param varName name of the variable to output
  21671. * @returns the shader code
  21672. */
  21673. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21674. protected _buildBlock(state: NodeMaterialBuildState): this;
  21675. protected _dumpPropertiesCode(): string;
  21676. serialize(): any;
  21677. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21678. }
  21679. }
  21680. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21681. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21682. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21683. import { Nullable } from "babylonjs/types";
  21684. /**
  21685. * Defines a connection point to be used for points with a custom object type
  21686. */
  21687. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21688. private _blockType;
  21689. private _blockName;
  21690. private _nameForCheking?;
  21691. /**
  21692. * Creates a new connection point
  21693. * @param name defines the connection point name
  21694. * @param ownerBlock defines the block hosting this connection point
  21695. * @param direction defines the direction of the connection point
  21696. */
  21697. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21698. /**
  21699. * Gets a number indicating if the current point can be connected to another point
  21700. * @param connectionPoint defines the other connection point
  21701. * @returns a number defining the compatibility state
  21702. */
  21703. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21704. /**
  21705. * Creates a block suitable to be used as an input for this input point.
  21706. * If null is returned, a block based on the point type will be created.
  21707. * @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
  21708. */
  21709. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21710. }
  21711. }
  21712. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21713. /**
  21714. * Enum defining the type of properties that can be edited in the property pages in the NME
  21715. */
  21716. export enum PropertyTypeForEdition {
  21717. /** property is a boolean */
  21718. Boolean = 0,
  21719. /** property is a float */
  21720. Float = 1,
  21721. /** property is a Vector2 */
  21722. Vector2 = 2,
  21723. /** property is a list of values */
  21724. List = 3
  21725. }
  21726. /**
  21727. * Interface that defines an option in a variable of type list
  21728. */
  21729. export interface IEditablePropertyListOption {
  21730. /** label of the option */
  21731. "label": string;
  21732. /** value of the option */
  21733. "value": number;
  21734. }
  21735. /**
  21736. * Interface that defines the options available for an editable property
  21737. */
  21738. export interface IEditablePropertyOption {
  21739. /** min value */
  21740. "min"?: number;
  21741. /** max value */
  21742. "max"?: number;
  21743. /** notifiers: indicates which actions to take when the property is changed */
  21744. "notifiers"?: {
  21745. /** the material should be rebuilt */
  21746. "rebuild"?: boolean;
  21747. /** the preview should be updated */
  21748. "update"?: boolean;
  21749. };
  21750. /** list of the options for a variable of type list */
  21751. "options"?: IEditablePropertyListOption[];
  21752. }
  21753. /**
  21754. * Interface that describes an editable property
  21755. */
  21756. export interface IPropertyDescriptionForEdition {
  21757. /** name of the property */
  21758. "propertyName": string;
  21759. /** display name of the property */
  21760. "displayName": string;
  21761. /** type of the property */
  21762. "type": PropertyTypeForEdition;
  21763. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21764. "groupName": string;
  21765. /** options for the property */
  21766. "options": IEditablePropertyOption;
  21767. }
  21768. /**
  21769. * Decorator that flags a property in a node material block as being editable
  21770. */
  21771. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21772. }
  21773. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21774. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21775. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21776. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21778. import { Nullable } from "babylonjs/types";
  21779. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21780. import { Mesh } from "babylonjs/Meshes/mesh";
  21781. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21782. import { Effect } from "babylonjs/Materials/effect";
  21783. import { Scene } from "babylonjs/scene";
  21784. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21785. /**
  21786. * Block used to implement the refraction part of the sub surface module of the PBR material
  21787. */
  21788. export class RefractionBlock extends NodeMaterialBlock {
  21789. /** @hidden */
  21790. _define3DName: string;
  21791. /** @hidden */
  21792. _refractionMatrixName: string;
  21793. /** @hidden */
  21794. _defineLODRefractionAlpha: string;
  21795. /** @hidden */
  21796. _defineLinearSpecularRefraction: string;
  21797. /** @hidden */
  21798. _defineOppositeZ: string;
  21799. /** @hidden */
  21800. _cubeSamplerName: string;
  21801. /** @hidden */
  21802. _2DSamplerName: string;
  21803. /** @hidden */
  21804. _vRefractionMicrosurfaceInfosName: string;
  21805. /** @hidden */
  21806. _vRefractionInfosName: string;
  21807. private _scene;
  21808. /**
  21809. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21810. * Materials half opaque for instance using refraction could benefit from this control.
  21811. */
  21812. linkRefractionWithTransparency: boolean;
  21813. /**
  21814. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21815. */
  21816. invertRefractionY: boolean;
  21817. /**
  21818. * Gets or sets the texture associated with the node
  21819. */
  21820. texture: Nullable<BaseTexture>;
  21821. /**
  21822. * Create a new RefractionBlock
  21823. * @param name defines the block name
  21824. */
  21825. constructor(name: string);
  21826. /**
  21827. * Gets the current class name
  21828. * @returns the class name
  21829. */
  21830. getClassName(): string;
  21831. /**
  21832. * Gets the intensity input component
  21833. */
  21834. get intensity(): NodeMaterialConnectionPoint;
  21835. /**
  21836. * Gets the index of refraction input component
  21837. */
  21838. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21839. /**
  21840. * Gets the tint at distance input component
  21841. */
  21842. get tintAtDistance(): NodeMaterialConnectionPoint;
  21843. /**
  21844. * Gets the view input component
  21845. */
  21846. get view(): NodeMaterialConnectionPoint;
  21847. /**
  21848. * Gets the refraction object output component
  21849. */
  21850. get refraction(): NodeMaterialConnectionPoint;
  21851. /**
  21852. * Returns true if the block has a texture
  21853. */
  21854. get hasTexture(): boolean;
  21855. protected _getTexture(): Nullable<BaseTexture>;
  21856. autoConfigure(material: NodeMaterial): void;
  21857. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21858. isReady(): boolean;
  21859. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21860. /**
  21861. * Gets the main code of the block (fragment side)
  21862. * @param state current state of the node material building
  21863. * @returns the shader code
  21864. */
  21865. getCode(state: NodeMaterialBuildState): string;
  21866. protected _buildBlock(state: NodeMaterialBuildState): this;
  21867. protected _dumpPropertiesCode(): string;
  21868. serialize(): any;
  21869. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21870. }
  21871. }
  21872. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21873. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21874. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21875. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21876. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21878. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21880. import { Nullable } from "babylonjs/types";
  21881. import { Scene } from "babylonjs/scene";
  21882. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21883. /**
  21884. * Base block used as input for post process
  21885. */
  21886. export class CurrentScreenBlock extends NodeMaterialBlock {
  21887. private _samplerName;
  21888. private _linearDefineName;
  21889. private _gammaDefineName;
  21890. private _mainUVName;
  21891. private _tempTextureRead;
  21892. /**
  21893. * Gets or sets the texture associated with the node
  21894. */
  21895. texture: Nullable<BaseTexture>;
  21896. /**
  21897. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21898. */
  21899. convertToGammaSpace: boolean;
  21900. /**
  21901. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21902. */
  21903. convertToLinearSpace: boolean;
  21904. /**
  21905. * Create a new CurrentScreenBlock
  21906. * @param name defines the block name
  21907. */
  21908. constructor(name: string);
  21909. /**
  21910. * Gets the current class name
  21911. * @returns the class name
  21912. */
  21913. getClassName(): string;
  21914. /**
  21915. * Gets the uv input component
  21916. */
  21917. get uv(): NodeMaterialConnectionPoint;
  21918. /**
  21919. * Gets the rgba output component
  21920. */
  21921. get rgba(): NodeMaterialConnectionPoint;
  21922. /**
  21923. * Gets the rgb output component
  21924. */
  21925. get rgb(): NodeMaterialConnectionPoint;
  21926. /**
  21927. * Gets the r output component
  21928. */
  21929. get r(): NodeMaterialConnectionPoint;
  21930. /**
  21931. * Gets the g output component
  21932. */
  21933. get g(): NodeMaterialConnectionPoint;
  21934. /**
  21935. * Gets the b output component
  21936. */
  21937. get b(): NodeMaterialConnectionPoint;
  21938. /**
  21939. * Gets the a output component
  21940. */
  21941. get a(): NodeMaterialConnectionPoint;
  21942. /**
  21943. * Initialize the block and prepare the context for build
  21944. * @param state defines the state that will be used for the build
  21945. */
  21946. initialize(state: NodeMaterialBuildState): void;
  21947. get target(): NodeMaterialBlockTargets;
  21948. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21949. isReady(): boolean;
  21950. private _injectVertexCode;
  21951. private _writeTextureRead;
  21952. private _writeOutput;
  21953. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21954. serialize(): any;
  21955. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21956. }
  21957. }
  21958. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21959. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21960. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21961. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21963. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21964. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21965. import { Nullable } from "babylonjs/types";
  21966. import { Scene } from "babylonjs/scene";
  21967. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21968. /**
  21969. * Base block used for the particle texture
  21970. */
  21971. export class ParticleTextureBlock extends NodeMaterialBlock {
  21972. private _samplerName;
  21973. private _linearDefineName;
  21974. private _gammaDefineName;
  21975. private _tempTextureRead;
  21976. /**
  21977. * Gets or sets the texture associated with the node
  21978. */
  21979. texture: Nullable<BaseTexture>;
  21980. /**
  21981. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21982. */
  21983. convertToGammaSpace: boolean;
  21984. /**
  21985. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21986. */
  21987. convertToLinearSpace: boolean;
  21988. /**
  21989. * Create a new ParticleTextureBlock
  21990. * @param name defines the block name
  21991. */
  21992. constructor(name: string);
  21993. /**
  21994. * Gets the current class name
  21995. * @returns the class name
  21996. */
  21997. getClassName(): string;
  21998. /**
  21999. * Gets the uv input component
  22000. */
  22001. get uv(): NodeMaterialConnectionPoint;
  22002. /**
  22003. * Gets the rgba output component
  22004. */
  22005. get rgba(): NodeMaterialConnectionPoint;
  22006. /**
  22007. * Gets the rgb output component
  22008. */
  22009. get rgb(): NodeMaterialConnectionPoint;
  22010. /**
  22011. * Gets the r output component
  22012. */
  22013. get r(): NodeMaterialConnectionPoint;
  22014. /**
  22015. * Gets the g output component
  22016. */
  22017. get g(): NodeMaterialConnectionPoint;
  22018. /**
  22019. * Gets the b output component
  22020. */
  22021. get b(): NodeMaterialConnectionPoint;
  22022. /**
  22023. * Gets the a output component
  22024. */
  22025. get a(): NodeMaterialConnectionPoint;
  22026. /**
  22027. * Initialize the block and prepare the context for build
  22028. * @param state defines the state that will be used for the build
  22029. */
  22030. initialize(state: NodeMaterialBuildState): void;
  22031. autoConfigure(material: NodeMaterial): void;
  22032. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22033. isReady(): boolean;
  22034. private _writeOutput;
  22035. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22036. serialize(): any;
  22037. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22038. }
  22039. }
  22040. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22041. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22042. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22043. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22044. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22045. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22046. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22047. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22048. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22049. import { Scene } from "babylonjs/scene";
  22050. /**
  22051. * Class used to store shared data between 2 NodeMaterialBuildState
  22052. */
  22053. export class NodeMaterialBuildStateSharedData {
  22054. /**
  22055. * Gets the list of emitted varyings
  22056. */
  22057. temps: string[];
  22058. /**
  22059. * Gets the list of emitted varyings
  22060. */
  22061. varyings: string[];
  22062. /**
  22063. * Gets the varying declaration string
  22064. */
  22065. varyingDeclaration: string;
  22066. /**
  22067. * Input blocks
  22068. */
  22069. inputBlocks: InputBlock[];
  22070. /**
  22071. * Input blocks
  22072. */
  22073. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22074. /**
  22075. * Bindable blocks (Blocks that need to set data to the effect)
  22076. */
  22077. bindableBlocks: NodeMaterialBlock[];
  22078. /**
  22079. * List of blocks that can provide a compilation fallback
  22080. */
  22081. blocksWithFallbacks: NodeMaterialBlock[];
  22082. /**
  22083. * List of blocks that can provide a define update
  22084. */
  22085. blocksWithDefines: NodeMaterialBlock[];
  22086. /**
  22087. * List of blocks that can provide a repeatable content
  22088. */
  22089. repeatableContentBlocks: NodeMaterialBlock[];
  22090. /**
  22091. * List of blocks that can provide a dynamic list of uniforms
  22092. */
  22093. dynamicUniformBlocks: NodeMaterialBlock[];
  22094. /**
  22095. * List of blocks that can block the isReady function for the material
  22096. */
  22097. blockingBlocks: NodeMaterialBlock[];
  22098. /**
  22099. * Gets the list of animated inputs
  22100. */
  22101. animatedInputs: InputBlock[];
  22102. /**
  22103. * Build Id used to avoid multiple recompilations
  22104. */
  22105. buildId: number;
  22106. /** List of emitted variables */
  22107. variableNames: {
  22108. [key: string]: number;
  22109. };
  22110. /** List of emitted defines */
  22111. defineNames: {
  22112. [key: string]: number;
  22113. };
  22114. /** Should emit comments? */
  22115. emitComments: boolean;
  22116. /** Emit build activity */
  22117. verbose: boolean;
  22118. /** Gets or sets the hosting scene */
  22119. scene: Scene;
  22120. /**
  22121. * Gets the compilation hints emitted at compilation time
  22122. */
  22123. hints: {
  22124. needWorldViewMatrix: boolean;
  22125. needWorldViewProjectionMatrix: boolean;
  22126. needAlphaBlending: boolean;
  22127. needAlphaTesting: boolean;
  22128. };
  22129. /**
  22130. * List of compilation checks
  22131. */
  22132. checks: {
  22133. emitVertex: boolean;
  22134. emitFragment: boolean;
  22135. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22136. };
  22137. /**
  22138. * Is vertex program allowed to be empty?
  22139. */
  22140. allowEmptyVertexProgram: boolean;
  22141. /** Creates a new shared data */
  22142. constructor();
  22143. /**
  22144. * Emits console errors and exceptions if there is a failing check
  22145. */
  22146. emitErrors(): void;
  22147. }
  22148. }
  22149. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22150. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22151. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22152. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22153. /**
  22154. * Class used to store node based material build state
  22155. */
  22156. export class NodeMaterialBuildState {
  22157. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22158. supportUniformBuffers: boolean;
  22159. /**
  22160. * Gets the list of emitted attributes
  22161. */
  22162. attributes: string[];
  22163. /**
  22164. * Gets the list of emitted uniforms
  22165. */
  22166. uniforms: string[];
  22167. /**
  22168. * Gets the list of emitted constants
  22169. */
  22170. constants: string[];
  22171. /**
  22172. * Gets the list of emitted samplers
  22173. */
  22174. samplers: string[];
  22175. /**
  22176. * Gets the list of emitted functions
  22177. */
  22178. functions: {
  22179. [key: string]: string;
  22180. };
  22181. /**
  22182. * Gets the list of emitted extensions
  22183. */
  22184. extensions: {
  22185. [key: string]: string;
  22186. };
  22187. /**
  22188. * Gets the target of the compilation state
  22189. */
  22190. target: NodeMaterialBlockTargets;
  22191. /**
  22192. * Gets the list of emitted counters
  22193. */
  22194. counters: {
  22195. [key: string]: number;
  22196. };
  22197. /**
  22198. * Shared data between multiple NodeMaterialBuildState instances
  22199. */
  22200. sharedData: NodeMaterialBuildStateSharedData;
  22201. /** @hidden */
  22202. _vertexState: NodeMaterialBuildState;
  22203. /** @hidden */
  22204. _attributeDeclaration: string;
  22205. /** @hidden */
  22206. _uniformDeclaration: string;
  22207. /** @hidden */
  22208. _constantDeclaration: string;
  22209. /** @hidden */
  22210. _samplerDeclaration: string;
  22211. /** @hidden */
  22212. _varyingTransfer: string;
  22213. /** @hidden */
  22214. _injectAtEnd: string;
  22215. private _repeatableContentAnchorIndex;
  22216. /** @hidden */
  22217. _builtCompilationString: string;
  22218. /**
  22219. * Gets the emitted compilation strings
  22220. */
  22221. compilationString: string;
  22222. /**
  22223. * Finalize the compilation strings
  22224. * @param state defines the current compilation state
  22225. */
  22226. finalize(state: NodeMaterialBuildState): void;
  22227. /** @hidden */
  22228. get _repeatableContentAnchor(): string;
  22229. /** @hidden */
  22230. _getFreeVariableName(prefix: string): string;
  22231. /** @hidden */
  22232. _getFreeDefineName(prefix: string): string;
  22233. /** @hidden */
  22234. _excludeVariableName(name: string): void;
  22235. /** @hidden */
  22236. _emit2DSampler(name: string): void;
  22237. /** @hidden */
  22238. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22239. /** @hidden */
  22240. _emitExtension(name: string, extension: string, define?: string): void;
  22241. /** @hidden */
  22242. _emitFunction(name: string, code: string, comments: string): void;
  22243. /** @hidden */
  22244. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22245. replaceStrings?: {
  22246. search: RegExp;
  22247. replace: string;
  22248. }[];
  22249. repeatKey?: string;
  22250. }): string;
  22251. /** @hidden */
  22252. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22253. repeatKey?: string;
  22254. removeAttributes?: boolean;
  22255. removeUniforms?: boolean;
  22256. removeVaryings?: boolean;
  22257. removeIfDef?: boolean;
  22258. replaceStrings?: {
  22259. search: RegExp;
  22260. replace: string;
  22261. }[];
  22262. }, storeKey?: string): void;
  22263. /** @hidden */
  22264. _registerTempVariable(name: string): boolean;
  22265. /** @hidden */
  22266. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22267. /** @hidden */
  22268. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22269. /** @hidden */
  22270. _emitFloat(value: number): string;
  22271. }
  22272. }
  22273. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22274. /**
  22275. * Helper class used to generate session unique ID
  22276. */
  22277. export class UniqueIdGenerator {
  22278. private static _UniqueIdCounter;
  22279. /**
  22280. * Gets an unique (relatively to the current scene) Id
  22281. */
  22282. static get UniqueId(): number;
  22283. }
  22284. }
  22285. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22286. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22287. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22288. import { Nullable } from "babylonjs/types";
  22289. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22290. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22291. import { Effect } from "babylonjs/Materials/effect";
  22292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22293. import { Mesh } from "babylonjs/Meshes/mesh";
  22294. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22295. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22296. import { Scene } from "babylonjs/scene";
  22297. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22298. /**
  22299. * Defines a block that can be used inside a node based material
  22300. */
  22301. export class NodeMaterialBlock {
  22302. private _buildId;
  22303. private _buildTarget;
  22304. private _target;
  22305. private _isFinalMerger;
  22306. private _isInput;
  22307. private _name;
  22308. protected _isUnique: boolean;
  22309. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22310. inputsAreExclusive: boolean;
  22311. /** @hidden */
  22312. _codeVariableName: string;
  22313. /** @hidden */
  22314. _inputs: NodeMaterialConnectionPoint[];
  22315. /** @hidden */
  22316. _outputs: NodeMaterialConnectionPoint[];
  22317. /** @hidden */
  22318. _preparationId: number;
  22319. /**
  22320. * Gets the name of the block
  22321. */
  22322. get name(): string;
  22323. /**
  22324. * Sets the name of the block. Will check if the name is valid.
  22325. */
  22326. set name(newName: string);
  22327. /**
  22328. * Gets or sets the unique id of the node
  22329. */
  22330. uniqueId: number;
  22331. /**
  22332. * Gets or sets the comments associated with this block
  22333. */
  22334. comments: string;
  22335. /**
  22336. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22337. */
  22338. get isUnique(): boolean;
  22339. /**
  22340. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22341. */
  22342. get isFinalMerger(): boolean;
  22343. /**
  22344. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22345. */
  22346. get isInput(): boolean;
  22347. /**
  22348. * Gets or sets the build Id
  22349. */
  22350. get buildId(): number;
  22351. set buildId(value: number);
  22352. /**
  22353. * Gets or sets the target of the block
  22354. */
  22355. get target(): NodeMaterialBlockTargets;
  22356. set target(value: NodeMaterialBlockTargets);
  22357. /**
  22358. * Gets the list of input points
  22359. */
  22360. get inputs(): NodeMaterialConnectionPoint[];
  22361. /** Gets the list of output points */
  22362. get outputs(): NodeMaterialConnectionPoint[];
  22363. /**
  22364. * Find an input by its name
  22365. * @param name defines the name of the input to look for
  22366. * @returns the input or null if not found
  22367. */
  22368. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22369. /**
  22370. * Find an output by its name
  22371. * @param name defines the name of the outputto look for
  22372. * @returns the output or null if not found
  22373. */
  22374. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22375. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22376. visibleInInspector: boolean;
  22377. /**
  22378. * Creates a new NodeMaterialBlock
  22379. * @param name defines the block name
  22380. * @param target defines the target of that block (Vertex by default)
  22381. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22382. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22383. */
  22384. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22385. /**
  22386. * Initialize the block and prepare the context for build
  22387. * @param state defines the state that will be used for the build
  22388. */
  22389. initialize(state: NodeMaterialBuildState): void;
  22390. /**
  22391. * Bind data to effect. Will only be called for blocks with isBindable === true
  22392. * @param effect defines the effect to bind data to
  22393. * @param nodeMaterial defines the hosting NodeMaterial
  22394. * @param mesh defines the mesh that will be rendered
  22395. * @param subMesh defines the submesh that will be rendered
  22396. */
  22397. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22398. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22399. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22400. protected _writeFloat(value: number): string;
  22401. /**
  22402. * Gets the current class name e.g. "NodeMaterialBlock"
  22403. * @returns the class name
  22404. */
  22405. getClassName(): string;
  22406. /**
  22407. * Register a new input. Must be called inside a block constructor
  22408. * @param name defines the connection point name
  22409. * @param type defines the connection point type
  22410. * @param isOptional defines a boolean indicating that this input can be omitted
  22411. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22412. * @param point an already created connection point. If not provided, create a new one
  22413. * @returns the current block
  22414. */
  22415. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22416. /**
  22417. * Register a new output. Must be called inside a block constructor
  22418. * @param name defines the connection point name
  22419. * @param type defines the connection point type
  22420. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22421. * @param point an already created connection point. If not provided, create a new one
  22422. * @returns the current block
  22423. */
  22424. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22425. /**
  22426. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22427. * @param forOutput defines an optional connection point to check compatibility with
  22428. * @returns the first available input or null
  22429. */
  22430. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22431. /**
  22432. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22433. * @param forBlock defines an optional block to check compatibility with
  22434. * @returns the first available input or null
  22435. */
  22436. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22437. /**
  22438. * Gets the sibling of the given output
  22439. * @param current defines the current output
  22440. * @returns the next output in the list or null
  22441. */
  22442. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22443. /**
  22444. * Connect current block with another block
  22445. * @param other defines the block to connect with
  22446. * @param options define the various options to help pick the right connections
  22447. * @returns the current block
  22448. */
  22449. connectTo(other: NodeMaterialBlock, options?: {
  22450. input?: string;
  22451. output?: string;
  22452. outputSwizzle?: string;
  22453. }): this | undefined;
  22454. protected _buildBlock(state: NodeMaterialBuildState): void;
  22455. /**
  22456. * Add uniforms, samplers and uniform buffers at compilation time
  22457. * @param state defines the state to update
  22458. * @param nodeMaterial defines the node material requesting the update
  22459. * @param defines defines the material defines to update
  22460. * @param uniformBuffers defines the list of uniform buffer names
  22461. */
  22462. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22463. /**
  22464. * Add potential fallbacks if shader compilation fails
  22465. * @param mesh defines the mesh to be rendered
  22466. * @param fallbacks defines the current prioritized list of fallbacks
  22467. */
  22468. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22469. /**
  22470. * Initialize defines for shader compilation
  22471. * @param mesh defines the mesh to be rendered
  22472. * @param nodeMaterial defines the node material requesting the update
  22473. * @param defines defines the material defines to update
  22474. * @param useInstances specifies that instances should be used
  22475. */
  22476. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22477. /**
  22478. * Update defines for shader compilation
  22479. * @param mesh defines the mesh to be rendered
  22480. * @param nodeMaterial defines the node material requesting the update
  22481. * @param defines defines the material defines to update
  22482. * @param useInstances specifies that instances should be used
  22483. * @param subMesh defines which submesh to render
  22484. */
  22485. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22486. /**
  22487. * Lets the block try to connect some inputs automatically
  22488. * @param material defines the hosting NodeMaterial
  22489. */
  22490. autoConfigure(material: NodeMaterial): void;
  22491. /**
  22492. * Function called when a block is declared as repeatable content generator
  22493. * @param vertexShaderState defines the current compilation state for the vertex shader
  22494. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22495. * @param mesh defines the mesh to be rendered
  22496. * @param defines defines the material defines to update
  22497. */
  22498. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22499. /**
  22500. * Checks if the block is ready
  22501. * @param mesh defines the mesh to be rendered
  22502. * @param nodeMaterial defines the node material requesting the update
  22503. * @param defines defines the material defines to update
  22504. * @param useInstances specifies that instances should be used
  22505. * @returns true if the block is ready
  22506. */
  22507. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22508. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22509. private _processBuild;
  22510. /**
  22511. * Validates the new name for the block node.
  22512. * @param newName the new name to be given to the node.
  22513. * @returns false if the name is a reserve word, else true.
  22514. */
  22515. validateBlockName(newName: string): boolean;
  22516. /**
  22517. * Compile the current node and generate the shader code
  22518. * @param state defines the current compilation state (uniforms, samplers, current string)
  22519. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22520. * @returns true if already built
  22521. */
  22522. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22523. protected _inputRename(name: string): string;
  22524. protected _outputRename(name: string): string;
  22525. protected _dumpPropertiesCode(): string;
  22526. /** @hidden */
  22527. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22528. /** @hidden */
  22529. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22530. /**
  22531. * Clone the current block to a new identical block
  22532. * @param scene defines the hosting scene
  22533. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22534. * @returns a copy of the current block
  22535. */
  22536. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22537. /**
  22538. * Serializes this block in a JSON representation
  22539. * @returns the serialized block object
  22540. */
  22541. serialize(): any;
  22542. /** @hidden */
  22543. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22544. private _deserializePortDisplayNamesAndExposedOnFrame;
  22545. /**
  22546. * Release resources
  22547. */
  22548. dispose(): void;
  22549. }
  22550. }
  22551. declare module "babylonjs/Materials/pushMaterial" {
  22552. import { Nullable } from "babylonjs/types";
  22553. import { Scene } from "babylonjs/scene";
  22554. import { Matrix } from "babylonjs/Maths/math.vector";
  22555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22556. import { Mesh } from "babylonjs/Meshes/mesh";
  22557. import { Material } from "babylonjs/Materials/material";
  22558. import { Effect } from "babylonjs/Materials/effect";
  22559. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22560. /**
  22561. * Base class of materials working in push mode in babylon JS
  22562. * @hidden
  22563. */
  22564. export class PushMaterial extends Material {
  22565. protected _activeEffect: Effect;
  22566. protected _normalMatrix: Matrix;
  22567. constructor(name: string, scene: Scene);
  22568. getEffect(): Effect;
  22569. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22570. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22571. /**
  22572. * Binds the given world matrix to the active effect
  22573. *
  22574. * @param world the matrix to bind
  22575. */
  22576. bindOnlyWorldMatrix(world: Matrix): void;
  22577. /**
  22578. * Binds the given normal matrix to the active effect
  22579. *
  22580. * @param normalMatrix the matrix to bind
  22581. */
  22582. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22583. bind(world: Matrix, mesh?: Mesh): void;
  22584. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22585. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22586. }
  22587. }
  22588. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22590. /**
  22591. * Root class for all node material optimizers
  22592. */
  22593. export class NodeMaterialOptimizer {
  22594. /**
  22595. * Function used to optimize a NodeMaterial graph
  22596. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22597. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22598. */
  22599. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22600. }
  22601. }
  22602. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22603. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22604. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22605. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22606. import { Scene } from "babylonjs/scene";
  22607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22608. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22609. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22610. /**
  22611. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22612. */
  22613. export class TransformBlock extends NodeMaterialBlock {
  22614. /**
  22615. * Defines the value to use to complement W value to transform it to a Vector4
  22616. */
  22617. complementW: number;
  22618. /**
  22619. * Defines the value to use to complement z value to transform it to a Vector4
  22620. */
  22621. complementZ: number;
  22622. /**
  22623. * Creates a new TransformBlock
  22624. * @param name defines the block name
  22625. */
  22626. constructor(name: string);
  22627. /**
  22628. * Gets the current class name
  22629. * @returns the class name
  22630. */
  22631. getClassName(): string;
  22632. /**
  22633. * Gets the vector input
  22634. */
  22635. get vector(): NodeMaterialConnectionPoint;
  22636. /**
  22637. * Gets the output component
  22638. */
  22639. get output(): NodeMaterialConnectionPoint;
  22640. /**
  22641. * Gets the xyz output component
  22642. */
  22643. get xyz(): NodeMaterialConnectionPoint;
  22644. /**
  22645. * Gets the matrix transform input
  22646. */
  22647. get transform(): NodeMaterialConnectionPoint;
  22648. protected _buildBlock(state: NodeMaterialBuildState): this;
  22649. /**
  22650. * Update defines for shader compilation
  22651. * @param mesh defines the mesh to be rendered
  22652. * @param nodeMaterial defines the node material requesting the update
  22653. * @param defines defines the material defines to update
  22654. * @param useInstances specifies that instances should be used
  22655. * @param subMesh defines which submesh to render
  22656. */
  22657. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22658. serialize(): any;
  22659. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22660. protected _dumpPropertiesCode(): string;
  22661. }
  22662. }
  22663. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22664. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22665. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22666. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22667. /**
  22668. * Block used to output the vertex position
  22669. */
  22670. export class VertexOutputBlock extends NodeMaterialBlock {
  22671. /**
  22672. * Creates a new VertexOutputBlock
  22673. * @param name defines the block name
  22674. */
  22675. constructor(name: string);
  22676. /**
  22677. * Gets the current class name
  22678. * @returns the class name
  22679. */
  22680. getClassName(): string;
  22681. /**
  22682. * Gets the vector input component
  22683. */
  22684. get vector(): NodeMaterialConnectionPoint;
  22685. protected _buildBlock(state: NodeMaterialBuildState): this;
  22686. }
  22687. }
  22688. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22690. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22692. /**
  22693. * Block used to output the final color
  22694. */
  22695. export class FragmentOutputBlock extends NodeMaterialBlock {
  22696. /**
  22697. * Create a new FragmentOutputBlock
  22698. * @param name defines the block name
  22699. */
  22700. constructor(name: string);
  22701. /**
  22702. * Gets the current class name
  22703. * @returns the class name
  22704. */
  22705. getClassName(): string;
  22706. /**
  22707. * Gets the rgba input component
  22708. */
  22709. get rgba(): NodeMaterialConnectionPoint;
  22710. /**
  22711. * Gets the rgb input component
  22712. */
  22713. get rgb(): NodeMaterialConnectionPoint;
  22714. /**
  22715. * Gets the a input component
  22716. */
  22717. get a(): NodeMaterialConnectionPoint;
  22718. protected _buildBlock(state: NodeMaterialBuildState): this;
  22719. }
  22720. }
  22721. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22722. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22723. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22724. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22725. /**
  22726. * Block used for the particle ramp gradient section
  22727. */
  22728. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22729. /**
  22730. * Create a new ParticleRampGradientBlock
  22731. * @param name defines the block name
  22732. */
  22733. constructor(name: string);
  22734. /**
  22735. * Gets the current class name
  22736. * @returns the class name
  22737. */
  22738. getClassName(): string;
  22739. /**
  22740. * Gets the color input component
  22741. */
  22742. get color(): NodeMaterialConnectionPoint;
  22743. /**
  22744. * Gets the rampColor output component
  22745. */
  22746. get rampColor(): NodeMaterialConnectionPoint;
  22747. /**
  22748. * Initialize the block and prepare the context for build
  22749. * @param state defines the state that will be used for the build
  22750. */
  22751. initialize(state: NodeMaterialBuildState): void;
  22752. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22753. }
  22754. }
  22755. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22756. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22757. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22758. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22759. /**
  22760. * Block used for the particle blend multiply section
  22761. */
  22762. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22763. /**
  22764. * Create a new ParticleBlendMultiplyBlock
  22765. * @param name defines the block name
  22766. */
  22767. constructor(name: string);
  22768. /**
  22769. * Gets the current class name
  22770. * @returns the class name
  22771. */
  22772. getClassName(): string;
  22773. /**
  22774. * Gets the color input component
  22775. */
  22776. get color(): NodeMaterialConnectionPoint;
  22777. /**
  22778. * Gets the alphaTexture input component
  22779. */
  22780. get alphaTexture(): NodeMaterialConnectionPoint;
  22781. /**
  22782. * Gets the alphaColor input component
  22783. */
  22784. get alphaColor(): NodeMaterialConnectionPoint;
  22785. /**
  22786. * Gets the blendColor output component
  22787. */
  22788. get blendColor(): NodeMaterialConnectionPoint;
  22789. /**
  22790. * Initialize the block and prepare the context for build
  22791. * @param state defines the state that will be used for the build
  22792. */
  22793. initialize(state: NodeMaterialBuildState): void;
  22794. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22795. }
  22796. }
  22797. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22798. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22799. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22800. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22801. /**
  22802. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22803. */
  22804. export class VectorMergerBlock extends NodeMaterialBlock {
  22805. /**
  22806. * Create a new VectorMergerBlock
  22807. * @param name defines the block name
  22808. */
  22809. constructor(name: string);
  22810. /**
  22811. * Gets the current class name
  22812. * @returns the class name
  22813. */
  22814. getClassName(): string;
  22815. /**
  22816. * Gets the xyz component (input)
  22817. */
  22818. get xyzIn(): NodeMaterialConnectionPoint;
  22819. /**
  22820. * Gets the xy component (input)
  22821. */
  22822. get xyIn(): NodeMaterialConnectionPoint;
  22823. /**
  22824. * Gets the x component (input)
  22825. */
  22826. get x(): NodeMaterialConnectionPoint;
  22827. /**
  22828. * Gets the y component (input)
  22829. */
  22830. get y(): NodeMaterialConnectionPoint;
  22831. /**
  22832. * Gets the z component (input)
  22833. */
  22834. get z(): NodeMaterialConnectionPoint;
  22835. /**
  22836. * Gets the w component (input)
  22837. */
  22838. get w(): NodeMaterialConnectionPoint;
  22839. /**
  22840. * Gets the xyzw component (output)
  22841. */
  22842. get xyzw(): NodeMaterialConnectionPoint;
  22843. /**
  22844. * Gets the xyz component (output)
  22845. */
  22846. get xyzOut(): NodeMaterialConnectionPoint;
  22847. /**
  22848. * Gets the xy component (output)
  22849. */
  22850. get xyOut(): NodeMaterialConnectionPoint;
  22851. /**
  22852. * Gets the xy component (output)
  22853. * @deprecated Please use xyOut instead.
  22854. */
  22855. get xy(): NodeMaterialConnectionPoint;
  22856. /**
  22857. * Gets the xyz component (output)
  22858. * @deprecated Please use xyzOut instead.
  22859. */
  22860. get xyz(): NodeMaterialConnectionPoint;
  22861. protected _buildBlock(state: NodeMaterialBuildState): this;
  22862. }
  22863. }
  22864. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22865. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22866. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22867. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22868. import { Vector2 } from "babylonjs/Maths/math.vector";
  22869. import { Scene } from "babylonjs/scene";
  22870. /**
  22871. * Block used to remap a float from a range to a new one
  22872. */
  22873. export class RemapBlock extends NodeMaterialBlock {
  22874. /**
  22875. * Gets or sets the source range
  22876. */
  22877. sourceRange: Vector2;
  22878. /**
  22879. * Gets or sets the target range
  22880. */
  22881. targetRange: Vector2;
  22882. /**
  22883. * Creates a new RemapBlock
  22884. * @param name defines the block name
  22885. */
  22886. constructor(name: string);
  22887. /**
  22888. * Gets the current class name
  22889. * @returns the class name
  22890. */
  22891. getClassName(): string;
  22892. /**
  22893. * Gets the input component
  22894. */
  22895. get input(): NodeMaterialConnectionPoint;
  22896. /**
  22897. * Gets the source min input component
  22898. */
  22899. get sourceMin(): NodeMaterialConnectionPoint;
  22900. /**
  22901. * Gets the source max input component
  22902. */
  22903. get sourceMax(): NodeMaterialConnectionPoint;
  22904. /**
  22905. * Gets the target min input component
  22906. */
  22907. get targetMin(): NodeMaterialConnectionPoint;
  22908. /**
  22909. * Gets the target max input component
  22910. */
  22911. get targetMax(): NodeMaterialConnectionPoint;
  22912. /**
  22913. * Gets the output component
  22914. */
  22915. get output(): NodeMaterialConnectionPoint;
  22916. protected _buildBlock(state: NodeMaterialBuildState): this;
  22917. protected _dumpPropertiesCode(): string;
  22918. serialize(): any;
  22919. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22920. }
  22921. }
  22922. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22923. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22924. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22925. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22926. /**
  22927. * Block used to multiply 2 values
  22928. */
  22929. export class MultiplyBlock extends NodeMaterialBlock {
  22930. /**
  22931. * Creates a new MultiplyBlock
  22932. * @param name defines the block name
  22933. */
  22934. constructor(name: string);
  22935. /**
  22936. * Gets the current class name
  22937. * @returns the class name
  22938. */
  22939. getClassName(): string;
  22940. /**
  22941. * Gets the left operand input component
  22942. */
  22943. get left(): NodeMaterialConnectionPoint;
  22944. /**
  22945. * Gets the right operand input component
  22946. */
  22947. get right(): NodeMaterialConnectionPoint;
  22948. /**
  22949. * Gets the output component
  22950. */
  22951. get output(): NodeMaterialConnectionPoint;
  22952. protected _buildBlock(state: NodeMaterialBuildState): this;
  22953. }
  22954. }
  22955. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22956. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22957. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22958. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22959. /**
  22960. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22961. */
  22962. export class ColorSplitterBlock extends NodeMaterialBlock {
  22963. /**
  22964. * Create a new ColorSplitterBlock
  22965. * @param name defines the block name
  22966. */
  22967. constructor(name: string);
  22968. /**
  22969. * Gets the current class name
  22970. * @returns the class name
  22971. */
  22972. getClassName(): string;
  22973. /**
  22974. * Gets the rgba component (input)
  22975. */
  22976. get rgba(): NodeMaterialConnectionPoint;
  22977. /**
  22978. * Gets the rgb component (input)
  22979. */
  22980. get rgbIn(): NodeMaterialConnectionPoint;
  22981. /**
  22982. * Gets the rgb component (output)
  22983. */
  22984. get rgbOut(): NodeMaterialConnectionPoint;
  22985. /**
  22986. * Gets the r component (output)
  22987. */
  22988. get r(): NodeMaterialConnectionPoint;
  22989. /**
  22990. * Gets the g component (output)
  22991. */
  22992. get g(): NodeMaterialConnectionPoint;
  22993. /**
  22994. * Gets the b component (output)
  22995. */
  22996. get b(): NodeMaterialConnectionPoint;
  22997. /**
  22998. * Gets the a component (output)
  22999. */
  23000. get a(): NodeMaterialConnectionPoint;
  23001. protected _inputRename(name: string): string;
  23002. protected _outputRename(name: string): string;
  23003. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23004. }
  23005. }
  23006. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23007. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23008. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23009. import { Scene } from "babylonjs/scene";
  23010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23011. import { Matrix } from "babylonjs/Maths/math.vector";
  23012. import { Mesh } from "babylonjs/Meshes/mesh";
  23013. import { Engine } from "babylonjs/Engines/engine";
  23014. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23015. import { Observable } from "babylonjs/Misc/observable";
  23016. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23017. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23018. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23019. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23020. import { Nullable } from "babylonjs/types";
  23021. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23022. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23023. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23024. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23025. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23026. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23027. import { Effect } from "babylonjs/Materials/effect";
  23028. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23029. import { Camera } from "babylonjs/Cameras/camera";
  23030. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23031. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23032. /**
  23033. * Interface used to configure the node material editor
  23034. */
  23035. export interface INodeMaterialEditorOptions {
  23036. /** Define the URl to load node editor script */
  23037. editorURL?: string;
  23038. }
  23039. /** @hidden */
  23040. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23041. NORMAL: boolean;
  23042. TANGENT: boolean;
  23043. UV1: boolean;
  23044. /** BONES */
  23045. NUM_BONE_INFLUENCERS: number;
  23046. BonesPerMesh: number;
  23047. BONETEXTURE: boolean;
  23048. /** MORPH TARGETS */
  23049. MORPHTARGETS: boolean;
  23050. MORPHTARGETS_NORMAL: boolean;
  23051. MORPHTARGETS_TANGENT: boolean;
  23052. MORPHTARGETS_UV: boolean;
  23053. NUM_MORPH_INFLUENCERS: number;
  23054. /** IMAGE PROCESSING */
  23055. IMAGEPROCESSING: boolean;
  23056. VIGNETTE: boolean;
  23057. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23058. VIGNETTEBLENDMODEOPAQUE: boolean;
  23059. TONEMAPPING: boolean;
  23060. TONEMAPPING_ACES: boolean;
  23061. CONTRAST: boolean;
  23062. EXPOSURE: boolean;
  23063. COLORCURVES: boolean;
  23064. COLORGRADING: boolean;
  23065. COLORGRADING3D: boolean;
  23066. SAMPLER3DGREENDEPTH: boolean;
  23067. SAMPLER3DBGRMAP: boolean;
  23068. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23069. /** MISC. */
  23070. BUMPDIRECTUV: number;
  23071. constructor();
  23072. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23073. }
  23074. /**
  23075. * Class used to configure NodeMaterial
  23076. */
  23077. export interface INodeMaterialOptions {
  23078. /**
  23079. * Defines if blocks should emit comments
  23080. */
  23081. emitComments: boolean;
  23082. }
  23083. /**
  23084. * Class used to create a node based material built by assembling shader blocks
  23085. */
  23086. export class NodeMaterial extends PushMaterial {
  23087. private static _BuildIdGenerator;
  23088. private _options;
  23089. private _vertexCompilationState;
  23090. private _fragmentCompilationState;
  23091. private _sharedData;
  23092. private _buildId;
  23093. private _buildWasSuccessful;
  23094. private _cachedWorldViewMatrix;
  23095. private _cachedWorldViewProjectionMatrix;
  23096. private _optimizers;
  23097. private _animationFrame;
  23098. /** Define the Url to load node editor script */
  23099. static EditorURL: string;
  23100. /** Define the Url to load snippets */
  23101. static SnippetUrl: string;
  23102. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23103. static IgnoreTexturesAtLoadTime: boolean;
  23104. private BJSNODEMATERIALEDITOR;
  23105. /** Get the inspector from bundle or global */
  23106. private _getGlobalNodeMaterialEditor;
  23107. /**
  23108. * Snippet ID if the material was created from the snippet server
  23109. */
  23110. snippetId: string;
  23111. /**
  23112. * Gets or sets data used by visual editor
  23113. * @see https://nme.babylonjs.com
  23114. */
  23115. editorData: any;
  23116. /**
  23117. * 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)
  23118. */
  23119. ignoreAlpha: boolean;
  23120. /**
  23121. * Defines the maximum number of lights that can be used in the material
  23122. */
  23123. maxSimultaneousLights: number;
  23124. /**
  23125. * Observable raised when the material is built
  23126. */
  23127. onBuildObservable: Observable<NodeMaterial>;
  23128. /**
  23129. * Gets or sets the root nodes of the material vertex shader
  23130. */
  23131. _vertexOutputNodes: NodeMaterialBlock[];
  23132. /**
  23133. * Gets or sets the root nodes of the material fragment (pixel) shader
  23134. */
  23135. _fragmentOutputNodes: NodeMaterialBlock[];
  23136. /** Gets or sets options to control the node material overall behavior */
  23137. get options(): INodeMaterialOptions;
  23138. set options(options: INodeMaterialOptions);
  23139. /**
  23140. * Default configuration related to image processing available in the standard Material.
  23141. */
  23142. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23143. /**
  23144. * Gets the image processing configuration used either in this material.
  23145. */
  23146. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23147. /**
  23148. * Sets the Default image processing configuration used either in the this material.
  23149. *
  23150. * If sets to null, the scene one is in use.
  23151. */
  23152. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23153. /**
  23154. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23155. */
  23156. attachedBlocks: NodeMaterialBlock[];
  23157. /**
  23158. * Specifies the mode of the node material
  23159. * @hidden
  23160. */
  23161. _mode: NodeMaterialModes;
  23162. /**
  23163. * Gets the mode property
  23164. */
  23165. get mode(): NodeMaterialModes;
  23166. /**
  23167. * Create a new node based material
  23168. * @param name defines the material name
  23169. * @param scene defines the hosting scene
  23170. * @param options defines creation option
  23171. */
  23172. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23173. /**
  23174. * Gets the current class name of the material e.g. "NodeMaterial"
  23175. * @returns the class name
  23176. */
  23177. getClassName(): string;
  23178. /**
  23179. * Keep track of the image processing observer to allow dispose and replace.
  23180. */
  23181. private _imageProcessingObserver;
  23182. /**
  23183. * Attaches a new image processing configuration to the Standard Material.
  23184. * @param configuration
  23185. */
  23186. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23187. /**
  23188. * Get a block by its name
  23189. * @param name defines the name of the block to retrieve
  23190. * @returns the required block or null if not found
  23191. */
  23192. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23193. /**
  23194. * Get a block by its name
  23195. * @param predicate defines the predicate used to find the good candidate
  23196. * @returns the required block or null if not found
  23197. */
  23198. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23199. /**
  23200. * Get an input block by its name
  23201. * @param predicate defines the predicate used to find the good candidate
  23202. * @returns the required input block or null if not found
  23203. */
  23204. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23205. /**
  23206. * Gets the list of input blocks attached to this material
  23207. * @returns an array of InputBlocks
  23208. */
  23209. getInputBlocks(): InputBlock[];
  23210. /**
  23211. * Adds a new optimizer to the list of optimizers
  23212. * @param optimizer defines the optimizers to add
  23213. * @returns the current material
  23214. */
  23215. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23216. /**
  23217. * Remove an optimizer from the list of optimizers
  23218. * @param optimizer defines the optimizers to remove
  23219. * @returns the current material
  23220. */
  23221. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23222. /**
  23223. * Add a new block to the list of output nodes
  23224. * @param node defines the node to add
  23225. * @returns the current material
  23226. */
  23227. addOutputNode(node: NodeMaterialBlock): this;
  23228. /**
  23229. * Remove a block from the list of root nodes
  23230. * @param node defines the node to remove
  23231. * @returns the current material
  23232. */
  23233. removeOutputNode(node: NodeMaterialBlock): this;
  23234. private _addVertexOutputNode;
  23235. private _removeVertexOutputNode;
  23236. private _addFragmentOutputNode;
  23237. private _removeFragmentOutputNode;
  23238. /**
  23239. * Specifies if the material will require alpha blending
  23240. * @returns a boolean specifying if alpha blending is needed
  23241. */
  23242. needAlphaBlending(): boolean;
  23243. /**
  23244. * Specifies if this material should be rendered in alpha test mode
  23245. * @returns a boolean specifying if an alpha test is needed.
  23246. */
  23247. needAlphaTesting(): boolean;
  23248. private _initializeBlock;
  23249. private _resetDualBlocks;
  23250. /**
  23251. * Remove a block from the current node material
  23252. * @param block defines the block to remove
  23253. */
  23254. removeBlock(block: NodeMaterialBlock): void;
  23255. /**
  23256. * Build the material and generates the inner effect
  23257. * @param verbose defines if the build should log activity
  23258. */
  23259. build(verbose?: boolean): void;
  23260. /**
  23261. * Runs an otpimization phase to try to improve the shader code
  23262. */
  23263. optimize(): void;
  23264. private _prepareDefinesForAttributes;
  23265. /**
  23266. * Create a post process from the material
  23267. * @param camera The camera to apply the render pass to.
  23268. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23269. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23270. * @param engine The engine which the post process will be applied. (default: current engine)
  23271. * @param reusable If the post process can be reused on the same frame. (default: false)
  23272. * @param textureType Type of textures used when performing the post process. (default: 0)
  23273. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23274. * @returns the post process created
  23275. */
  23276. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  23277. /**
  23278. * Create the post process effect from the material
  23279. * @param postProcess The post process to create the effect for
  23280. */
  23281. createEffectForPostProcess(postProcess: PostProcess): void;
  23282. private _createEffectOrPostProcess;
  23283. private _createEffectForParticles;
  23284. /**
  23285. * Create the effect to be used as the custom effect for a particle system
  23286. * @param particleSystem Particle system to create the effect for
  23287. * @param onCompiled defines a function to call when the effect creation is successful
  23288. * @param onError defines a function to call when the effect creation has failed
  23289. */
  23290. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23291. private _processDefines;
  23292. /**
  23293. * Get if the submesh is ready to be used and all its information available.
  23294. * Child classes can use it to update shaders
  23295. * @param mesh defines the mesh to check
  23296. * @param subMesh defines which submesh to check
  23297. * @param useInstances specifies that instances should be used
  23298. * @returns a boolean indicating that the submesh is ready or not
  23299. */
  23300. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23301. /**
  23302. * Get a string representing the shaders built by the current node graph
  23303. */
  23304. get compiledShaders(): string;
  23305. /**
  23306. * Binds the world matrix to the material
  23307. * @param world defines the world transformation matrix
  23308. */
  23309. bindOnlyWorldMatrix(world: Matrix): void;
  23310. /**
  23311. * Binds the submesh to this material by preparing the effect and shader to draw
  23312. * @param world defines the world transformation matrix
  23313. * @param mesh defines the mesh containing the submesh
  23314. * @param subMesh defines the submesh to bind the material to
  23315. */
  23316. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23317. /**
  23318. * Gets the active textures from the material
  23319. * @returns an array of textures
  23320. */
  23321. getActiveTextures(): BaseTexture[];
  23322. /**
  23323. * Gets the list of texture blocks
  23324. * @returns an array of texture blocks
  23325. */
  23326. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23327. /**
  23328. * Specifies if the material uses a texture
  23329. * @param texture defines the texture to check against the material
  23330. * @returns a boolean specifying if the material uses the texture
  23331. */
  23332. hasTexture(texture: BaseTexture): boolean;
  23333. /**
  23334. * Disposes the material
  23335. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23336. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23337. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23338. */
  23339. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23340. /** Creates the node editor window. */
  23341. private _createNodeEditor;
  23342. /**
  23343. * Launch the node material editor
  23344. * @param config Define the configuration of the editor
  23345. * @return a promise fulfilled when the node editor is visible
  23346. */
  23347. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23348. /**
  23349. * Clear the current material
  23350. */
  23351. clear(): void;
  23352. /**
  23353. * Clear the current material and set it to a default state
  23354. */
  23355. setToDefault(): void;
  23356. /**
  23357. * Clear the current material and set it to a default state for post process
  23358. */
  23359. setToDefaultPostProcess(): void;
  23360. /**
  23361. * Clear the current material and set it to a default state for particle
  23362. */
  23363. setToDefaultParticle(): void;
  23364. /**
  23365. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23366. * @param url defines the url to load from
  23367. * @returns a promise that will fullfil when the material is fully loaded
  23368. */
  23369. loadAsync(url: string): Promise<void>;
  23370. private _gatherBlocks;
  23371. /**
  23372. * Generate a string containing the code declaration required to create an equivalent of this material
  23373. * @returns a string
  23374. */
  23375. generateCode(): string;
  23376. /**
  23377. * Serializes this material in a JSON representation
  23378. * @returns the serialized material object
  23379. */
  23380. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23381. private _restoreConnections;
  23382. /**
  23383. * Clear the current graph and load a new one from a serialization object
  23384. * @param source defines the JSON representation of the material
  23385. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23386. * @param merge defines whether or not the source must be merged or replace the current content
  23387. */
  23388. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23389. /**
  23390. * Makes a duplicate of the current material.
  23391. * @param name - name to use for the new material.
  23392. */
  23393. clone(name: string): NodeMaterial;
  23394. /**
  23395. * Creates a node material from parsed material data
  23396. * @param source defines the JSON representation of the material
  23397. * @param scene defines the hosting scene
  23398. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23399. * @returns a new node material
  23400. */
  23401. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23402. /**
  23403. * Creates a node material from a snippet saved in a remote file
  23404. * @param name defines the name of the material to create
  23405. * @param url defines the url to load from
  23406. * @param scene defines the hosting scene
  23407. * @returns a promise that will resolve to the new node material
  23408. */
  23409. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23410. /**
  23411. * Creates a node material from a snippet saved by the node material editor
  23412. * @param snippetId defines the snippet to load
  23413. * @param scene defines the hosting scene
  23414. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23415. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23416. * @returns a promise that will resolve to the new node material
  23417. */
  23418. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23419. /**
  23420. * Creates a new node material set to default basic configuration
  23421. * @param name defines the name of the material
  23422. * @param scene defines the hosting scene
  23423. * @returns a new NodeMaterial
  23424. */
  23425. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23426. }
  23427. }
  23428. declare module "babylonjs/PostProcesses/postProcess" {
  23429. import { Nullable } from "babylonjs/types";
  23430. import { SmartArray } from "babylonjs/Misc/smartArray";
  23431. import { Observable } from "babylonjs/Misc/observable";
  23432. import { Vector2 } from "babylonjs/Maths/math.vector";
  23433. import { Camera } from "babylonjs/Cameras/camera";
  23434. import { Effect } from "babylonjs/Materials/effect";
  23435. import "babylonjs/Shaders/postprocess.vertex";
  23436. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23437. import { Engine } from "babylonjs/Engines/engine";
  23438. import { Color4 } from "babylonjs/Maths/math.color";
  23439. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23440. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23441. import { Scene } from "babylonjs/scene";
  23442. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23443. /**
  23444. * Size options for a post process
  23445. */
  23446. export type PostProcessOptions = {
  23447. width: number;
  23448. height: number;
  23449. };
  23450. /**
  23451. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23452. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23453. */
  23454. export class PostProcess {
  23455. /**
  23456. * Gets or sets the unique id of the post process
  23457. */
  23458. uniqueId: number;
  23459. /** Name of the PostProcess. */
  23460. name: string;
  23461. /**
  23462. * Width of the texture to apply the post process on
  23463. */
  23464. width: number;
  23465. /**
  23466. * Height of the texture to apply the post process on
  23467. */
  23468. height: number;
  23469. /**
  23470. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23471. */
  23472. nodeMaterialSource: Nullable<NodeMaterial>;
  23473. /**
  23474. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23475. * @hidden
  23476. */
  23477. _outputTexture: Nullable<InternalTexture>;
  23478. /**
  23479. * Sampling mode used by the shader
  23480. * See https://doc.babylonjs.com/classes/3.1/texture
  23481. */
  23482. renderTargetSamplingMode: number;
  23483. /**
  23484. * Clear color to use when screen clearing
  23485. */
  23486. clearColor: Color4;
  23487. /**
  23488. * If the buffer needs to be cleared before applying the post process. (default: true)
  23489. * Should be set to false if shader will overwrite all previous pixels.
  23490. */
  23491. autoClear: boolean;
  23492. /**
  23493. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23494. */
  23495. alphaMode: number;
  23496. /**
  23497. * Sets the setAlphaBlendConstants of the babylon engine
  23498. */
  23499. alphaConstants: Color4;
  23500. /**
  23501. * Animations to be used for the post processing
  23502. */
  23503. animations: import("babylonjs/Animations/animation").Animation[];
  23504. /**
  23505. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23506. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23507. */
  23508. enablePixelPerfectMode: boolean;
  23509. /**
  23510. * Force the postprocess to be applied without taking in account viewport
  23511. */
  23512. forceFullscreenViewport: boolean;
  23513. /**
  23514. * List of inspectable custom properties (used by the Inspector)
  23515. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23516. */
  23517. inspectableCustomProperties: IInspectable[];
  23518. /**
  23519. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23520. *
  23521. * | Value | Type | Description |
  23522. * | ----- | ----------------------------------- | ----------- |
  23523. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23524. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23525. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23526. *
  23527. */
  23528. scaleMode: number;
  23529. /**
  23530. * Force textures to be a power of two (default: false)
  23531. */
  23532. alwaysForcePOT: boolean;
  23533. private _samples;
  23534. /**
  23535. * Number of sample textures (default: 1)
  23536. */
  23537. get samples(): number;
  23538. set samples(n: number);
  23539. /**
  23540. * Modify the scale of the post process to be the same as the viewport (default: false)
  23541. */
  23542. adaptScaleToCurrentViewport: boolean;
  23543. private _camera;
  23544. protected _scene: Scene;
  23545. private _engine;
  23546. private _options;
  23547. private _reusable;
  23548. private _textureType;
  23549. private _textureFormat;
  23550. /**
  23551. * Smart array of input and output textures for the post process.
  23552. * @hidden
  23553. */
  23554. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23555. /**
  23556. * The index in _textures that corresponds to the output texture.
  23557. * @hidden
  23558. */
  23559. _currentRenderTextureInd: number;
  23560. private _effect;
  23561. private _samplers;
  23562. private _fragmentUrl;
  23563. private _vertexUrl;
  23564. private _parameters;
  23565. private _scaleRatio;
  23566. protected _indexParameters: any;
  23567. private _shareOutputWithPostProcess;
  23568. private _texelSize;
  23569. private _forcedOutputTexture;
  23570. /**
  23571. * Returns the fragment url or shader name used in the post process.
  23572. * @returns the fragment url or name in the shader store.
  23573. */
  23574. getEffectName(): string;
  23575. /**
  23576. * An event triggered when the postprocess is activated.
  23577. */
  23578. onActivateObservable: Observable<Camera>;
  23579. private _onActivateObserver;
  23580. /**
  23581. * A function that is added to the onActivateObservable
  23582. */
  23583. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23584. /**
  23585. * An event triggered when the postprocess changes its size.
  23586. */
  23587. onSizeChangedObservable: Observable<PostProcess>;
  23588. private _onSizeChangedObserver;
  23589. /**
  23590. * A function that is added to the onSizeChangedObservable
  23591. */
  23592. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23593. /**
  23594. * An event triggered when the postprocess applies its effect.
  23595. */
  23596. onApplyObservable: Observable<Effect>;
  23597. private _onApplyObserver;
  23598. /**
  23599. * A function that is added to the onApplyObservable
  23600. */
  23601. set onApply(callback: (effect: Effect) => void);
  23602. /**
  23603. * An event triggered before rendering the postprocess
  23604. */
  23605. onBeforeRenderObservable: Observable<Effect>;
  23606. private _onBeforeRenderObserver;
  23607. /**
  23608. * A function that is added to the onBeforeRenderObservable
  23609. */
  23610. set onBeforeRender(callback: (effect: Effect) => void);
  23611. /**
  23612. * An event triggered after rendering the postprocess
  23613. */
  23614. onAfterRenderObservable: Observable<Effect>;
  23615. private _onAfterRenderObserver;
  23616. /**
  23617. * A function that is added to the onAfterRenderObservable
  23618. */
  23619. set onAfterRender(callback: (efect: Effect) => void);
  23620. /**
  23621. * 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
  23622. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23623. */
  23624. get inputTexture(): InternalTexture;
  23625. set inputTexture(value: InternalTexture);
  23626. /**
  23627. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23628. * the only way to unset it is to use this function to restore its internal state
  23629. */
  23630. restoreDefaultInputTexture(): void;
  23631. /**
  23632. * Gets the camera which post process is applied to.
  23633. * @returns The camera the post process is applied to.
  23634. */
  23635. getCamera(): Camera;
  23636. /**
  23637. * Gets the texel size of the postprocess.
  23638. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23639. */
  23640. get texelSize(): Vector2;
  23641. /**
  23642. * Creates a new instance PostProcess
  23643. * @param name The name of the PostProcess.
  23644. * @param fragmentUrl The url of the fragment shader to be used.
  23645. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23646. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23647. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23648. * @param camera The camera to apply the render pass to.
  23649. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23650. * @param engine The engine which the post process will be applied. (default: current engine)
  23651. * @param reusable If the post process can be reused on the same frame. (default: false)
  23652. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23653. * @param textureType Type of textures used when performing the post process. (default: 0)
  23654. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23655. * @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
  23656. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23657. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23658. */
  23659. 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);
  23660. /**
  23661. * Gets a string identifying the name of the class
  23662. * @returns "PostProcess" string
  23663. */
  23664. getClassName(): string;
  23665. /**
  23666. * Gets the engine which this post process belongs to.
  23667. * @returns The engine the post process was enabled with.
  23668. */
  23669. getEngine(): Engine;
  23670. /**
  23671. * The effect that is created when initializing the post process.
  23672. * @returns The created effect corresponding the the postprocess.
  23673. */
  23674. getEffect(): Effect;
  23675. /**
  23676. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23677. * @param postProcess The post process to share the output with.
  23678. * @returns This post process.
  23679. */
  23680. shareOutputWith(postProcess: PostProcess): PostProcess;
  23681. /**
  23682. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23683. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23684. */
  23685. useOwnOutput(): void;
  23686. /**
  23687. * Updates the effect with the current post process compile time values and recompiles the shader.
  23688. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23689. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23690. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23691. * @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
  23692. * @param onCompiled Called when the shader has been compiled.
  23693. * @param onError Called if there is an error when compiling a shader.
  23694. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23695. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23696. */
  23697. 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;
  23698. /**
  23699. * The post process is reusable if it can be used multiple times within one frame.
  23700. * @returns If the post process is reusable
  23701. */
  23702. isReusable(): boolean;
  23703. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23704. markTextureDirty(): void;
  23705. /**
  23706. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23707. * 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.
  23708. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23709. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23710. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23711. * @returns The target texture that was bound to be written to.
  23712. */
  23713. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23714. /**
  23715. * If the post process is supported.
  23716. */
  23717. get isSupported(): boolean;
  23718. /**
  23719. * The aspect ratio of the output texture.
  23720. */
  23721. get aspectRatio(): number;
  23722. /**
  23723. * Get a value indicating if the post-process is ready to be used
  23724. * @returns true if the post-process is ready (shader is compiled)
  23725. */
  23726. isReady(): boolean;
  23727. /**
  23728. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23729. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23730. */
  23731. apply(): Nullable<Effect>;
  23732. private _disposeTextures;
  23733. /**
  23734. * Disposes the post process.
  23735. * @param camera The camera to dispose the post process on.
  23736. */
  23737. dispose(camera?: Camera): void;
  23738. /**
  23739. * Serializes the particle system to a JSON object
  23740. * @returns the JSON object
  23741. */
  23742. serialize(): any;
  23743. /**
  23744. * Creates a material from parsed material data
  23745. * @param parsedPostProcess defines parsed post process data
  23746. * @param scene defines the hosting scene
  23747. * @param rootUrl defines the root URL to use to load textures
  23748. * @returns a new post process
  23749. */
  23750. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23751. }
  23752. }
  23753. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23754. /** @hidden */
  23755. export var kernelBlurVaryingDeclaration: {
  23756. name: string;
  23757. shader: string;
  23758. };
  23759. }
  23760. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23761. /** @hidden */
  23762. export var kernelBlurFragment: {
  23763. name: string;
  23764. shader: string;
  23765. };
  23766. }
  23767. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23768. /** @hidden */
  23769. export var kernelBlurFragment2: {
  23770. name: string;
  23771. shader: string;
  23772. };
  23773. }
  23774. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23775. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23776. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23777. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23778. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23779. /** @hidden */
  23780. export var kernelBlurPixelShader: {
  23781. name: string;
  23782. shader: string;
  23783. };
  23784. }
  23785. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23786. /** @hidden */
  23787. export var kernelBlurVertex: {
  23788. name: string;
  23789. shader: string;
  23790. };
  23791. }
  23792. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23793. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23794. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23795. /** @hidden */
  23796. export var kernelBlurVertexShader: {
  23797. name: string;
  23798. shader: string;
  23799. };
  23800. }
  23801. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23802. import { Vector2 } from "babylonjs/Maths/math.vector";
  23803. import { Nullable } from "babylonjs/types";
  23804. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23805. import { Camera } from "babylonjs/Cameras/camera";
  23806. import { Effect } from "babylonjs/Materials/effect";
  23807. import { Engine } from "babylonjs/Engines/engine";
  23808. import "babylonjs/Shaders/kernelBlur.fragment";
  23809. import "babylonjs/Shaders/kernelBlur.vertex";
  23810. import { Scene } from "babylonjs/scene";
  23811. /**
  23812. * The Blur Post Process which blurs an image based on a kernel and direction.
  23813. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23814. */
  23815. export class BlurPostProcess extends PostProcess {
  23816. private blockCompilation;
  23817. protected _kernel: number;
  23818. protected _idealKernel: number;
  23819. protected _packedFloat: boolean;
  23820. private _staticDefines;
  23821. /** The direction in which to blur the image. */
  23822. direction: Vector2;
  23823. /**
  23824. * Sets the length in pixels of the blur sample region
  23825. */
  23826. set kernel(v: number);
  23827. /**
  23828. * Gets the length in pixels of the blur sample region
  23829. */
  23830. get kernel(): number;
  23831. /**
  23832. * Sets wether or not the blur needs to unpack/repack floats
  23833. */
  23834. set packedFloat(v: boolean);
  23835. /**
  23836. * Gets wether or not the blur is unpacking/repacking floats
  23837. */
  23838. get packedFloat(): boolean;
  23839. /**
  23840. * Gets a string identifying the name of the class
  23841. * @returns "BlurPostProcess" string
  23842. */
  23843. getClassName(): string;
  23844. /**
  23845. * Creates a new instance BlurPostProcess
  23846. * @param name The name of the effect.
  23847. * @param direction The direction in which to blur the image.
  23848. * @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.
  23849. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23850. * @param camera The camera to apply the render pass to.
  23851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23852. * @param engine The engine which the post process will be applied. (default: current engine)
  23853. * @param reusable If the post process can be reused on the same frame. (default: false)
  23854. * @param textureType Type of textures used when performing the post process. (default: 0)
  23855. * @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)
  23856. */
  23857. 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);
  23858. /**
  23859. * Updates the effect with the current post process compile time values and recompiles the shader.
  23860. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23861. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23862. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23863. * @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
  23864. * @param onCompiled Called when the shader has been compiled.
  23865. * @param onError Called if there is an error when compiling a shader.
  23866. */
  23867. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23868. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23869. /**
  23870. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23871. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23872. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23873. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23874. * The gaps between physical kernels are compensated for in the weighting of the samples
  23875. * @param idealKernel Ideal blur kernel.
  23876. * @return Nearest best kernel.
  23877. */
  23878. protected _nearestBestKernel(idealKernel: number): number;
  23879. /**
  23880. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23881. * @param x The point on the Gaussian distribution to sample.
  23882. * @return the value of the Gaussian function at x.
  23883. */
  23884. protected _gaussianWeight(x: number): number;
  23885. /**
  23886. * Generates a string that can be used as a floating point number in GLSL.
  23887. * @param x Value to print.
  23888. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23889. * @return GLSL float string.
  23890. */
  23891. protected _glslFloat(x: number, decimalFigures?: number): string;
  23892. /** @hidden */
  23893. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23894. }
  23895. }
  23896. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23897. import { Scene } from "babylonjs/scene";
  23898. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23899. import { Plane } from "babylonjs/Maths/math.plane";
  23900. /**
  23901. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23902. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23903. * You can then easily use it as a reflectionTexture on a flat surface.
  23904. * In case the surface is not a plane, please consider relying on reflection probes.
  23905. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23906. */
  23907. export class MirrorTexture extends RenderTargetTexture {
  23908. private scene;
  23909. /**
  23910. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23911. * 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.
  23912. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23913. */
  23914. mirrorPlane: Plane;
  23915. /**
  23916. * Define the blur ratio used to blur the reflection if needed.
  23917. */
  23918. set blurRatio(value: number);
  23919. get blurRatio(): number;
  23920. /**
  23921. * Define the adaptive blur kernel used to blur the reflection if needed.
  23922. * This will autocompute the closest best match for the `blurKernel`
  23923. */
  23924. set adaptiveBlurKernel(value: number);
  23925. /**
  23926. * Define the blur kernel used to blur the reflection if needed.
  23927. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23928. */
  23929. set blurKernel(value: number);
  23930. /**
  23931. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23932. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23933. */
  23934. set blurKernelX(value: number);
  23935. get blurKernelX(): number;
  23936. /**
  23937. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23938. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23939. */
  23940. set blurKernelY(value: number);
  23941. get blurKernelY(): number;
  23942. private _autoComputeBlurKernel;
  23943. protected _onRatioRescale(): void;
  23944. private _updateGammaSpace;
  23945. private _imageProcessingConfigChangeObserver;
  23946. private _transformMatrix;
  23947. private _mirrorMatrix;
  23948. private _savedViewMatrix;
  23949. private _blurX;
  23950. private _blurY;
  23951. private _adaptiveBlurKernel;
  23952. private _blurKernelX;
  23953. private _blurKernelY;
  23954. private _blurRatio;
  23955. /**
  23956. * Instantiates a Mirror Texture.
  23957. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23958. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23959. * You can then easily use it as a reflectionTexture on a flat surface.
  23960. * In case the surface is not a plane, please consider relying on reflection probes.
  23961. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23962. * @param name
  23963. * @param size
  23964. * @param scene
  23965. * @param generateMipMaps
  23966. * @param type
  23967. * @param samplingMode
  23968. * @param generateDepthBuffer
  23969. */
  23970. constructor(name: string, size: number | {
  23971. width: number;
  23972. height: number;
  23973. } | {
  23974. ratio: number;
  23975. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23976. private _preparePostProcesses;
  23977. /**
  23978. * Clone the mirror texture.
  23979. * @returns the cloned texture
  23980. */
  23981. clone(): MirrorTexture;
  23982. /**
  23983. * Serialize the texture to a JSON representation you could use in Parse later on
  23984. * @returns the serialized JSON representation
  23985. */
  23986. serialize(): any;
  23987. /**
  23988. * Dispose the texture and release its associated resources.
  23989. */
  23990. dispose(): void;
  23991. }
  23992. }
  23993. declare module "babylonjs/Materials/Textures/texture" {
  23994. import { Observable } from "babylonjs/Misc/observable";
  23995. import { Nullable } from "babylonjs/types";
  23996. import { Matrix } from "babylonjs/Maths/math.vector";
  23997. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23998. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23999. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24000. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  24001. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  24002. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24003. import { Scene } from "babylonjs/scene";
  24004. /**
  24005. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24006. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24007. */
  24008. export class Texture extends BaseTexture {
  24009. /**
  24010. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24011. */
  24012. static SerializeBuffers: boolean;
  24013. /** @hidden */
  24014. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24015. /** @hidden */
  24016. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24017. /** @hidden */
  24018. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24019. /** nearest is mag = nearest and min = nearest and mip = linear */
  24020. static readonly NEAREST_SAMPLINGMODE: number;
  24021. /** nearest is mag = nearest and min = nearest and mip = linear */
  24022. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24023. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24024. static readonly BILINEAR_SAMPLINGMODE: number;
  24025. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24026. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24027. /** Trilinear is mag = linear and min = linear and mip = linear */
  24028. static readonly TRILINEAR_SAMPLINGMODE: number;
  24029. /** Trilinear is mag = linear and min = linear and mip = linear */
  24030. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24031. /** mag = nearest and min = nearest and mip = nearest */
  24032. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24033. /** mag = nearest and min = linear and mip = nearest */
  24034. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24035. /** mag = nearest and min = linear and mip = linear */
  24036. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24037. /** mag = nearest and min = linear and mip = none */
  24038. static readonly NEAREST_LINEAR: number;
  24039. /** mag = nearest and min = nearest and mip = none */
  24040. static readonly NEAREST_NEAREST: number;
  24041. /** mag = linear and min = nearest and mip = nearest */
  24042. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24043. /** mag = linear and min = nearest and mip = linear */
  24044. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24045. /** mag = linear and min = linear and mip = none */
  24046. static readonly LINEAR_LINEAR: number;
  24047. /** mag = linear and min = nearest and mip = none */
  24048. static readonly LINEAR_NEAREST: number;
  24049. /** Explicit coordinates mode */
  24050. static readonly EXPLICIT_MODE: number;
  24051. /** Spherical coordinates mode */
  24052. static readonly SPHERICAL_MODE: number;
  24053. /** Planar coordinates mode */
  24054. static readonly PLANAR_MODE: number;
  24055. /** Cubic coordinates mode */
  24056. static readonly CUBIC_MODE: number;
  24057. /** Projection coordinates mode */
  24058. static readonly PROJECTION_MODE: number;
  24059. /** Inverse Cubic coordinates mode */
  24060. static readonly SKYBOX_MODE: number;
  24061. /** Inverse Cubic coordinates mode */
  24062. static readonly INVCUBIC_MODE: number;
  24063. /** Equirectangular coordinates mode */
  24064. static readonly EQUIRECTANGULAR_MODE: number;
  24065. /** Equirectangular Fixed coordinates mode */
  24066. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24067. /** Equirectangular Fixed Mirrored coordinates mode */
  24068. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24069. /** Texture is not repeating outside of 0..1 UVs */
  24070. static readonly CLAMP_ADDRESSMODE: number;
  24071. /** Texture is repeating outside of 0..1 UVs */
  24072. static readonly WRAP_ADDRESSMODE: number;
  24073. /** Texture is repeating and mirrored */
  24074. static readonly MIRROR_ADDRESSMODE: number;
  24075. /**
  24076. * 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
  24077. */
  24078. static UseSerializedUrlIfAny: boolean;
  24079. /**
  24080. * Define the url of the texture.
  24081. */
  24082. url: Nullable<string>;
  24083. /**
  24084. * Define an offset on the texture to offset the u coordinates of the UVs
  24085. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24086. */
  24087. uOffset: number;
  24088. /**
  24089. * Define an offset on the texture to offset the v coordinates of the UVs
  24090. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24091. */
  24092. vOffset: number;
  24093. /**
  24094. * Define an offset on the texture to scale the u coordinates of the UVs
  24095. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24096. */
  24097. uScale: number;
  24098. /**
  24099. * Define an offset on the texture to scale the v coordinates of the UVs
  24100. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24101. */
  24102. vScale: number;
  24103. /**
  24104. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24105. * @see https://doc.babylonjs.com/how_to/more_materials
  24106. */
  24107. uAng: number;
  24108. /**
  24109. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24110. * @see https://doc.babylonjs.com/how_to/more_materials
  24111. */
  24112. vAng: number;
  24113. /**
  24114. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24115. * @see https://doc.babylonjs.com/how_to/more_materials
  24116. */
  24117. wAng: number;
  24118. /**
  24119. * Defines the center of rotation (U)
  24120. */
  24121. uRotationCenter: number;
  24122. /**
  24123. * Defines the center of rotation (V)
  24124. */
  24125. vRotationCenter: number;
  24126. /**
  24127. * Defines the center of rotation (W)
  24128. */
  24129. wRotationCenter: number;
  24130. /**
  24131. * Are mip maps generated for this texture or not.
  24132. */
  24133. get noMipmap(): boolean;
  24134. /**
  24135. * List of inspectable custom properties (used by the Inspector)
  24136. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24137. */
  24138. inspectableCustomProperties: Nullable<IInspectable[]>;
  24139. private _noMipmap;
  24140. /** @hidden */
  24141. _invertY: boolean;
  24142. private _rowGenerationMatrix;
  24143. private _cachedTextureMatrix;
  24144. private _projectionModeMatrix;
  24145. private _t0;
  24146. private _t1;
  24147. private _t2;
  24148. private _cachedUOffset;
  24149. private _cachedVOffset;
  24150. private _cachedUScale;
  24151. private _cachedVScale;
  24152. private _cachedUAng;
  24153. private _cachedVAng;
  24154. private _cachedWAng;
  24155. private _cachedProjectionMatrixId;
  24156. private _cachedCoordinatesMode;
  24157. /** @hidden */
  24158. protected _initialSamplingMode: number;
  24159. /** @hidden */
  24160. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24161. private _deleteBuffer;
  24162. protected _format: Nullable<number>;
  24163. private _delayedOnLoad;
  24164. private _delayedOnError;
  24165. private _mimeType?;
  24166. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24167. get mimeType(): string | undefined;
  24168. /**
  24169. * Observable triggered once the texture has been loaded.
  24170. */
  24171. onLoadObservable: Observable<Texture>;
  24172. protected _isBlocking: boolean;
  24173. /**
  24174. * Is the texture preventing material to render while loading.
  24175. * If false, a default texture will be used instead of the loading one during the preparation step.
  24176. */
  24177. set isBlocking(value: boolean);
  24178. get isBlocking(): boolean;
  24179. /**
  24180. * Get the current sampling mode associated with the texture.
  24181. */
  24182. get samplingMode(): number;
  24183. /**
  24184. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24185. */
  24186. get invertY(): boolean;
  24187. /**
  24188. * Instantiates a new texture.
  24189. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24190. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24191. * @param url defines the url of the picture to load as a texture
  24192. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24193. * @param noMipmap defines if the texture will require mip maps or not
  24194. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24195. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24196. * @param onLoad defines a callback triggered when the texture has been loaded
  24197. * @param onError defines a callback triggered when an error occurred during the loading session
  24198. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24199. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24200. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24201. * @param mimeType defines an optional mime type information
  24202. */
  24203. 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);
  24204. /**
  24205. * Update the url (and optional buffer) of this texture if url was null during construction.
  24206. * @param url the url of the texture
  24207. * @param buffer the buffer of the texture (defaults to null)
  24208. * @param onLoad callback called when the texture is loaded (defaults to null)
  24209. */
  24210. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24211. /**
  24212. * Finish the loading sequence of a texture flagged as delayed load.
  24213. * @hidden
  24214. */
  24215. delayLoad(): void;
  24216. private _prepareRowForTextureGeneration;
  24217. /**
  24218. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24219. * @returns the transform matrix of the texture.
  24220. */
  24221. getTextureMatrix(uBase?: number): Matrix;
  24222. /**
  24223. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24224. * @returns The reflection texture transform
  24225. */
  24226. getReflectionTextureMatrix(): Matrix;
  24227. /**
  24228. * Clones the texture.
  24229. * @returns the cloned texture
  24230. */
  24231. clone(): Texture;
  24232. /**
  24233. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24234. * @returns The JSON representation of the texture
  24235. */
  24236. serialize(): any;
  24237. /**
  24238. * Get the current class name of the texture useful for serialization or dynamic coding.
  24239. * @returns "Texture"
  24240. */
  24241. getClassName(): string;
  24242. /**
  24243. * Dispose the texture and release its associated resources.
  24244. */
  24245. dispose(): void;
  24246. /**
  24247. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24248. * @param parsedTexture Define the JSON representation of the texture
  24249. * @param scene Define the scene the parsed texture should be instantiated in
  24250. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24251. * @returns The parsed texture if successful
  24252. */
  24253. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24254. /**
  24255. * Creates a texture from its base 64 representation.
  24256. * @param data Define the base64 payload without the data: prefix
  24257. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24258. * @param scene Define the scene the texture should belong to
  24259. * @param noMipmap Forces the texture to not create mip map information if true
  24260. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24261. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24262. * @param onLoad define a callback triggered when the texture has been loaded
  24263. * @param onError define a callback triggered when an error occurred during the loading session
  24264. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24265. * @returns the created texture
  24266. */
  24267. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24268. /**
  24269. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24270. * @param data Define the base64 payload without the data: prefix
  24271. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24272. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24273. * @param scene Define the scene the texture should belong to
  24274. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24275. * @param noMipmap Forces the texture to not create mip map information if true
  24276. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24277. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24278. * @param onLoad define a callback triggered when the texture has been loaded
  24279. * @param onError define a callback triggered when an error occurred during the loading session
  24280. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24281. * @returns the created texture
  24282. */
  24283. 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;
  24284. }
  24285. }
  24286. declare module "babylonjs/PostProcesses/postProcessManager" {
  24287. import { Nullable } from "babylonjs/types";
  24288. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24289. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24290. import { Scene } from "babylonjs/scene";
  24291. /**
  24292. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24293. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24294. */
  24295. export class PostProcessManager {
  24296. private _scene;
  24297. private _indexBuffer;
  24298. private _vertexBuffers;
  24299. /**
  24300. * Creates a new instance PostProcess
  24301. * @param scene The scene that the post process is associated with.
  24302. */
  24303. constructor(scene: Scene);
  24304. private _prepareBuffers;
  24305. private _buildIndexBuffer;
  24306. /**
  24307. * Rebuilds the vertex buffers of the manager.
  24308. * @hidden
  24309. */
  24310. _rebuild(): void;
  24311. /**
  24312. * Prepares a frame to be run through a post process.
  24313. * @param sourceTexture The input texture to the post procesess. (default: null)
  24314. * @param postProcesses An array of post processes to be run. (default: null)
  24315. * @returns True if the post processes were able to be run.
  24316. * @hidden
  24317. */
  24318. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24319. /**
  24320. * Manually render a set of post processes to a texture.
  24321. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24322. * @param postProcesses An array of post processes to be run.
  24323. * @param targetTexture The target texture to render to.
  24324. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24325. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24326. * @param lodLevel defines which lod of the texture to render to
  24327. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24328. */
  24329. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24330. /**
  24331. * Finalize the result of the output of the postprocesses.
  24332. * @param doNotPresent If true the result will not be displayed to the screen.
  24333. * @param targetTexture The target texture to render to.
  24334. * @param faceIndex The index of the face to bind the target texture to.
  24335. * @param postProcesses The array of post processes to render.
  24336. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24337. * @hidden
  24338. */
  24339. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24340. /**
  24341. * Disposes of the post process manager.
  24342. */
  24343. dispose(): void;
  24344. }
  24345. }
  24346. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24347. import { Observable } from "babylonjs/Misc/observable";
  24348. import { SmartArray } from "babylonjs/Misc/smartArray";
  24349. import { Nullable, Immutable } from "babylonjs/types";
  24350. import { Camera } from "babylonjs/Cameras/camera";
  24351. import { Scene } from "babylonjs/scene";
  24352. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24353. import { Color4 } from "babylonjs/Maths/math.color";
  24354. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24356. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24357. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24358. import { Texture } from "babylonjs/Materials/Textures/texture";
  24359. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24360. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24361. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24362. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24363. import { Engine } from "babylonjs/Engines/engine";
  24364. /**
  24365. * This Helps creating a texture that will be created from a camera in your scene.
  24366. * It is basically a dynamic texture that could be used to create special effects for instance.
  24367. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24368. */
  24369. export class RenderTargetTexture extends Texture {
  24370. /**
  24371. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24372. */
  24373. static readonly REFRESHRATE_RENDER_ONCE: number;
  24374. /**
  24375. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24376. */
  24377. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24378. /**
  24379. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24380. * the central point of your effect and can save a lot of performances.
  24381. */
  24382. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24383. /**
  24384. * Use this predicate to dynamically define the list of mesh you want to render.
  24385. * If set, the renderList property will be overwritten.
  24386. */
  24387. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24388. private _renderList;
  24389. /**
  24390. * Use this list to define the list of mesh you want to render.
  24391. */
  24392. get renderList(): Nullable<Array<AbstractMesh>>;
  24393. set renderList(value: Nullable<Array<AbstractMesh>>);
  24394. /**
  24395. * Use this function to overload the renderList array at rendering time.
  24396. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24397. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24398. * the cube (if the RTT is a cube, else layerOrFace=0).
  24399. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24400. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24401. * hold dummy elements!
  24402. */
  24403. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24404. private _hookArray;
  24405. /**
  24406. * Define if particles should be rendered in your texture.
  24407. */
  24408. renderParticles: boolean;
  24409. /**
  24410. * Define if sprites should be rendered in your texture.
  24411. */
  24412. renderSprites: boolean;
  24413. /**
  24414. * Define the camera used to render the texture.
  24415. */
  24416. activeCamera: Nullable<Camera>;
  24417. /**
  24418. * Override the mesh isReady function with your own one.
  24419. */
  24420. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24421. /**
  24422. * Override the render function of the texture with your own one.
  24423. */
  24424. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24425. /**
  24426. * Define if camera post processes should be use while rendering the texture.
  24427. */
  24428. useCameraPostProcesses: boolean;
  24429. /**
  24430. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24431. */
  24432. ignoreCameraViewport: boolean;
  24433. private _postProcessManager;
  24434. private _postProcesses;
  24435. private _resizeObserver;
  24436. /**
  24437. * An event triggered when the texture is unbind.
  24438. */
  24439. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24440. /**
  24441. * An event triggered when the texture is unbind.
  24442. */
  24443. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24444. private _onAfterUnbindObserver;
  24445. /**
  24446. * Set a after unbind callback in the texture.
  24447. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24448. */
  24449. set onAfterUnbind(callback: () => void);
  24450. /**
  24451. * An event triggered before rendering the texture
  24452. */
  24453. onBeforeRenderObservable: Observable<number>;
  24454. private _onBeforeRenderObserver;
  24455. /**
  24456. * Set a before render callback in the texture.
  24457. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24458. */
  24459. set onBeforeRender(callback: (faceIndex: number) => void);
  24460. /**
  24461. * An event triggered after rendering the texture
  24462. */
  24463. onAfterRenderObservable: Observable<number>;
  24464. private _onAfterRenderObserver;
  24465. /**
  24466. * Set a after render callback in the texture.
  24467. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24468. */
  24469. set onAfterRender(callback: (faceIndex: number) => void);
  24470. /**
  24471. * An event triggered after the texture clear
  24472. */
  24473. onClearObservable: Observable<Engine>;
  24474. private _onClearObserver;
  24475. /**
  24476. * Set a clear callback in the texture.
  24477. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24478. */
  24479. set onClear(callback: (Engine: Engine) => void);
  24480. /**
  24481. * An event triggered when the texture is resized.
  24482. */
  24483. onResizeObservable: Observable<RenderTargetTexture>;
  24484. /**
  24485. * Define the clear color of the Render Target if it should be different from the scene.
  24486. */
  24487. clearColor: Color4;
  24488. protected _size: number | {
  24489. width: number;
  24490. height: number;
  24491. layers?: number;
  24492. };
  24493. protected _initialSizeParameter: number | {
  24494. width: number;
  24495. height: number;
  24496. } | {
  24497. ratio: number;
  24498. };
  24499. protected _sizeRatio: Nullable<number>;
  24500. /** @hidden */
  24501. _generateMipMaps: boolean;
  24502. protected _renderingManager: RenderingManager;
  24503. /** @hidden */
  24504. _waitingRenderList?: string[];
  24505. protected _doNotChangeAspectRatio: boolean;
  24506. protected _currentRefreshId: number;
  24507. protected _refreshRate: number;
  24508. protected _textureMatrix: Matrix;
  24509. protected _samples: number;
  24510. protected _renderTargetOptions: RenderTargetCreationOptions;
  24511. /**
  24512. * Gets render target creation options that were used.
  24513. */
  24514. get renderTargetOptions(): RenderTargetCreationOptions;
  24515. protected _onRatioRescale(): void;
  24516. /**
  24517. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24518. * It must define where the camera used to render the texture is set
  24519. */
  24520. boundingBoxPosition: Vector3;
  24521. private _boundingBoxSize;
  24522. /**
  24523. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24524. * When defined, the cubemap will switch to local mode
  24525. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24526. * @example https://www.babylonjs-playground.com/#RNASML
  24527. */
  24528. set boundingBoxSize(value: Vector3);
  24529. get boundingBoxSize(): Vector3;
  24530. /**
  24531. * In case the RTT has been created with a depth texture, get the associated
  24532. * depth texture.
  24533. * Otherwise, return null.
  24534. */
  24535. get depthStencilTexture(): Nullable<InternalTexture>;
  24536. /**
  24537. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24538. * or used a shadow, depth texture...
  24539. * @param name The friendly name of the texture
  24540. * @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)
  24541. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24542. * @param generateMipMaps True if mip maps need to be generated after render.
  24543. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24544. * @param type The type of the buffer in the RTT (int, half float, float...)
  24545. * @param isCube True if a cube texture needs to be created
  24546. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24547. * @param generateDepthBuffer True to generate a depth buffer
  24548. * @param generateStencilBuffer True to generate a stencil buffer
  24549. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24550. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24551. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24552. */
  24553. constructor(name: string, size: number | {
  24554. width: number;
  24555. height: number;
  24556. layers?: number;
  24557. } | {
  24558. ratio: number;
  24559. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24560. /**
  24561. * Creates a depth stencil texture.
  24562. * This is only available in WebGL 2 or with the depth texture extension available.
  24563. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24564. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24565. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24566. */
  24567. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24568. private _processSizeParameter;
  24569. /**
  24570. * Define the number of samples to use in case of MSAA.
  24571. * It defaults to one meaning no MSAA has been enabled.
  24572. */
  24573. get samples(): number;
  24574. set samples(value: number);
  24575. /**
  24576. * Resets the refresh counter of the texture and start bak from scratch.
  24577. * Could be useful to regenerate the texture if it is setup to render only once.
  24578. */
  24579. resetRefreshCounter(): void;
  24580. /**
  24581. * Define the refresh rate of the texture or the rendering frequency.
  24582. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24583. */
  24584. get refreshRate(): number;
  24585. set refreshRate(value: number);
  24586. /**
  24587. * Adds a post process to the render target rendering passes.
  24588. * @param postProcess define the post process to add
  24589. */
  24590. addPostProcess(postProcess: PostProcess): void;
  24591. /**
  24592. * Clear all the post processes attached to the render target
  24593. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24594. */
  24595. clearPostProcesses(dispose?: boolean): void;
  24596. /**
  24597. * Remove one of the post process from the list of attached post processes to the texture
  24598. * @param postProcess define the post process to remove from the list
  24599. */
  24600. removePostProcess(postProcess: PostProcess): void;
  24601. /** @hidden */
  24602. _shouldRender(): boolean;
  24603. /**
  24604. * Gets the actual render size of the texture.
  24605. * @returns the width of the render size
  24606. */
  24607. getRenderSize(): number;
  24608. /**
  24609. * Gets the actual render width of the texture.
  24610. * @returns the width of the render size
  24611. */
  24612. getRenderWidth(): number;
  24613. /**
  24614. * Gets the actual render height of the texture.
  24615. * @returns the height of the render size
  24616. */
  24617. getRenderHeight(): number;
  24618. /**
  24619. * Gets the actual number of layers of the texture.
  24620. * @returns the number of layers
  24621. */
  24622. getRenderLayers(): number;
  24623. /**
  24624. * Get if the texture can be rescaled or not.
  24625. */
  24626. get canRescale(): boolean;
  24627. /**
  24628. * Resize the texture using a ratio.
  24629. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24630. */
  24631. scale(ratio: number): void;
  24632. /**
  24633. * Get the texture reflection matrix used to rotate/transform the reflection.
  24634. * @returns the reflection matrix
  24635. */
  24636. getReflectionTextureMatrix(): Matrix;
  24637. /**
  24638. * Resize the texture to a new desired size.
  24639. * Be carrefull as it will recreate all the data in the new texture.
  24640. * @param size Define the new size. It can be:
  24641. * - a number for squared texture,
  24642. * - an object containing { width: number, height: number }
  24643. * - or an object containing a ratio { ratio: number }
  24644. */
  24645. resize(size: number | {
  24646. width: number;
  24647. height: number;
  24648. } | {
  24649. ratio: number;
  24650. }): void;
  24651. private _defaultRenderListPrepared;
  24652. /**
  24653. * Renders all the objects from the render list into the texture.
  24654. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24655. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24656. */
  24657. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24658. private _bestReflectionRenderTargetDimension;
  24659. private _prepareRenderingManager;
  24660. /**
  24661. * @hidden
  24662. * @param faceIndex face index to bind to if this is a cubetexture
  24663. * @param layer defines the index of the texture to bind in the array
  24664. */
  24665. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24666. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24667. private renderToTarget;
  24668. /**
  24669. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24670. * This allowed control for front to back rendering or reversly depending of the special needs.
  24671. *
  24672. * @param renderingGroupId The rendering group id corresponding to its index
  24673. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24674. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24675. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24676. */
  24677. 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;
  24678. /**
  24679. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24680. *
  24681. * @param renderingGroupId The rendering group id corresponding to its index
  24682. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24683. */
  24684. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24685. /**
  24686. * Clones the texture.
  24687. * @returns the cloned texture
  24688. */
  24689. clone(): RenderTargetTexture;
  24690. /**
  24691. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24692. * @returns The JSON representation of the texture
  24693. */
  24694. serialize(): any;
  24695. /**
  24696. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24697. */
  24698. disposeFramebufferObjects(): void;
  24699. /**
  24700. * Dispose the texture and release its associated resources.
  24701. */
  24702. dispose(): void;
  24703. /** @hidden */
  24704. _rebuild(): void;
  24705. /**
  24706. * Clear the info related to rendering groups preventing retention point in material dispose.
  24707. */
  24708. freeRenderingGroups(): void;
  24709. /**
  24710. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24711. * @returns the view count
  24712. */
  24713. getViewCount(): number;
  24714. }
  24715. }
  24716. declare module "babylonjs/Misc/guid" {
  24717. /**
  24718. * Class used to manipulate GUIDs
  24719. */
  24720. export class GUID {
  24721. /**
  24722. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24723. * Be aware Math.random() could cause collisions, but:
  24724. * "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"
  24725. * @returns a pseudo random id
  24726. */
  24727. static RandomId(): string;
  24728. }
  24729. }
  24730. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24731. import { Nullable } from "babylonjs/types";
  24732. import { Scene } from "babylonjs/scene";
  24733. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24734. import { Material } from "babylonjs/Materials/material";
  24735. import { Effect } from "babylonjs/Materials/effect";
  24736. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24737. /**
  24738. * Options to be used when creating a shadow depth material
  24739. */
  24740. export interface IIOptionShadowDepthMaterial {
  24741. /** Variables in the vertex shader code that need to have their names remapped.
  24742. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24743. * "var_name" should be either: worldPos or vNormalW
  24744. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24745. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24746. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24747. */
  24748. remappedVariables?: string[];
  24749. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24750. standalone?: boolean;
  24751. }
  24752. /**
  24753. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24754. */
  24755. export class ShadowDepthWrapper {
  24756. private _scene;
  24757. private _options?;
  24758. private _baseMaterial;
  24759. private _onEffectCreatedObserver;
  24760. private _subMeshToEffect;
  24761. private _subMeshToDepthEffect;
  24762. private _meshes;
  24763. /** @hidden */
  24764. _matriceNames: any;
  24765. /** Gets the standalone status of the wrapper */
  24766. get standalone(): boolean;
  24767. /** Gets the base material the wrapper is built upon */
  24768. get baseMaterial(): Material;
  24769. /**
  24770. * Instantiate a new shadow depth wrapper.
  24771. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24772. * generate the shadow depth map. For more information, please refer to the documentation:
  24773. * https://doc.babylonjs.com/babylon101/shadows
  24774. * @param baseMaterial Material to wrap
  24775. * @param scene Define the scene the material belongs to
  24776. * @param options Options used to create the wrapper
  24777. */
  24778. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24779. /**
  24780. * Gets the effect to use to generate the depth map
  24781. * @param subMesh subMesh to get the effect for
  24782. * @param shadowGenerator shadow generator to get the effect for
  24783. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24784. */
  24785. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24786. /**
  24787. * Specifies that the submesh is ready to be used for depth rendering
  24788. * @param subMesh submesh to check
  24789. * @param defines the list of defines to take into account when checking the effect
  24790. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24791. * @param useInstances specifies that instances should be used
  24792. * @returns a boolean indicating that the submesh is ready or not
  24793. */
  24794. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24795. /**
  24796. * Disposes the resources
  24797. */
  24798. dispose(): void;
  24799. private _makeEffect;
  24800. }
  24801. }
  24802. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24803. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24804. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24805. import { Nullable } from "babylonjs/types";
  24806. module "babylonjs/Engines/thinEngine" {
  24807. interface ThinEngine {
  24808. /**
  24809. * Unbind a list of render target textures from the webGL context
  24810. * This is used only when drawBuffer extension or webGL2 are active
  24811. * @param textures defines the render target textures to unbind
  24812. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24813. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24814. */
  24815. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24816. /**
  24817. * Create a multi render target texture
  24818. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24819. * @param size defines the size of the texture
  24820. * @param options defines the creation options
  24821. * @returns the cube texture as an InternalTexture
  24822. */
  24823. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24824. /**
  24825. * Update the sample count for a given multiple render target texture
  24826. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24827. * @param textures defines the textures to update
  24828. * @param samples defines the sample count to set
  24829. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24830. */
  24831. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24832. /**
  24833. * Select a subsets of attachments to draw to.
  24834. * @param attachments gl attachments
  24835. */
  24836. bindAttachments(attachments: number[]): void;
  24837. }
  24838. }
  24839. }
  24840. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24841. import { Scene } from "babylonjs/scene";
  24842. import { Engine } from "babylonjs/Engines/engine";
  24843. import { Texture } from "babylonjs/Materials/Textures/texture";
  24844. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24845. import "babylonjs/Engines/Extensions/engine.multiRender";
  24846. /**
  24847. * Creation options of the multi render target texture.
  24848. */
  24849. export interface IMultiRenderTargetOptions {
  24850. /**
  24851. * Define if the texture needs to create mip maps after render.
  24852. */
  24853. generateMipMaps?: boolean;
  24854. /**
  24855. * Define the types of all the draw buffers we want to create
  24856. */
  24857. types?: number[];
  24858. /**
  24859. * Define the sampling modes of all the draw buffers we want to create
  24860. */
  24861. samplingModes?: number[];
  24862. /**
  24863. * Define if a depth buffer is required
  24864. */
  24865. generateDepthBuffer?: boolean;
  24866. /**
  24867. * Define if a stencil buffer is required
  24868. */
  24869. generateStencilBuffer?: boolean;
  24870. /**
  24871. * Define if a depth texture is required instead of a depth buffer
  24872. */
  24873. generateDepthTexture?: boolean;
  24874. /**
  24875. * Define the number of desired draw buffers
  24876. */
  24877. textureCount?: number;
  24878. /**
  24879. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24880. */
  24881. doNotChangeAspectRatio?: boolean;
  24882. /**
  24883. * Define the default type of the buffers we are creating
  24884. */
  24885. defaultType?: number;
  24886. }
  24887. /**
  24888. * A multi render target, like a render target provides the ability to render to a texture.
  24889. * Unlike the render target, it can render to several draw buffers in one draw.
  24890. * This is specially interesting in deferred rendering or for any effects requiring more than
  24891. * just one color from a single pass.
  24892. */
  24893. export class MultiRenderTarget extends RenderTargetTexture {
  24894. private _internalTextures;
  24895. private _textures;
  24896. private _multiRenderTargetOptions;
  24897. private _count;
  24898. /**
  24899. * Get if draw buffers are currently supported by the used hardware and browser.
  24900. */
  24901. get isSupported(): boolean;
  24902. /**
  24903. * Get the list of textures generated by the multi render target.
  24904. */
  24905. get textures(): Texture[];
  24906. /**
  24907. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24908. */
  24909. get count(): number;
  24910. /**
  24911. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24912. */
  24913. get depthTexture(): Texture;
  24914. /**
  24915. * Set the wrapping mode on U of all the textures we are rendering to.
  24916. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24917. */
  24918. set wrapU(wrap: number);
  24919. /**
  24920. * Set the wrapping mode on V of all the textures we are rendering to.
  24921. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24922. */
  24923. set wrapV(wrap: number);
  24924. /**
  24925. * Instantiate a new multi render target texture.
  24926. * A multi render target, like a render target provides the ability to render to a texture.
  24927. * Unlike the render target, it can render to several draw buffers in one draw.
  24928. * This is specially interesting in deferred rendering or for any effects requiring more than
  24929. * just one color from a single pass.
  24930. * @param name Define the name of the texture
  24931. * @param size Define the size of the buffers to render to
  24932. * @param count Define the number of target we are rendering into
  24933. * @param scene Define the scene the texture belongs to
  24934. * @param options Define the options used to create the multi render target
  24935. */
  24936. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24937. /** @hidden */
  24938. _rebuild(): void;
  24939. private _createInternalTextures;
  24940. private _createTextures;
  24941. /**
  24942. * Define the number of samples used if MSAA is enabled.
  24943. */
  24944. get samples(): number;
  24945. set samples(value: number);
  24946. /**
  24947. * Resize all the textures in the multi render target.
  24948. * Be carrefull as it will recreate all the data in the new texture.
  24949. * @param size Define the new size
  24950. */
  24951. resize(size: any): void;
  24952. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24953. /**
  24954. * Dispose the render targets and their associated resources
  24955. */
  24956. dispose(): void;
  24957. /**
  24958. * Release all the underlying texture used as draw buffers.
  24959. */
  24960. releaseInternalTextures(): void;
  24961. }
  24962. }
  24963. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  24964. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24965. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24966. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24967. /** @hidden */
  24968. export var imageProcessingPixelShader: {
  24969. name: string;
  24970. shader: string;
  24971. };
  24972. }
  24973. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  24974. import { Nullable } from "babylonjs/types";
  24975. import { Color4 } from "babylonjs/Maths/math.color";
  24976. import { Camera } from "babylonjs/Cameras/camera";
  24977. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24978. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24979. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  24980. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24981. import { Engine } from "babylonjs/Engines/engine";
  24982. import "babylonjs/Shaders/imageProcessing.fragment";
  24983. import "babylonjs/Shaders/postprocess.vertex";
  24984. /**
  24985. * ImageProcessingPostProcess
  24986. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24987. */
  24988. export class ImageProcessingPostProcess extends PostProcess {
  24989. /**
  24990. * Default configuration related to image processing available in the PBR Material.
  24991. */
  24992. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24993. /**
  24994. * Gets the image processing configuration used either in this material.
  24995. */
  24996. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24997. /**
  24998. * Sets the Default image processing configuration used either in the this material.
  24999. *
  25000. * If sets to null, the scene one is in use.
  25001. */
  25002. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25003. /**
  25004. * Keep track of the image processing observer to allow dispose and replace.
  25005. */
  25006. private _imageProcessingObserver;
  25007. /**
  25008. * Attaches a new image processing configuration to the PBR Material.
  25009. * @param configuration
  25010. */
  25011. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25012. /**
  25013. * If the post process is supported.
  25014. */
  25015. get isSupported(): boolean;
  25016. /**
  25017. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25018. */
  25019. get colorCurves(): Nullable<ColorCurves>;
  25020. /**
  25021. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25022. */
  25023. set colorCurves(value: Nullable<ColorCurves>);
  25024. /**
  25025. * Gets wether the color curves effect is enabled.
  25026. */
  25027. get colorCurvesEnabled(): boolean;
  25028. /**
  25029. * Sets wether the color curves effect is enabled.
  25030. */
  25031. set colorCurvesEnabled(value: boolean);
  25032. /**
  25033. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25034. */
  25035. get colorGradingTexture(): Nullable<BaseTexture>;
  25036. /**
  25037. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25038. */
  25039. set colorGradingTexture(value: Nullable<BaseTexture>);
  25040. /**
  25041. * Gets wether the color grading effect is enabled.
  25042. */
  25043. get colorGradingEnabled(): boolean;
  25044. /**
  25045. * Gets wether the color grading effect is enabled.
  25046. */
  25047. set colorGradingEnabled(value: boolean);
  25048. /**
  25049. * Gets exposure used in the effect.
  25050. */
  25051. get exposure(): number;
  25052. /**
  25053. * Sets exposure used in the effect.
  25054. */
  25055. set exposure(value: number);
  25056. /**
  25057. * Gets wether tonemapping is enabled or not.
  25058. */
  25059. get toneMappingEnabled(): boolean;
  25060. /**
  25061. * Sets wether tonemapping is enabled or not
  25062. */
  25063. set toneMappingEnabled(value: boolean);
  25064. /**
  25065. * Gets the type of tone mapping effect.
  25066. */
  25067. get toneMappingType(): number;
  25068. /**
  25069. * Sets the type of tone mapping effect.
  25070. */
  25071. set toneMappingType(value: number);
  25072. /**
  25073. * Gets contrast used in the effect.
  25074. */
  25075. get contrast(): number;
  25076. /**
  25077. * Sets contrast used in the effect.
  25078. */
  25079. set contrast(value: number);
  25080. /**
  25081. * Gets Vignette stretch size.
  25082. */
  25083. get vignetteStretch(): number;
  25084. /**
  25085. * Sets Vignette stretch size.
  25086. */
  25087. set vignetteStretch(value: number);
  25088. /**
  25089. * Gets Vignette centre X Offset.
  25090. */
  25091. get vignetteCentreX(): number;
  25092. /**
  25093. * Sets Vignette centre X Offset.
  25094. */
  25095. set vignetteCentreX(value: number);
  25096. /**
  25097. * Gets Vignette centre Y Offset.
  25098. */
  25099. get vignetteCentreY(): number;
  25100. /**
  25101. * Sets Vignette centre Y Offset.
  25102. */
  25103. set vignetteCentreY(value: number);
  25104. /**
  25105. * Gets Vignette weight or intensity of the vignette effect.
  25106. */
  25107. get vignetteWeight(): number;
  25108. /**
  25109. * Sets Vignette weight or intensity of the vignette effect.
  25110. */
  25111. set vignetteWeight(value: number);
  25112. /**
  25113. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25114. * if vignetteEnabled is set to true.
  25115. */
  25116. get vignetteColor(): Color4;
  25117. /**
  25118. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25119. * if vignetteEnabled is set to true.
  25120. */
  25121. set vignetteColor(value: Color4);
  25122. /**
  25123. * Gets Camera field of view used by the Vignette effect.
  25124. */
  25125. get vignetteCameraFov(): number;
  25126. /**
  25127. * Sets Camera field of view used by the Vignette effect.
  25128. */
  25129. set vignetteCameraFov(value: number);
  25130. /**
  25131. * Gets the vignette blend mode allowing different kind of effect.
  25132. */
  25133. get vignetteBlendMode(): number;
  25134. /**
  25135. * Sets the vignette blend mode allowing different kind of effect.
  25136. */
  25137. set vignetteBlendMode(value: number);
  25138. /**
  25139. * Gets wether the vignette effect is enabled.
  25140. */
  25141. get vignetteEnabled(): boolean;
  25142. /**
  25143. * Sets wether the vignette effect is enabled.
  25144. */
  25145. set vignetteEnabled(value: boolean);
  25146. private _fromLinearSpace;
  25147. /**
  25148. * Gets wether the input of the processing is in Gamma or Linear Space.
  25149. */
  25150. get fromLinearSpace(): boolean;
  25151. /**
  25152. * Sets wether the input of the processing is in Gamma or Linear Space.
  25153. */
  25154. set fromLinearSpace(value: boolean);
  25155. /**
  25156. * Defines cache preventing GC.
  25157. */
  25158. private _defines;
  25159. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25160. /**
  25161. * "ImageProcessingPostProcess"
  25162. * @returns "ImageProcessingPostProcess"
  25163. */
  25164. getClassName(): string;
  25165. /**
  25166. * @hidden
  25167. */
  25168. _updateParameters(): void;
  25169. dispose(camera?: Camera): void;
  25170. }
  25171. }
  25172. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  25173. /** @hidden */
  25174. export var fibonacci: {
  25175. name: string;
  25176. shader: string;
  25177. };
  25178. }
  25179. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  25180. /** @hidden */
  25181. export var subSurfaceScatteringFunctions: {
  25182. name: string;
  25183. shader: string;
  25184. };
  25185. }
  25186. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  25187. /** @hidden */
  25188. export var diffusionProfile: {
  25189. name: string;
  25190. shader: string;
  25191. };
  25192. }
  25193. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  25194. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  25195. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25196. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  25197. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  25198. /** @hidden */
  25199. export var subSurfaceScatteringPixelShader: {
  25200. name: string;
  25201. shader: string;
  25202. };
  25203. }
  25204. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  25205. import { Nullable } from "babylonjs/types";
  25206. import { Camera } from "babylonjs/Cameras/camera";
  25207. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25208. import { Engine } from "babylonjs/Engines/engine";
  25209. import { Scene } from "babylonjs/scene";
  25210. import "babylonjs/Shaders/imageProcessing.fragment";
  25211. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  25212. import "babylonjs/Shaders/postprocess.vertex";
  25213. /**
  25214. * Sub surface scattering post process
  25215. */
  25216. export class SubSurfaceScatteringPostProcess extends PostProcess {
  25217. /**
  25218. * Gets a string identifying the name of the class
  25219. * @returns "SubSurfaceScatteringPostProcess" string
  25220. */
  25221. getClassName(): string;
  25222. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25223. }
  25224. }
  25225. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  25226. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25227. /**
  25228. * Interface for defining prepass effects in the prepass post-process pipeline
  25229. */
  25230. export interface PrePassEffectConfiguration {
  25231. /**
  25232. * Post process to attach for this effect
  25233. */
  25234. postProcess: PostProcess;
  25235. /**
  25236. * Is the effect enabled
  25237. */
  25238. enabled: boolean;
  25239. /**
  25240. * Disposes the effect configuration
  25241. */
  25242. dispose(): void;
  25243. /**
  25244. * Disposes the effect configuration
  25245. */
  25246. createPostProcess: () => PostProcess;
  25247. }
  25248. }
  25249. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  25250. import { Scene } from "babylonjs/scene";
  25251. import { Color3 } from "babylonjs/Maths/math.color";
  25252. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  25253. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25254. /**
  25255. * Contains all parameters needed for the prepass to perform
  25256. * screen space subsurface scattering
  25257. */
  25258. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  25259. private _ssDiffusionS;
  25260. private _ssFilterRadii;
  25261. private _ssDiffusionD;
  25262. /**
  25263. * Post process to attach for screen space subsurface scattering
  25264. */
  25265. postProcess: SubSurfaceScatteringPostProcess;
  25266. /**
  25267. * Diffusion profile color for subsurface scattering
  25268. */
  25269. get ssDiffusionS(): number[];
  25270. /**
  25271. * Diffusion profile max color channel value for subsurface scattering
  25272. */
  25273. get ssDiffusionD(): number[];
  25274. /**
  25275. * Diffusion profile filter radius for subsurface scattering
  25276. */
  25277. get ssFilterRadii(): number[];
  25278. /**
  25279. * Is subsurface enabled
  25280. */
  25281. enabled: boolean;
  25282. /**
  25283. * Diffusion profile colors for subsurface scattering
  25284. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  25285. * See ...
  25286. * Note that you can only store up to 5 of them
  25287. */
  25288. ssDiffusionProfileColors: Color3[];
  25289. /**
  25290. * Defines the ratio real world => scene units.
  25291. * Used for subsurface scattering
  25292. */
  25293. metersPerUnit: number;
  25294. private _scene;
  25295. /**
  25296. * Builds a subsurface configuration object
  25297. * @param scene The scene
  25298. */
  25299. constructor(scene: Scene);
  25300. /**
  25301. * Adds a new diffusion profile.
  25302. * Useful for more realistic subsurface scattering on diverse materials.
  25303. * @param color The color of the diffusion profile. Should be the average color of the material.
  25304. * @return The index of the diffusion profile for the material subsurface configuration
  25305. */
  25306. addDiffusionProfile(color: Color3): number;
  25307. /**
  25308. * Creates the sss post process
  25309. * @return The created post process
  25310. */
  25311. createPostProcess(): SubSurfaceScatteringPostProcess;
  25312. /**
  25313. * Deletes all diffusion profiles.
  25314. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  25315. */
  25316. clearAllDiffusionProfiles(): void;
  25317. /**
  25318. * Disposes this object
  25319. */
  25320. dispose(): void;
  25321. /**
  25322. * @hidden
  25323. * https://zero-radiance.github.io/post/sampling-diffusion/
  25324. *
  25325. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  25326. * ------------------------------------------------------------------------------------
  25327. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  25328. * PDF[r, phi, s] = r * R[r, phi, s]
  25329. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  25330. * ------------------------------------------------------------------------------------
  25331. * We importance sample the color channel with the widest scattering distance.
  25332. */
  25333. getDiffusionProfileParameters(color: Color3): number;
  25334. /**
  25335. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  25336. * 'u' is the random number (the value of the CDF): [0, 1).
  25337. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  25338. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  25339. */
  25340. private _sampleBurleyDiffusionProfile;
  25341. }
  25342. }
  25343. declare module "babylonjs/Rendering/prePassRenderer" {
  25344. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25345. import { Scene } from "babylonjs/scene";
  25346. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25347. import { Effect } from "babylonjs/Materials/effect";
  25348. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  25349. /**
  25350. * Renders a pre pass of the scene
  25351. * This means every mesh in the scene will be rendered to a render target texture
  25352. * And then this texture will be composited to the rendering canvas with post processes
  25353. * It is necessary for effects like subsurface scattering or deferred shading
  25354. */
  25355. export class PrePassRenderer {
  25356. /** @hidden */
  25357. static _SceneComponentInitialization: (scene: Scene) => void;
  25358. private _scene;
  25359. private _engine;
  25360. private _isDirty;
  25361. /**
  25362. * Number of textures in the multi render target texture where the scene is directly rendered
  25363. */
  25364. readonly mrtCount: number;
  25365. /**
  25366. * The render target where the scene is directly rendered
  25367. */
  25368. prePassRT: MultiRenderTarget;
  25369. private _mrtTypes;
  25370. private _multiRenderAttachments;
  25371. private _defaultAttachments;
  25372. private _clearAttachments;
  25373. private _postProcesses;
  25374. private readonly _clearColor;
  25375. /**
  25376. * Image processing post process for composition
  25377. */
  25378. imageProcessingPostProcess: ImageProcessingPostProcess;
  25379. /**
  25380. * Configuration for sub surface scattering post process
  25381. */
  25382. subSurfaceConfiguration: SubSurfaceConfiguration;
  25383. /**
  25384. * Should materials render their geometry on the MRT
  25385. */
  25386. materialsShouldRenderGeometry: boolean;
  25387. /**
  25388. * Should materials render the irradiance information on the MRT
  25389. */
  25390. materialsShouldRenderIrradiance: boolean;
  25391. private _enabled;
  25392. /**
  25393. * Indicates if the prepass is enabled
  25394. */
  25395. get enabled(): boolean;
  25396. /**
  25397. * How many samples are used for MSAA of the scene render target
  25398. */
  25399. get samples(): number;
  25400. set samples(n: number);
  25401. /**
  25402. * Instanciates a prepass renderer
  25403. * @param scene The scene
  25404. */
  25405. constructor(scene: Scene);
  25406. private _initializeAttachments;
  25407. private _createCompositionEffect;
  25408. /**
  25409. * Indicates if rendering a prepass is supported
  25410. */
  25411. get isSupported(): boolean;
  25412. /**
  25413. * Sets the proper output textures to draw in the engine.
  25414. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25415. */
  25416. bindAttachmentsForEffect(effect: Effect): void;
  25417. /**
  25418. * @hidden
  25419. */
  25420. _beforeCameraDraw(): void;
  25421. /**
  25422. * @hidden
  25423. */
  25424. _afterCameraDraw(): void;
  25425. private _checkRTSize;
  25426. private _bindFrameBuffer;
  25427. /**
  25428. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25429. */
  25430. clear(): void;
  25431. private _setState;
  25432. private _enable;
  25433. private _disable;
  25434. private _resetPostProcessChain;
  25435. private _bindPostProcessChain;
  25436. /**
  25437. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25438. */
  25439. markAsDirty(): void;
  25440. private _update;
  25441. /**
  25442. * Disposes the prepass renderer.
  25443. */
  25444. dispose(): void;
  25445. }
  25446. }
  25447. declare module "babylonjs/Materials/material" {
  25448. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25449. import { SmartArray } from "babylonjs/Misc/smartArray";
  25450. import { Observable } from "babylonjs/Misc/observable";
  25451. import { Nullable } from "babylonjs/types";
  25452. import { Scene } from "babylonjs/scene";
  25453. import { Matrix } from "babylonjs/Maths/math.vector";
  25454. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25456. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25457. import { Effect } from "babylonjs/Materials/effect";
  25458. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25459. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25460. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25461. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25462. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25463. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25464. import { Mesh } from "babylonjs/Meshes/mesh";
  25465. import { Animation } from "babylonjs/Animations/animation";
  25466. /**
  25467. * Options for compiling materials.
  25468. */
  25469. export interface IMaterialCompilationOptions {
  25470. /**
  25471. * Defines whether clip planes are enabled.
  25472. */
  25473. clipPlane: boolean;
  25474. /**
  25475. * Defines whether instances are enabled.
  25476. */
  25477. useInstances: boolean;
  25478. }
  25479. /**
  25480. * Options passed when calling customShaderNameResolve
  25481. */
  25482. export interface ICustomShaderNameResolveOptions {
  25483. /**
  25484. * 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
  25485. */
  25486. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25487. }
  25488. /**
  25489. * Base class for the main features of a material in Babylon.js
  25490. */
  25491. export class Material implements IAnimatable {
  25492. /**
  25493. * Returns the triangle fill mode
  25494. */
  25495. static readonly TriangleFillMode: number;
  25496. /**
  25497. * Returns the wireframe mode
  25498. */
  25499. static readonly WireFrameFillMode: number;
  25500. /**
  25501. * Returns the point fill mode
  25502. */
  25503. static readonly PointFillMode: number;
  25504. /**
  25505. * Returns the point list draw mode
  25506. */
  25507. static readonly PointListDrawMode: number;
  25508. /**
  25509. * Returns the line list draw mode
  25510. */
  25511. static readonly LineListDrawMode: number;
  25512. /**
  25513. * Returns the line loop draw mode
  25514. */
  25515. static readonly LineLoopDrawMode: number;
  25516. /**
  25517. * Returns the line strip draw mode
  25518. */
  25519. static readonly LineStripDrawMode: number;
  25520. /**
  25521. * Returns the triangle strip draw mode
  25522. */
  25523. static readonly TriangleStripDrawMode: number;
  25524. /**
  25525. * Returns the triangle fan draw mode
  25526. */
  25527. static readonly TriangleFanDrawMode: number;
  25528. /**
  25529. * Stores the clock-wise side orientation
  25530. */
  25531. static readonly ClockWiseSideOrientation: number;
  25532. /**
  25533. * Stores the counter clock-wise side orientation
  25534. */
  25535. static readonly CounterClockWiseSideOrientation: number;
  25536. /**
  25537. * The dirty texture flag value
  25538. */
  25539. static readonly TextureDirtyFlag: number;
  25540. /**
  25541. * The dirty light flag value
  25542. */
  25543. static readonly LightDirtyFlag: number;
  25544. /**
  25545. * The dirty fresnel flag value
  25546. */
  25547. static readonly FresnelDirtyFlag: number;
  25548. /**
  25549. * The dirty attribute flag value
  25550. */
  25551. static readonly AttributesDirtyFlag: number;
  25552. /**
  25553. * The dirty misc flag value
  25554. */
  25555. static readonly MiscDirtyFlag: number;
  25556. /**
  25557. * The all dirty flag value
  25558. */
  25559. static readonly AllDirtyFlag: number;
  25560. /**
  25561. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25562. */
  25563. static readonly MATERIAL_OPAQUE: number;
  25564. /**
  25565. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25566. */
  25567. static readonly MATERIAL_ALPHATEST: number;
  25568. /**
  25569. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25570. */
  25571. static readonly MATERIAL_ALPHABLEND: number;
  25572. /**
  25573. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25574. * They are also discarded below the alpha cutoff threshold to improve performances.
  25575. */
  25576. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25577. /**
  25578. * The Whiteout method is used to blend normals.
  25579. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25580. */
  25581. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25582. /**
  25583. * The Reoriented Normal Mapping method is used to blend normals.
  25584. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25585. */
  25586. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25587. /**
  25588. * Custom callback helping to override the default shader used in the material.
  25589. */
  25590. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25591. /**
  25592. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25593. */
  25594. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25595. /**
  25596. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25597. * This means that the material can keep using a previous shader while a new one is being compiled.
  25598. * This is mostly used when shader parallel compilation is supported (true by default)
  25599. */
  25600. allowShaderHotSwapping: boolean;
  25601. /**
  25602. * The ID of the material
  25603. */
  25604. id: string;
  25605. /**
  25606. * Gets or sets the unique id of the material
  25607. */
  25608. uniqueId: number;
  25609. /**
  25610. * The name of the material
  25611. */
  25612. name: string;
  25613. /**
  25614. * Gets or sets user defined metadata
  25615. */
  25616. metadata: any;
  25617. /**
  25618. * For internal use only. Please do not use.
  25619. */
  25620. reservedDataStore: any;
  25621. /**
  25622. * Specifies if the ready state should be checked on each call
  25623. */
  25624. checkReadyOnEveryCall: boolean;
  25625. /**
  25626. * Specifies if the ready state should be checked once
  25627. */
  25628. checkReadyOnlyOnce: boolean;
  25629. /**
  25630. * The state of the material
  25631. */
  25632. state: string;
  25633. /**
  25634. * If the material can be rendered to several textures with MRT extension
  25635. */
  25636. get canRenderToMRT(): boolean;
  25637. /**
  25638. * The alpha value of the material
  25639. */
  25640. protected _alpha: number;
  25641. /**
  25642. * List of inspectable custom properties (used by the Inspector)
  25643. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25644. */
  25645. inspectableCustomProperties: IInspectable[];
  25646. /**
  25647. * Sets the alpha value of the material
  25648. */
  25649. set alpha(value: number);
  25650. /**
  25651. * Gets the alpha value of the material
  25652. */
  25653. get alpha(): number;
  25654. /**
  25655. * Specifies if back face culling is enabled
  25656. */
  25657. protected _backFaceCulling: boolean;
  25658. /**
  25659. * Sets the back-face culling state
  25660. */
  25661. set backFaceCulling(value: boolean);
  25662. /**
  25663. * Gets the back-face culling state
  25664. */
  25665. get backFaceCulling(): boolean;
  25666. /**
  25667. * Stores the value for side orientation
  25668. */
  25669. sideOrientation: number;
  25670. /**
  25671. * Callback triggered when the material is compiled
  25672. */
  25673. onCompiled: Nullable<(effect: Effect) => void>;
  25674. /**
  25675. * Callback triggered when an error occurs
  25676. */
  25677. onError: Nullable<(effect: Effect, errors: string) => void>;
  25678. /**
  25679. * Callback triggered to get the render target textures
  25680. */
  25681. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25682. /**
  25683. * Gets a boolean indicating that current material needs to register RTT
  25684. */
  25685. get hasRenderTargetTextures(): boolean;
  25686. /**
  25687. * Specifies if the material should be serialized
  25688. */
  25689. doNotSerialize: boolean;
  25690. /**
  25691. * @hidden
  25692. */
  25693. _storeEffectOnSubMeshes: boolean;
  25694. /**
  25695. * Stores the animations for the material
  25696. */
  25697. animations: Nullable<Array<Animation>>;
  25698. /**
  25699. * An event triggered when the material is disposed
  25700. */
  25701. onDisposeObservable: Observable<Material>;
  25702. /**
  25703. * An observer which watches for dispose events
  25704. */
  25705. private _onDisposeObserver;
  25706. private _onUnBindObservable;
  25707. /**
  25708. * Called during a dispose event
  25709. */
  25710. set onDispose(callback: () => void);
  25711. private _onBindObservable;
  25712. /**
  25713. * An event triggered when the material is bound
  25714. */
  25715. get onBindObservable(): Observable<AbstractMesh>;
  25716. /**
  25717. * An observer which watches for bind events
  25718. */
  25719. private _onBindObserver;
  25720. /**
  25721. * Called during a bind event
  25722. */
  25723. set onBind(callback: (Mesh: AbstractMesh) => void);
  25724. /**
  25725. * An event triggered when the material is unbound
  25726. */
  25727. get onUnBindObservable(): Observable<Material>;
  25728. protected _onEffectCreatedObservable: Nullable<Observable<{
  25729. effect: Effect;
  25730. subMesh: Nullable<SubMesh>;
  25731. }>>;
  25732. /**
  25733. * An event triggered when the effect is (re)created
  25734. */
  25735. get onEffectCreatedObservable(): Observable<{
  25736. effect: Effect;
  25737. subMesh: Nullable<SubMesh>;
  25738. }>;
  25739. /**
  25740. * Stores the value of the alpha mode
  25741. */
  25742. private _alphaMode;
  25743. /**
  25744. * Sets the value of the alpha mode.
  25745. *
  25746. * | Value | Type | Description |
  25747. * | --- | --- | --- |
  25748. * | 0 | ALPHA_DISABLE | |
  25749. * | 1 | ALPHA_ADD | |
  25750. * | 2 | ALPHA_COMBINE | |
  25751. * | 3 | ALPHA_SUBTRACT | |
  25752. * | 4 | ALPHA_MULTIPLY | |
  25753. * | 5 | ALPHA_MAXIMIZED | |
  25754. * | 6 | ALPHA_ONEONE | |
  25755. * | 7 | ALPHA_PREMULTIPLIED | |
  25756. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25757. * | 9 | ALPHA_INTERPOLATE | |
  25758. * | 10 | ALPHA_SCREENMODE | |
  25759. *
  25760. */
  25761. set alphaMode(value: number);
  25762. /**
  25763. * Gets the value of the alpha mode
  25764. */
  25765. get alphaMode(): number;
  25766. /**
  25767. * Stores the state of the need depth pre-pass value
  25768. */
  25769. private _needDepthPrePass;
  25770. /**
  25771. * Sets the need depth pre-pass value
  25772. */
  25773. set needDepthPrePass(value: boolean);
  25774. /**
  25775. * Gets the depth pre-pass value
  25776. */
  25777. get needDepthPrePass(): boolean;
  25778. /**
  25779. * Specifies if depth writing should be disabled
  25780. */
  25781. disableDepthWrite: boolean;
  25782. /**
  25783. * Specifies if color writing should be disabled
  25784. */
  25785. disableColorWrite: boolean;
  25786. /**
  25787. * Specifies if depth writing should be forced
  25788. */
  25789. forceDepthWrite: boolean;
  25790. /**
  25791. * Specifies the depth function that should be used. 0 means the default engine function
  25792. */
  25793. depthFunction: number;
  25794. /**
  25795. * Specifies if there should be a separate pass for culling
  25796. */
  25797. separateCullingPass: boolean;
  25798. /**
  25799. * Stores the state specifing if fog should be enabled
  25800. */
  25801. private _fogEnabled;
  25802. /**
  25803. * Sets the state for enabling fog
  25804. */
  25805. set fogEnabled(value: boolean);
  25806. /**
  25807. * Gets the value of the fog enabled state
  25808. */
  25809. get fogEnabled(): boolean;
  25810. /**
  25811. * Stores the size of points
  25812. */
  25813. pointSize: number;
  25814. /**
  25815. * Stores the z offset value
  25816. */
  25817. zOffset: number;
  25818. get wireframe(): boolean;
  25819. /**
  25820. * Sets the state of wireframe mode
  25821. */
  25822. set wireframe(value: boolean);
  25823. /**
  25824. * Gets the value specifying if point clouds are enabled
  25825. */
  25826. get pointsCloud(): boolean;
  25827. /**
  25828. * Sets the state of point cloud mode
  25829. */
  25830. set pointsCloud(value: boolean);
  25831. /**
  25832. * Gets the material fill mode
  25833. */
  25834. get fillMode(): number;
  25835. /**
  25836. * Sets the material fill mode
  25837. */
  25838. set fillMode(value: number);
  25839. /**
  25840. * @hidden
  25841. * Stores the effects for the material
  25842. */
  25843. _effect: Nullable<Effect>;
  25844. /**
  25845. * Specifies if uniform buffers should be used
  25846. */
  25847. private _useUBO;
  25848. /**
  25849. * Stores a reference to the scene
  25850. */
  25851. private _scene;
  25852. /**
  25853. * Stores the fill mode state
  25854. */
  25855. private _fillMode;
  25856. /**
  25857. * Specifies if the depth write state should be cached
  25858. */
  25859. private _cachedDepthWriteState;
  25860. /**
  25861. * Specifies if the color write state should be cached
  25862. */
  25863. private _cachedColorWriteState;
  25864. /**
  25865. * Specifies if the depth function state should be cached
  25866. */
  25867. private _cachedDepthFunctionState;
  25868. /**
  25869. * Stores the uniform buffer
  25870. */
  25871. protected _uniformBuffer: UniformBuffer;
  25872. /** @hidden */
  25873. _indexInSceneMaterialArray: number;
  25874. /** @hidden */
  25875. meshMap: Nullable<{
  25876. [id: string]: AbstractMesh | undefined;
  25877. }>;
  25878. /**
  25879. * Creates a material instance
  25880. * @param name defines the name of the material
  25881. * @param scene defines the scene to reference
  25882. * @param doNotAdd specifies if the material should be added to the scene
  25883. */
  25884. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25885. /**
  25886. * Returns a string representation of the current material
  25887. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25888. * @returns a string with material information
  25889. */
  25890. toString(fullDetails?: boolean): string;
  25891. /**
  25892. * Gets the class name of the material
  25893. * @returns a string with the class name of the material
  25894. */
  25895. getClassName(): string;
  25896. /**
  25897. * Specifies if updates for the material been locked
  25898. */
  25899. get isFrozen(): boolean;
  25900. /**
  25901. * Locks updates for the material
  25902. */
  25903. freeze(): void;
  25904. /**
  25905. * Unlocks updates for the material
  25906. */
  25907. unfreeze(): void;
  25908. /**
  25909. * Specifies if the material is ready to be used
  25910. * @param mesh defines the mesh to check
  25911. * @param useInstances specifies if instances should be used
  25912. * @returns a boolean indicating if the material is ready to be used
  25913. */
  25914. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25915. /**
  25916. * Specifies that the submesh is ready to be used
  25917. * @param mesh defines the mesh to check
  25918. * @param subMesh defines which submesh to check
  25919. * @param useInstances specifies that instances should be used
  25920. * @returns a boolean indicating that the submesh is ready or not
  25921. */
  25922. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25923. /**
  25924. * Returns the material effect
  25925. * @returns the effect associated with the material
  25926. */
  25927. getEffect(): Nullable<Effect>;
  25928. /**
  25929. * Returns the current scene
  25930. * @returns a Scene
  25931. */
  25932. getScene(): Scene;
  25933. /**
  25934. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25935. */
  25936. protected _forceAlphaTest: boolean;
  25937. /**
  25938. * The transparency mode of the material.
  25939. */
  25940. protected _transparencyMode: Nullable<number>;
  25941. /**
  25942. * Gets the current transparency mode.
  25943. */
  25944. get transparencyMode(): Nullable<number>;
  25945. /**
  25946. * Sets the transparency mode of the material.
  25947. *
  25948. * | Value | Type | Description |
  25949. * | ----- | ----------------------------------- | ----------- |
  25950. * | 0 | OPAQUE | |
  25951. * | 1 | ALPHATEST | |
  25952. * | 2 | ALPHABLEND | |
  25953. * | 3 | ALPHATESTANDBLEND | |
  25954. *
  25955. */
  25956. set transparencyMode(value: Nullable<number>);
  25957. /**
  25958. * Returns true if alpha blending should be disabled.
  25959. */
  25960. protected get _disableAlphaBlending(): boolean;
  25961. /**
  25962. * Specifies whether or not this material should be rendered in alpha blend mode.
  25963. * @returns a boolean specifying if alpha blending is needed
  25964. */
  25965. needAlphaBlending(): boolean;
  25966. /**
  25967. * Specifies if the mesh will require alpha blending
  25968. * @param mesh defines the mesh to check
  25969. * @returns a boolean specifying if alpha blending is needed for the mesh
  25970. */
  25971. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25972. /**
  25973. * Specifies whether or not this material should be rendered in alpha test mode.
  25974. * @returns a boolean specifying if an alpha test is needed.
  25975. */
  25976. needAlphaTesting(): boolean;
  25977. /**
  25978. * Specifies if material alpha testing should be turned on for the mesh
  25979. * @param mesh defines the mesh to check
  25980. */
  25981. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25982. /**
  25983. * Gets the texture used for the alpha test
  25984. * @returns the texture to use for alpha testing
  25985. */
  25986. getAlphaTestTexture(): Nullable<BaseTexture>;
  25987. /**
  25988. * Marks the material to indicate that it needs to be re-calculated
  25989. */
  25990. markDirty(): void;
  25991. /** @hidden */
  25992. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25993. /**
  25994. * Binds the material to the mesh
  25995. * @param world defines the world transformation matrix
  25996. * @param mesh defines the mesh to bind the material to
  25997. */
  25998. bind(world: Matrix, mesh?: Mesh): void;
  25999. /**
  26000. * Binds the submesh to the material
  26001. * @param world defines the world transformation matrix
  26002. * @param mesh defines the mesh containing the submesh
  26003. * @param subMesh defines the submesh to bind the material to
  26004. */
  26005. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26006. /**
  26007. * Binds the world matrix to the material
  26008. * @param world defines the world transformation matrix
  26009. */
  26010. bindOnlyWorldMatrix(world: Matrix): void;
  26011. /**
  26012. * Binds the scene's uniform buffer to the effect.
  26013. * @param effect defines the effect to bind to the scene uniform buffer
  26014. * @param sceneUbo defines the uniform buffer storing scene data
  26015. */
  26016. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  26017. /**
  26018. * Binds the view matrix to the effect
  26019. * @param effect defines the effect to bind the view matrix to
  26020. */
  26021. bindView(effect: Effect): void;
  26022. /**
  26023. * Binds the view projection matrix to the effect
  26024. * @param effect defines the effect to bind the view projection matrix to
  26025. */
  26026. bindViewProjection(effect: Effect): void;
  26027. /**
  26028. * Processes to execute after binding the material to a mesh
  26029. * @param mesh defines the rendered mesh
  26030. */
  26031. protected _afterBind(mesh?: Mesh): void;
  26032. /**
  26033. * Unbinds the material from the mesh
  26034. */
  26035. unbind(): void;
  26036. /**
  26037. * Gets the active textures from the material
  26038. * @returns an array of textures
  26039. */
  26040. getActiveTextures(): BaseTexture[];
  26041. /**
  26042. * Specifies if the material uses a texture
  26043. * @param texture defines the texture to check against the material
  26044. * @returns a boolean specifying if the material uses the texture
  26045. */
  26046. hasTexture(texture: BaseTexture): boolean;
  26047. /**
  26048. * Makes a duplicate of the material, and gives it a new name
  26049. * @param name defines the new name for the duplicated material
  26050. * @returns the cloned material
  26051. */
  26052. clone(name: string): Nullable<Material>;
  26053. /**
  26054. * Gets the meshes bound to the material
  26055. * @returns an array of meshes bound to the material
  26056. */
  26057. getBindedMeshes(): AbstractMesh[];
  26058. /**
  26059. * Force shader compilation
  26060. * @param mesh defines the mesh associated with this material
  26061. * @param onCompiled defines a function to execute once the material is compiled
  26062. * @param options defines the options to configure the compilation
  26063. * @param onError defines a function to execute if the material fails compiling
  26064. */
  26065. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  26066. /**
  26067. * Force shader compilation
  26068. * @param mesh defines the mesh that will use this material
  26069. * @param options defines additional options for compiling the shaders
  26070. * @returns a promise that resolves when the compilation completes
  26071. */
  26072. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  26073. private static readonly _AllDirtyCallBack;
  26074. private static readonly _ImageProcessingDirtyCallBack;
  26075. private static readonly _TextureDirtyCallBack;
  26076. private static readonly _FresnelDirtyCallBack;
  26077. private static readonly _MiscDirtyCallBack;
  26078. private static readonly _LightsDirtyCallBack;
  26079. private static readonly _AttributeDirtyCallBack;
  26080. private static _FresnelAndMiscDirtyCallBack;
  26081. private static _TextureAndMiscDirtyCallBack;
  26082. private static readonly _DirtyCallbackArray;
  26083. private static readonly _RunDirtyCallBacks;
  26084. /**
  26085. * Marks a define in the material to indicate that it needs to be re-computed
  26086. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26087. */
  26088. markAsDirty(flag: number): void;
  26089. /**
  26090. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26091. * @param func defines a function which checks material defines against the submeshes
  26092. */
  26093. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26094. /**
  26095. * Indicates that the scene should check if the rendering now needs a prepass
  26096. */
  26097. protected _markScenePrePassDirty(): void;
  26098. /**
  26099. * Indicates that we need to re-calculated for all submeshes
  26100. */
  26101. protected _markAllSubMeshesAsAllDirty(): void;
  26102. /**
  26103. * Indicates that image processing needs to be re-calculated for all submeshes
  26104. */
  26105. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26106. /**
  26107. * Indicates that textures need to be re-calculated for all submeshes
  26108. */
  26109. protected _markAllSubMeshesAsTexturesDirty(): void;
  26110. /**
  26111. * Indicates that fresnel needs to be re-calculated for all submeshes
  26112. */
  26113. protected _markAllSubMeshesAsFresnelDirty(): void;
  26114. /**
  26115. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26116. */
  26117. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26118. /**
  26119. * Indicates that lights need to be re-calculated for all submeshes
  26120. */
  26121. protected _markAllSubMeshesAsLightsDirty(): void;
  26122. /**
  26123. * Indicates that attributes need to be re-calculated for all submeshes
  26124. */
  26125. protected _markAllSubMeshesAsAttributesDirty(): void;
  26126. /**
  26127. * Indicates that misc needs to be re-calculated for all submeshes
  26128. */
  26129. protected _markAllSubMeshesAsMiscDirty(): void;
  26130. /**
  26131. * Indicates that textures and misc need to be re-calculated for all submeshes
  26132. */
  26133. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26134. /**
  26135. * Sets the required values to the prepass renderer.
  26136. * @param prePassRenderer defines the prepass renderer to setup.
  26137. * @returns true if the pre pass is needed.
  26138. */
  26139. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26140. /**
  26141. * Disposes the material
  26142. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26143. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26144. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26145. */
  26146. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26147. /** @hidden */
  26148. private releaseVertexArrayObject;
  26149. /**
  26150. * Serializes this material
  26151. * @returns the serialized material object
  26152. */
  26153. serialize(): any;
  26154. /**
  26155. * Creates a material from parsed material data
  26156. * @param parsedMaterial defines parsed material data
  26157. * @param scene defines the hosting scene
  26158. * @param rootUrl defines the root URL to use to load textures
  26159. * @returns a new material
  26160. */
  26161. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26162. }
  26163. }
  26164. declare module "babylonjs/Materials/multiMaterial" {
  26165. import { Nullable } from "babylonjs/types";
  26166. import { Scene } from "babylonjs/scene";
  26167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26168. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26169. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26170. import { Material } from "babylonjs/Materials/material";
  26171. /**
  26172. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26173. * separate meshes. This can be use to improve performances.
  26174. * @see https://doc.babylonjs.com/how_to/multi_materials
  26175. */
  26176. export class MultiMaterial extends Material {
  26177. private _subMaterials;
  26178. /**
  26179. * Gets or Sets the list of Materials used within the multi material.
  26180. * They need to be ordered according to the submeshes order in the associated mesh
  26181. */
  26182. get subMaterials(): Nullable<Material>[];
  26183. set subMaterials(value: Nullable<Material>[]);
  26184. /**
  26185. * Function used to align with Node.getChildren()
  26186. * @returns the list of Materials used within the multi material
  26187. */
  26188. getChildren(): Nullable<Material>[];
  26189. /**
  26190. * Instantiates a new Multi Material
  26191. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26192. * separate meshes. This can be use to improve performances.
  26193. * @see https://doc.babylonjs.com/how_to/multi_materials
  26194. * @param name Define the name in the scene
  26195. * @param scene Define the scene the material belongs to
  26196. */
  26197. constructor(name: string, scene: Scene);
  26198. private _hookArray;
  26199. /**
  26200. * Get one of the submaterial by its index in the submaterials array
  26201. * @param index The index to look the sub material at
  26202. * @returns The Material if the index has been defined
  26203. */
  26204. getSubMaterial(index: number): Nullable<Material>;
  26205. /**
  26206. * Get the list of active textures for the whole sub materials list.
  26207. * @returns All the textures that will be used during the rendering
  26208. */
  26209. getActiveTextures(): BaseTexture[];
  26210. /**
  26211. * Gets the current class name of the material e.g. "MultiMaterial"
  26212. * Mainly use in serialization.
  26213. * @returns the class name
  26214. */
  26215. getClassName(): string;
  26216. /**
  26217. * Checks if the material is ready to render the requested sub mesh
  26218. * @param mesh Define the mesh the submesh belongs to
  26219. * @param subMesh Define the sub mesh to look readyness for
  26220. * @param useInstances Define whether or not the material is used with instances
  26221. * @returns true if ready, otherwise false
  26222. */
  26223. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26224. /**
  26225. * Clones the current material and its related sub materials
  26226. * @param name Define the name of the newly cloned material
  26227. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26228. * @returns the cloned material
  26229. */
  26230. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26231. /**
  26232. * Serializes the materials into a JSON representation.
  26233. * @returns the JSON representation
  26234. */
  26235. serialize(): any;
  26236. /**
  26237. * Dispose the material and release its associated resources
  26238. * @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)
  26239. * @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)
  26240. * @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)
  26241. */
  26242. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26243. /**
  26244. * Creates a MultiMaterial from parsed MultiMaterial data.
  26245. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26246. * @param scene defines the hosting scene
  26247. * @returns a new MultiMaterial
  26248. */
  26249. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26250. }
  26251. }
  26252. declare module "babylonjs/Meshes/subMesh" {
  26253. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26254. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26255. import { Engine } from "babylonjs/Engines/engine";
  26256. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26257. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26258. import { Effect } from "babylonjs/Materials/effect";
  26259. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26260. import { Plane } from "babylonjs/Maths/math.plane";
  26261. import { Collider } from "babylonjs/Collisions/collider";
  26262. import { Material } from "babylonjs/Materials/material";
  26263. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26265. import { Mesh } from "babylonjs/Meshes/mesh";
  26266. import { Ray } from "babylonjs/Culling/ray";
  26267. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26268. /**
  26269. * Defines a subdivision inside a mesh
  26270. */
  26271. export class SubMesh implements ICullable {
  26272. /** the material index to use */
  26273. materialIndex: number;
  26274. /** vertex index start */
  26275. verticesStart: number;
  26276. /** vertices count */
  26277. verticesCount: number;
  26278. /** index start */
  26279. indexStart: number;
  26280. /** indices count */
  26281. indexCount: number;
  26282. /** @hidden */
  26283. _materialDefines: Nullable<MaterialDefines>;
  26284. /** @hidden */
  26285. _materialEffect: Nullable<Effect>;
  26286. /** @hidden */
  26287. _effectOverride: Nullable<Effect>;
  26288. /**
  26289. * Gets material defines used by the effect associated to the sub mesh
  26290. */
  26291. get materialDefines(): Nullable<MaterialDefines>;
  26292. /**
  26293. * Sets material defines used by the effect associated to the sub mesh
  26294. */
  26295. set materialDefines(defines: Nullable<MaterialDefines>);
  26296. /**
  26297. * Gets associated effect
  26298. */
  26299. get effect(): Nullable<Effect>;
  26300. /**
  26301. * Sets associated effect (effect used to render this submesh)
  26302. * @param effect defines the effect to associate with
  26303. * @param defines defines the set of defines used to compile this effect
  26304. */
  26305. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26306. /** @hidden */
  26307. _linesIndexCount: number;
  26308. private _mesh;
  26309. private _renderingMesh;
  26310. private _boundingInfo;
  26311. private _linesIndexBuffer;
  26312. /** @hidden */
  26313. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26314. /** @hidden */
  26315. _trianglePlanes: Plane[];
  26316. /** @hidden */
  26317. _lastColliderTransformMatrix: Nullable<Matrix>;
  26318. /** @hidden */
  26319. _renderId: number;
  26320. /** @hidden */
  26321. _alphaIndex: number;
  26322. /** @hidden */
  26323. _distanceToCamera: number;
  26324. /** @hidden */
  26325. _id: number;
  26326. private _currentMaterial;
  26327. /**
  26328. * Add a new submesh to a mesh
  26329. * @param materialIndex defines the material index to use
  26330. * @param verticesStart defines vertex index start
  26331. * @param verticesCount defines vertices count
  26332. * @param indexStart defines index start
  26333. * @param indexCount defines indices count
  26334. * @param mesh defines the parent mesh
  26335. * @param renderingMesh defines an optional rendering mesh
  26336. * @param createBoundingBox defines if bounding box should be created for this submesh
  26337. * @returns the new submesh
  26338. */
  26339. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26340. /**
  26341. * Creates a new submesh
  26342. * @param materialIndex defines the material index to use
  26343. * @param verticesStart defines vertex index start
  26344. * @param verticesCount defines vertices count
  26345. * @param indexStart defines index start
  26346. * @param indexCount defines indices count
  26347. * @param mesh defines the parent mesh
  26348. * @param renderingMesh defines an optional rendering mesh
  26349. * @param createBoundingBox defines if bounding box should be created for this submesh
  26350. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26351. */
  26352. constructor(
  26353. /** the material index to use */
  26354. materialIndex: number,
  26355. /** vertex index start */
  26356. verticesStart: number,
  26357. /** vertices count */
  26358. verticesCount: number,
  26359. /** index start */
  26360. indexStart: number,
  26361. /** indices count */
  26362. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26363. /**
  26364. * Returns true if this submesh covers the entire parent mesh
  26365. * @ignorenaming
  26366. */
  26367. get IsGlobal(): boolean;
  26368. /**
  26369. * Returns the submesh BoudingInfo object
  26370. * @returns current bounding info (or mesh's one if the submesh is global)
  26371. */
  26372. getBoundingInfo(): BoundingInfo;
  26373. /**
  26374. * Sets the submesh BoundingInfo
  26375. * @param boundingInfo defines the new bounding info to use
  26376. * @returns the SubMesh
  26377. */
  26378. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26379. /**
  26380. * Returns the mesh of the current submesh
  26381. * @return the parent mesh
  26382. */
  26383. getMesh(): AbstractMesh;
  26384. /**
  26385. * Returns the rendering mesh of the submesh
  26386. * @returns the rendering mesh (could be different from parent mesh)
  26387. */
  26388. getRenderingMesh(): Mesh;
  26389. /**
  26390. * Returns the replacement mesh of the submesh
  26391. * @returns the replacement mesh (could be different from parent mesh)
  26392. */
  26393. getReplacementMesh(): Nullable<AbstractMesh>;
  26394. /**
  26395. * Returns the effective mesh of the submesh
  26396. * @returns the effective mesh (could be different from parent mesh)
  26397. */
  26398. getEffectiveMesh(): AbstractMesh;
  26399. /**
  26400. * Returns the submesh material
  26401. * @returns null or the current material
  26402. */
  26403. getMaterial(): Nullable<Material>;
  26404. private _IsMultiMaterial;
  26405. /**
  26406. * Sets a new updated BoundingInfo object to the submesh
  26407. * @param data defines an optional position array to use to determine the bounding info
  26408. * @returns the SubMesh
  26409. */
  26410. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26411. /** @hidden */
  26412. _checkCollision(collider: Collider): boolean;
  26413. /**
  26414. * Updates the submesh BoundingInfo
  26415. * @param world defines the world matrix to use to update the bounding info
  26416. * @returns the submesh
  26417. */
  26418. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26419. /**
  26420. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26421. * @param frustumPlanes defines the frustum planes
  26422. * @returns true if the submesh is intersecting with the frustum
  26423. */
  26424. isInFrustum(frustumPlanes: Plane[]): boolean;
  26425. /**
  26426. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26427. * @param frustumPlanes defines the frustum planes
  26428. * @returns true if the submesh is inside the frustum
  26429. */
  26430. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26431. /**
  26432. * Renders the submesh
  26433. * @param enableAlphaMode defines if alpha needs to be used
  26434. * @returns the submesh
  26435. */
  26436. render(enableAlphaMode: boolean): SubMesh;
  26437. /**
  26438. * @hidden
  26439. */
  26440. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26441. /**
  26442. * Checks if the submesh intersects with a ray
  26443. * @param ray defines the ray to test
  26444. * @returns true is the passed ray intersects the submesh bounding box
  26445. */
  26446. canIntersects(ray: Ray): boolean;
  26447. /**
  26448. * Intersects current submesh with a ray
  26449. * @param ray defines the ray to test
  26450. * @param positions defines mesh's positions array
  26451. * @param indices defines mesh's indices array
  26452. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26453. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26454. * @returns intersection info or null if no intersection
  26455. */
  26456. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26457. /** @hidden */
  26458. private _intersectLines;
  26459. /** @hidden */
  26460. private _intersectUnIndexedLines;
  26461. /** @hidden */
  26462. private _intersectTriangles;
  26463. /** @hidden */
  26464. private _intersectUnIndexedTriangles;
  26465. /** @hidden */
  26466. _rebuild(): void;
  26467. /**
  26468. * Creates a new submesh from the passed mesh
  26469. * @param newMesh defines the new hosting mesh
  26470. * @param newRenderingMesh defines an optional rendering mesh
  26471. * @returns the new submesh
  26472. */
  26473. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26474. /**
  26475. * Release associated resources
  26476. */
  26477. dispose(): void;
  26478. /**
  26479. * Gets the class name
  26480. * @returns the string "SubMesh".
  26481. */
  26482. getClassName(): string;
  26483. /**
  26484. * Creates a new submesh from indices data
  26485. * @param materialIndex the index of the main mesh material
  26486. * @param startIndex the index where to start the copy in the mesh indices array
  26487. * @param indexCount the number of indices to copy then from the startIndex
  26488. * @param mesh the main mesh to create the submesh from
  26489. * @param renderingMesh the optional rendering mesh
  26490. * @returns a new submesh
  26491. */
  26492. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26493. }
  26494. }
  26495. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26496. /**
  26497. * Class used to represent data loading progression
  26498. */
  26499. export class SceneLoaderFlags {
  26500. private static _ForceFullSceneLoadingForIncremental;
  26501. private static _ShowLoadingScreen;
  26502. private static _CleanBoneMatrixWeights;
  26503. private static _loggingLevel;
  26504. /**
  26505. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26506. */
  26507. static get ForceFullSceneLoadingForIncremental(): boolean;
  26508. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26509. /**
  26510. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26511. */
  26512. static get ShowLoadingScreen(): boolean;
  26513. static set ShowLoadingScreen(value: boolean);
  26514. /**
  26515. * Defines the current logging level (while loading the scene)
  26516. * @ignorenaming
  26517. */
  26518. static get loggingLevel(): number;
  26519. static set loggingLevel(value: number);
  26520. /**
  26521. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26522. */
  26523. static get CleanBoneMatrixWeights(): boolean;
  26524. static set CleanBoneMatrixWeights(value: boolean);
  26525. }
  26526. }
  26527. declare module "babylonjs/Meshes/geometry" {
  26528. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26529. import { Scene } from "babylonjs/scene";
  26530. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26531. import { Engine } from "babylonjs/Engines/engine";
  26532. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26533. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26534. import { Effect } from "babylonjs/Materials/effect";
  26535. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26536. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26537. import { Mesh } from "babylonjs/Meshes/mesh";
  26538. /**
  26539. * Class used to store geometry data (vertex buffers + index buffer)
  26540. */
  26541. export class Geometry implements IGetSetVerticesData {
  26542. /**
  26543. * Gets or sets the ID of the geometry
  26544. */
  26545. id: string;
  26546. /**
  26547. * Gets or sets the unique ID of the geometry
  26548. */
  26549. uniqueId: number;
  26550. /**
  26551. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26552. */
  26553. delayLoadState: number;
  26554. /**
  26555. * Gets the file containing the data to load when running in delay load state
  26556. */
  26557. delayLoadingFile: Nullable<string>;
  26558. /**
  26559. * Callback called when the geometry is updated
  26560. */
  26561. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26562. private _scene;
  26563. private _engine;
  26564. private _meshes;
  26565. private _totalVertices;
  26566. /** @hidden */
  26567. _indices: IndicesArray;
  26568. /** @hidden */
  26569. _vertexBuffers: {
  26570. [key: string]: VertexBuffer;
  26571. };
  26572. private _isDisposed;
  26573. private _extend;
  26574. private _boundingBias;
  26575. /** @hidden */
  26576. _delayInfo: Array<string>;
  26577. private _indexBuffer;
  26578. private _indexBufferIsUpdatable;
  26579. /** @hidden */
  26580. _boundingInfo: Nullable<BoundingInfo>;
  26581. /** @hidden */
  26582. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26583. /** @hidden */
  26584. _softwareSkinningFrameId: number;
  26585. private _vertexArrayObjects;
  26586. private _updatable;
  26587. /** @hidden */
  26588. _positions: Nullable<Vector3[]>;
  26589. /**
  26590. * 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
  26591. */
  26592. get boundingBias(): Vector2;
  26593. /**
  26594. * 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
  26595. */
  26596. set boundingBias(value: Vector2);
  26597. /**
  26598. * Static function used to attach a new empty geometry to a mesh
  26599. * @param mesh defines the mesh to attach the geometry to
  26600. * @returns the new Geometry
  26601. */
  26602. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26603. /** Get the list of meshes using this geometry */
  26604. get meshes(): Mesh[];
  26605. /**
  26606. * 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
  26607. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26608. */
  26609. useBoundingInfoFromGeometry: boolean;
  26610. /**
  26611. * Creates a new geometry
  26612. * @param id defines the unique ID
  26613. * @param scene defines the hosting scene
  26614. * @param vertexData defines the VertexData used to get geometry data
  26615. * @param updatable defines if geometry must be updatable (false by default)
  26616. * @param mesh defines the mesh that will be associated with the geometry
  26617. */
  26618. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26619. /**
  26620. * Gets the current extend of the geometry
  26621. */
  26622. get extend(): {
  26623. minimum: Vector3;
  26624. maximum: Vector3;
  26625. };
  26626. /**
  26627. * Gets the hosting scene
  26628. * @returns the hosting Scene
  26629. */
  26630. getScene(): Scene;
  26631. /**
  26632. * Gets the hosting engine
  26633. * @returns the hosting Engine
  26634. */
  26635. getEngine(): Engine;
  26636. /**
  26637. * Defines if the geometry is ready to use
  26638. * @returns true if the geometry is ready to be used
  26639. */
  26640. isReady(): boolean;
  26641. /**
  26642. * Gets a value indicating that the geometry should not be serialized
  26643. */
  26644. get doNotSerialize(): boolean;
  26645. /** @hidden */
  26646. _rebuild(): void;
  26647. /**
  26648. * Affects all geometry data in one call
  26649. * @param vertexData defines the geometry data
  26650. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26651. */
  26652. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26653. /**
  26654. * Set specific vertex data
  26655. * @param kind defines the data kind (Position, normal, etc...)
  26656. * @param data defines the vertex data to use
  26657. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26658. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26659. */
  26660. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26661. /**
  26662. * Removes a specific vertex data
  26663. * @param kind defines the data kind (Position, normal, etc...)
  26664. */
  26665. removeVerticesData(kind: string): void;
  26666. /**
  26667. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26668. * @param buffer defines the vertex buffer to use
  26669. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26670. */
  26671. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26672. /**
  26673. * Update a specific vertex buffer
  26674. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26675. * It will do nothing if the buffer is not updatable
  26676. * @param kind defines the data kind (Position, normal, etc...)
  26677. * @param data defines the data to use
  26678. * @param offset defines the offset in the target buffer where to store the data
  26679. * @param useBytes set to true if the offset is in bytes
  26680. */
  26681. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26682. /**
  26683. * Update a specific vertex buffer
  26684. * This function will create a new buffer if the current one is not updatable
  26685. * @param kind defines the data kind (Position, normal, etc...)
  26686. * @param data defines the data to use
  26687. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26688. */
  26689. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26690. private _updateBoundingInfo;
  26691. /** @hidden */
  26692. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26693. /**
  26694. * Gets total number of vertices
  26695. * @returns the total number of vertices
  26696. */
  26697. getTotalVertices(): number;
  26698. /**
  26699. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26700. * @param kind defines the data kind (Position, normal, etc...)
  26701. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26702. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26703. * @returns a float array containing vertex data
  26704. */
  26705. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26706. /**
  26707. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26708. * @param kind defines the data kind (Position, normal, etc...)
  26709. * @returns true if the vertex buffer with the specified kind is updatable
  26710. */
  26711. isVertexBufferUpdatable(kind: string): boolean;
  26712. /**
  26713. * Gets a specific vertex buffer
  26714. * @param kind defines the data kind (Position, normal, etc...)
  26715. * @returns a VertexBuffer
  26716. */
  26717. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26718. /**
  26719. * Returns all vertex buffers
  26720. * @return an object holding all vertex buffers indexed by kind
  26721. */
  26722. getVertexBuffers(): Nullable<{
  26723. [key: string]: VertexBuffer;
  26724. }>;
  26725. /**
  26726. * Gets a boolean indicating if specific vertex buffer is present
  26727. * @param kind defines the data kind (Position, normal, etc...)
  26728. * @returns true if data is present
  26729. */
  26730. isVerticesDataPresent(kind: string): boolean;
  26731. /**
  26732. * Gets a list of all attached data kinds (Position, normal, etc...)
  26733. * @returns a list of string containing all kinds
  26734. */
  26735. getVerticesDataKinds(): string[];
  26736. /**
  26737. * Update index buffer
  26738. * @param indices defines the indices to store in the index buffer
  26739. * @param offset defines the offset in the target buffer where to store the data
  26740. * @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)
  26741. */
  26742. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26743. /**
  26744. * Creates a new index buffer
  26745. * @param indices defines the indices to store in the index buffer
  26746. * @param totalVertices defines the total number of vertices (could be null)
  26747. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26748. */
  26749. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26750. /**
  26751. * Return the total number of indices
  26752. * @returns the total number of indices
  26753. */
  26754. getTotalIndices(): number;
  26755. /**
  26756. * Gets the index buffer array
  26757. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26758. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26759. * @returns the index buffer array
  26760. */
  26761. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26762. /**
  26763. * Gets the index buffer
  26764. * @return the index buffer
  26765. */
  26766. getIndexBuffer(): Nullable<DataBuffer>;
  26767. /** @hidden */
  26768. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26769. /**
  26770. * Release the associated resources for a specific mesh
  26771. * @param mesh defines the source mesh
  26772. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26773. */
  26774. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26775. /**
  26776. * Apply current geometry to a given mesh
  26777. * @param mesh defines the mesh to apply geometry to
  26778. */
  26779. applyToMesh(mesh: Mesh): void;
  26780. private _updateExtend;
  26781. private _applyToMesh;
  26782. private notifyUpdate;
  26783. /**
  26784. * Load the geometry if it was flagged as delay loaded
  26785. * @param scene defines the hosting scene
  26786. * @param onLoaded defines a callback called when the geometry is loaded
  26787. */
  26788. load(scene: Scene, onLoaded?: () => void): void;
  26789. private _queueLoad;
  26790. /**
  26791. * Invert the geometry to move from a right handed system to a left handed one.
  26792. */
  26793. toLeftHanded(): void;
  26794. /** @hidden */
  26795. _resetPointsArrayCache(): void;
  26796. /** @hidden */
  26797. _generatePointsArray(): boolean;
  26798. /**
  26799. * Gets a value indicating if the geometry is disposed
  26800. * @returns true if the geometry was disposed
  26801. */
  26802. isDisposed(): boolean;
  26803. private _disposeVertexArrayObjects;
  26804. /**
  26805. * Free all associated resources
  26806. */
  26807. dispose(): void;
  26808. /**
  26809. * Clone the current geometry into a new geometry
  26810. * @param id defines the unique ID of the new geometry
  26811. * @returns a new geometry object
  26812. */
  26813. copy(id: string): Geometry;
  26814. /**
  26815. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26816. * @return a JSON representation of the current geometry data (without the vertices data)
  26817. */
  26818. serialize(): any;
  26819. private toNumberArray;
  26820. /**
  26821. * Serialize all vertices data into a JSON oject
  26822. * @returns a JSON representation of the current geometry data
  26823. */
  26824. serializeVerticeData(): any;
  26825. /**
  26826. * Extracts a clone of a mesh geometry
  26827. * @param mesh defines the source mesh
  26828. * @param id defines the unique ID of the new geometry object
  26829. * @returns the new geometry object
  26830. */
  26831. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26832. /**
  26833. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26834. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26835. * Be aware Math.random() could cause collisions, but:
  26836. * "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"
  26837. * @returns a string containing a new GUID
  26838. */
  26839. static RandomId(): string;
  26840. /** @hidden */
  26841. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26842. private static _CleanMatricesWeights;
  26843. /**
  26844. * Create a new geometry from persisted data (Using .babylon file format)
  26845. * @param parsedVertexData defines the persisted data
  26846. * @param scene defines the hosting scene
  26847. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26848. * @returns the new geometry object
  26849. */
  26850. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26851. }
  26852. }
  26853. declare module "babylonjs/Meshes/mesh.vertexData" {
  26854. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26855. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26856. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26857. import { Geometry } from "babylonjs/Meshes/geometry";
  26858. import { Mesh } from "babylonjs/Meshes/mesh";
  26859. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  26860. /**
  26861. * Define an interface for all classes that will get and set the data on vertices
  26862. */
  26863. export interface IGetSetVerticesData {
  26864. /**
  26865. * Gets a boolean indicating if specific vertex data is present
  26866. * @param kind defines the vertex data kind to use
  26867. * @returns true is data kind is present
  26868. */
  26869. isVerticesDataPresent(kind: string): boolean;
  26870. /**
  26871. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26872. * @param kind defines the data kind (Position, normal, etc...)
  26873. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26874. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26875. * @returns a float array containing vertex data
  26876. */
  26877. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26878. /**
  26879. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26880. * @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.
  26881. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26882. * @returns the indices array or an empty array if the mesh has no geometry
  26883. */
  26884. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26885. /**
  26886. * Set specific vertex data
  26887. * @param kind defines the data kind (Position, normal, etc...)
  26888. * @param data defines the vertex data to use
  26889. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26890. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26891. */
  26892. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26893. /**
  26894. * Update a specific associated vertex buffer
  26895. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26896. * - VertexBuffer.PositionKind
  26897. * - VertexBuffer.UVKind
  26898. * - VertexBuffer.UV2Kind
  26899. * - VertexBuffer.UV3Kind
  26900. * - VertexBuffer.UV4Kind
  26901. * - VertexBuffer.UV5Kind
  26902. * - VertexBuffer.UV6Kind
  26903. * - VertexBuffer.ColorKind
  26904. * - VertexBuffer.MatricesIndicesKind
  26905. * - VertexBuffer.MatricesIndicesExtraKind
  26906. * - VertexBuffer.MatricesWeightsKind
  26907. * - VertexBuffer.MatricesWeightsExtraKind
  26908. * @param data defines the data source
  26909. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26910. * @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)
  26911. */
  26912. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26913. /**
  26914. * Creates a new index buffer
  26915. * @param indices defines the indices to store in the index buffer
  26916. * @param totalVertices defines the total number of vertices (could be null)
  26917. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26918. */
  26919. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26920. }
  26921. /**
  26922. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26923. */
  26924. export class VertexData {
  26925. /**
  26926. * Mesh side orientation : usually the external or front surface
  26927. */
  26928. static readonly FRONTSIDE: number;
  26929. /**
  26930. * Mesh side orientation : usually the internal or back surface
  26931. */
  26932. static readonly BACKSIDE: number;
  26933. /**
  26934. * Mesh side orientation : both internal and external or front and back surfaces
  26935. */
  26936. static readonly DOUBLESIDE: number;
  26937. /**
  26938. * Mesh side orientation : by default, `FRONTSIDE`
  26939. */
  26940. static readonly DEFAULTSIDE: number;
  26941. /**
  26942. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26943. */
  26944. positions: Nullable<FloatArray>;
  26945. /**
  26946. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26947. */
  26948. normals: Nullable<FloatArray>;
  26949. /**
  26950. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26951. */
  26952. tangents: Nullable<FloatArray>;
  26953. /**
  26954. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26955. */
  26956. uvs: Nullable<FloatArray>;
  26957. /**
  26958. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26959. */
  26960. uvs2: Nullable<FloatArray>;
  26961. /**
  26962. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26963. */
  26964. uvs3: Nullable<FloatArray>;
  26965. /**
  26966. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26967. */
  26968. uvs4: Nullable<FloatArray>;
  26969. /**
  26970. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26971. */
  26972. uvs5: Nullable<FloatArray>;
  26973. /**
  26974. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26975. */
  26976. uvs6: Nullable<FloatArray>;
  26977. /**
  26978. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26979. */
  26980. colors: Nullable<FloatArray>;
  26981. /**
  26982. * 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).
  26983. */
  26984. matricesIndices: Nullable<FloatArray>;
  26985. /**
  26986. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26987. */
  26988. matricesWeights: Nullable<FloatArray>;
  26989. /**
  26990. * An array extending the number of possible indices
  26991. */
  26992. matricesIndicesExtra: Nullable<FloatArray>;
  26993. /**
  26994. * An array extending the number of possible weights when the number of indices is extended
  26995. */
  26996. matricesWeightsExtra: Nullable<FloatArray>;
  26997. /**
  26998. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26999. */
  27000. indices: Nullable<IndicesArray>;
  27001. /**
  27002. * Uses the passed data array to set the set the values for the specified kind of data
  27003. * @param data a linear array of floating numbers
  27004. * @param kind the type of data that is being set, eg positions, colors etc
  27005. */
  27006. set(data: FloatArray, kind: string): void;
  27007. /**
  27008. * Associates the vertexData to the passed Mesh.
  27009. * Sets it as updatable or not (default `false`)
  27010. * @param mesh the mesh the vertexData is applied to
  27011. * @param updatable when used and having the value true allows new data to update the vertexData
  27012. * @returns the VertexData
  27013. */
  27014. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27015. /**
  27016. * Associates the vertexData to the passed Geometry.
  27017. * Sets it as updatable or not (default `false`)
  27018. * @param geometry the geometry the vertexData is applied to
  27019. * @param updatable when used and having the value true allows new data to update the vertexData
  27020. * @returns VertexData
  27021. */
  27022. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27023. /**
  27024. * Updates the associated mesh
  27025. * @param mesh the mesh to be updated
  27026. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27027. * @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
  27028. * @returns VertexData
  27029. */
  27030. updateMesh(mesh: Mesh): VertexData;
  27031. /**
  27032. * Updates the associated geometry
  27033. * @param geometry the geometry to be updated
  27034. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27035. * @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
  27036. * @returns VertexData.
  27037. */
  27038. updateGeometry(geometry: Geometry): VertexData;
  27039. private _applyTo;
  27040. private _update;
  27041. /**
  27042. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27043. * @param matrix the transforming matrix
  27044. * @returns the VertexData
  27045. */
  27046. transform(matrix: Matrix): VertexData;
  27047. /**
  27048. * Merges the passed VertexData into the current one
  27049. * @param other the VertexData to be merged into the current one
  27050. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27051. * @returns the modified VertexData
  27052. */
  27053. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27054. private _mergeElement;
  27055. private _validate;
  27056. /**
  27057. * Serializes the VertexData
  27058. * @returns a serialized object
  27059. */
  27060. serialize(): any;
  27061. /**
  27062. * Extracts the vertexData from a mesh
  27063. * @param mesh the mesh from which to extract the VertexData
  27064. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27065. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27066. * @returns the object VertexData associated to the passed mesh
  27067. */
  27068. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27069. /**
  27070. * Extracts the vertexData from the geometry
  27071. * @param geometry the geometry from which to extract the VertexData
  27072. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27073. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27074. * @returns the object VertexData associated to the passed mesh
  27075. */
  27076. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27077. private static _ExtractFrom;
  27078. /**
  27079. * Creates the VertexData for a Ribbon
  27080. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27081. * * pathArray array of paths, each of which an array of successive Vector3
  27082. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27083. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27084. * * 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
  27085. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27086. * * 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)
  27087. * * 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)
  27088. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27089. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27090. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27091. * @returns the VertexData of the ribbon
  27092. */
  27093. static CreateRibbon(options: {
  27094. pathArray: Vector3[][];
  27095. closeArray?: boolean;
  27096. closePath?: boolean;
  27097. offset?: number;
  27098. sideOrientation?: number;
  27099. frontUVs?: Vector4;
  27100. backUVs?: Vector4;
  27101. invertUV?: boolean;
  27102. uvs?: Vector2[];
  27103. colors?: Color4[];
  27104. }): VertexData;
  27105. /**
  27106. * Creates the VertexData for a box
  27107. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27108. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27109. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27110. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27111. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27112. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27113. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27114. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27115. * * 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)
  27116. * * 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)
  27117. * @returns the VertexData of the box
  27118. */
  27119. static CreateBox(options: {
  27120. size?: number;
  27121. width?: number;
  27122. height?: number;
  27123. depth?: number;
  27124. faceUV?: Vector4[];
  27125. faceColors?: Color4[];
  27126. sideOrientation?: number;
  27127. frontUVs?: Vector4;
  27128. backUVs?: Vector4;
  27129. }): VertexData;
  27130. /**
  27131. * Creates the VertexData for a tiled box
  27132. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27133. * * faceTiles sets the pattern, tile size and number of tiles for a face
  27134. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27135. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27136. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27137. * @returns the VertexData of the box
  27138. */
  27139. static CreateTiledBox(options: {
  27140. pattern?: number;
  27141. width?: number;
  27142. height?: number;
  27143. depth?: number;
  27144. tileSize?: number;
  27145. tileWidth?: number;
  27146. tileHeight?: number;
  27147. alignHorizontal?: number;
  27148. alignVertical?: number;
  27149. faceUV?: Vector4[];
  27150. faceColors?: Color4[];
  27151. sideOrientation?: number;
  27152. }): VertexData;
  27153. /**
  27154. * Creates the VertexData for a tiled plane
  27155. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27156. * * pattern a limited pattern arrangement depending on the number
  27157. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27158. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27159. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27160. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27161. * * 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)
  27162. * * 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)
  27163. * @returns the VertexData of the tiled plane
  27164. */
  27165. static CreateTiledPlane(options: {
  27166. pattern?: number;
  27167. tileSize?: number;
  27168. tileWidth?: number;
  27169. tileHeight?: number;
  27170. size?: number;
  27171. width?: number;
  27172. height?: number;
  27173. alignHorizontal?: number;
  27174. alignVertical?: number;
  27175. sideOrientation?: number;
  27176. frontUVs?: Vector4;
  27177. backUVs?: Vector4;
  27178. }): VertexData;
  27179. /**
  27180. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27181. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27182. * * segments sets the number of horizontal strips optional, default 32
  27183. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27184. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27185. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27186. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27187. * * 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
  27188. * * 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
  27189. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27190. * * 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)
  27191. * * 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)
  27192. * @returns the VertexData of the ellipsoid
  27193. */
  27194. static CreateSphere(options: {
  27195. segments?: number;
  27196. diameter?: number;
  27197. diameterX?: number;
  27198. diameterY?: number;
  27199. diameterZ?: number;
  27200. arc?: number;
  27201. slice?: number;
  27202. sideOrientation?: number;
  27203. frontUVs?: Vector4;
  27204. backUVs?: Vector4;
  27205. }): VertexData;
  27206. /**
  27207. * Creates the VertexData for a cylinder, cone or prism
  27208. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27209. * * height sets the height (y direction) of the cylinder, optional, default 2
  27210. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27211. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27212. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27213. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27214. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27215. * * 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
  27216. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27217. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27218. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27219. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27221. * * 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)
  27222. * * 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)
  27223. * @returns the VertexData of the cylinder, cone or prism
  27224. */
  27225. static CreateCylinder(options: {
  27226. height?: number;
  27227. diameterTop?: number;
  27228. diameterBottom?: number;
  27229. diameter?: number;
  27230. tessellation?: number;
  27231. subdivisions?: number;
  27232. arc?: number;
  27233. faceColors?: Color4[];
  27234. faceUV?: Vector4[];
  27235. hasRings?: boolean;
  27236. enclose?: boolean;
  27237. sideOrientation?: number;
  27238. frontUVs?: Vector4;
  27239. backUVs?: Vector4;
  27240. }): VertexData;
  27241. /**
  27242. * Creates the VertexData for a torus
  27243. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27244. * * diameter the diameter of the torus, optional default 1
  27245. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27246. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27247. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27248. * * 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)
  27249. * * 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)
  27250. * @returns the VertexData of the torus
  27251. */
  27252. static CreateTorus(options: {
  27253. diameter?: number;
  27254. thickness?: number;
  27255. tessellation?: number;
  27256. sideOrientation?: number;
  27257. frontUVs?: Vector4;
  27258. backUVs?: Vector4;
  27259. }): VertexData;
  27260. /**
  27261. * Creates the VertexData of the LineSystem
  27262. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27263. * - lines an array of lines, each line being an array of successive Vector3
  27264. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27265. * @returns the VertexData of the LineSystem
  27266. */
  27267. static CreateLineSystem(options: {
  27268. lines: Vector3[][];
  27269. colors?: Nullable<Color4[][]>;
  27270. }): VertexData;
  27271. /**
  27272. * Create the VertexData for a DashedLines
  27273. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27274. * - points an array successive Vector3
  27275. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27276. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27277. * - dashNb the intended total number of dashes, optional, default 200
  27278. * @returns the VertexData for the DashedLines
  27279. */
  27280. static CreateDashedLines(options: {
  27281. points: Vector3[];
  27282. dashSize?: number;
  27283. gapSize?: number;
  27284. dashNb?: number;
  27285. }): VertexData;
  27286. /**
  27287. * Creates the VertexData for a Ground
  27288. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27289. * - width the width (x direction) of the ground, optional, default 1
  27290. * - height the height (z direction) of the ground, optional, default 1
  27291. * - subdivisions the number of subdivisions per side, optional, default 1
  27292. * @returns the VertexData of the Ground
  27293. */
  27294. static CreateGround(options: {
  27295. width?: number;
  27296. height?: number;
  27297. subdivisions?: number;
  27298. subdivisionsX?: number;
  27299. subdivisionsY?: number;
  27300. }): VertexData;
  27301. /**
  27302. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27303. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27304. * * xmin the ground minimum X coordinate, optional, default -1
  27305. * * zmin the ground minimum Z coordinate, optional, default -1
  27306. * * xmax the ground maximum X coordinate, optional, default 1
  27307. * * zmax the ground maximum Z coordinate, optional, default 1
  27308. * * 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}
  27309. * * 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}
  27310. * @returns the VertexData of the TiledGround
  27311. */
  27312. static CreateTiledGround(options: {
  27313. xmin: number;
  27314. zmin: number;
  27315. xmax: number;
  27316. zmax: number;
  27317. subdivisions?: {
  27318. w: number;
  27319. h: number;
  27320. };
  27321. precision?: {
  27322. w: number;
  27323. h: number;
  27324. };
  27325. }): VertexData;
  27326. /**
  27327. * Creates the VertexData of the Ground designed from a heightmap
  27328. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27329. * * width the width (x direction) of the ground
  27330. * * height the height (z direction) of the ground
  27331. * * subdivisions the number of subdivisions per side
  27332. * * minHeight the minimum altitude on the ground, optional, default 0
  27333. * * maxHeight the maximum altitude on the ground, optional default 1
  27334. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27335. * * buffer the array holding the image color data
  27336. * * bufferWidth the width of image
  27337. * * bufferHeight the height of image
  27338. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27339. * @returns the VertexData of the Ground designed from a heightmap
  27340. */
  27341. static CreateGroundFromHeightMap(options: {
  27342. width: number;
  27343. height: number;
  27344. subdivisions: number;
  27345. minHeight: number;
  27346. maxHeight: number;
  27347. colorFilter: Color3;
  27348. buffer: Uint8Array;
  27349. bufferWidth: number;
  27350. bufferHeight: number;
  27351. alphaFilter: number;
  27352. }): VertexData;
  27353. /**
  27354. * Creates the VertexData for a Plane
  27355. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27356. * * size sets the width and height of the plane to the value of size, optional default 1
  27357. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27358. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27359. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27360. * * 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)
  27361. * * 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)
  27362. * @returns the VertexData of the box
  27363. */
  27364. static CreatePlane(options: {
  27365. size?: number;
  27366. width?: number;
  27367. height?: number;
  27368. sideOrientation?: number;
  27369. frontUVs?: Vector4;
  27370. backUVs?: Vector4;
  27371. }): VertexData;
  27372. /**
  27373. * Creates the VertexData of the Disc or regular Polygon
  27374. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27375. * * radius the radius of the disc, optional default 0.5
  27376. * * tessellation the number of polygon sides, optional, default 64
  27377. * * 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
  27378. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27379. * * 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)
  27380. * * 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)
  27381. * @returns the VertexData of the box
  27382. */
  27383. static CreateDisc(options: {
  27384. radius?: number;
  27385. tessellation?: number;
  27386. arc?: number;
  27387. sideOrientation?: number;
  27388. frontUVs?: Vector4;
  27389. backUVs?: Vector4;
  27390. }): VertexData;
  27391. /**
  27392. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27393. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27394. * @param polygon a mesh built from polygonTriangulation.build()
  27395. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27396. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27397. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27398. * @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)
  27399. * @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)
  27400. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27401. * @returns the VertexData of the Polygon
  27402. */
  27403. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27404. /**
  27405. * Creates the VertexData of the IcoSphere
  27406. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27407. * * radius the radius of the IcoSphere, optional default 1
  27408. * * radiusX allows stretching in the x direction, optional, default radius
  27409. * * radiusY allows stretching in the y direction, optional, default radius
  27410. * * radiusZ allows stretching in the z direction, optional, default radius
  27411. * * flat when true creates a flat shaded mesh, optional, default true
  27412. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27413. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27414. * * 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)
  27415. * * 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)
  27416. * @returns the VertexData of the IcoSphere
  27417. */
  27418. static CreateIcoSphere(options: {
  27419. radius?: number;
  27420. radiusX?: number;
  27421. radiusY?: number;
  27422. radiusZ?: number;
  27423. flat?: boolean;
  27424. subdivisions?: number;
  27425. sideOrientation?: number;
  27426. frontUVs?: Vector4;
  27427. backUVs?: Vector4;
  27428. }): VertexData;
  27429. /**
  27430. * Creates the VertexData for a Polyhedron
  27431. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27432. * * type provided types are:
  27433. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27434. * * 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)
  27435. * * size the size of the IcoSphere, optional default 1
  27436. * * sizeX allows stretching in the x direction, optional, default size
  27437. * * sizeY allows stretching in the y direction, optional, default size
  27438. * * sizeZ allows stretching in the z direction, optional, default size
  27439. * * 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
  27440. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27441. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27442. * * flat when true creates a flat shaded mesh, optional, default true
  27443. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27444. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27445. * * 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)
  27446. * * 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)
  27447. * @returns the VertexData of the Polyhedron
  27448. */
  27449. static CreatePolyhedron(options: {
  27450. type?: number;
  27451. size?: number;
  27452. sizeX?: number;
  27453. sizeY?: number;
  27454. sizeZ?: number;
  27455. custom?: any;
  27456. faceUV?: Vector4[];
  27457. faceColors?: Color4[];
  27458. flat?: boolean;
  27459. sideOrientation?: number;
  27460. frontUVs?: Vector4;
  27461. backUVs?: Vector4;
  27462. }): VertexData;
  27463. /**
  27464. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  27465. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  27466. * @returns the VertexData of the Capsule
  27467. */
  27468. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  27469. /**
  27470. * Creates the VertexData for a TorusKnot
  27471. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27472. * * radius the radius of the torus knot, optional, default 2
  27473. * * tube the thickness of the tube, optional, default 0.5
  27474. * * radialSegments the number of sides on each tube segments, optional, default 32
  27475. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27476. * * p the number of windings around the z axis, optional, default 2
  27477. * * q the number of windings around the x axis, optional, default 3
  27478. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27479. * * 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)
  27480. * * 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)
  27481. * @returns the VertexData of the Torus Knot
  27482. */
  27483. static CreateTorusKnot(options: {
  27484. radius?: number;
  27485. tube?: number;
  27486. radialSegments?: number;
  27487. tubularSegments?: number;
  27488. p?: number;
  27489. q?: number;
  27490. sideOrientation?: number;
  27491. frontUVs?: Vector4;
  27492. backUVs?: Vector4;
  27493. }): VertexData;
  27494. /**
  27495. * Compute normals for given positions and indices
  27496. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27497. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27498. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27499. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27500. * * facetNormals : optional array of facet normals (vector3)
  27501. * * facetPositions : optional array of facet positions (vector3)
  27502. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27503. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27504. * * bInfo : optional bounding info, required for facetPartitioning computation
  27505. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27506. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27507. * * useRightHandedSystem: optional boolean to for right handed system computation
  27508. * * depthSort : optional boolean to enable the facet depth sort computation
  27509. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27510. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27511. */
  27512. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27513. facetNormals?: any;
  27514. facetPositions?: any;
  27515. facetPartitioning?: any;
  27516. ratio?: number;
  27517. bInfo?: any;
  27518. bbSize?: Vector3;
  27519. subDiv?: any;
  27520. useRightHandedSystem?: boolean;
  27521. depthSort?: boolean;
  27522. distanceTo?: Vector3;
  27523. depthSortedFacets?: any;
  27524. }): void;
  27525. /** @hidden */
  27526. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27527. /**
  27528. * Applies VertexData created from the imported parameters to the geometry
  27529. * @param parsedVertexData the parsed data from an imported file
  27530. * @param geometry the geometry to apply the VertexData to
  27531. */
  27532. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27533. }
  27534. }
  27535. declare module "babylonjs/Morph/morphTarget" {
  27536. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27537. import { Observable } from "babylonjs/Misc/observable";
  27538. import { Nullable, FloatArray } from "babylonjs/types";
  27539. import { Scene } from "babylonjs/scene";
  27540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27541. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27542. /**
  27543. * Defines a target to use with MorphTargetManager
  27544. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27545. */
  27546. export class MorphTarget implements IAnimatable {
  27547. /** defines the name of the target */
  27548. name: string;
  27549. /**
  27550. * Gets or sets the list of animations
  27551. */
  27552. animations: import("babylonjs/Animations/animation").Animation[];
  27553. private _scene;
  27554. private _positions;
  27555. private _normals;
  27556. private _tangents;
  27557. private _uvs;
  27558. private _influence;
  27559. private _uniqueId;
  27560. /**
  27561. * Observable raised when the influence changes
  27562. */
  27563. onInfluenceChanged: Observable<boolean>;
  27564. /** @hidden */
  27565. _onDataLayoutChanged: Observable<void>;
  27566. /**
  27567. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27568. */
  27569. get influence(): number;
  27570. set influence(influence: number);
  27571. /**
  27572. * Gets or sets the id of the morph Target
  27573. */
  27574. id: string;
  27575. private _animationPropertiesOverride;
  27576. /**
  27577. * Gets or sets the animation properties override
  27578. */
  27579. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27580. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27581. /**
  27582. * Creates a new MorphTarget
  27583. * @param name defines the name of the target
  27584. * @param influence defines the influence to use
  27585. * @param scene defines the scene the morphtarget belongs to
  27586. */
  27587. constructor(
  27588. /** defines the name of the target */
  27589. name: string, influence?: number, scene?: Nullable<Scene>);
  27590. /**
  27591. * Gets the unique ID of this manager
  27592. */
  27593. get uniqueId(): number;
  27594. /**
  27595. * Gets a boolean defining if the target contains position data
  27596. */
  27597. get hasPositions(): boolean;
  27598. /**
  27599. * Gets a boolean defining if the target contains normal data
  27600. */
  27601. get hasNormals(): boolean;
  27602. /**
  27603. * Gets a boolean defining if the target contains tangent data
  27604. */
  27605. get hasTangents(): boolean;
  27606. /**
  27607. * Gets a boolean defining if the target contains texture coordinates data
  27608. */
  27609. get hasUVs(): boolean;
  27610. /**
  27611. * Affects position data to this target
  27612. * @param data defines the position data to use
  27613. */
  27614. setPositions(data: Nullable<FloatArray>): void;
  27615. /**
  27616. * Gets the position data stored in this target
  27617. * @returns a FloatArray containing the position data (or null if not present)
  27618. */
  27619. getPositions(): Nullable<FloatArray>;
  27620. /**
  27621. * Affects normal data to this target
  27622. * @param data defines the normal data to use
  27623. */
  27624. setNormals(data: Nullable<FloatArray>): void;
  27625. /**
  27626. * Gets the normal data stored in this target
  27627. * @returns a FloatArray containing the normal data (or null if not present)
  27628. */
  27629. getNormals(): Nullable<FloatArray>;
  27630. /**
  27631. * Affects tangent data to this target
  27632. * @param data defines the tangent data to use
  27633. */
  27634. setTangents(data: Nullable<FloatArray>): void;
  27635. /**
  27636. * Gets the tangent data stored in this target
  27637. * @returns a FloatArray containing the tangent data (or null if not present)
  27638. */
  27639. getTangents(): Nullable<FloatArray>;
  27640. /**
  27641. * Affects texture coordinates data to this target
  27642. * @param data defines the texture coordinates data to use
  27643. */
  27644. setUVs(data: Nullable<FloatArray>): void;
  27645. /**
  27646. * Gets the texture coordinates data stored in this target
  27647. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27648. */
  27649. getUVs(): Nullable<FloatArray>;
  27650. /**
  27651. * Clone the current target
  27652. * @returns a new MorphTarget
  27653. */
  27654. clone(): MorphTarget;
  27655. /**
  27656. * Serializes the current target into a Serialization object
  27657. * @returns the serialized object
  27658. */
  27659. serialize(): any;
  27660. /**
  27661. * Returns the string "MorphTarget"
  27662. * @returns "MorphTarget"
  27663. */
  27664. getClassName(): string;
  27665. /**
  27666. * Creates a new target from serialized data
  27667. * @param serializationObject defines the serialized data to use
  27668. * @returns a new MorphTarget
  27669. */
  27670. static Parse(serializationObject: any): MorphTarget;
  27671. /**
  27672. * Creates a MorphTarget from mesh data
  27673. * @param mesh defines the source mesh
  27674. * @param name defines the name to use for the new target
  27675. * @param influence defines the influence to attach to the target
  27676. * @returns a new MorphTarget
  27677. */
  27678. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27679. }
  27680. }
  27681. declare module "babylonjs/Morph/morphTargetManager" {
  27682. import { Nullable } from "babylonjs/types";
  27683. import { Scene } from "babylonjs/scene";
  27684. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27685. /**
  27686. * This class is used to deform meshes using morphing between different targets
  27687. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27688. */
  27689. export class MorphTargetManager {
  27690. private _targets;
  27691. private _targetInfluenceChangedObservers;
  27692. private _targetDataLayoutChangedObservers;
  27693. private _activeTargets;
  27694. private _scene;
  27695. private _influences;
  27696. private _supportsNormals;
  27697. private _supportsTangents;
  27698. private _supportsUVs;
  27699. private _vertexCount;
  27700. private _uniqueId;
  27701. private _tempInfluences;
  27702. /**
  27703. * Gets or sets a boolean indicating if normals must be morphed
  27704. */
  27705. enableNormalMorphing: boolean;
  27706. /**
  27707. * Gets or sets a boolean indicating if tangents must be morphed
  27708. */
  27709. enableTangentMorphing: boolean;
  27710. /**
  27711. * Gets or sets a boolean indicating if UV must be morphed
  27712. */
  27713. enableUVMorphing: boolean;
  27714. /**
  27715. * Creates a new MorphTargetManager
  27716. * @param scene defines the current scene
  27717. */
  27718. constructor(scene?: Nullable<Scene>);
  27719. /**
  27720. * Gets the unique ID of this manager
  27721. */
  27722. get uniqueId(): number;
  27723. /**
  27724. * Gets the number of vertices handled by this manager
  27725. */
  27726. get vertexCount(): number;
  27727. /**
  27728. * Gets a boolean indicating if this manager supports morphing of normals
  27729. */
  27730. get supportsNormals(): boolean;
  27731. /**
  27732. * Gets a boolean indicating if this manager supports morphing of tangents
  27733. */
  27734. get supportsTangents(): boolean;
  27735. /**
  27736. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27737. */
  27738. get supportsUVs(): boolean;
  27739. /**
  27740. * Gets the number of targets stored in this manager
  27741. */
  27742. get numTargets(): number;
  27743. /**
  27744. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27745. */
  27746. get numInfluencers(): number;
  27747. /**
  27748. * Gets the list of influences (one per target)
  27749. */
  27750. get influences(): Float32Array;
  27751. /**
  27752. * Gets the active target at specified index. An active target is a target with an influence > 0
  27753. * @param index defines the index to check
  27754. * @returns the requested target
  27755. */
  27756. getActiveTarget(index: number): MorphTarget;
  27757. /**
  27758. * Gets the target at specified index
  27759. * @param index defines the index to check
  27760. * @returns the requested target
  27761. */
  27762. getTarget(index: number): MorphTarget;
  27763. /**
  27764. * Add a new target to this manager
  27765. * @param target defines the target to add
  27766. */
  27767. addTarget(target: MorphTarget): void;
  27768. /**
  27769. * Removes a target from the manager
  27770. * @param target defines the target to remove
  27771. */
  27772. removeTarget(target: MorphTarget): void;
  27773. /**
  27774. * Clone the current manager
  27775. * @returns a new MorphTargetManager
  27776. */
  27777. clone(): MorphTargetManager;
  27778. /**
  27779. * Serializes the current manager into a Serialization object
  27780. * @returns the serialized object
  27781. */
  27782. serialize(): any;
  27783. private _syncActiveTargets;
  27784. /**
  27785. * Syncrhonize the targets with all the meshes using this morph target manager
  27786. */
  27787. synchronize(): void;
  27788. /**
  27789. * Creates a new MorphTargetManager from serialized data
  27790. * @param serializationObject defines the serialized data
  27791. * @param scene defines the hosting scene
  27792. * @returns the new MorphTargetManager
  27793. */
  27794. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27795. }
  27796. }
  27797. declare module "babylonjs/Meshes/meshLODLevel" {
  27798. import { Mesh } from "babylonjs/Meshes/mesh";
  27799. import { Nullable } from "babylonjs/types";
  27800. /**
  27801. * Class used to represent a specific level of detail of a mesh
  27802. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27803. */
  27804. export class MeshLODLevel {
  27805. /** Defines the distance where this level should start being displayed */
  27806. distance: number;
  27807. /** Defines the mesh to use to render this level */
  27808. mesh: Nullable<Mesh>;
  27809. /**
  27810. * Creates a new LOD level
  27811. * @param distance defines the distance where this level should star being displayed
  27812. * @param mesh defines the mesh to use to render this level
  27813. */
  27814. constructor(
  27815. /** Defines the distance where this level should start being displayed */
  27816. distance: number,
  27817. /** Defines the mesh to use to render this level */
  27818. mesh: Nullable<Mesh>);
  27819. }
  27820. }
  27821. declare module "babylonjs/Misc/canvasGenerator" {
  27822. /**
  27823. * Helper class used to generate a canvas to manipulate images
  27824. */
  27825. export class CanvasGenerator {
  27826. /**
  27827. * Create a new canvas (or offscreen canvas depending on the context)
  27828. * @param width defines the expected width
  27829. * @param height defines the expected height
  27830. * @return a new canvas or offscreen canvas
  27831. */
  27832. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27833. }
  27834. }
  27835. declare module "babylonjs/Meshes/groundMesh" {
  27836. import { Scene } from "babylonjs/scene";
  27837. import { Vector3 } from "babylonjs/Maths/math.vector";
  27838. import { Mesh } from "babylonjs/Meshes/mesh";
  27839. /**
  27840. * Mesh representing the gorund
  27841. */
  27842. export class GroundMesh extends Mesh {
  27843. /** If octree should be generated */
  27844. generateOctree: boolean;
  27845. private _heightQuads;
  27846. /** @hidden */
  27847. _subdivisionsX: number;
  27848. /** @hidden */
  27849. _subdivisionsY: number;
  27850. /** @hidden */
  27851. _width: number;
  27852. /** @hidden */
  27853. _height: number;
  27854. /** @hidden */
  27855. _minX: number;
  27856. /** @hidden */
  27857. _maxX: number;
  27858. /** @hidden */
  27859. _minZ: number;
  27860. /** @hidden */
  27861. _maxZ: number;
  27862. constructor(name: string, scene: Scene);
  27863. /**
  27864. * "GroundMesh"
  27865. * @returns "GroundMesh"
  27866. */
  27867. getClassName(): string;
  27868. /**
  27869. * The minimum of x and y subdivisions
  27870. */
  27871. get subdivisions(): number;
  27872. /**
  27873. * X subdivisions
  27874. */
  27875. get subdivisionsX(): number;
  27876. /**
  27877. * Y subdivisions
  27878. */
  27879. get subdivisionsY(): number;
  27880. /**
  27881. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27882. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27883. * @param chunksCount the number of subdivisions for x and y
  27884. * @param octreeBlocksSize (Default: 32)
  27885. */
  27886. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27887. /**
  27888. * Returns a height (y) value in the Worl system :
  27889. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27890. * @param x x coordinate
  27891. * @param z z coordinate
  27892. * @returns the ground y position if (x, z) are outside the ground surface.
  27893. */
  27894. getHeightAtCoordinates(x: number, z: number): number;
  27895. /**
  27896. * Returns a normalized vector (Vector3) orthogonal to the ground
  27897. * at the ground coordinates (x, z) expressed in the World system.
  27898. * @param x x coordinate
  27899. * @param z z coordinate
  27900. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27901. */
  27902. getNormalAtCoordinates(x: number, z: number): Vector3;
  27903. /**
  27904. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27905. * at the ground coordinates (x, z) expressed in the World system.
  27906. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27907. * @param x x coordinate
  27908. * @param z z coordinate
  27909. * @param ref vector to store the result
  27910. * @returns the GroundMesh.
  27911. */
  27912. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27913. /**
  27914. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27915. * if the ground has been updated.
  27916. * This can be used in the render loop.
  27917. * @returns the GroundMesh.
  27918. */
  27919. updateCoordinateHeights(): GroundMesh;
  27920. private _getFacetAt;
  27921. private _initHeightQuads;
  27922. private _computeHeightQuads;
  27923. /**
  27924. * Serializes this ground mesh
  27925. * @param serializationObject object to write serialization to
  27926. */
  27927. serialize(serializationObject: any): void;
  27928. /**
  27929. * Parses a serialized ground mesh
  27930. * @param parsedMesh the serialized mesh
  27931. * @param scene the scene to create the ground mesh in
  27932. * @returns the created ground mesh
  27933. */
  27934. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27935. }
  27936. }
  27937. declare module "babylonjs/Physics/physicsJoint" {
  27938. import { Vector3 } from "babylonjs/Maths/math.vector";
  27939. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27940. /**
  27941. * Interface for Physics-Joint data
  27942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27943. */
  27944. export interface PhysicsJointData {
  27945. /**
  27946. * The main pivot of the joint
  27947. */
  27948. mainPivot?: Vector3;
  27949. /**
  27950. * The connected pivot of the joint
  27951. */
  27952. connectedPivot?: Vector3;
  27953. /**
  27954. * The main axis of the joint
  27955. */
  27956. mainAxis?: Vector3;
  27957. /**
  27958. * The connected axis of the joint
  27959. */
  27960. connectedAxis?: Vector3;
  27961. /**
  27962. * The collision of the joint
  27963. */
  27964. collision?: boolean;
  27965. /**
  27966. * Native Oimo/Cannon/Energy data
  27967. */
  27968. nativeParams?: any;
  27969. }
  27970. /**
  27971. * This is a holder class for the physics joint created by the physics plugin
  27972. * It holds a set of functions to control the underlying joint
  27973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27974. */
  27975. export class PhysicsJoint {
  27976. /**
  27977. * The type of the physics joint
  27978. */
  27979. type: number;
  27980. /**
  27981. * The data for the physics joint
  27982. */
  27983. jointData: PhysicsJointData;
  27984. private _physicsJoint;
  27985. protected _physicsPlugin: IPhysicsEnginePlugin;
  27986. /**
  27987. * Initializes the physics joint
  27988. * @param type The type of the physics joint
  27989. * @param jointData The data for the physics joint
  27990. */
  27991. constructor(
  27992. /**
  27993. * The type of the physics joint
  27994. */
  27995. type: number,
  27996. /**
  27997. * The data for the physics joint
  27998. */
  27999. jointData: PhysicsJointData);
  28000. /**
  28001. * Gets the physics joint
  28002. */
  28003. get physicsJoint(): any;
  28004. /**
  28005. * Sets the physics joint
  28006. */
  28007. set physicsJoint(newJoint: any);
  28008. /**
  28009. * Sets the physics plugin
  28010. */
  28011. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  28012. /**
  28013. * Execute a function that is physics-plugin specific.
  28014. * @param {Function} func the function that will be executed.
  28015. * It accepts two parameters: the physics world and the physics joint
  28016. */
  28017. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  28018. /**
  28019. * Distance-Joint type
  28020. */
  28021. static DistanceJoint: number;
  28022. /**
  28023. * Hinge-Joint type
  28024. */
  28025. static HingeJoint: number;
  28026. /**
  28027. * Ball-and-Socket joint type
  28028. */
  28029. static BallAndSocketJoint: number;
  28030. /**
  28031. * Wheel-Joint type
  28032. */
  28033. static WheelJoint: number;
  28034. /**
  28035. * Slider-Joint type
  28036. */
  28037. static SliderJoint: number;
  28038. /**
  28039. * Prismatic-Joint type
  28040. */
  28041. static PrismaticJoint: number;
  28042. /**
  28043. * Universal-Joint type
  28044. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  28045. */
  28046. static UniversalJoint: number;
  28047. /**
  28048. * Hinge-Joint 2 type
  28049. */
  28050. static Hinge2Joint: number;
  28051. /**
  28052. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  28053. */
  28054. static PointToPointJoint: number;
  28055. /**
  28056. * Spring-Joint type
  28057. */
  28058. static SpringJoint: number;
  28059. /**
  28060. * Lock-Joint type
  28061. */
  28062. static LockJoint: number;
  28063. }
  28064. /**
  28065. * A class representing a physics distance joint
  28066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28067. */
  28068. export class DistanceJoint extends PhysicsJoint {
  28069. /**
  28070. *
  28071. * @param jointData The data for the Distance-Joint
  28072. */
  28073. constructor(jointData: DistanceJointData);
  28074. /**
  28075. * Update the predefined distance.
  28076. * @param maxDistance The maximum preferred distance
  28077. * @param minDistance The minimum preferred distance
  28078. */
  28079. updateDistance(maxDistance: number, minDistance?: number): void;
  28080. }
  28081. /**
  28082. * Represents a Motor-Enabled Joint
  28083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28084. */
  28085. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  28086. /**
  28087. * Initializes the Motor-Enabled Joint
  28088. * @param type The type of the joint
  28089. * @param jointData The physica joint data for the joint
  28090. */
  28091. constructor(type: number, jointData: PhysicsJointData);
  28092. /**
  28093. * Set the motor values.
  28094. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28095. * @param force the force to apply
  28096. * @param maxForce max force for this motor.
  28097. */
  28098. setMotor(force?: number, maxForce?: number): void;
  28099. /**
  28100. * Set the motor's limits.
  28101. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28102. * @param upperLimit The upper limit of the motor
  28103. * @param lowerLimit The lower limit of the motor
  28104. */
  28105. setLimit(upperLimit: number, lowerLimit?: number): void;
  28106. }
  28107. /**
  28108. * This class represents a single physics Hinge-Joint
  28109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28110. */
  28111. export class HingeJoint extends MotorEnabledJoint {
  28112. /**
  28113. * Initializes the Hinge-Joint
  28114. * @param jointData The joint data for the Hinge-Joint
  28115. */
  28116. constructor(jointData: PhysicsJointData);
  28117. /**
  28118. * Set the motor values.
  28119. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28120. * @param {number} force the force to apply
  28121. * @param {number} maxForce max force for this motor.
  28122. */
  28123. setMotor(force?: number, maxForce?: number): void;
  28124. /**
  28125. * Set the motor's limits.
  28126. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28127. * @param upperLimit The upper limit of the motor
  28128. * @param lowerLimit The lower limit of the motor
  28129. */
  28130. setLimit(upperLimit: number, lowerLimit?: number): void;
  28131. }
  28132. /**
  28133. * This class represents a dual hinge physics joint (same as wheel joint)
  28134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28135. */
  28136. export class Hinge2Joint extends MotorEnabledJoint {
  28137. /**
  28138. * Initializes the Hinge2-Joint
  28139. * @param jointData The joint data for the Hinge2-Joint
  28140. */
  28141. constructor(jointData: PhysicsJointData);
  28142. /**
  28143. * Set the motor values.
  28144. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28145. * @param {number} targetSpeed the speed the motor is to reach
  28146. * @param {number} maxForce max force for this motor.
  28147. * @param {motorIndex} the motor's index, 0 or 1.
  28148. */
  28149. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28150. /**
  28151. * Set the motor limits.
  28152. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28153. * @param {number} upperLimit the upper limit
  28154. * @param {number} lowerLimit lower limit
  28155. * @param {motorIndex} the motor's index, 0 or 1.
  28156. */
  28157. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28158. }
  28159. /**
  28160. * Interface for a motor enabled joint
  28161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28162. */
  28163. export interface IMotorEnabledJoint {
  28164. /**
  28165. * Physics joint
  28166. */
  28167. physicsJoint: any;
  28168. /**
  28169. * Sets the motor of the motor-enabled joint
  28170. * @param force The force of the motor
  28171. * @param maxForce The maximum force of the motor
  28172. * @param motorIndex The index of the motor
  28173. */
  28174. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28175. /**
  28176. * Sets the limit of the motor
  28177. * @param upperLimit The upper limit of the motor
  28178. * @param lowerLimit The lower limit of the motor
  28179. * @param motorIndex The index of the motor
  28180. */
  28181. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28182. }
  28183. /**
  28184. * Joint data for a Distance-Joint
  28185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28186. */
  28187. export interface DistanceJointData extends PhysicsJointData {
  28188. /**
  28189. * Max distance the 2 joint objects can be apart
  28190. */
  28191. maxDistance: number;
  28192. }
  28193. /**
  28194. * Joint data from a spring joint
  28195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28196. */
  28197. export interface SpringJointData extends PhysicsJointData {
  28198. /**
  28199. * Length of the spring
  28200. */
  28201. length: number;
  28202. /**
  28203. * Stiffness of the spring
  28204. */
  28205. stiffness: number;
  28206. /**
  28207. * Damping of the spring
  28208. */
  28209. damping: number;
  28210. /** this callback will be called when applying the force to the impostors. */
  28211. forceApplicationCallback: () => void;
  28212. }
  28213. }
  28214. declare module "babylonjs/Physics/physicsRaycastResult" {
  28215. import { Vector3 } from "babylonjs/Maths/math.vector";
  28216. /**
  28217. * Holds the data for the raycast result
  28218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28219. */
  28220. export class PhysicsRaycastResult {
  28221. private _hasHit;
  28222. private _hitDistance;
  28223. private _hitNormalWorld;
  28224. private _hitPointWorld;
  28225. private _rayFromWorld;
  28226. private _rayToWorld;
  28227. /**
  28228. * Gets if there was a hit
  28229. */
  28230. get hasHit(): boolean;
  28231. /**
  28232. * Gets the distance from the hit
  28233. */
  28234. get hitDistance(): number;
  28235. /**
  28236. * Gets the hit normal/direction in the world
  28237. */
  28238. get hitNormalWorld(): Vector3;
  28239. /**
  28240. * Gets the hit point in the world
  28241. */
  28242. get hitPointWorld(): Vector3;
  28243. /**
  28244. * Gets the ray "start point" of the ray in the world
  28245. */
  28246. get rayFromWorld(): Vector3;
  28247. /**
  28248. * Gets the ray "end point" of the ray in the world
  28249. */
  28250. get rayToWorld(): Vector3;
  28251. /**
  28252. * Sets the hit data (normal & point in world space)
  28253. * @param hitNormalWorld defines the normal in world space
  28254. * @param hitPointWorld defines the point in world space
  28255. */
  28256. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28257. /**
  28258. * Sets the distance from the start point to the hit point
  28259. * @param distance
  28260. */
  28261. setHitDistance(distance: number): void;
  28262. /**
  28263. * Calculates the distance manually
  28264. */
  28265. calculateHitDistance(): void;
  28266. /**
  28267. * Resets all the values to default
  28268. * @param from The from point on world space
  28269. * @param to The to point on world space
  28270. */
  28271. reset(from?: Vector3, to?: Vector3): void;
  28272. }
  28273. /**
  28274. * Interface for the size containing width and height
  28275. */
  28276. interface IXYZ {
  28277. /**
  28278. * X
  28279. */
  28280. x: number;
  28281. /**
  28282. * Y
  28283. */
  28284. y: number;
  28285. /**
  28286. * Z
  28287. */
  28288. z: number;
  28289. }
  28290. }
  28291. declare module "babylonjs/Physics/IPhysicsEngine" {
  28292. import { Nullable } from "babylonjs/types";
  28293. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28295. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28296. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28297. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28298. /**
  28299. * Interface used to describe a physics joint
  28300. */
  28301. export interface PhysicsImpostorJoint {
  28302. /** Defines the main impostor to which the joint is linked */
  28303. mainImpostor: PhysicsImpostor;
  28304. /** Defines the impostor that is connected to the main impostor using this joint */
  28305. connectedImpostor: PhysicsImpostor;
  28306. /** Defines the joint itself */
  28307. joint: PhysicsJoint;
  28308. }
  28309. /** @hidden */
  28310. export interface IPhysicsEnginePlugin {
  28311. world: any;
  28312. name: string;
  28313. setGravity(gravity: Vector3): void;
  28314. setTimeStep(timeStep: number): void;
  28315. getTimeStep(): number;
  28316. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28317. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28318. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28319. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28320. removePhysicsBody(impostor: PhysicsImpostor): void;
  28321. generateJoint(joint: PhysicsImpostorJoint): void;
  28322. removeJoint(joint: PhysicsImpostorJoint): void;
  28323. isSupported(): boolean;
  28324. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28325. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28326. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28327. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28328. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28329. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28330. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28331. getBodyMass(impostor: PhysicsImpostor): number;
  28332. getBodyFriction(impostor: PhysicsImpostor): number;
  28333. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28334. getBodyRestitution(impostor: PhysicsImpostor): number;
  28335. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28336. getBodyPressure?(impostor: PhysicsImpostor): number;
  28337. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28338. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28339. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28340. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28341. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28342. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28343. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28344. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28345. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28346. sleepBody(impostor: PhysicsImpostor): void;
  28347. wakeUpBody(impostor: PhysicsImpostor): void;
  28348. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28349. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28350. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28351. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28352. getRadius(impostor: PhysicsImpostor): number;
  28353. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28354. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28355. dispose(): void;
  28356. }
  28357. /**
  28358. * Interface used to define a physics engine
  28359. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28360. */
  28361. export interface IPhysicsEngine {
  28362. /**
  28363. * Gets the gravity vector used by the simulation
  28364. */
  28365. gravity: Vector3;
  28366. /**
  28367. * Sets the gravity vector used by the simulation
  28368. * @param gravity defines the gravity vector to use
  28369. */
  28370. setGravity(gravity: Vector3): void;
  28371. /**
  28372. * Set the time step of the physics engine.
  28373. * Default is 1/60.
  28374. * To slow it down, enter 1/600 for example.
  28375. * To speed it up, 1/30
  28376. * @param newTimeStep the new timestep to apply to this world.
  28377. */
  28378. setTimeStep(newTimeStep: number): void;
  28379. /**
  28380. * Get the time step of the physics engine.
  28381. * @returns the current time step
  28382. */
  28383. getTimeStep(): number;
  28384. /**
  28385. * Set the sub time step of the physics engine.
  28386. * Default is 0 meaning there is no sub steps
  28387. * To increase physics resolution precision, set a small value (like 1 ms)
  28388. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28389. */
  28390. setSubTimeStep(subTimeStep: number): void;
  28391. /**
  28392. * Get the sub time step of the physics engine.
  28393. * @returns the current sub time step
  28394. */
  28395. getSubTimeStep(): number;
  28396. /**
  28397. * Release all resources
  28398. */
  28399. dispose(): void;
  28400. /**
  28401. * Gets the name of the current physics plugin
  28402. * @returns the name of the plugin
  28403. */
  28404. getPhysicsPluginName(): string;
  28405. /**
  28406. * Adding a new impostor for the impostor tracking.
  28407. * This will be done by the impostor itself.
  28408. * @param impostor the impostor to add
  28409. */
  28410. addImpostor(impostor: PhysicsImpostor): void;
  28411. /**
  28412. * Remove an impostor from the engine.
  28413. * This impostor and its mesh will not longer be updated by the physics engine.
  28414. * @param impostor the impostor to remove
  28415. */
  28416. removeImpostor(impostor: PhysicsImpostor): void;
  28417. /**
  28418. * Add a joint to the physics engine
  28419. * @param mainImpostor defines the main impostor to which the joint is added.
  28420. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28421. * @param joint defines the joint that will connect both impostors.
  28422. */
  28423. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28424. /**
  28425. * Removes a joint from the simulation
  28426. * @param mainImpostor defines the impostor used with the joint
  28427. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28428. * @param joint defines the joint to remove
  28429. */
  28430. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28431. /**
  28432. * Gets the current plugin used to run the simulation
  28433. * @returns current plugin
  28434. */
  28435. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28436. /**
  28437. * Gets the list of physic impostors
  28438. * @returns an array of PhysicsImpostor
  28439. */
  28440. getImpostors(): Array<PhysicsImpostor>;
  28441. /**
  28442. * Gets the impostor for a physics enabled object
  28443. * @param object defines the object impersonated by the impostor
  28444. * @returns the PhysicsImpostor or null if not found
  28445. */
  28446. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28447. /**
  28448. * Gets the impostor for a physics body object
  28449. * @param body defines physics body used by the impostor
  28450. * @returns the PhysicsImpostor or null if not found
  28451. */
  28452. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28453. /**
  28454. * Does a raycast in the physics world
  28455. * @param from when should the ray start?
  28456. * @param to when should the ray end?
  28457. * @returns PhysicsRaycastResult
  28458. */
  28459. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28460. /**
  28461. * Called by the scene. No need to call it.
  28462. * @param delta defines the timespam between frames
  28463. */
  28464. _step(delta: number): void;
  28465. }
  28466. }
  28467. declare module "babylonjs/Physics/physicsImpostor" {
  28468. import { Nullable, IndicesArray } from "babylonjs/types";
  28469. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28470. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28472. import { Scene } from "babylonjs/scene";
  28473. import { Bone } from "babylonjs/Bones/bone";
  28474. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28475. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28476. import { Space } from "babylonjs/Maths/math.axis";
  28477. /**
  28478. * The interface for the physics imposter parameters
  28479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28480. */
  28481. export interface PhysicsImpostorParameters {
  28482. /**
  28483. * The mass of the physics imposter
  28484. */
  28485. mass: number;
  28486. /**
  28487. * The friction of the physics imposter
  28488. */
  28489. friction?: number;
  28490. /**
  28491. * The coefficient of restitution of the physics imposter
  28492. */
  28493. restitution?: number;
  28494. /**
  28495. * The native options of the physics imposter
  28496. */
  28497. nativeOptions?: any;
  28498. /**
  28499. * Specifies if the parent should be ignored
  28500. */
  28501. ignoreParent?: boolean;
  28502. /**
  28503. * Specifies if bi-directional transformations should be disabled
  28504. */
  28505. disableBidirectionalTransformation?: boolean;
  28506. /**
  28507. * The pressure inside the physics imposter, soft object only
  28508. */
  28509. pressure?: number;
  28510. /**
  28511. * The stiffness the physics imposter, soft object only
  28512. */
  28513. stiffness?: number;
  28514. /**
  28515. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28516. */
  28517. velocityIterations?: number;
  28518. /**
  28519. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28520. */
  28521. positionIterations?: number;
  28522. /**
  28523. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28524. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28525. * Add to fix multiple points
  28526. */
  28527. fixedPoints?: number;
  28528. /**
  28529. * The collision margin around a soft object
  28530. */
  28531. margin?: number;
  28532. /**
  28533. * The collision margin around a soft object
  28534. */
  28535. damping?: number;
  28536. /**
  28537. * The path for a rope based on an extrusion
  28538. */
  28539. path?: any;
  28540. /**
  28541. * The shape of an extrusion used for a rope based on an extrusion
  28542. */
  28543. shape?: any;
  28544. }
  28545. /**
  28546. * Interface for a physics-enabled object
  28547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28548. */
  28549. export interface IPhysicsEnabledObject {
  28550. /**
  28551. * The position of the physics-enabled object
  28552. */
  28553. position: Vector3;
  28554. /**
  28555. * The rotation of the physics-enabled object
  28556. */
  28557. rotationQuaternion: Nullable<Quaternion>;
  28558. /**
  28559. * The scale of the physics-enabled object
  28560. */
  28561. scaling: Vector3;
  28562. /**
  28563. * The rotation of the physics-enabled object
  28564. */
  28565. rotation?: Vector3;
  28566. /**
  28567. * The parent of the physics-enabled object
  28568. */
  28569. parent?: any;
  28570. /**
  28571. * The bounding info of the physics-enabled object
  28572. * @returns The bounding info of the physics-enabled object
  28573. */
  28574. getBoundingInfo(): BoundingInfo;
  28575. /**
  28576. * Computes the world matrix
  28577. * @param force Specifies if the world matrix should be computed by force
  28578. * @returns A world matrix
  28579. */
  28580. computeWorldMatrix(force: boolean): Matrix;
  28581. /**
  28582. * Gets the world matrix
  28583. * @returns A world matrix
  28584. */
  28585. getWorldMatrix?(): Matrix;
  28586. /**
  28587. * Gets the child meshes
  28588. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28589. * @returns An array of abstract meshes
  28590. */
  28591. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28592. /**
  28593. * Gets the vertex data
  28594. * @param kind The type of vertex data
  28595. * @returns A nullable array of numbers, or a float32 array
  28596. */
  28597. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28598. /**
  28599. * Gets the indices from the mesh
  28600. * @returns A nullable array of index arrays
  28601. */
  28602. getIndices?(): Nullable<IndicesArray>;
  28603. /**
  28604. * Gets the scene from the mesh
  28605. * @returns the indices array or null
  28606. */
  28607. getScene?(): Scene;
  28608. /**
  28609. * Gets the absolute position from the mesh
  28610. * @returns the absolute position
  28611. */
  28612. getAbsolutePosition(): Vector3;
  28613. /**
  28614. * Gets the absolute pivot point from the mesh
  28615. * @returns the absolute pivot point
  28616. */
  28617. getAbsolutePivotPoint(): Vector3;
  28618. /**
  28619. * Rotates the mesh
  28620. * @param axis The axis of rotation
  28621. * @param amount The amount of rotation
  28622. * @param space The space of the rotation
  28623. * @returns The rotation transform node
  28624. */
  28625. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28626. /**
  28627. * Translates the mesh
  28628. * @param axis The axis of translation
  28629. * @param distance The distance of translation
  28630. * @param space The space of the translation
  28631. * @returns The transform node
  28632. */
  28633. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28634. /**
  28635. * Sets the absolute position of the mesh
  28636. * @param absolutePosition The absolute position of the mesh
  28637. * @returns The transform node
  28638. */
  28639. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28640. /**
  28641. * Gets the class name of the mesh
  28642. * @returns The class name
  28643. */
  28644. getClassName(): string;
  28645. }
  28646. /**
  28647. * Represents a physics imposter
  28648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28649. */
  28650. export class PhysicsImpostor {
  28651. /**
  28652. * The physics-enabled object used as the physics imposter
  28653. */
  28654. object: IPhysicsEnabledObject;
  28655. /**
  28656. * The type of the physics imposter
  28657. */
  28658. type: number;
  28659. private _options;
  28660. private _scene?;
  28661. /**
  28662. * The default object size of the imposter
  28663. */
  28664. static DEFAULT_OBJECT_SIZE: Vector3;
  28665. /**
  28666. * The identity quaternion of the imposter
  28667. */
  28668. static IDENTITY_QUATERNION: Quaternion;
  28669. /** @hidden */
  28670. _pluginData: any;
  28671. private _physicsEngine;
  28672. private _physicsBody;
  28673. private _bodyUpdateRequired;
  28674. private _onBeforePhysicsStepCallbacks;
  28675. private _onAfterPhysicsStepCallbacks;
  28676. /** @hidden */
  28677. _onPhysicsCollideCallbacks: Array<{
  28678. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28679. otherImpostors: Array<PhysicsImpostor>;
  28680. }>;
  28681. private _deltaPosition;
  28682. private _deltaRotation;
  28683. private _deltaRotationConjugated;
  28684. /** @hidden */
  28685. _isFromLine: boolean;
  28686. private _parent;
  28687. private _isDisposed;
  28688. private static _tmpVecs;
  28689. private static _tmpQuat;
  28690. /**
  28691. * Specifies if the physics imposter is disposed
  28692. */
  28693. get isDisposed(): boolean;
  28694. /**
  28695. * Gets the mass of the physics imposter
  28696. */
  28697. get mass(): number;
  28698. set mass(value: number);
  28699. /**
  28700. * Gets the coefficient of friction
  28701. */
  28702. get friction(): number;
  28703. /**
  28704. * Sets the coefficient of friction
  28705. */
  28706. set friction(value: number);
  28707. /**
  28708. * Gets the coefficient of restitution
  28709. */
  28710. get restitution(): number;
  28711. /**
  28712. * Sets the coefficient of restitution
  28713. */
  28714. set restitution(value: number);
  28715. /**
  28716. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28717. */
  28718. get pressure(): number;
  28719. /**
  28720. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28721. */
  28722. set pressure(value: number);
  28723. /**
  28724. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28725. */
  28726. get stiffness(): number;
  28727. /**
  28728. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28729. */
  28730. set stiffness(value: number);
  28731. /**
  28732. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28733. */
  28734. get velocityIterations(): number;
  28735. /**
  28736. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28737. */
  28738. set velocityIterations(value: number);
  28739. /**
  28740. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28741. */
  28742. get positionIterations(): number;
  28743. /**
  28744. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28745. */
  28746. set positionIterations(value: number);
  28747. /**
  28748. * The unique id of the physics imposter
  28749. * set by the physics engine when adding this impostor to the array
  28750. */
  28751. uniqueId: number;
  28752. /**
  28753. * @hidden
  28754. */
  28755. soft: boolean;
  28756. /**
  28757. * @hidden
  28758. */
  28759. segments: number;
  28760. private _joints;
  28761. /**
  28762. * Initializes the physics imposter
  28763. * @param object The physics-enabled object used as the physics imposter
  28764. * @param type The type of the physics imposter
  28765. * @param _options The options for the physics imposter
  28766. * @param _scene The Babylon scene
  28767. */
  28768. constructor(
  28769. /**
  28770. * The physics-enabled object used as the physics imposter
  28771. */
  28772. object: IPhysicsEnabledObject,
  28773. /**
  28774. * The type of the physics imposter
  28775. */
  28776. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28777. /**
  28778. * This function will completly initialize this impostor.
  28779. * It will create a new body - but only if this mesh has no parent.
  28780. * If it has, this impostor will not be used other than to define the impostor
  28781. * of the child mesh.
  28782. * @hidden
  28783. */
  28784. _init(): void;
  28785. private _getPhysicsParent;
  28786. /**
  28787. * Should a new body be generated.
  28788. * @returns boolean specifying if body initialization is required
  28789. */
  28790. isBodyInitRequired(): boolean;
  28791. /**
  28792. * Sets the updated scaling
  28793. * @param updated Specifies if the scaling is updated
  28794. */
  28795. setScalingUpdated(): void;
  28796. /**
  28797. * Force a regeneration of this or the parent's impostor's body.
  28798. * Use under cautious - This will remove all joints already implemented.
  28799. */
  28800. forceUpdate(): void;
  28801. /**
  28802. * Gets the body that holds this impostor. Either its own, or its parent.
  28803. */
  28804. get physicsBody(): any;
  28805. /**
  28806. * Get the parent of the physics imposter
  28807. * @returns Physics imposter or null
  28808. */
  28809. get parent(): Nullable<PhysicsImpostor>;
  28810. /**
  28811. * Sets the parent of the physics imposter
  28812. */
  28813. set parent(value: Nullable<PhysicsImpostor>);
  28814. /**
  28815. * Set the physics body. Used mainly by the physics engine/plugin
  28816. */
  28817. set physicsBody(physicsBody: any);
  28818. /**
  28819. * Resets the update flags
  28820. */
  28821. resetUpdateFlags(): void;
  28822. /**
  28823. * Gets the object extend size
  28824. * @returns the object extend size
  28825. */
  28826. getObjectExtendSize(): Vector3;
  28827. /**
  28828. * Gets the object center
  28829. * @returns The object center
  28830. */
  28831. getObjectCenter(): Vector3;
  28832. /**
  28833. * Get a specific parameter from the options parameters
  28834. * @param paramName The object parameter name
  28835. * @returns The object parameter
  28836. */
  28837. getParam(paramName: string): any;
  28838. /**
  28839. * Sets a specific parameter in the options given to the physics plugin
  28840. * @param paramName The parameter name
  28841. * @param value The value of the parameter
  28842. */
  28843. setParam(paramName: string, value: number): void;
  28844. /**
  28845. * Specifically change the body's mass option. Won't recreate the physics body object
  28846. * @param mass The mass of the physics imposter
  28847. */
  28848. setMass(mass: number): void;
  28849. /**
  28850. * Gets the linear velocity
  28851. * @returns linear velocity or null
  28852. */
  28853. getLinearVelocity(): Nullable<Vector3>;
  28854. /**
  28855. * Sets the linear velocity
  28856. * @param velocity linear velocity or null
  28857. */
  28858. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28859. /**
  28860. * Gets the angular velocity
  28861. * @returns angular velocity or null
  28862. */
  28863. getAngularVelocity(): Nullable<Vector3>;
  28864. /**
  28865. * Sets the angular velocity
  28866. * @param velocity The velocity or null
  28867. */
  28868. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28869. /**
  28870. * Execute a function with the physics plugin native code
  28871. * Provide a function the will have two variables - the world object and the physics body object
  28872. * @param func The function to execute with the physics plugin native code
  28873. */
  28874. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28875. /**
  28876. * Register a function that will be executed before the physics world is stepping forward
  28877. * @param func The function to execute before the physics world is stepped forward
  28878. */
  28879. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28880. /**
  28881. * Unregister a function that will be executed before the physics world is stepping forward
  28882. * @param func The function to execute before the physics world is stepped forward
  28883. */
  28884. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28885. /**
  28886. * Register a function that will be executed after the physics step
  28887. * @param func The function to execute after physics step
  28888. */
  28889. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28890. /**
  28891. * Unregisters a function that will be executed after the physics step
  28892. * @param func The function to execute after physics step
  28893. */
  28894. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28895. /**
  28896. * register a function that will be executed when this impostor collides against a different body
  28897. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28898. * @param func Callback that is executed on collision
  28899. */
  28900. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28901. /**
  28902. * Unregisters the physics imposter on contact
  28903. * @param collideAgainst The physics object to collide against
  28904. * @param func Callback to execute on collision
  28905. */
  28906. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28907. private _tmpQuat;
  28908. private _tmpQuat2;
  28909. /**
  28910. * Get the parent rotation
  28911. * @returns The parent rotation
  28912. */
  28913. getParentsRotation(): Quaternion;
  28914. /**
  28915. * this function is executed by the physics engine.
  28916. */
  28917. beforeStep: () => void;
  28918. /**
  28919. * this function is executed by the physics engine
  28920. */
  28921. afterStep: () => void;
  28922. /**
  28923. * Legacy collision detection event support
  28924. */
  28925. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28926. /**
  28927. * event and body object due to cannon's event-based architecture.
  28928. */
  28929. onCollide: (e: {
  28930. body: any;
  28931. }) => void;
  28932. /**
  28933. * Apply a force
  28934. * @param force The force to apply
  28935. * @param contactPoint The contact point for the force
  28936. * @returns The physics imposter
  28937. */
  28938. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28939. /**
  28940. * Apply an impulse
  28941. * @param force The impulse force
  28942. * @param contactPoint The contact point for the impulse force
  28943. * @returns The physics imposter
  28944. */
  28945. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28946. /**
  28947. * A help function to create a joint
  28948. * @param otherImpostor A physics imposter used to create a joint
  28949. * @param jointType The type of joint
  28950. * @param jointData The data for the joint
  28951. * @returns The physics imposter
  28952. */
  28953. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28954. /**
  28955. * Add a joint to this impostor with a different impostor
  28956. * @param otherImpostor A physics imposter used to add a joint
  28957. * @param joint The joint to add
  28958. * @returns The physics imposter
  28959. */
  28960. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28961. /**
  28962. * Add an anchor to a cloth impostor
  28963. * @param otherImpostor rigid impostor to anchor to
  28964. * @param width ratio across width from 0 to 1
  28965. * @param height ratio up height from 0 to 1
  28966. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28967. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28968. * @returns impostor the soft imposter
  28969. */
  28970. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28971. /**
  28972. * Add a hook to a rope impostor
  28973. * @param otherImpostor rigid impostor to anchor to
  28974. * @param length ratio across rope from 0 to 1
  28975. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28976. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28977. * @returns impostor the rope imposter
  28978. */
  28979. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28980. /**
  28981. * Will keep this body still, in a sleep mode.
  28982. * @returns the physics imposter
  28983. */
  28984. sleep(): PhysicsImpostor;
  28985. /**
  28986. * Wake the body up.
  28987. * @returns The physics imposter
  28988. */
  28989. wakeUp(): PhysicsImpostor;
  28990. /**
  28991. * Clones the physics imposter
  28992. * @param newObject The physics imposter clones to this physics-enabled object
  28993. * @returns A nullable physics imposter
  28994. */
  28995. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28996. /**
  28997. * Disposes the physics imposter
  28998. */
  28999. dispose(): void;
  29000. /**
  29001. * Sets the delta position
  29002. * @param position The delta position amount
  29003. */
  29004. setDeltaPosition(position: Vector3): void;
  29005. /**
  29006. * Sets the delta rotation
  29007. * @param rotation The delta rotation amount
  29008. */
  29009. setDeltaRotation(rotation: Quaternion): void;
  29010. /**
  29011. * Gets the box size of the physics imposter and stores the result in the input parameter
  29012. * @param result Stores the box size
  29013. * @returns The physics imposter
  29014. */
  29015. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  29016. /**
  29017. * Gets the radius of the physics imposter
  29018. * @returns Radius of the physics imposter
  29019. */
  29020. getRadius(): number;
  29021. /**
  29022. * Sync a bone with this impostor
  29023. * @param bone The bone to sync to the impostor.
  29024. * @param boneMesh The mesh that the bone is influencing.
  29025. * @param jointPivot The pivot of the joint / bone in local space.
  29026. * @param distToJoint Optional distance from the impostor to the joint.
  29027. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29028. */
  29029. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  29030. /**
  29031. * Sync impostor to a bone
  29032. * @param bone The bone that the impostor will be synced to.
  29033. * @param boneMesh The mesh that the bone is influencing.
  29034. * @param jointPivot The pivot of the joint / bone in local space.
  29035. * @param distToJoint Optional distance from the impostor to the joint.
  29036. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29037. * @param boneAxis Optional vector3 axis the bone is aligned with
  29038. */
  29039. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  29040. /**
  29041. * No-Imposter type
  29042. */
  29043. static NoImpostor: number;
  29044. /**
  29045. * Sphere-Imposter type
  29046. */
  29047. static SphereImpostor: number;
  29048. /**
  29049. * Box-Imposter type
  29050. */
  29051. static BoxImpostor: number;
  29052. /**
  29053. * Plane-Imposter type
  29054. */
  29055. static PlaneImpostor: number;
  29056. /**
  29057. * Mesh-imposter type
  29058. */
  29059. static MeshImpostor: number;
  29060. /**
  29061. * Capsule-Impostor type (Ammo.js plugin only)
  29062. */
  29063. static CapsuleImpostor: number;
  29064. /**
  29065. * Cylinder-Imposter type
  29066. */
  29067. static CylinderImpostor: number;
  29068. /**
  29069. * Particle-Imposter type
  29070. */
  29071. static ParticleImpostor: number;
  29072. /**
  29073. * Heightmap-Imposter type
  29074. */
  29075. static HeightmapImpostor: number;
  29076. /**
  29077. * ConvexHull-Impostor type (Ammo.js plugin only)
  29078. */
  29079. static ConvexHullImpostor: number;
  29080. /**
  29081. * Custom-Imposter type (Ammo.js plugin only)
  29082. */
  29083. static CustomImpostor: number;
  29084. /**
  29085. * Rope-Imposter type
  29086. */
  29087. static RopeImpostor: number;
  29088. /**
  29089. * Cloth-Imposter type
  29090. */
  29091. static ClothImpostor: number;
  29092. /**
  29093. * Softbody-Imposter type
  29094. */
  29095. static SoftbodyImpostor: number;
  29096. }
  29097. }
  29098. declare module "babylonjs/Meshes/mesh" {
  29099. import { Observable } from "babylonjs/Misc/observable";
  29100. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29101. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29102. import { Camera } from "babylonjs/Cameras/camera";
  29103. import { Scene } from "babylonjs/scene";
  29104. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29105. import { Color4 } from "babylonjs/Maths/math.color";
  29106. import { Engine } from "babylonjs/Engines/engine";
  29107. import { Node } from "babylonjs/node";
  29108. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29109. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29110. import { Buffer } from "babylonjs/Meshes/buffer";
  29111. import { Geometry } from "babylonjs/Meshes/geometry";
  29112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29113. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29114. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  29115. import { Effect } from "babylonjs/Materials/effect";
  29116. import { Material } from "babylonjs/Materials/material";
  29117. import { Skeleton } from "babylonjs/Bones/skeleton";
  29118. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  29119. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  29120. import { Path3D } from "babylonjs/Maths/math.path";
  29121. import { Plane } from "babylonjs/Maths/math.plane";
  29122. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29123. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  29124. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  29125. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29126. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  29127. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  29128. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  29129. /**
  29130. * @hidden
  29131. **/
  29132. export class _CreationDataStorage {
  29133. closePath?: boolean;
  29134. closeArray?: boolean;
  29135. idx: number[];
  29136. dashSize: number;
  29137. gapSize: number;
  29138. path3D: Path3D;
  29139. pathArray: Vector3[][];
  29140. arc: number;
  29141. radius: number;
  29142. cap: number;
  29143. tessellation: number;
  29144. }
  29145. /**
  29146. * @hidden
  29147. **/
  29148. class _InstanceDataStorage {
  29149. visibleInstances: any;
  29150. batchCache: _InstancesBatch;
  29151. instancesBufferSize: number;
  29152. instancesBuffer: Nullable<Buffer>;
  29153. instancesData: Float32Array;
  29154. overridenInstanceCount: number;
  29155. isFrozen: boolean;
  29156. previousBatch: Nullable<_InstancesBatch>;
  29157. hardwareInstancedRendering: boolean;
  29158. sideOrientation: number;
  29159. manualUpdate: boolean;
  29160. }
  29161. /**
  29162. * @hidden
  29163. **/
  29164. export class _InstancesBatch {
  29165. mustReturn: boolean;
  29166. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29167. renderSelf: boolean[];
  29168. hardwareInstancedRendering: boolean[];
  29169. }
  29170. /**
  29171. * @hidden
  29172. **/
  29173. class _ThinInstanceDataStorage {
  29174. instancesCount: number;
  29175. matrixBuffer: Nullable<Buffer>;
  29176. matrixBufferSize: number;
  29177. matrixData: Nullable<Float32Array>;
  29178. boundingVectors: Array<Vector3>;
  29179. worldMatrices: Nullable<Matrix[]>;
  29180. }
  29181. /**
  29182. * Class used to represent renderable models
  29183. */
  29184. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29185. /**
  29186. * Mesh side orientation : usually the external or front surface
  29187. */
  29188. static readonly FRONTSIDE: number;
  29189. /**
  29190. * Mesh side orientation : usually the internal or back surface
  29191. */
  29192. static readonly BACKSIDE: number;
  29193. /**
  29194. * Mesh side orientation : both internal and external or front and back surfaces
  29195. */
  29196. static readonly DOUBLESIDE: number;
  29197. /**
  29198. * Mesh side orientation : by default, `FRONTSIDE`
  29199. */
  29200. static readonly DEFAULTSIDE: number;
  29201. /**
  29202. * Mesh cap setting : no cap
  29203. */
  29204. static readonly NO_CAP: number;
  29205. /**
  29206. * Mesh cap setting : one cap at the beginning of the mesh
  29207. */
  29208. static readonly CAP_START: number;
  29209. /**
  29210. * Mesh cap setting : one cap at the end of the mesh
  29211. */
  29212. static readonly CAP_END: number;
  29213. /**
  29214. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29215. */
  29216. static readonly CAP_ALL: number;
  29217. /**
  29218. * Mesh pattern setting : no flip or rotate
  29219. */
  29220. static readonly NO_FLIP: number;
  29221. /**
  29222. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29223. */
  29224. static readonly FLIP_TILE: number;
  29225. /**
  29226. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29227. */
  29228. static readonly ROTATE_TILE: number;
  29229. /**
  29230. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29231. */
  29232. static readonly FLIP_ROW: number;
  29233. /**
  29234. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29235. */
  29236. static readonly ROTATE_ROW: number;
  29237. /**
  29238. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29239. */
  29240. static readonly FLIP_N_ROTATE_TILE: number;
  29241. /**
  29242. * Mesh pattern setting : rotate pattern and rotate
  29243. */
  29244. static readonly FLIP_N_ROTATE_ROW: number;
  29245. /**
  29246. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29247. */
  29248. static readonly CENTER: number;
  29249. /**
  29250. * Mesh tile positioning : part tiles on left
  29251. */
  29252. static readonly LEFT: number;
  29253. /**
  29254. * Mesh tile positioning : part tiles on right
  29255. */
  29256. static readonly RIGHT: number;
  29257. /**
  29258. * Mesh tile positioning : part tiles on top
  29259. */
  29260. static readonly TOP: number;
  29261. /**
  29262. * Mesh tile positioning : part tiles on bottom
  29263. */
  29264. static readonly BOTTOM: number;
  29265. /**
  29266. * Gets the default side orientation.
  29267. * @param orientation the orientation to value to attempt to get
  29268. * @returns the default orientation
  29269. * @hidden
  29270. */
  29271. static _GetDefaultSideOrientation(orientation?: number): number;
  29272. private _internalMeshDataInfo;
  29273. get computeBonesUsingShaders(): boolean;
  29274. set computeBonesUsingShaders(value: boolean);
  29275. /**
  29276. * An event triggered before rendering the mesh
  29277. */
  29278. get onBeforeRenderObservable(): Observable<Mesh>;
  29279. /**
  29280. * An event triggered before binding the mesh
  29281. */
  29282. get onBeforeBindObservable(): Observable<Mesh>;
  29283. /**
  29284. * An event triggered after rendering the mesh
  29285. */
  29286. get onAfterRenderObservable(): Observable<Mesh>;
  29287. /**
  29288. * An event triggered before drawing the mesh
  29289. */
  29290. get onBeforeDrawObservable(): Observable<Mesh>;
  29291. private _onBeforeDrawObserver;
  29292. /**
  29293. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29294. */
  29295. set onBeforeDraw(callback: () => void);
  29296. get hasInstances(): boolean;
  29297. get hasThinInstances(): boolean;
  29298. /**
  29299. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29300. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29301. */
  29302. delayLoadState: number;
  29303. /**
  29304. * Gets the list of instances created from this mesh
  29305. * it is not supposed to be modified manually.
  29306. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29307. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29308. */
  29309. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29310. /**
  29311. * Gets the file containing delay loading data for this mesh
  29312. */
  29313. delayLoadingFile: string;
  29314. /** @hidden */
  29315. _binaryInfo: any;
  29316. /**
  29317. * User defined function used to change how LOD level selection is done
  29318. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29319. */
  29320. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29321. /**
  29322. * Gets or sets the morph target manager
  29323. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29324. */
  29325. get morphTargetManager(): Nullable<MorphTargetManager>;
  29326. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29327. /** @hidden */
  29328. _creationDataStorage: Nullable<_CreationDataStorage>;
  29329. /** @hidden */
  29330. _geometry: Nullable<Geometry>;
  29331. /** @hidden */
  29332. _delayInfo: Array<string>;
  29333. /** @hidden */
  29334. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29335. /** @hidden */
  29336. _instanceDataStorage: _InstanceDataStorage;
  29337. /** @hidden */
  29338. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29339. private _effectiveMaterial;
  29340. /** @hidden */
  29341. _shouldGenerateFlatShading: boolean;
  29342. /** @hidden */
  29343. _originalBuilderSideOrientation: number;
  29344. /**
  29345. * Use this property to change the original side orientation defined at construction time
  29346. */
  29347. overrideMaterialSideOrientation: Nullable<number>;
  29348. /**
  29349. * Gets the source mesh (the one used to clone this one from)
  29350. */
  29351. get source(): Nullable<Mesh>;
  29352. /**
  29353. * Gets the list of clones of this mesh
  29354. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  29355. * Note that useClonedMeshMap=true is the default setting
  29356. */
  29357. get cloneMeshMap(): Nullable<{
  29358. [id: string]: Mesh | undefined;
  29359. }>;
  29360. /**
  29361. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29362. */
  29363. get isUnIndexed(): boolean;
  29364. set isUnIndexed(value: boolean);
  29365. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29366. get worldMatrixInstancedBuffer(): Float32Array;
  29367. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29368. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29369. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29370. /**
  29371. * @constructor
  29372. * @param name The value used by scene.getMeshByName() to do a lookup.
  29373. * @param scene The scene to add this mesh to.
  29374. * @param parent The parent of this mesh, if it has one
  29375. * @param source An optional Mesh from which geometry is shared, cloned.
  29376. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29377. * When false, achieved by calling a clone(), also passing False.
  29378. * This will make creation of children, recursive.
  29379. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29380. */
  29381. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29382. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29383. doNotInstantiate: boolean;
  29384. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29385. /**
  29386. * Gets the class name
  29387. * @returns the string "Mesh".
  29388. */
  29389. getClassName(): string;
  29390. /** @hidden */
  29391. get _isMesh(): boolean;
  29392. /**
  29393. * Returns a description of this mesh
  29394. * @param fullDetails define if full details about this mesh must be used
  29395. * @returns a descriptive string representing this mesh
  29396. */
  29397. toString(fullDetails?: boolean): string;
  29398. /** @hidden */
  29399. _unBindEffect(): void;
  29400. /**
  29401. * Gets a boolean indicating if this mesh has LOD
  29402. */
  29403. get hasLODLevels(): boolean;
  29404. /**
  29405. * Gets the list of MeshLODLevel associated with the current mesh
  29406. * @returns an array of MeshLODLevel
  29407. */
  29408. getLODLevels(): MeshLODLevel[];
  29409. private _sortLODLevels;
  29410. /**
  29411. * Add a mesh as LOD level triggered at the given distance.
  29412. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29413. * @param distance The distance from the center of the object to show this level
  29414. * @param mesh The mesh to be added as LOD level (can be null)
  29415. * @return This mesh (for chaining)
  29416. */
  29417. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29418. /**
  29419. * Returns the LOD level mesh at the passed distance or null if not found.
  29420. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29421. * @param distance The distance from the center of the object to show this level
  29422. * @returns a Mesh or `null`
  29423. */
  29424. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29425. /**
  29426. * Remove a mesh from the LOD array
  29427. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29428. * @param mesh defines the mesh to be removed
  29429. * @return This mesh (for chaining)
  29430. */
  29431. removeLODLevel(mesh: Mesh): Mesh;
  29432. /**
  29433. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29434. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29435. * @param camera defines the camera to use to compute distance
  29436. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29437. * @return This mesh (for chaining)
  29438. */
  29439. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29440. /**
  29441. * Gets the mesh internal Geometry object
  29442. */
  29443. get geometry(): Nullable<Geometry>;
  29444. /**
  29445. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29446. * @returns the total number of vertices
  29447. */
  29448. getTotalVertices(): number;
  29449. /**
  29450. * Returns the content of an associated vertex buffer
  29451. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29452. * - VertexBuffer.PositionKind
  29453. * - VertexBuffer.UVKind
  29454. * - VertexBuffer.UV2Kind
  29455. * - VertexBuffer.UV3Kind
  29456. * - VertexBuffer.UV4Kind
  29457. * - VertexBuffer.UV5Kind
  29458. * - VertexBuffer.UV6Kind
  29459. * - VertexBuffer.ColorKind
  29460. * - VertexBuffer.MatricesIndicesKind
  29461. * - VertexBuffer.MatricesIndicesExtraKind
  29462. * - VertexBuffer.MatricesWeightsKind
  29463. * - VertexBuffer.MatricesWeightsExtraKind
  29464. * @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
  29465. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29466. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29467. */
  29468. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29469. /**
  29470. * Returns the mesh VertexBuffer object from the requested `kind`
  29471. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29472. * - VertexBuffer.PositionKind
  29473. * - VertexBuffer.NormalKind
  29474. * - VertexBuffer.UVKind
  29475. * - VertexBuffer.UV2Kind
  29476. * - VertexBuffer.UV3Kind
  29477. * - VertexBuffer.UV4Kind
  29478. * - VertexBuffer.UV5Kind
  29479. * - VertexBuffer.UV6Kind
  29480. * - VertexBuffer.ColorKind
  29481. * - VertexBuffer.MatricesIndicesKind
  29482. * - VertexBuffer.MatricesIndicesExtraKind
  29483. * - VertexBuffer.MatricesWeightsKind
  29484. * - VertexBuffer.MatricesWeightsExtraKind
  29485. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29486. */
  29487. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29488. /**
  29489. * Tests if a specific vertex buffer is associated with this mesh
  29490. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29491. * - VertexBuffer.PositionKind
  29492. * - VertexBuffer.NormalKind
  29493. * - VertexBuffer.UVKind
  29494. * - VertexBuffer.UV2Kind
  29495. * - VertexBuffer.UV3Kind
  29496. * - VertexBuffer.UV4Kind
  29497. * - VertexBuffer.UV5Kind
  29498. * - VertexBuffer.UV6Kind
  29499. * - VertexBuffer.ColorKind
  29500. * - VertexBuffer.MatricesIndicesKind
  29501. * - VertexBuffer.MatricesIndicesExtraKind
  29502. * - VertexBuffer.MatricesWeightsKind
  29503. * - VertexBuffer.MatricesWeightsExtraKind
  29504. * @returns a boolean
  29505. */
  29506. isVerticesDataPresent(kind: string): boolean;
  29507. /**
  29508. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29509. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29510. * - VertexBuffer.PositionKind
  29511. * - VertexBuffer.UVKind
  29512. * - VertexBuffer.UV2Kind
  29513. * - VertexBuffer.UV3Kind
  29514. * - VertexBuffer.UV4Kind
  29515. * - VertexBuffer.UV5Kind
  29516. * - VertexBuffer.UV6Kind
  29517. * - VertexBuffer.ColorKind
  29518. * - VertexBuffer.MatricesIndicesKind
  29519. * - VertexBuffer.MatricesIndicesExtraKind
  29520. * - VertexBuffer.MatricesWeightsKind
  29521. * - VertexBuffer.MatricesWeightsExtraKind
  29522. * @returns a boolean
  29523. */
  29524. isVertexBufferUpdatable(kind: string): boolean;
  29525. /**
  29526. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29527. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29528. * - VertexBuffer.PositionKind
  29529. * - VertexBuffer.NormalKind
  29530. * - VertexBuffer.UVKind
  29531. * - VertexBuffer.UV2Kind
  29532. * - VertexBuffer.UV3Kind
  29533. * - VertexBuffer.UV4Kind
  29534. * - VertexBuffer.UV5Kind
  29535. * - VertexBuffer.UV6Kind
  29536. * - VertexBuffer.ColorKind
  29537. * - VertexBuffer.MatricesIndicesKind
  29538. * - VertexBuffer.MatricesIndicesExtraKind
  29539. * - VertexBuffer.MatricesWeightsKind
  29540. * - VertexBuffer.MatricesWeightsExtraKind
  29541. * @returns an array of strings
  29542. */
  29543. getVerticesDataKinds(): string[];
  29544. /**
  29545. * Returns a positive integer : the total number of indices in this mesh geometry.
  29546. * @returns the numner of indices or zero if the mesh has no geometry.
  29547. */
  29548. getTotalIndices(): number;
  29549. /**
  29550. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29551. * @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.
  29552. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29553. * @returns the indices array or an empty array if the mesh has no geometry
  29554. */
  29555. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29556. get isBlocked(): boolean;
  29557. /**
  29558. * Determine if the current mesh is ready to be rendered
  29559. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29560. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29561. * @returns true if all associated assets are ready (material, textures, shaders)
  29562. */
  29563. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29564. /**
  29565. * 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.
  29566. */
  29567. get areNormalsFrozen(): boolean;
  29568. /**
  29569. * 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.
  29570. * @returns the current mesh
  29571. */
  29572. freezeNormals(): Mesh;
  29573. /**
  29574. * 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
  29575. * @returns the current mesh
  29576. */
  29577. unfreezeNormals(): Mesh;
  29578. /**
  29579. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29580. */
  29581. set overridenInstanceCount(count: number);
  29582. /** @hidden */
  29583. _preActivate(): Mesh;
  29584. /** @hidden */
  29585. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29586. /** @hidden */
  29587. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29588. protected _afterComputeWorldMatrix(): void;
  29589. /** @hidden */
  29590. _postActivate(): void;
  29591. /**
  29592. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29593. * This means the mesh underlying bounding box and sphere are recomputed.
  29594. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29595. * @returns the current mesh
  29596. */
  29597. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29598. /** @hidden */
  29599. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29600. /**
  29601. * This function will subdivide the mesh into multiple submeshes
  29602. * @param count defines the expected number of submeshes
  29603. */
  29604. subdivide(count: number): void;
  29605. /**
  29606. * Copy a FloatArray into a specific associated vertex buffer
  29607. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29608. * - VertexBuffer.PositionKind
  29609. * - VertexBuffer.UVKind
  29610. * - VertexBuffer.UV2Kind
  29611. * - VertexBuffer.UV3Kind
  29612. * - VertexBuffer.UV4Kind
  29613. * - VertexBuffer.UV5Kind
  29614. * - VertexBuffer.UV6Kind
  29615. * - VertexBuffer.ColorKind
  29616. * - VertexBuffer.MatricesIndicesKind
  29617. * - VertexBuffer.MatricesIndicesExtraKind
  29618. * - VertexBuffer.MatricesWeightsKind
  29619. * - VertexBuffer.MatricesWeightsExtraKind
  29620. * @param data defines the data source
  29621. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29622. * @param stride defines the data stride size (can be null)
  29623. * @returns the current mesh
  29624. */
  29625. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29626. /**
  29627. * Delete a vertex buffer associated with this mesh
  29628. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29629. * - VertexBuffer.PositionKind
  29630. * - VertexBuffer.UVKind
  29631. * - VertexBuffer.UV2Kind
  29632. * - VertexBuffer.UV3Kind
  29633. * - VertexBuffer.UV4Kind
  29634. * - VertexBuffer.UV5Kind
  29635. * - VertexBuffer.UV6Kind
  29636. * - VertexBuffer.ColorKind
  29637. * - VertexBuffer.MatricesIndicesKind
  29638. * - VertexBuffer.MatricesIndicesExtraKind
  29639. * - VertexBuffer.MatricesWeightsKind
  29640. * - VertexBuffer.MatricesWeightsExtraKind
  29641. */
  29642. removeVerticesData(kind: string): void;
  29643. /**
  29644. * Flags an associated vertex buffer as updatable
  29645. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29646. * - VertexBuffer.PositionKind
  29647. * - VertexBuffer.UVKind
  29648. * - VertexBuffer.UV2Kind
  29649. * - VertexBuffer.UV3Kind
  29650. * - VertexBuffer.UV4Kind
  29651. * - VertexBuffer.UV5Kind
  29652. * - VertexBuffer.UV6Kind
  29653. * - VertexBuffer.ColorKind
  29654. * - VertexBuffer.MatricesIndicesKind
  29655. * - VertexBuffer.MatricesIndicesExtraKind
  29656. * - VertexBuffer.MatricesWeightsKind
  29657. * - VertexBuffer.MatricesWeightsExtraKind
  29658. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29659. */
  29660. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29661. /**
  29662. * Sets the mesh global Vertex Buffer
  29663. * @param buffer defines the buffer to use
  29664. * @returns the current mesh
  29665. */
  29666. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29667. /**
  29668. * Update a specific associated vertex buffer
  29669. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29670. * - VertexBuffer.PositionKind
  29671. * - VertexBuffer.UVKind
  29672. * - VertexBuffer.UV2Kind
  29673. * - VertexBuffer.UV3Kind
  29674. * - VertexBuffer.UV4Kind
  29675. * - VertexBuffer.UV5Kind
  29676. * - VertexBuffer.UV6Kind
  29677. * - VertexBuffer.ColorKind
  29678. * - VertexBuffer.MatricesIndicesKind
  29679. * - VertexBuffer.MatricesIndicesExtraKind
  29680. * - VertexBuffer.MatricesWeightsKind
  29681. * - VertexBuffer.MatricesWeightsExtraKind
  29682. * @param data defines the data source
  29683. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29684. * @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)
  29685. * @returns the current mesh
  29686. */
  29687. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29688. /**
  29689. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29690. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29691. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29692. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29693. * @returns the current mesh
  29694. */
  29695. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29696. /**
  29697. * Creates a un-shared specific occurence of the geometry for the mesh.
  29698. * @returns the current mesh
  29699. */
  29700. makeGeometryUnique(): Mesh;
  29701. /**
  29702. * Set the index buffer of this mesh
  29703. * @param indices defines the source data
  29704. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29705. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29706. * @returns the current mesh
  29707. */
  29708. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29709. /**
  29710. * Update the current index buffer
  29711. * @param indices defines the source data
  29712. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29713. * @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)
  29714. * @returns the current mesh
  29715. */
  29716. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29717. /**
  29718. * Invert the geometry to move from a right handed system to a left handed one.
  29719. * @returns the current mesh
  29720. */
  29721. toLeftHanded(): Mesh;
  29722. /** @hidden */
  29723. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29724. /** @hidden */
  29725. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29726. /**
  29727. * Registers for this mesh a javascript function called just before the rendering process
  29728. * @param func defines the function to call before rendering this mesh
  29729. * @returns the current mesh
  29730. */
  29731. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29732. /**
  29733. * Disposes a previously registered javascript function called before the rendering
  29734. * @param func defines the function to remove
  29735. * @returns the current mesh
  29736. */
  29737. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29738. /**
  29739. * Registers for this mesh a javascript function called just after the rendering is complete
  29740. * @param func defines the function to call after rendering this mesh
  29741. * @returns the current mesh
  29742. */
  29743. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29744. /**
  29745. * Disposes a previously registered javascript function called after the rendering.
  29746. * @param func defines the function to remove
  29747. * @returns the current mesh
  29748. */
  29749. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29750. /** @hidden */
  29751. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29752. /** @hidden */
  29753. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29754. /** @hidden */
  29755. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29756. /** @hidden */
  29757. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29758. /** @hidden */
  29759. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29760. /** @hidden */
  29761. _rebuild(): void;
  29762. /** @hidden */
  29763. _freeze(): void;
  29764. /** @hidden */
  29765. _unFreeze(): void;
  29766. /**
  29767. * 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
  29768. * @param subMesh defines the subMesh to render
  29769. * @param enableAlphaMode defines if alpha mode can be changed
  29770. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29771. * @returns the current mesh
  29772. */
  29773. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29774. private _onBeforeDraw;
  29775. /**
  29776. * Renormalize the mesh and patch it up if there are no weights
  29777. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29778. * However in the case of zero weights then we set just a single influence to 1.
  29779. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29780. */
  29781. cleanMatrixWeights(): void;
  29782. private normalizeSkinFourWeights;
  29783. private normalizeSkinWeightsAndExtra;
  29784. /**
  29785. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29786. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29787. * the user know there was an issue with importing the mesh
  29788. * @returns a validation object with skinned, valid and report string
  29789. */
  29790. validateSkinning(): {
  29791. skinned: boolean;
  29792. valid: boolean;
  29793. report: string;
  29794. };
  29795. /** @hidden */
  29796. _checkDelayState(): Mesh;
  29797. private _queueLoad;
  29798. /**
  29799. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29800. * A mesh is in the frustum if its bounding box intersects the frustum
  29801. * @param frustumPlanes defines the frustum to test
  29802. * @returns true if the mesh is in the frustum planes
  29803. */
  29804. isInFrustum(frustumPlanes: Plane[]): boolean;
  29805. /**
  29806. * Sets the mesh material by the material or multiMaterial `id` property
  29807. * @param id is a string identifying the material or the multiMaterial
  29808. * @returns the current mesh
  29809. */
  29810. setMaterialByID(id: string): Mesh;
  29811. /**
  29812. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29813. * @returns an array of IAnimatable
  29814. */
  29815. getAnimatables(): IAnimatable[];
  29816. /**
  29817. * Modifies the mesh geometry according to the passed transformation matrix.
  29818. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29819. * The mesh normals are modified using the same transformation.
  29820. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29821. * @param transform defines the transform matrix to use
  29822. * @see https://doc.babylonjs.com/resources/baking_transformations
  29823. * @returns the current mesh
  29824. */
  29825. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29826. /**
  29827. * Modifies the mesh geometry according to its own current World Matrix.
  29828. * The mesh World Matrix is then reset.
  29829. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29830. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29831. * @see https://doc.babylonjs.com/resources/baking_transformations
  29832. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29833. * @returns the current mesh
  29834. */
  29835. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29836. /** @hidden */
  29837. get _positions(): Nullable<Vector3[]>;
  29838. /** @hidden */
  29839. _resetPointsArrayCache(): Mesh;
  29840. /** @hidden */
  29841. _generatePointsArray(): boolean;
  29842. /**
  29843. * Returns a new Mesh object generated from the current mesh properties.
  29844. * This method must not get confused with createInstance()
  29845. * @param name is a string, the name given to the new mesh
  29846. * @param newParent can be any Node object (default `null`)
  29847. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29848. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29849. * @returns a new mesh
  29850. */
  29851. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29852. /**
  29853. * Releases resources associated with this mesh.
  29854. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29855. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29856. */
  29857. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29858. /** @hidden */
  29859. _disposeInstanceSpecificData(): void;
  29860. /** @hidden */
  29861. _disposeThinInstanceSpecificData(): void;
  29862. /**
  29863. * Modifies the mesh geometry according to a displacement map.
  29864. * 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.
  29865. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29866. * @param url is a string, the URL from the image file is to be downloaded.
  29867. * @param minHeight is the lower limit of the displacement.
  29868. * @param maxHeight is the upper limit of the displacement.
  29869. * @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.
  29870. * @param uvOffset is an optional vector2 used to offset UV.
  29871. * @param uvScale is an optional vector2 used to scale UV.
  29872. * @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.
  29873. * @returns the Mesh.
  29874. */
  29875. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29876. /**
  29877. * Modifies the mesh geometry according to a displacementMap buffer.
  29878. * 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.
  29879. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29880. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29881. * @param heightMapWidth is the width of the buffer image.
  29882. * @param heightMapHeight is the height of the buffer image.
  29883. * @param minHeight is the lower limit of the displacement.
  29884. * @param maxHeight is the upper limit of the displacement.
  29885. * @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.
  29886. * @param uvOffset is an optional vector2 used to offset UV.
  29887. * @param uvScale is an optional vector2 used to scale UV.
  29888. * @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.
  29889. * @returns the Mesh.
  29890. */
  29891. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29892. /**
  29893. * Modify the mesh to get a flat shading rendering.
  29894. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29895. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29896. * @returns current mesh
  29897. */
  29898. convertToFlatShadedMesh(): Mesh;
  29899. /**
  29900. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29901. * In other words, more vertices, no more indices and a single bigger VBO.
  29902. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29903. * @returns current mesh
  29904. */
  29905. convertToUnIndexedMesh(): Mesh;
  29906. /**
  29907. * Inverses facet orientations.
  29908. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29909. * @param flipNormals will also inverts the normals
  29910. * @returns current mesh
  29911. */
  29912. flipFaces(flipNormals?: boolean): Mesh;
  29913. /**
  29914. * Increase the number of facets and hence vertices in a mesh
  29915. * Vertex normals are interpolated from existing vertex normals
  29916. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29917. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29918. */
  29919. increaseVertices(numberPerEdge: number): void;
  29920. /**
  29921. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29922. * This will undo any application of covertToFlatShadedMesh
  29923. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29924. */
  29925. forceSharedVertices(): void;
  29926. /** @hidden */
  29927. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29928. /** @hidden */
  29929. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29930. /**
  29931. * Creates a new InstancedMesh object from the mesh model.
  29932. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29933. * @param name defines the name of the new instance
  29934. * @returns a new InstancedMesh
  29935. */
  29936. createInstance(name: string): InstancedMesh;
  29937. /**
  29938. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29939. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29940. * @returns the current mesh
  29941. */
  29942. synchronizeInstances(): Mesh;
  29943. /**
  29944. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29945. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29946. * This should be used together with the simplification to avoid disappearing triangles.
  29947. * @param successCallback an optional success callback to be called after the optimization finished.
  29948. * @returns the current mesh
  29949. */
  29950. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29951. /**
  29952. * Serialize current mesh
  29953. * @param serializationObject defines the object which will receive the serialization data
  29954. */
  29955. serialize(serializationObject: any): void;
  29956. /** @hidden */
  29957. _syncGeometryWithMorphTargetManager(): void;
  29958. /** @hidden */
  29959. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29960. /**
  29961. * Returns a new Mesh object parsed from the source provided.
  29962. * @param parsedMesh is the source
  29963. * @param scene defines the hosting scene
  29964. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29965. * @returns a new Mesh
  29966. */
  29967. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29968. /**
  29969. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29970. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29971. * @param name defines the name of the mesh to create
  29972. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29973. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29974. * @param closePath creates a seam between the first and the last points of each path of the path array
  29975. * @param offset is taken in account only if the `pathArray` is containing a single path
  29976. * @param scene defines the hosting scene
  29977. * @param updatable defines if the mesh must be flagged as updatable
  29978. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29979. * @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)
  29980. * @returns a new Mesh
  29981. */
  29982. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29983. /**
  29984. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  29985. * @param name defines the name of the mesh to create
  29986. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29987. * @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
  29988. * @param scene defines the hosting scene
  29989. * @param updatable defines if the mesh must be flagged as updatable
  29990. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29991. * @returns a new Mesh
  29992. */
  29993. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29994. /**
  29995. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29996. * @param name defines the name of the mesh to create
  29997. * @param size sets the size (float) of each box side (default 1)
  29998. * @param scene defines the hosting scene
  29999. * @param updatable defines if the mesh must be flagged as updatable
  30000. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30001. * @returns a new Mesh
  30002. */
  30003. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30004. /**
  30005. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  30006. * @param name defines the name of the mesh to create
  30007. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30008. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30009. * @param scene defines the hosting scene
  30010. * @param updatable defines if the mesh must be flagged as updatable
  30011. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30012. * @returns a new Mesh
  30013. */
  30014. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30015. /**
  30016. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  30017. * @param name defines the name of the mesh to create
  30018. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30019. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30020. * @param scene defines the hosting scene
  30021. * @returns a new Mesh
  30022. */
  30023. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  30024. /**
  30025. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  30026. * @param name defines the name of the mesh to create
  30027. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  30028. * @param diameterTop set the top cap diameter (floats, default 1)
  30029. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  30030. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  30031. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  30032. * @param scene defines the hosting scene
  30033. * @param updatable defines if the mesh must be flagged as updatable
  30034. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30035. * @returns a new Mesh
  30036. */
  30037. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  30038. /**
  30039. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  30040. * @param name defines the name of the mesh to create
  30041. * @param diameter sets the diameter size (float) of the torus (default 1)
  30042. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  30043. * @param tessellation sets the number of torus sides (postive integer, default 16)
  30044. * @param scene defines the hosting scene
  30045. * @param updatable defines if the mesh must be flagged as updatable
  30046. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30047. * @returns a new Mesh
  30048. */
  30049. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30050. /**
  30051. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  30052. * @param name defines the name of the mesh to create
  30053. * @param radius sets the global radius size (float) of the torus knot (default 2)
  30054. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  30055. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  30056. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  30057. * @param p the number of windings on X axis (positive integers, default 2)
  30058. * @param q the number of windings on Y axis (positive integers, default 3)
  30059. * @param scene defines the hosting scene
  30060. * @param updatable defines if the mesh must be flagged as updatable
  30061. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30062. * @returns a new Mesh
  30063. */
  30064. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30065. /**
  30066. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  30067. * @param name defines the name of the mesh to create
  30068. * @param points is an array successive Vector3
  30069. * @param scene defines the hosting scene
  30070. * @param updatable defines if the mesh must be flagged as updatable
  30071. * @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).
  30072. * @returns a new Mesh
  30073. */
  30074. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  30075. /**
  30076. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  30077. * @param name defines the name of the mesh to create
  30078. * @param points is an array successive Vector3
  30079. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  30080. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  30081. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  30082. * @param scene defines the hosting scene
  30083. * @param updatable defines if the mesh must be flagged as updatable
  30084. * @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)
  30085. * @returns a new Mesh
  30086. */
  30087. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  30088. /**
  30089. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  30090. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  30091. * 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.
  30092. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30093. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  30094. * Remember you can only change the shape positions, not their number when updating a polygon.
  30095. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  30096. * @param name defines the name of the mesh to create
  30097. * @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
  30098. * @param scene defines the hosting scene
  30099. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30100. * @param updatable defines if the mesh must be flagged as updatable
  30101. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30102. * @param earcutInjection can be used to inject your own earcut reference
  30103. * @returns a new Mesh
  30104. */
  30105. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30106. /**
  30107. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  30108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  30109. * @param name defines the name of the mesh to create
  30110. * @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
  30111. * @param depth defines the height of extrusion
  30112. * @param scene defines the hosting scene
  30113. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30114. * @param updatable defines if the mesh must be flagged as updatable
  30115. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30116. * @param earcutInjection can be used to inject your own earcut reference
  30117. * @returns a new Mesh
  30118. */
  30119. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30120. /**
  30121. * Creates an extruded shape mesh.
  30122. * 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
  30123. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30125. * @param name defines the name of the mesh to create
  30126. * @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
  30127. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30128. * @param scale is the value to scale the shape
  30129. * @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
  30130. * @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
  30131. * @param scene defines the hosting scene
  30132. * @param updatable defines if the mesh must be flagged as updatable
  30133. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30134. * @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)
  30135. * @returns a new Mesh
  30136. */
  30137. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30138. /**
  30139. * Creates an custom extruded shape mesh.
  30140. * The custom extrusion is a parametric shape.
  30141. * It has no predefined shape. Its final shape will depend on the input parameters.
  30142. * Please consider using the same method from the MeshBuilder class instead
  30143. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30144. * @param name defines the name of the mesh to create
  30145. * @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
  30146. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30147. * @param scaleFunction is a custom Javascript function called on each path point
  30148. * @param rotationFunction is a custom Javascript function called on each path point
  30149. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  30150. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  30151. * @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
  30152. * @param scene defines the hosting scene
  30153. * @param updatable defines if the mesh must be flagged as updatable
  30154. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30155. * @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)
  30156. * @returns a new Mesh
  30157. */
  30158. 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;
  30159. /**
  30160. * Creates lathe mesh.
  30161. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30162. * Please consider using the same method from the MeshBuilder class instead
  30163. * @param name defines the name of the mesh to create
  30164. * @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
  30165. * @param radius is the radius value of the lathe
  30166. * @param tessellation is the side number of the lathe.
  30167. * @param scene defines the hosting scene
  30168. * @param updatable defines if the mesh must be flagged as updatable
  30169. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30170. * @returns a new Mesh
  30171. */
  30172. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30173. /**
  30174. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30175. * @param name defines the name of the mesh to create
  30176. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30177. * @param scene defines the hosting scene
  30178. * @param updatable defines if the mesh must be flagged as updatable
  30179. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30180. * @returns a new Mesh
  30181. */
  30182. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30183. /**
  30184. * Creates a ground mesh.
  30185. * Please consider using the same method from the MeshBuilder class instead
  30186. * @param name defines the name of the mesh to create
  30187. * @param width set the width of the ground
  30188. * @param height set the height of the ground
  30189. * @param subdivisions sets the number of subdivisions per side
  30190. * @param scene defines the hosting scene
  30191. * @param updatable defines if the mesh must be flagged as updatable
  30192. * @returns a new Mesh
  30193. */
  30194. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30195. /**
  30196. * Creates a tiled ground mesh.
  30197. * Please consider using the same method from the MeshBuilder class instead
  30198. * @param name defines the name of the mesh to create
  30199. * @param xmin set the ground minimum X coordinate
  30200. * @param zmin set the ground minimum Y coordinate
  30201. * @param xmax set the ground maximum X coordinate
  30202. * @param zmax set the ground maximum Z coordinate
  30203. * @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
  30204. * @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
  30205. * @param scene defines the hosting scene
  30206. * @param updatable defines if the mesh must be flagged as updatable
  30207. * @returns a new Mesh
  30208. */
  30209. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30210. w: number;
  30211. h: number;
  30212. }, precision: {
  30213. w: number;
  30214. h: number;
  30215. }, scene: Scene, updatable?: boolean): Mesh;
  30216. /**
  30217. * Creates a ground mesh from a height map.
  30218. * Please consider using the same method from the MeshBuilder class instead
  30219. * @see https://doc.babylonjs.com/babylon101/height_map
  30220. * @param name defines the name of the mesh to create
  30221. * @param url sets the URL of the height map image resource
  30222. * @param width set the ground width size
  30223. * @param height set the ground height size
  30224. * @param subdivisions sets the number of subdivision per side
  30225. * @param minHeight is the minimum altitude on the ground
  30226. * @param maxHeight is the maximum altitude on the ground
  30227. * @param scene defines the hosting scene
  30228. * @param updatable defines if the mesh must be flagged as updatable
  30229. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30230. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30231. * @returns a new Mesh
  30232. */
  30233. 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;
  30234. /**
  30235. * Creates a tube mesh.
  30236. * The tube is a parametric shape.
  30237. * It has no predefined shape. Its final shape will depend on the input parameters.
  30238. * Please consider using the same method from the MeshBuilder class instead
  30239. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30240. * @param name defines the name of the mesh to create
  30241. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30242. * @param radius sets the tube radius size
  30243. * @param tessellation is the number of sides on the tubular surface
  30244. * @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
  30245. * @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
  30246. * @param scene defines the hosting scene
  30247. * @param updatable defines if the mesh must be flagged as updatable
  30248. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30249. * @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)
  30250. * @returns a new Mesh
  30251. */
  30252. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30253. (i: number, distance: number): number;
  30254. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30255. /**
  30256. * Creates a polyhedron mesh.
  30257. * Please consider using the same method from the MeshBuilder class instead.
  30258. * * 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
  30259. * * The parameter `size` (positive float, default 1) sets the polygon size
  30260. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30261. * * 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`
  30262. * * 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
  30263. * * 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)`)
  30264. * * 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
  30265. * * 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
  30266. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30269. * @param name defines the name of the mesh to create
  30270. * @param options defines the options used to create the mesh
  30271. * @param scene defines the hosting scene
  30272. * @returns a new Mesh
  30273. */
  30274. static CreatePolyhedron(name: string, options: {
  30275. type?: number;
  30276. size?: number;
  30277. sizeX?: number;
  30278. sizeY?: number;
  30279. sizeZ?: number;
  30280. custom?: any;
  30281. faceUV?: Vector4[];
  30282. faceColors?: Color4[];
  30283. updatable?: boolean;
  30284. sideOrientation?: number;
  30285. }, scene: Scene): Mesh;
  30286. /**
  30287. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30288. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30289. * * 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`)
  30290. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30291. * * 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
  30292. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30293. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30295. * @param name defines the name of the mesh
  30296. * @param options defines the options used to create the mesh
  30297. * @param scene defines the hosting scene
  30298. * @returns a new Mesh
  30299. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30300. */
  30301. static CreateIcoSphere(name: string, options: {
  30302. radius?: number;
  30303. flat?: boolean;
  30304. subdivisions?: number;
  30305. sideOrientation?: number;
  30306. updatable?: boolean;
  30307. }, scene: Scene): Mesh;
  30308. /**
  30309. * Creates a decal mesh.
  30310. * Please consider using the same method from the MeshBuilder class instead.
  30311. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30312. * @param name defines the name of the mesh
  30313. * @param sourceMesh defines the mesh receiving the decal
  30314. * @param position sets the position of the decal in world coordinates
  30315. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30316. * @param size sets the decal scaling
  30317. * @param angle sets the angle to rotate the decal
  30318. * @returns a new Mesh
  30319. */
  30320. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30321. /** Creates a Capsule Mesh
  30322. * @param name defines the name of the mesh.
  30323. * @param options the constructors options used to shape the mesh.
  30324. * @param scene defines the scene the mesh is scoped to.
  30325. * @returns the capsule mesh
  30326. * @see https://doc.babylonjs.com/how_to/capsule_shape
  30327. */
  30328. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  30329. /**
  30330. * Prepare internal position array for software CPU skinning
  30331. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30332. */
  30333. setPositionsForCPUSkinning(): Float32Array;
  30334. /**
  30335. * Prepare internal normal array for software CPU skinning
  30336. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30337. */
  30338. setNormalsForCPUSkinning(): Float32Array;
  30339. /**
  30340. * Updates the vertex buffer by applying transformation from the bones
  30341. * @param skeleton defines the skeleton to apply to current mesh
  30342. * @returns the current mesh
  30343. */
  30344. applySkeleton(skeleton: Skeleton): Mesh;
  30345. /**
  30346. * 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
  30347. * @param meshes defines the list of meshes to scan
  30348. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30349. */
  30350. static MinMax(meshes: AbstractMesh[]): {
  30351. min: Vector3;
  30352. max: Vector3;
  30353. };
  30354. /**
  30355. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30356. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30357. * @returns a vector3
  30358. */
  30359. static Center(meshesOrMinMaxVector: {
  30360. min: Vector3;
  30361. max: Vector3;
  30362. } | AbstractMesh[]): Vector3;
  30363. /**
  30364. * Merge the array of meshes into a single mesh for performance reasons.
  30365. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30366. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30367. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30368. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30369. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30370. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30371. * @returns a new mesh
  30372. */
  30373. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30374. /** @hidden */
  30375. addInstance(instance: InstancedMesh): void;
  30376. /** @hidden */
  30377. removeInstance(instance: InstancedMesh): void;
  30378. }
  30379. }
  30380. declare module "babylonjs/Cameras/camera" {
  30381. import { SmartArray } from "babylonjs/Misc/smartArray";
  30382. import { Observable } from "babylonjs/Misc/observable";
  30383. import { Nullable } from "babylonjs/types";
  30384. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30385. import { Scene } from "babylonjs/scene";
  30386. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30387. import { Node } from "babylonjs/node";
  30388. import { Mesh } from "babylonjs/Meshes/mesh";
  30389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30390. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30391. import { Viewport } from "babylonjs/Maths/math.viewport";
  30392. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30393. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30394. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30395. import { Ray } from "babylonjs/Culling/ray";
  30396. /**
  30397. * This is the base class of all the camera used in the application.
  30398. * @see https://doc.babylonjs.com/features/cameras
  30399. */
  30400. export class Camera extends Node {
  30401. /** @hidden */
  30402. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30403. /**
  30404. * This is the default projection mode used by the cameras.
  30405. * It helps recreating a feeling of perspective and better appreciate depth.
  30406. * This is the best way to simulate real life cameras.
  30407. */
  30408. static readonly PERSPECTIVE_CAMERA: number;
  30409. /**
  30410. * This helps creating camera with an orthographic mode.
  30411. * 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.
  30412. */
  30413. static readonly ORTHOGRAPHIC_CAMERA: number;
  30414. /**
  30415. * This is the default FOV mode for perspective cameras.
  30416. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30417. */
  30418. static readonly FOVMODE_VERTICAL_FIXED: number;
  30419. /**
  30420. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30421. */
  30422. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30423. /**
  30424. * This specifies ther is no need for a camera rig.
  30425. * Basically only one eye is rendered corresponding to the camera.
  30426. */
  30427. static readonly RIG_MODE_NONE: number;
  30428. /**
  30429. * Simulates a camera Rig with one blue eye and one red eye.
  30430. * This can be use with 3d blue and red glasses.
  30431. */
  30432. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30433. /**
  30434. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30435. */
  30436. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30437. /**
  30438. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30439. */
  30440. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30441. /**
  30442. * Defines that both eyes of the camera will be rendered over under each other.
  30443. */
  30444. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30445. /**
  30446. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30447. */
  30448. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30449. /**
  30450. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30451. */
  30452. static readonly RIG_MODE_VR: number;
  30453. /**
  30454. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30455. */
  30456. static readonly RIG_MODE_WEBVR: number;
  30457. /**
  30458. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30459. */
  30460. static readonly RIG_MODE_CUSTOM: number;
  30461. /**
  30462. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30463. */
  30464. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30465. /**
  30466. * Define the input manager associated with the camera.
  30467. */
  30468. inputs: CameraInputsManager<Camera>;
  30469. /** @hidden */
  30470. _position: Vector3;
  30471. /**
  30472. * Define the current local position of the camera in the scene
  30473. */
  30474. get position(): Vector3;
  30475. set position(newPosition: Vector3);
  30476. protected _upVector: Vector3;
  30477. /**
  30478. * The vector the camera should consider as up.
  30479. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30480. */
  30481. set upVector(vec: Vector3);
  30482. get upVector(): Vector3;
  30483. /**
  30484. * Define the current limit on the left side for an orthographic camera
  30485. * In scene unit
  30486. */
  30487. orthoLeft: Nullable<number>;
  30488. /**
  30489. * Define the current limit on the right side for an orthographic camera
  30490. * In scene unit
  30491. */
  30492. orthoRight: Nullable<number>;
  30493. /**
  30494. * Define the current limit on the bottom side for an orthographic camera
  30495. * In scene unit
  30496. */
  30497. orthoBottom: Nullable<number>;
  30498. /**
  30499. * Define the current limit on the top side for an orthographic camera
  30500. * In scene unit
  30501. */
  30502. orthoTop: Nullable<number>;
  30503. /**
  30504. * Field Of View is set in Radians. (default is 0.8)
  30505. */
  30506. fov: number;
  30507. /**
  30508. * Define the minimum distance the camera can see from.
  30509. * This is important to note that the depth buffer are not infinite and the closer it starts
  30510. * the more your scene might encounter depth fighting issue.
  30511. */
  30512. minZ: number;
  30513. /**
  30514. * Define the maximum distance the camera can see to.
  30515. * This is important to note that the depth buffer are not infinite and the further it end
  30516. * the more your scene might encounter depth fighting issue.
  30517. */
  30518. maxZ: number;
  30519. /**
  30520. * Define the default inertia of the camera.
  30521. * This helps giving a smooth feeling to the camera movement.
  30522. */
  30523. inertia: number;
  30524. /**
  30525. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30526. */
  30527. mode: number;
  30528. /**
  30529. * Define whether the camera is intermediate.
  30530. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30531. */
  30532. isIntermediate: boolean;
  30533. /**
  30534. * Define the viewport of the camera.
  30535. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30536. */
  30537. viewport: Viewport;
  30538. /**
  30539. * Restricts the camera to viewing objects with the same layerMask.
  30540. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30541. */
  30542. layerMask: number;
  30543. /**
  30544. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30545. */
  30546. fovMode: number;
  30547. /**
  30548. * Rig mode of the camera.
  30549. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30550. * This is normally controlled byt the camera themselves as internal use.
  30551. */
  30552. cameraRigMode: number;
  30553. /**
  30554. * Defines the distance between both "eyes" in case of a RIG
  30555. */
  30556. interaxialDistance: number;
  30557. /**
  30558. * Defines if stereoscopic rendering is done side by side or over under.
  30559. */
  30560. isStereoscopicSideBySide: boolean;
  30561. /**
  30562. * 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
  30563. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30564. * else in the scene. (Eg. security camera)
  30565. *
  30566. * 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)
  30567. */
  30568. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30569. /**
  30570. * When set, the camera will render to this render target instead of the default canvas
  30571. *
  30572. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30573. */
  30574. outputRenderTarget: Nullable<RenderTargetTexture>;
  30575. /**
  30576. * Observable triggered when the camera view matrix has changed.
  30577. */
  30578. onViewMatrixChangedObservable: Observable<Camera>;
  30579. /**
  30580. * Observable triggered when the camera Projection matrix has changed.
  30581. */
  30582. onProjectionMatrixChangedObservable: Observable<Camera>;
  30583. /**
  30584. * Observable triggered when the inputs have been processed.
  30585. */
  30586. onAfterCheckInputsObservable: Observable<Camera>;
  30587. /**
  30588. * Observable triggered when reset has been called and applied to the camera.
  30589. */
  30590. onRestoreStateObservable: Observable<Camera>;
  30591. /**
  30592. * Is this camera a part of a rig system?
  30593. */
  30594. isRigCamera: boolean;
  30595. /**
  30596. * If isRigCamera set to true this will be set with the parent camera.
  30597. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30598. */
  30599. rigParent?: Camera;
  30600. /** @hidden */
  30601. _cameraRigParams: any;
  30602. /** @hidden */
  30603. _rigCameras: Camera[];
  30604. /** @hidden */
  30605. _rigPostProcess: Nullable<PostProcess>;
  30606. protected _webvrViewMatrix: Matrix;
  30607. /** @hidden */
  30608. _skipRendering: boolean;
  30609. /** @hidden */
  30610. _projectionMatrix: Matrix;
  30611. /** @hidden */
  30612. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30613. /** @hidden */
  30614. _activeMeshes: SmartArray<AbstractMesh>;
  30615. protected _globalPosition: Vector3;
  30616. /** @hidden */
  30617. _computedViewMatrix: Matrix;
  30618. private _doNotComputeProjectionMatrix;
  30619. private _transformMatrix;
  30620. private _frustumPlanes;
  30621. private _refreshFrustumPlanes;
  30622. private _storedFov;
  30623. private _stateStored;
  30624. /**
  30625. * Instantiates a new camera object.
  30626. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30627. * @see https://doc.babylonjs.com/features/cameras
  30628. * @param name Defines the name of the camera in the scene
  30629. * @param position Defines the position of the camera
  30630. * @param scene Defines the scene the camera belongs too
  30631. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30632. */
  30633. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30634. /**
  30635. * Store current camera state (fov, position, etc..)
  30636. * @returns the camera
  30637. */
  30638. storeState(): Camera;
  30639. /**
  30640. * Restores the camera state values if it has been stored. You must call storeState() first
  30641. */
  30642. protected _restoreStateValues(): boolean;
  30643. /**
  30644. * Restored camera state. You must call storeState() first.
  30645. * @returns true if restored and false otherwise
  30646. */
  30647. restoreState(): boolean;
  30648. /**
  30649. * Gets the class name of the camera.
  30650. * @returns the class name
  30651. */
  30652. getClassName(): string;
  30653. /** @hidden */
  30654. readonly _isCamera: boolean;
  30655. /**
  30656. * Gets a string representation of the camera useful for debug purpose.
  30657. * @param fullDetails Defines that a more verboe level of logging is required
  30658. * @returns the string representation
  30659. */
  30660. toString(fullDetails?: boolean): string;
  30661. /**
  30662. * Gets the current world space position of the camera.
  30663. */
  30664. get globalPosition(): Vector3;
  30665. /**
  30666. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30667. * @returns the active meshe list
  30668. */
  30669. getActiveMeshes(): SmartArray<AbstractMesh>;
  30670. /**
  30671. * Check whether a mesh is part of the current active mesh list of the camera
  30672. * @param mesh Defines the mesh to check
  30673. * @returns true if active, false otherwise
  30674. */
  30675. isActiveMesh(mesh: Mesh): boolean;
  30676. /**
  30677. * Is this camera ready to be used/rendered
  30678. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30679. * @return true if the camera is ready
  30680. */
  30681. isReady(completeCheck?: boolean): boolean;
  30682. /** @hidden */
  30683. _initCache(): void;
  30684. /** @hidden */
  30685. _updateCache(ignoreParentClass?: boolean): void;
  30686. /** @hidden */
  30687. _isSynchronized(): boolean;
  30688. /** @hidden */
  30689. _isSynchronizedViewMatrix(): boolean;
  30690. /** @hidden */
  30691. _isSynchronizedProjectionMatrix(): boolean;
  30692. /**
  30693. * Attach the input controls to a specific dom element to get the input from.
  30694. * @param element Defines the element the controls should be listened from
  30695. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30696. */
  30697. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30698. /**
  30699. * Detach the current controls from the specified dom element.
  30700. * @param element Defines the element to stop listening the inputs from
  30701. */
  30702. detachControl(element: HTMLElement): void;
  30703. /**
  30704. * Update the camera state according to the different inputs gathered during the frame.
  30705. */
  30706. update(): void;
  30707. /** @hidden */
  30708. _checkInputs(): void;
  30709. /** @hidden */
  30710. get rigCameras(): Camera[];
  30711. /**
  30712. * Gets the post process used by the rig cameras
  30713. */
  30714. get rigPostProcess(): Nullable<PostProcess>;
  30715. /**
  30716. * Internal, gets the first post proces.
  30717. * @returns the first post process to be run on this camera.
  30718. */
  30719. _getFirstPostProcess(): Nullable<PostProcess>;
  30720. private _cascadePostProcessesToRigCams;
  30721. /**
  30722. * Attach a post process to the camera.
  30723. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30724. * @param postProcess The post process to attach to the camera
  30725. * @param insertAt The position of the post process in case several of them are in use in the scene
  30726. * @returns the position the post process has been inserted at
  30727. */
  30728. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30729. /**
  30730. * Detach a post process to the camera.
  30731. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30732. * @param postProcess The post process to detach from the camera
  30733. */
  30734. detachPostProcess(postProcess: PostProcess): void;
  30735. /**
  30736. * Gets the current world matrix of the camera
  30737. */
  30738. getWorldMatrix(): Matrix;
  30739. /** @hidden */
  30740. _getViewMatrix(): Matrix;
  30741. /**
  30742. * Gets the current view matrix of the camera.
  30743. * @param force forces the camera to recompute the matrix without looking at the cached state
  30744. * @returns the view matrix
  30745. */
  30746. getViewMatrix(force?: boolean): Matrix;
  30747. /**
  30748. * Freeze the projection matrix.
  30749. * It will prevent the cache check of the camera projection compute and can speed up perf
  30750. * if no parameter of the camera are meant to change
  30751. * @param projection Defines manually a projection if necessary
  30752. */
  30753. freezeProjectionMatrix(projection?: Matrix): void;
  30754. /**
  30755. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30756. */
  30757. unfreezeProjectionMatrix(): void;
  30758. /**
  30759. * Gets the current projection matrix of the camera.
  30760. * @param force forces the camera to recompute the matrix without looking at the cached state
  30761. * @returns the projection matrix
  30762. */
  30763. getProjectionMatrix(force?: boolean): Matrix;
  30764. /**
  30765. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30766. * @returns a Matrix
  30767. */
  30768. getTransformationMatrix(): Matrix;
  30769. private _updateFrustumPlanes;
  30770. /**
  30771. * Checks if a cullable object (mesh...) is in the camera frustum
  30772. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30773. * @param target The object to check
  30774. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30775. * @returns true if the object is in frustum otherwise false
  30776. */
  30777. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30778. /**
  30779. * Checks if a cullable object (mesh...) is in the camera frustum
  30780. * Unlike isInFrustum this cheks the full bounding box
  30781. * @param target The object to check
  30782. * @returns true if the object is in frustum otherwise false
  30783. */
  30784. isCompletelyInFrustum(target: ICullable): boolean;
  30785. /**
  30786. * Gets a ray in the forward direction from the camera.
  30787. * @param length Defines the length of the ray to create
  30788. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30789. * @param origin Defines the start point of the ray which defaults to the camera position
  30790. * @returns the forward ray
  30791. */
  30792. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30793. /**
  30794. * Gets a ray in the forward direction from the camera.
  30795. * @param refRay the ray to (re)use when setting the values
  30796. * @param length Defines the length of the ray to create
  30797. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30798. * @param origin Defines the start point of the ray which defaults to the camera position
  30799. * @returns the forward ray
  30800. */
  30801. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30802. /**
  30803. * Releases resources associated with this node.
  30804. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30805. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30806. */
  30807. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30808. /** @hidden */
  30809. _isLeftCamera: boolean;
  30810. /**
  30811. * Gets the left camera of a rig setup in case of Rigged Camera
  30812. */
  30813. get isLeftCamera(): boolean;
  30814. /** @hidden */
  30815. _isRightCamera: boolean;
  30816. /**
  30817. * Gets the right camera of a rig setup in case of Rigged Camera
  30818. */
  30819. get isRightCamera(): boolean;
  30820. /**
  30821. * Gets the left camera of a rig setup in case of Rigged Camera
  30822. */
  30823. get leftCamera(): Nullable<FreeCamera>;
  30824. /**
  30825. * Gets the right camera of a rig setup in case of Rigged Camera
  30826. */
  30827. get rightCamera(): Nullable<FreeCamera>;
  30828. /**
  30829. * Gets the left camera target of a rig setup in case of Rigged Camera
  30830. * @returns the target position
  30831. */
  30832. getLeftTarget(): Nullable<Vector3>;
  30833. /**
  30834. * Gets the right camera target of a rig setup in case of Rigged Camera
  30835. * @returns the target position
  30836. */
  30837. getRightTarget(): Nullable<Vector3>;
  30838. /**
  30839. * @hidden
  30840. */
  30841. setCameraRigMode(mode: number, rigParams: any): void;
  30842. /** @hidden */
  30843. static _setStereoscopicRigMode(camera: Camera): void;
  30844. /** @hidden */
  30845. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30846. /** @hidden */
  30847. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30848. /** @hidden */
  30849. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30850. /** @hidden */
  30851. _getVRProjectionMatrix(): Matrix;
  30852. protected _updateCameraRotationMatrix(): void;
  30853. protected _updateWebVRCameraRotationMatrix(): void;
  30854. /**
  30855. * This function MUST be overwritten by the different WebVR cameras available.
  30856. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30857. * @hidden
  30858. */
  30859. _getWebVRProjectionMatrix(): Matrix;
  30860. /**
  30861. * This function MUST be overwritten by the different WebVR cameras available.
  30862. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30863. * @hidden
  30864. */
  30865. _getWebVRViewMatrix(): Matrix;
  30866. /** @hidden */
  30867. setCameraRigParameter(name: string, value: any): void;
  30868. /**
  30869. * needs to be overridden by children so sub has required properties to be copied
  30870. * @hidden
  30871. */
  30872. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30873. /**
  30874. * May need to be overridden by children
  30875. * @hidden
  30876. */
  30877. _updateRigCameras(): void;
  30878. /** @hidden */
  30879. _setupInputs(): void;
  30880. /**
  30881. * Serialiaze the camera setup to a json represention
  30882. * @returns the JSON representation
  30883. */
  30884. serialize(): any;
  30885. /**
  30886. * Clones the current camera.
  30887. * @param name The cloned camera name
  30888. * @returns the cloned camera
  30889. */
  30890. clone(name: string): Camera;
  30891. /**
  30892. * Gets the direction of the camera relative to a given local axis.
  30893. * @param localAxis Defines the reference axis to provide a relative direction.
  30894. * @return the direction
  30895. */
  30896. getDirection(localAxis: Vector3): Vector3;
  30897. /**
  30898. * Returns the current camera absolute rotation
  30899. */
  30900. get absoluteRotation(): Quaternion;
  30901. /**
  30902. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30903. * @param localAxis Defines the reference axis to provide a relative direction.
  30904. * @param result Defines the vector to store the result in
  30905. */
  30906. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30907. /**
  30908. * Gets a camera constructor for a given camera type
  30909. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30910. * @param name The name of the camera the result will be able to instantiate
  30911. * @param scene The scene the result will construct the camera in
  30912. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30913. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30914. * @returns a factory method to construc the camera
  30915. */
  30916. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30917. /**
  30918. * Compute the world matrix of the camera.
  30919. * @returns the camera world matrix
  30920. */
  30921. computeWorldMatrix(): Matrix;
  30922. /**
  30923. * Parse a JSON and creates the camera from the parsed information
  30924. * @param parsedCamera The JSON to parse
  30925. * @param scene The scene to instantiate the camera in
  30926. * @returns the newly constructed camera
  30927. */
  30928. static Parse(parsedCamera: any, scene: Scene): Camera;
  30929. }
  30930. }
  30931. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30932. import { Nullable } from "babylonjs/types";
  30933. import { Scene } from "babylonjs/scene";
  30934. import { Vector4 } from "babylonjs/Maths/math.vector";
  30935. import { Mesh } from "babylonjs/Meshes/mesh";
  30936. /**
  30937. * Class containing static functions to help procedurally build meshes
  30938. */
  30939. export class DiscBuilder {
  30940. /**
  30941. * Creates a plane polygonal mesh. By default, this is a disc
  30942. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30943. * * 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
  30944. * * 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
  30945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30948. * @param name defines the name of the mesh
  30949. * @param options defines the options used to create the mesh
  30950. * @param scene defines the hosting scene
  30951. * @returns the plane polygonal mesh
  30952. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30953. */
  30954. static CreateDisc(name: string, options: {
  30955. radius?: number;
  30956. tessellation?: number;
  30957. arc?: number;
  30958. updatable?: boolean;
  30959. sideOrientation?: number;
  30960. frontUVs?: Vector4;
  30961. backUVs?: Vector4;
  30962. }, scene?: Nullable<Scene>): Mesh;
  30963. }
  30964. }
  30965. declare module "babylonjs/Materials/fresnelParameters" {
  30966. import { DeepImmutable } from "babylonjs/types";
  30967. import { Color3 } from "babylonjs/Maths/math.color";
  30968. /**
  30969. * Options to be used when creating a FresnelParameters.
  30970. */
  30971. export type IFresnelParametersCreationOptions = {
  30972. /**
  30973. * Define the color used on edges (grazing angle)
  30974. */
  30975. leftColor?: Color3;
  30976. /**
  30977. * Define the color used on center
  30978. */
  30979. rightColor?: Color3;
  30980. /**
  30981. * Define bias applied to computed fresnel term
  30982. */
  30983. bias?: number;
  30984. /**
  30985. * Defined the power exponent applied to fresnel term
  30986. */
  30987. power?: number;
  30988. /**
  30989. * Define if the fresnel effect is enable or not.
  30990. */
  30991. isEnabled?: boolean;
  30992. };
  30993. /**
  30994. * Serialized format for FresnelParameters.
  30995. */
  30996. export type IFresnelParametersSerialized = {
  30997. /**
  30998. * Define the color used on edges (grazing angle) [as an array]
  30999. */
  31000. leftColor: number[];
  31001. /**
  31002. * Define the color used on center [as an array]
  31003. */
  31004. rightColor: number[];
  31005. /**
  31006. * Define bias applied to computed fresnel term
  31007. */
  31008. bias: number;
  31009. /**
  31010. * Defined the power exponent applied to fresnel term
  31011. */
  31012. power?: number;
  31013. /**
  31014. * Define if the fresnel effect is enable or not.
  31015. */
  31016. isEnabled: boolean;
  31017. };
  31018. /**
  31019. * This represents all the required information to add a fresnel effect on a material:
  31020. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31021. */
  31022. export class FresnelParameters {
  31023. private _isEnabled;
  31024. /**
  31025. * Define if the fresnel effect is enable or not.
  31026. */
  31027. get isEnabled(): boolean;
  31028. set isEnabled(value: boolean);
  31029. /**
  31030. * Define the color used on edges (grazing angle)
  31031. */
  31032. leftColor: Color3;
  31033. /**
  31034. * Define the color used on center
  31035. */
  31036. rightColor: Color3;
  31037. /**
  31038. * Define bias applied to computed fresnel term
  31039. */
  31040. bias: number;
  31041. /**
  31042. * Defined the power exponent applied to fresnel term
  31043. */
  31044. power: number;
  31045. /**
  31046. * Creates a new FresnelParameters object.
  31047. *
  31048. * @param options provide your own settings to optionally to override defaults
  31049. */
  31050. constructor(options?: IFresnelParametersCreationOptions);
  31051. /**
  31052. * Clones the current fresnel and its valuues
  31053. * @returns a clone fresnel configuration
  31054. */
  31055. clone(): FresnelParameters;
  31056. /**
  31057. * Determines equality between FresnelParameters objects
  31058. * @param otherFresnelParameters defines the second operand
  31059. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  31060. */
  31061. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  31062. /**
  31063. * Serializes the current fresnel parameters to a JSON representation.
  31064. * @return the JSON serialization
  31065. */
  31066. serialize(): IFresnelParametersSerialized;
  31067. /**
  31068. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31069. * @param parsedFresnelParameters Define the JSON representation
  31070. * @returns the parsed parameters
  31071. */
  31072. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  31073. }
  31074. }
  31075. declare module "babylonjs/Materials/materialFlags" {
  31076. /**
  31077. * This groups all the flags used to control the materials channel.
  31078. */
  31079. export class MaterialFlags {
  31080. private static _DiffuseTextureEnabled;
  31081. /**
  31082. * Are diffuse textures enabled in the application.
  31083. */
  31084. static get DiffuseTextureEnabled(): boolean;
  31085. static set DiffuseTextureEnabled(value: boolean);
  31086. private static _DetailTextureEnabled;
  31087. /**
  31088. * Are detail textures enabled in the application.
  31089. */
  31090. static get DetailTextureEnabled(): boolean;
  31091. static set DetailTextureEnabled(value: boolean);
  31092. private static _AmbientTextureEnabled;
  31093. /**
  31094. * Are ambient textures enabled in the application.
  31095. */
  31096. static get AmbientTextureEnabled(): boolean;
  31097. static set AmbientTextureEnabled(value: boolean);
  31098. private static _OpacityTextureEnabled;
  31099. /**
  31100. * Are opacity textures enabled in the application.
  31101. */
  31102. static get OpacityTextureEnabled(): boolean;
  31103. static set OpacityTextureEnabled(value: boolean);
  31104. private static _ReflectionTextureEnabled;
  31105. /**
  31106. * Are reflection textures enabled in the application.
  31107. */
  31108. static get ReflectionTextureEnabled(): boolean;
  31109. static set ReflectionTextureEnabled(value: boolean);
  31110. private static _EmissiveTextureEnabled;
  31111. /**
  31112. * Are emissive textures enabled in the application.
  31113. */
  31114. static get EmissiveTextureEnabled(): boolean;
  31115. static set EmissiveTextureEnabled(value: boolean);
  31116. private static _SpecularTextureEnabled;
  31117. /**
  31118. * Are specular textures enabled in the application.
  31119. */
  31120. static get SpecularTextureEnabled(): boolean;
  31121. static set SpecularTextureEnabled(value: boolean);
  31122. private static _BumpTextureEnabled;
  31123. /**
  31124. * Are bump textures enabled in the application.
  31125. */
  31126. static get BumpTextureEnabled(): boolean;
  31127. static set BumpTextureEnabled(value: boolean);
  31128. private static _LightmapTextureEnabled;
  31129. /**
  31130. * Are lightmap textures enabled in the application.
  31131. */
  31132. static get LightmapTextureEnabled(): boolean;
  31133. static set LightmapTextureEnabled(value: boolean);
  31134. private static _RefractionTextureEnabled;
  31135. /**
  31136. * Are refraction textures enabled in the application.
  31137. */
  31138. static get RefractionTextureEnabled(): boolean;
  31139. static set RefractionTextureEnabled(value: boolean);
  31140. private static _ColorGradingTextureEnabled;
  31141. /**
  31142. * Are color grading textures enabled in the application.
  31143. */
  31144. static get ColorGradingTextureEnabled(): boolean;
  31145. static set ColorGradingTextureEnabled(value: boolean);
  31146. private static _FresnelEnabled;
  31147. /**
  31148. * Are fresnels enabled in the application.
  31149. */
  31150. static get FresnelEnabled(): boolean;
  31151. static set FresnelEnabled(value: boolean);
  31152. private static _ClearCoatTextureEnabled;
  31153. /**
  31154. * Are clear coat textures enabled in the application.
  31155. */
  31156. static get ClearCoatTextureEnabled(): boolean;
  31157. static set ClearCoatTextureEnabled(value: boolean);
  31158. private static _ClearCoatBumpTextureEnabled;
  31159. /**
  31160. * Are clear coat bump textures enabled in the application.
  31161. */
  31162. static get ClearCoatBumpTextureEnabled(): boolean;
  31163. static set ClearCoatBumpTextureEnabled(value: boolean);
  31164. private static _ClearCoatTintTextureEnabled;
  31165. /**
  31166. * Are clear coat tint textures enabled in the application.
  31167. */
  31168. static get ClearCoatTintTextureEnabled(): boolean;
  31169. static set ClearCoatTintTextureEnabled(value: boolean);
  31170. private static _SheenTextureEnabled;
  31171. /**
  31172. * Are sheen textures enabled in the application.
  31173. */
  31174. static get SheenTextureEnabled(): boolean;
  31175. static set SheenTextureEnabled(value: boolean);
  31176. private static _AnisotropicTextureEnabled;
  31177. /**
  31178. * Are anisotropic textures enabled in the application.
  31179. */
  31180. static get AnisotropicTextureEnabled(): boolean;
  31181. static set AnisotropicTextureEnabled(value: boolean);
  31182. private static _ThicknessTextureEnabled;
  31183. /**
  31184. * Are thickness textures enabled in the application.
  31185. */
  31186. static get ThicknessTextureEnabled(): boolean;
  31187. static set ThicknessTextureEnabled(value: boolean);
  31188. }
  31189. }
  31190. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31191. /** @hidden */
  31192. export var defaultFragmentDeclaration: {
  31193. name: string;
  31194. shader: string;
  31195. };
  31196. }
  31197. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31198. /** @hidden */
  31199. export var defaultUboDeclaration: {
  31200. name: string;
  31201. shader: string;
  31202. };
  31203. }
  31204. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31205. /** @hidden */
  31206. export var prePassDeclaration: {
  31207. name: string;
  31208. shader: string;
  31209. };
  31210. }
  31211. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31212. /** @hidden */
  31213. export var lightFragmentDeclaration: {
  31214. name: string;
  31215. shader: string;
  31216. };
  31217. }
  31218. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31219. /** @hidden */
  31220. export var lightUboDeclaration: {
  31221. name: string;
  31222. shader: string;
  31223. };
  31224. }
  31225. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31226. /** @hidden */
  31227. export var lightsFragmentFunctions: {
  31228. name: string;
  31229. shader: string;
  31230. };
  31231. }
  31232. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31233. /** @hidden */
  31234. export var shadowsFragmentFunctions: {
  31235. name: string;
  31236. shader: string;
  31237. };
  31238. }
  31239. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31240. /** @hidden */
  31241. export var fresnelFunction: {
  31242. name: string;
  31243. shader: string;
  31244. };
  31245. }
  31246. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31247. /** @hidden */
  31248. export var bumpFragmentMainFunctions: {
  31249. name: string;
  31250. shader: string;
  31251. };
  31252. }
  31253. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31254. /** @hidden */
  31255. export var bumpFragmentFunctions: {
  31256. name: string;
  31257. shader: string;
  31258. };
  31259. }
  31260. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31261. /** @hidden */
  31262. export var logDepthDeclaration: {
  31263. name: string;
  31264. shader: string;
  31265. };
  31266. }
  31267. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31268. /** @hidden */
  31269. export var bumpFragment: {
  31270. name: string;
  31271. shader: string;
  31272. };
  31273. }
  31274. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31275. /** @hidden */
  31276. export var depthPrePass: {
  31277. name: string;
  31278. shader: string;
  31279. };
  31280. }
  31281. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31282. /** @hidden */
  31283. export var lightFragment: {
  31284. name: string;
  31285. shader: string;
  31286. };
  31287. }
  31288. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31289. /** @hidden */
  31290. export var logDepthFragment: {
  31291. name: string;
  31292. shader: string;
  31293. };
  31294. }
  31295. declare module "babylonjs/Shaders/default.fragment" {
  31296. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31297. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31298. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31299. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31300. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31301. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31302. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31303. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31304. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31305. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31306. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31307. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31308. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31309. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31310. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31311. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31312. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31313. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31314. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31315. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31316. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31317. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31318. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31319. /** @hidden */
  31320. export var defaultPixelShader: {
  31321. name: string;
  31322. shader: string;
  31323. };
  31324. }
  31325. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31326. /** @hidden */
  31327. export var defaultVertexDeclaration: {
  31328. name: string;
  31329. shader: string;
  31330. };
  31331. }
  31332. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31333. /** @hidden */
  31334. export var bumpVertexDeclaration: {
  31335. name: string;
  31336. shader: string;
  31337. };
  31338. }
  31339. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31340. /** @hidden */
  31341. export var bumpVertex: {
  31342. name: string;
  31343. shader: string;
  31344. };
  31345. }
  31346. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31347. /** @hidden */
  31348. export var fogVertex: {
  31349. name: string;
  31350. shader: string;
  31351. };
  31352. }
  31353. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31354. /** @hidden */
  31355. export var shadowsVertex: {
  31356. name: string;
  31357. shader: string;
  31358. };
  31359. }
  31360. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31361. /** @hidden */
  31362. export var pointCloudVertex: {
  31363. name: string;
  31364. shader: string;
  31365. };
  31366. }
  31367. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31368. /** @hidden */
  31369. export var logDepthVertex: {
  31370. name: string;
  31371. shader: string;
  31372. };
  31373. }
  31374. declare module "babylonjs/Shaders/default.vertex" {
  31375. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31376. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31377. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31378. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31379. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31380. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31381. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31382. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31383. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31384. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31385. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31386. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31387. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31388. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31389. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31390. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31391. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31392. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31393. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31394. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31395. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31396. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31397. /** @hidden */
  31398. export var defaultVertexShader: {
  31399. name: string;
  31400. shader: string;
  31401. };
  31402. }
  31403. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31404. import { Nullable } from "babylonjs/types";
  31405. import { Scene } from "babylonjs/scene";
  31406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31407. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31408. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31409. /**
  31410. * @hidden
  31411. */
  31412. export interface IMaterialDetailMapDefines {
  31413. DETAIL: boolean;
  31414. DETAILDIRECTUV: number;
  31415. DETAIL_NORMALBLENDMETHOD: number;
  31416. /** @hidden */
  31417. _areTexturesDirty: boolean;
  31418. }
  31419. /**
  31420. * Define the code related to the detail map parameters of a material
  31421. *
  31422. * Inspired from:
  31423. * 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
  31424. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31425. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31426. */
  31427. export class DetailMapConfiguration {
  31428. private _texture;
  31429. /**
  31430. * The detail texture of the material.
  31431. */
  31432. texture: Nullable<BaseTexture>;
  31433. /**
  31434. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31435. * Bigger values mean stronger blending
  31436. */
  31437. diffuseBlendLevel: number;
  31438. /**
  31439. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31440. * Bigger values mean stronger blending. Only used with PBR materials
  31441. */
  31442. roughnessBlendLevel: number;
  31443. /**
  31444. * Defines how strong the bump effect from the detail map is
  31445. * Bigger values mean stronger effect
  31446. */
  31447. bumpLevel: number;
  31448. private _normalBlendMethod;
  31449. /**
  31450. * The method used to blend the bump and detail normals together
  31451. */
  31452. normalBlendMethod: number;
  31453. private _isEnabled;
  31454. /**
  31455. * Enable or disable the detail map on this material
  31456. */
  31457. isEnabled: boolean;
  31458. /** @hidden */
  31459. private _internalMarkAllSubMeshesAsTexturesDirty;
  31460. /** @hidden */
  31461. _markAllSubMeshesAsTexturesDirty(): void;
  31462. /**
  31463. * Instantiate a new detail map
  31464. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31465. */
  31466. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31467. /**
  31468. * Gets whether the submesh is ready to be used or not.
  31469. * @param defines the list of "defines" to update.
  31470. * @param scene defines the scene the material belongs to.
  31471. * @returns - boolean indicating that the submesh is ready or not.
  31472. */
  31473. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31474. /**
  31475. * Update the defines for detail map usage
  31476. * @param defines the list of "defines" to update.
  31477. * @param scene defines the scene the material belongs to.
  31478. */
  31479. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31480. /**
  31481. * Binds the material data.
  31482. * @param uniformBuffer defines the Uniform buffer to fill in.
  31483. * @param scene defines the scene the material belongs to.
  31484. * @param isFrozen defines whether the material is frozen or not.
  31485. */
  31486. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31487. /**
  31488. * Checks to see if a texture is used in the material.
  31489. * @param texture - Base texture to use.
  31490. * @returns - Boolean specifying if a texture is used in the material.
  31491. */
  31492. hasTexture(texture: BaseTexture): boolean;
  31493. /**
  31494. * Returns an array of the actively used textures.
  31495. * @param activeTextures Array of BaseTextures
  31496. */
  31497. getActiveTextures(activeTextures: BaseTexture[]): void;
  31498. /**
  31499. * Returns the animatable textures.
  31500. * @param animatables Array of animatable textures.
  31501. */
  31502. getAnimatables(animatables: IAnimatable[]): void;
  31503. /**
  31504. * Disposes the resources of the material.
  31505. * @param forceDisposeTextures - Forces the disposal of all textures.
  31506. */
  31507. dispose(forceDisposeTextures?: boolean): void;
  31508. /**
  31509. * Get the current class name useful for serialization or dynamic coding.
  31510. * @returns "DetailMap"
  31511. */
  31512. getClassName(): string;
  31513. /**
  31514. * Add the required uniforms to the current list.
  31515. * @param uniforms defines the current uniform list.
  31516. */
  31517. static AddUniforms(uniforms: string[]): void;
  31518. /**
  31519. * Add the required samplers to the current list.
  31520. * @param samplers defines the current sampler list.
  31521. */
  31522. static AddSamplers(samplers: string[]): void;
  31523. /**
  31524. * Add the required uniforms to the current buffer.
  31525. * @param uniformBuffer defines the current uniform buffer.
  31526. */
  31527. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31528. /**
  31529. * Makes a duplicate of the current instance into another one.
  31530. * @param detailMap define the instance where to copy the info
  31531. */
  31532. copyTo(detailMap: DetailMapConfiguration): void;
  31533. /**
  31534. * Serializes this detail map instance
  31535. * @returns - An object with the serialized instance.
  31536. */
  31537. serialize(): any;
  31538. /**
  31539. * Parses a detail map setting from a serialized object.
  31540. * @param source - Serialized object.
  31541. * @param scene Defines the scene we are parsing for
  31542. * @param rootUrl Defines the rootUrl to load from
  31543. */
  31544. parse(source: any, scene: Scene, rootUrl: string): void;
  31545. }
  31546. }
  31547. declare module "babylonjs/Materials/standardMaterial" {
  31548. import { SmartArray } from "babylonjs/Misc/smartArray";
  31549. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31550. import { Nullable } from "babylonjs/types";
  31551. import { Scene } from "babylonjs/scene";
  31552. import { Matrix } from "babylonjs/Maths/math.vector";
  31553. import { Color3 } from "babylonjs/Maths/math.color";
  31554. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31556. import { Mesh } from "babylonjs/Meshes/mesh";
  31557. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31558. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31559. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31560. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31561. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31562. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31563. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31564. import "babylonjs/Shaders/default.fragment";
  31565. import "babylonjs/Shaders/default.vertex";
  31566. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31567. /** @hidden */
  31568. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31569. MAINUV1: boolean;
  31570. MAINUV2: boolean;
  31571. DIFFUSE: boolean;
  31572. DIFFUSEDIRECTUV: number;
  31573. DETAIL: boolean;
  31574. DETAILDIRECTUV: number;
  31575. DETAIL_NORMALBLENDMETHOD: number;
  31576. AMBIENT: boolean;
  31577. AMBIENTDIRECTUV: number;
  31578. OPACITY: boolean;
  31579. OPACITYDIRECTUV: number;
  31580. OPACITYRGB: boolean;
  31581. REFLECTION: boolean;
  31582. EMISSIVE: boolean;
  31583. EMISSIVEDIRECTUV: number;
  31584. SPECULAR: boolean;
  31585. SPECULARDIRECTUV: number;
  31586. BUMP: boolean;
  31587. BUMPDIRECTUV: number;
  31588. PARALLAX: boolean;
  31589. PARALLAXOCCLUSION: boolean;
  31590. SPECULAROVERALPHA: boolean;
  31591. CLIPPLANE: boolean;
  31592. CLIPPLANE2: boolean;
  31593. CLIPPLANE3: boolean;
  31594. CLIPPLANE4: boolean;
  31595. CLIPPLANE5: boolean;
  31596. CLIPPLANE6: boolean;
  31597. ALPHATEST: boolean;
  31598. DEPTHPREPASS: boolean;
  31599. ALPHAFROMDIFFUSE: boolean;
  31600. POINTSIZE: boolean;
  31601. FOG: boolean;
  31602. SPECULARTERM: boolean;
  31603. DIFFUSEFRESNEL: boolean;
  31604. OPACITYFRESNEL: boolean;
  31605. REFLECTIONFRESNEL: boolean;
  31606. REFRACTIONFRESNEL: boolean;
  31607. EMISSIVEFRESNEL: boolean;
  31608. FRESNEL: boolean;
  31609. NORMAL: boolean;
  31610. UV1: boolean;
  31611. UV2: boolean;
  31612. VERTEXCOLOR: boolean;
  31613. VERTEXALPHA: boolean;
  31614. NUM_BONE_INFLUENCERS: number;
  31615. BonesPerMesh: number;
  31616. BONETEXTURE: boolean;
  31617. INSTANCES: boolean;
  31618. THIN_INSTANCES: boolean;
  31619. GLOSSINESS: boolean;
  31620. ROUGHNESS: boolean;
  31621. EMISSIVEASILLUMINATION: boolean;
  31622. LINKEMISSIVEWITHDIFFUSE: boolean;
  31623. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31624. LIGHTMAP: boolean;
  31625. LIGHTMAPDIRECTUV: number;
  31626. OBJECTSPACE_NORMALMAP: boolean;
  31627. USELIGHTMAPASSHADOWMAP: boolean;
  31628. REFLECTIONMAP_3D: boolean;
  31629. REFLECTIONMAP_SPHERICAL: boolean;
  31630. REFLECTIONMAP_PLANAR: boolean;
  31631. REFLECTIONMAP_CUBIC: boolean;
  31632. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31633. REFLECTIONMAP_PROJECTION: boolean;
  31634. REFLECTIONMAP_SKYBOX: boolean;
  31635. REFLECTIONMAP_EXPLICIT: boolean;
  31636. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31637. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31638. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31639. INVERTCUBICMAP: boolean;
  31640. LOGARITHMICDEPTH: boolean;
  31641. REFRACTION: boolean;
  31642. REFRACTIONMAP_3D: boolean;
  31643. REFLECTIONOVERALPHA: boolean;
  31644. TWOSIDEDLIGHTING: boolean;
  31645. SHADOWFLOAT: boolean;
  31646. MORPHTARGETS: boolean;
  31647. MORPHTARGETS_NORMAL: boolean;
  31648. MORPHTARGETS_TANGENT: boolean;
  31649. MORPHTARGETS_UV: boolean;
  31650. NUM_MORPH_INFLUENCERS: number;
  31651. NONUNIFORMSCALING: boolean;
  31652. PREMULTIPLYALPHA: boolean;
  31653. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31654. ALPHABLEND: boolean;
  31655. PREPASS: boolean;
  31656. SCENE_MRT_COUNT: number;
  31657. RGBDLIGHTMAP: boolean;
  31658. RGBDREFLECTION: boolean;
  31659. RGBDREFRACTION: boolean;
  31660. IMAGEPROCESSING: boolean;
  31661. VIGNETTE: boolean;
  31662. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31663. VIGNETTEBLENDMODEOPAQUE: boolean;
  31664. TONEMAPPING: boolean;
  31665. TONEMAPPING_ACES: boolean;
  31666. CONTRAST: boolean;
  31667. COLORCURVES: boolean;
  31668. COLORGRADING: boolean;
  31669. COLORGRADING3D: boolean;
  31670. SAMPLER3DGREENDEPTH: boolean;
  31671. SAMPLER3DBGRMAP: boolean;
  31672. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31673. MULTIVIEW: boolean;
  31674. /**
  31675. * If the reflection texture on this material is in linear color space
  31676. * @hidden
  31677. */
  31678. IS_REFLECTION_LINEAR: boolean;
  31679. /**
  31680. * If the refraction texture on this material is in linear color space
  31681. * @hidden
  31682. */
  31683. IS_REFRACTION_LINEAR: boolean;
  31684. EXPOSURE: boolean;
  31685. constructor();
  31686. setReflectionMode(modeToEnable: string): void;
  31687. }
  31688. /**
  31689. * This is the default material used in Babylon. It is the best trade off between quality
  31690. * and performances.
  31691. * @see https://doc.babylonjs.com/babylon101/materials
  31692. */
  31693. export class StandardMaterial extends PushMaterial {
  31694. private _diffuseTexture;
  31695. /**
  31696. * The basic texture of the material as viewed under a light.
  31697. */
  31698. diffuseTexture: Nullable<BaseTexture>;
  31699. private _ambientTexture;
  31700. /**
  31701. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31702. */
  31703. ambientTexture: Nullable<BaseTexture>;
  31704. private _opacityTexture;
  31705. /**
  31706. * Define the transparency of the material from a texture.
  31707. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31708. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31709. */
  31710. opacityTexture: Nullable<BaseTexture>;
  31711. private _reflectionTexture;
  31712. /**
  31713. * Define the texture used to display the reflection.
  31714. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31715. */
  31716. reflectionTexture: Nullable<BaseTexture>;
  31717. private _emissiveTexture;
  31718. /**
  31719. * Define texture of the material as if self lit.
  31720. * This will be mixed in the final result even in the absence of light.
  31721. */
  31722. emissiveTexture: Nullable<BaseTexture>;
  31723. private _specularTexture;
  31724. /**
  31725. * Define how the color and intensity of the highlight given by the light in the material.
  31726. */
  31727. specularTexture: Nullable<BaseTexture>;
  31728. private _bumpTexture;
  31729. /**
  31730. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31731. * 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.
  31732. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31733. */
  31734. bumpTexture: Nullable<BaseTexture>;
  31735. private _lightmapTexture;
  31736. /**
  31737. * Complex lighting can be computationally expensive to compute at runtime.
  31738. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31739. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31740. */
  31741. lightmapTexture: Nullable<BaseTexture>;
  31742. private _refractionTexture;
  31743. /**
  31744. * Define the texture used to display the refraction.
  31745. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31746. */
  31747. refractionTexture: Nullable<BaseTexture>;
  31748. /**
  31749. * The color of the material lit by the environmental background lighting.
  31750. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31751. */
  31752. ambientColor: Color3;
  31753. /**
  31754. * The basic color of the material as viewed under a light.
  31755. */
  31756. diffuseColor: Color3;
  31757. /**
  31758. * Define how the color and intensity of the highlight given by the light in the material.
  31759. */
  31760. specularColor: Color3;
  31761. /**
  31762. * Define the color of the material as if self lit.
  31763. * This will be mixed in the final result even in the absence of light.
  31764. */
  31765. emissiveColor: Color3;
  31766. /**
  31767. * Defines how sharp are the highlights in the material.
  31768. * The bigger the value the sharper giving a more glossy feeling to the result.
  31769. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31770. */
  31771. specularPower: number;
  31772. private _useAlphaFromDiffuseTexture;
  31773. /**
  31774. * Does the transparency come from the diffuse texture alpha channel.
  31775. */
  31776. useAlphaFromDiffuseTexture: boolean;
  31777. private _useEmissiveAsIllumination;
  31778. /**
  31779. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31780. */
  31781. useEmissiveAsIllumination: boolean;
  31782. private _linkEmissiveWithDiffuse;
  31783. /**
  31784. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31785. * the emissive level when the final color is close to one.
  31786. */
  31787. linkEmissiveWithDiffuse: boolean;
  31788. private _useSpecularOverAlpha;
  31789. /**
  31790. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31791. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31792. */
  31793. useSpecularOverAlpha: boolean;
  31794. private _useReflectionOverAlpha;
  31795. /**
  31796. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31797. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31798. */
  31799. useReflectionOverAlpha: boolean;
  31800. private _disableLighting;
  31801. /**
  31802. * Does lights from the scene impacts this material.
  31803. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31804. */
  31805. disableLighting: boolean;
  31806. private _useObjectSpaceNormalMap;
  31807. /**
  31808. * Allows using an object space normal map (instead of tangent space).
  31809. */
  31810. useObjectSpaceNormalMap: boolean;
  31811. private _useParallax;
  31812. /**
  31813. * Is parallax enabled or not.
  31814. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31815. */
  31816. useParallax: boolean;
  31817. private _useParallaxOcclusion;
  31818. /**
  31819. * Is parallax occlusion enabled or not.
  31820. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31821. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31822. */
  31823. useParallaxOcclusion: boolean;
  31824. /**
  31825. * 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.
  31826. */
  31827. parallaxScaleBias: number;
  31828. private _roughness;
  31829. /**
  31830. * Helps to define how blurry the reflections should appears in the material.
  31831. */
  31832. roughness: number;
  31833. /**
  31834. * In case of refraction, define the value of the index of refraction.
  31835. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31836. */
  31837. indexOfRefraction: number;
  31838. /**
  31839. * Invert the refraction texture alongside the y axis.
  31840. * It can be useful with procedural textures or probe for instance.
  31841. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31842. */
  31843. invertRefractionY: boolean;
  31844. /**
  31845. * Defines the alpha limits in alpha test mode.
  31846. */
  31847. alphaCutOff: number;
  31848. private _useLightmapAsShadowmap;
  31849. /**
  31850. * In case of light mapping, define whether the map contains light or shadow informations.
  31851. */
  31852. useLightmapAsShadowmap: boolean;
  31853. private _diffuseFresnelParameters;
  31854. /**
  31855. * Define the diffuse fresnel parameters of the material.
  31856. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31857. */
  31858. diffuseFresnelParameters: FresnelParameters;
  31859. private _opacityFresnelParameters;
  31860. /**
  31861. * Define the opacity fresnel parameters of the material.
  31862. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31863. */
  31864. opacityFresnelParameters: FresnelParameters;
  31865. private _reflectionFresnelParameters;
  31866. /**
  31867. * Define the reflection fresnel parameters of the material.
  31868. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31869. */
  31870. reflectionFresnelParameters: FresnelParameters;
  31871. private _refractionFresnelParameters;
  31872. /**
  31873. * Define the refraction fresnel parameters of the material.
  31874. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31875. */
  31876. refractionFresnelParameters: FresnelParameters;
  31877. private _emissiveFresnelParameters;
  31878. /**
  31879. * Define the emissive fresnel parameters of the material.
  31880. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31881. */
  31882. emissiveFresnelParameters: FresnelParameters;
  31883. private _useReflectionFresnelFromSpecular;
  31884. /**
  31885. * If true automatically deducts the fresnels values from the material specularity.
  31886. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31887. */
  31888. useReflectionFresnelFromSpecular: boolean;
  31889. private _useGlossinessFromSpecularMapAlpha;
  31890. /**
  31891. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31892. */
  31893. useGlossinessFromSpecularMapAlpha: boolean;
  31894. private _maxSimultaneousLights;
  31895. /**
  31896. * Defines the maximum number of lights that can be used in the material
  31897. */
  31898. maxSimultaneousLights: number;
  31899. private _invertNormalMapX;
  31900. /**
  31901. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31902. */
  31903. invertNormalMapX: boolean;
  31904. private _invertNormalMapY;
  31905. /**
  31906. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31907. */
  31908. invertNormalMapY: boolean;
  31909. private _twoSidedLighting;
  31910. /**
  31911. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31912. */
  31913. twoSidedLighting: boolean;
  31914. /**
  31915. * Default configuration related to image processing available in the standard Material.
  31916. */
  31917. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31918. /**
  31919. * Gets the image processing configuration used either in this material.
  31920. */
  31921. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31922. /**
  31923. * Sets the Default image processing configuration used either in the this material.
  31924. *
  31925. * If sets to null, the scene one is in use.
  31926. */
  31927. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31928. /**
  31929. * Keep track of the image processing observer to allow dispose and replace.
  31930. */
  31931. private _imageProcessingObserver;
  31932. /**
  31933. * Attaches a new image processing configuration to the Standard Material.
  31934. * @param configuration
  31935. */
  31936. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31937. /**
  31938. * Gets wether the color curves effect is enabled.
  31939. */
  31940. get cameraColorCurvesEnabled(): boolean;
  31941. /**
  31942. * Sets wether the color curves effect is enabled.
  31943. */
  31944. set cameraColorCurvesEnabled(value: boolean);
  31945. /**
  31946. * Gets wether the color grading effect is enabled.
  31947. */
  31948. get cameraColorGradingEnabled(): boolean;
  31949. /**
  31950. * Gets wether the color grading effect is enabled.
  31951. */
  31952. set cameraColorGradingEnabled(value: boolean);
  31953. /**
  31954. * Gets wether tonemapping is enabled or not.
  31955. */
  31956. get cameraToneMappingEnabled(): boolean;
  31957. /**
  31958. * Sets wether tonemapping is enabled or not
  31959. */
  31960. set cameraToneMappingEnabled(value: boolean);
  31961. /**
  31962. * The camera exposure used on this material.
  31963. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31964. * This corresponds to a photographic exposure.
  31965. */
  31966. get cameraExposure(): number;
  31967. /**
  31968. * The camera exposure used on this material.
  31969. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31970. * This corresponds to a photographic exposure.
  31971. */
  31972. set cameraExposure(value: number);
  31973. /**
  31974. * Gets The camera contrast used on this material.
  31975. */
  31976. get cameraContrast(): number;
  31977. /**
  31978. * Sets The camera contrast used on this material.
  31979. */
  31980. set cameraContrast(value: number);
  31981. /**
  31982. * Gets the Color Grading 2D Lookup Texture.
  31983. */
  31984. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  31985. /**
  31986. * Sets the Color Grading 2D Lookup Texture.
  31987. */
  31988. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  31989. /**
  31990. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31991. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31992. * 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;
  31993. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31994. */
  31995. get cameraColorCurves(): Nullable<ColorCurves>;
  31996. /**
  31997. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31998. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31999. * 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;
  32000. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32001. */
  32002. set cameraColorCurves(value: Nullable<ColorCurves>);
  32003. /**
  32004. * Can this material render to several textures at once
  32005. */
  32006. get canRenderToMRT(): boolean;
  32007. /**
  32008. * Defines the detail map parameters for the material.
  32009. */
  32010. readonly detailMap: DetailMapConfiguration;
  32011. protected _renderTargets: SmartArray<RenderTargetTexture>;
  32012. protected _worldViewProjectionMatrix: Matrix;
  32013. protected _globalAmbientColor: Color3;
  32014. protected _useLogarithmicDepth: boolean;
  32015. protected _rebuildInParallel: boolean;
  32016. /**
  32017. * Instantiates a new standard material.
  32018. * This is the default material used in Babylon. It is the best trade off between quality
  32019. * and performances.
  32020. * @see https://doc.babylonjs.com/babylon101/materials
  32021. * @param name Define the name of the material in the scene
  32022. * @param scene Define the scene the material belong to
  32023. */
  32024. constructor(name: string, scene: Scene);
  32025. /**
  32026. * Gets a boolean indicating that current material needs to register RTT
  32027. */
  32028. get hasRenderTargetTextures(): boolean;
  32029. /**
  32030. * Gets the current class name of the material e.g. "StandardMaterial"
  32031. * Mainly use in serialization.
  32032. * @returns the class name
  32033. */
  32034. getClassName(): string;
  32035. /**
  32036. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  32037. * You can try switching to logarithmic depth.
  32038. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  32039. */
  32040. get useLogarithmicDepth(): boolean;
  32041. set useLogarithmicDepth(value: boolean);
  32042. /**
  32043. * Specifies if the material will require alpha blending
  32044. * @returns a boolean specifying if alpha blending is needed
  32045. */
  32046. needAlphaBlending(): boolean;
  32047. /**
  32048. * Specifies if this material should be rendered in alpha test mode
  32049. * @returns a boolean specifying if an alpha test is needed.
  32050. */
  32051. needAlphaTesting(): boolean;
  32052. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  32053. /**
  32054. * Get the texture used for alpha test purpose.
  32055. * @returns the diffuse texture in case of the standard material.
  32056. */
  32057. getAlphaTestTexture(): Nullable<BaseTexture>;
  32058. /**
  32059. * Get if the submesh is ready to be used and all its information available.
  32060. * Child classes can use it to update shaders
  32061. * @param mesh defines the mesh to check
  32062. * @param subMesh defines which submesh to check
  32063. * @param useInstances specifies that instances should be used
  32064. * @returns a boolean indicating that the submesh is ready or not
  32065. */
  32066. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32067. /**
  32068. * Builds the material UBO layouts.
  32069. * Used internally during the effect preparation.
  32070. */
  32071. buildUniformLayout(): void;
  32072. /**
  32073. * Unbinds the material from the mesh
  32074. */
  32075. unbind(): void;
  32076. /**
  32077. * Binds the submesh to this material by preparing the effect and shader to draw
  32078. * @param world defines the world transformation matrix
  32079. * @param mesh defines the mesh containing the submesh
  32080. * @param subMesh defines the submesh to bind the material to
  32081. */
  32082. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32083. /**
  32084. * Get the list of animatables in the material.
  32085. * @returns the list of animatables object used in the material
  32086. */
  32087. getAnimatables(): IAnimatable[];
  32088. /**
  32089. * Gets the active textures from the material
  32090. * @returns an array of textures
  32091. */
  32092. getActiveTextures(): BaseTexture[];
  32093. /**
  32094. * Specifies if the material uses a texture
  32095. * @param texture defines the texture to check against the material
  32096. * @returns a boolean specifying if the material uses the texture
  32097. */
  32098. hasTexture(texture: BaseTexture): boolean;
  32099. /**
  32100. * Disposes the material
  32101. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32102. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32103. */
  32104. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32105. /**
  32106. * Makes a duplicate of the material, and gives it a new name
  32107. * @param name defines the new name for the duplicated material
  32108. * @returns the cloned material
  32109. */
  32110. clone(name: string): StandardMaterial;
  32111. /**
  32112. * Serializes this material in a JSON representation
  32113. * @returns the serialized material object
  32114. */
  32115. serialize(): any;
  32116. /**
  32117. * Creates a standard material from parsed material data
  32118. * @param source defines the JSON representation of the material
  32119. * @param scene defines the hosting scene
  32120. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  32121. * @returns a new standard material
  32122. */
  32123. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  32124. /**
  32125. * Are diffuse textures enabled in the application.
  32126. */
  32127. static get DiffuseTextureEnabled(): boolean;
  32128. static set DiffuseTextureEnabled(value: boolean);
  32129. /**
  32130. * Are detail textures enabled in the application.
  32131. */
  32132. static get DetailTextureEnabled(): boolean;
  32133. static set DetailTextureEnabled(value: boolean);
  32134. /**
  32135. * Are ambient textures enabled in the application.
  32136. */
  32137. static get AmbientTextureEnabled(): boolean;
  32138. static set AmbientTextureEnabled(value: boolean);
  32139. /**
  32140. * Are opacity textures enabled in the application.
  32141. */
  32142. static get OpacityTextureEnabled(): boolean;
  32143. static set OpacityTextureEnabled(value: boolean);
  32144. /**
  32145. * Are reflection textures enabled in the application.
  32146. */
  32147. static get ReflectionTextureEnabled(): boolean;
  32148. static set ReflectionTextureEnabled(value: boolean);
  32149. /**
  32150. * Are emissive textures enabled in the application.
  32151. */
  32152. static get EmissiveTextureEnabled(): boolean;
  32153. static set EmissiveTextureEnabled(value: boolean);
  32154. /**
  32155. * Are specular textures enabled in the application.
  32156. */
  32157. static get SpecularTextureEnabled(): boolean;
  32158. static set SpecularTextureEnabled(value: boolean);
  32159. /**
  32160. * Are bump textures enabled in the application.
  32161. */
  32162. static get BumpTextureEnabled(): boolean;
  32163. static set BumpTextureEnabled(value: boolean);
  32164. /**
  32165. * Are lightmap textures enabled in the application.
  32166. */
  32167. static get LightmapTextureEnabled(): boolean;
  32168. static set LightmapTextureEnabled(value: boolean);
  32169. /**
  32170. * Are refraction textures enabled in the application.
  32171. */
  32172. static get RefractionTextureEnabled(): boolean;
  32173. static set RefractionTextureEnabled(value: boolean);
  32174. /**
  32175. * Are color grading textures enabled in the application.
  32176. */
  32177. static get ColorGradingTextureEnabled(): boolean;
  32178. static set ColorGradingTextureEnabled(value: boolean);
  32179. /**
  32180. * Are fresnels enabled in the application.
  32181. */
  32182. static get FresnelEnabled(): boolean;
  32183. static set FresnelEnabled(value: boolean);
  32184. }
  32185. }
  32186. declare module "babylonjs/Particles/solidParticleSystem" {
  32187. import { Nullable } from "babylonjs/types";
  32188. import { Mesh } from "babylonjs/Meshes/mesh";
  32189. import { Scene, IDisposable } from "babylonjs/scene";
  32190. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32191. import { Material } from "babylonjs/Materials/material";
  32192. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32193. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32194. /**
  32195. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32196. *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.
  32197. * The SPS is also a particle system. It provides some methods to manage the particles.
  32198. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32199. *
  32200. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32201. */
  32202. export class SolidParticleSystem implements IDisposable {
  32203. /**
  32204. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32205. * Example : var p = SPS.particles[i];
  32206. */
  32207. particles: SolidParticle[];
  32208. /**
  32209. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32210. */
  32211. nbParticles: number;
  32212. /**
  32213. * If the particles must ever face the camera (default false). Useful for planar particles.
  32214. */
  32215. billboard: boolean;
  32216. /**
  32217. * Recompute normals when adding a shape
  32218. */
  32219. recomputeNormals: boolean;
  32220. /**
  32221. * This a counter ofr your own usage. It's not set by any SPS functions.
  32222. */
  32223. counter: number;
  32224. /**
  32225. * The SPS name. This name is also given to the underlying mesh.
  32226. */
  32227. name: string;
  32228. /**
  32229. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32230. */
  32231. mesh: Mesh;
  32232. /**
  32233. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32234. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32235. */
  32236. vars: any;
  32237. /**
  32238. * This array is populated when the SPS is set as 'pickable'.
  32239. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32240. * Each element of this array is an object `{idx: int, faceId: int}`.
  32241. * `idx` is the picked particle index in the `SPS.particles` array
  32242. * `faceId` is the picked face index counted within this particle.
  32243. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32244. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32245. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32246. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32247. */
  32248. pickedParticles: {
  32249. idx: number;
  32250. faceId: number;
  32251. }[];
  32252. /**
  32253. * This array is populated when the SPS is set as 'pickable'
  32254. * Each key of this array is a submesh index.
  32255. * Each element of this array is a second array defined like this :
  32256. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32257. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32258. * `idx` is the picked particle index in the `SPS.particles` array
  32259. * `faceId` is the picked face index counted within this particle.
  32260. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32261. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32262. */
  32263. pickedBySubMesh: {
  32264. idx: number;
  32265. faceId: number;
  32266. }[][];
  32267. /**
  32268. * This array is populated when `enableDepthSort` is set to true.
  32269. * Each element of this array is an instance of the class DepthSortedParticle.
  32270. */
  32271. depthSortedParticles: DepthSortedParticle[];
  32272. /**
  32273. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32274. * @hidden
  32275. */
  32276. _bSphereOnly: boolean;
  32277. /**
  32278. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32279. * @hidden
  32280. */
  32281. _bSphereRadiusFactor: number;
  32282. private _scene;
  32283. private _positions;
  32284. private _indices;
  32285. private _normals;
  32286. private _colors;
  32287. private _uvs;
  32288. private _indices32;
  32289. private _positions32;
  32290. private _normals32;
  32291. private _fixedNormal32;
  32292. private _colors32;
  32293. private _uvs32;
  32294. private _index;
  32295. private _updatable;
  32296. private _pickable;
  32297. private _isVisibilityBoxLocked;
  32298. private _alwaysVisible;
  32299. private _depthSort;
  32300. private _expandable;
  32301. private _shapeCounter;
  32302. private _copy;
  32303. private _color;
  32304. private _computeParticleColor;
  32305. private _computeParticleTexture;
  32306. private _computeParticleRotation;
  32307. private _computeParticleVertex;
  32308. private _computeBoundingBox;
  32309. private _depthSortParticles;
  32310. private _camera;
  32311. private _mustUnrotateFixedNormals;
  32312. private _particlesIntersect;
  32313. private _needs32Bits;
  32314. private _isNotBuilt;
  32315. private _lastParticleId;
  32316. private _idxOfId;
  32317. private _multimaterialEnabled;
  32318. private _useModelMaterial;
  32319. private _indicesByMaterial;
  32320. private _materialIndexes;
  32321. private _depthSortFunction;
  32322. private _materialSortFunction;
  32323. private _materials;
  32324. private _multimaterial;
  32325. private _materialIndexesById;
  32326. private _defaultMaterial;
  32327. private _autoUpdateSubMeshes;
  32328. private _tmpVertex;
  32329. /**
  32330. * Creates a SPS (Solid Particle System) object.
  32331. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32332. * @param scene (Scene) is the scene in which the SPS is added.
  32333. * @param options defines the options of the sps e.g.
  32334. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32335. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32336. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32337. * * 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.
  32338. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32339. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32340. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32341. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32342. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32343. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32344. */
  32345. constructor(name: string, scene: Scene, options?: {
  32346. updatable?: boolean;
  32347. isPickable?: boolean;
  32348. enableDepthSort?: boolean;
  32349. particleIntersection?: boolean;
  32350. boundingSphereOnly?: boolean;
  32351. bSphereRadiusFactor?: number;
  32352. expandable?: boolean;
  32353. useModelMaterial?: boolean;
  32354. enableMultiMaterial?: boolean;
  32355. });
  32356. /**
  32357. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32358. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32359. * @returns the created mesh
  32360. */
  32361. buildMesh(): Mesh;
  32362. /**
  32363. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32364. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32365. * Thus the particles generated from `digest()` have their property `position` set yet.
  32366. * @param mesh ( Mesh ) is the mesh to be digested
  32367. * @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
  32368. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32369. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32370. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32371. * @returns the current SPS
  32372. */
  32373. digest(mesh: Mesh, options?: {
  32374. facetNb?: number;
  32375. number?: number;
  32376. delta?: number;
  32377. storage?: [];
  32378. }): SolidParticleSystem;
  32379. /**
  32380. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32381. * @hidden
  32382. */
  32383. private _unrotateFixedNormals;
  32384. /**
  32385. * Resets the temporary working copy particle
  32386. * @hidden
  32387. */
  32388. private _resetCopy;
  32389. /**
  32390. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32391. * @param p the current index in the positions array to be updated
  32392. * @param ind the current index in the indices array
  32393. * @param shape a Vector3 array, the shape geometry
  32394. * @param positions the positions array to be updated
  32395. * @param meshInd the shape indices array
  32396. * @param indices the indices array to be updated
  32397. * @param meshUV the shape uv array
  32398. * @param uvs the uv array to be updated
  32399. * @param meshCol the shape color array
  32400. * @param colors the color array to be updated
  32401. * @param meshNor the shape normals array
  32402. * @param normals the normals array to be updated
  32403. * @param idx the particle index
  32404. * @param idxInShape the particle index in its shape
  32405. * @param options the addShape() method passed options
  32406. * @model the particle model
  32407. * @hidden
  32408. */
  32409. private _meshBuilder;
  32410. /**
  32411. * Returns a shape Vector3 array from positions float array
  32412. * @param positions float array
  32413. * @returns a vector3 array
  32414. * @hidden
  32415. */
  32416. private _posToShape;
  32417. /**
  32418. * Returns a shapeUV array from a float uvs (array deep copy)
  32419. * @param uvs as a float array
  32420. * @returns a shapeUV array
  32421. * @hidden
  32422. */
  32423. private _uvsToShapeUV;
  32424. /**
  32425. * Adds a new particle object in the particles array
  32426. * @param idx particle index in particles array
  32427. * @param id particle id
  32428. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32429. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32430. * @param model particle ModelShape object
  32431. * @param shapeId model shape identifier
  32432. * @param idxInShape index of the particle in the current model
  32433. * @param bInfo model bounding info object
  32434. * @param storage target storage array, if any
  32435. * @hidden
  32436. */
  32437. private _addParticle;
  32438. /**
  32439. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32440. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32441. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32442. * @param nb (positive integer) the number of particles to be created from this model
  32443. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32444. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32445. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32446. * @returns the number of shapes in the system
  32447. */
  32448. addShape(mesh: Mesh, nb: number, options?: {
  32449. positionFunction?: any;
  32450. vertexFunction?: any;
  32451. storage?: [];
  32452. }): number;
  32453. /**
  32454. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32455. * @hidden
  32456. */
  32457. private _rebuildParticle;
  32458. /**
  32459. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32460. * @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.
  32461. * @returns the SPS.
  32462. */
  32463. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32464. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32465. * Returns an array with the removed particles.
  32466. * 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.
  32467. * The SPS can't be empty so at least one particle needs to remain in place.
  32468. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32469. * @param start index of the first particle to remove
  32470. * @param end index of the last particle to remove (included)
  32471. * @returns an array populated with the removed particles
  32472. */
  32473. removeParticles(start: number, end: number): SolidParticle[];
  32474. /**
  32475. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32476. * @param solidParticleArray an array populated with Solid Particles objects
  32477. * @returns the SPS
  32478. */
  32479. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32480. /**
  32481. * Creates a new particle and modifies the SPS mesh geometry :
  32482. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32483. * - calls _addParticle() to populate the particle array
  32484. * factorized code from addShape() and insertParticlesFromArray()
  32485. * @param idx particle index in the particles array
  32486. * @param i particle index in its shape
  32487. * @param modelShape particle ModelShape object
  32488. * @param shape shape vertex array
  32489. * @param meshInd shape indices array
  32490. * @param meshUV shape uv array
  32491. * @param meshCol shape color array
  32492. * @param meshNor shape normals array
  32493. * @param bbInfo shape bounding info
  32494. * @param storage target particle storage
  32495. * @options addShape() passed options
  32496. * @hidden
  32497. */
  32498. private _insertNewParticle;
  32499. /**
  32500. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32501. * This method calls `updateParticle()` for each particle of the SPS.
  32502. * For an animated SPS, it is usually called within the render loop.
  32503. * 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.
  32504. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32505. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32506. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32507. * @returns the SPS.
  32508. */
  32509. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32510. /**
  32511. * Disposes the SPS.
  32512. */
  32513. dispose(): void;
  32514. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32515. * idx is the particle index in the SPS
  32516. * faceId is the picked face index counted within this particle.
  32517. * Returns null if the pickInfo can't identify a picked particle.
  32518. * @param pickingInfo (PickingInfo object)
  32519. * @returns {idx: number, faceId: number} or null
  32520. */
  32521. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32522. idx: number;
  32523. faceId: number;
  32524. }>;
  32525. /**
  32526. * Returns a SolidParticle object from its identifier : particle.id
  32527. * @param id (integer) the particle Id
  32528. * @returns the searched particle or null if not found in the SPS.
  32529. */
  32530. getParticleById(id: number): Nullable<SolidParticle>;
  32531. /**
  32532. * Returns a new array populated with the particles having the passed shapeId.
  32533. * @param shapeId (integer) the shape identifier
  32534. * @returns a new solid particle array
  32535. */
  32536. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32537. /**
  32538. * Populates the passed array "ref" with the particles having the passed shapeId.
  32539. * @param shapeId the shape identifier
  32540. * @returns the SPS
  32541. * @param ref
  32542. */
  32543. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32544. /**
  32545. * Computes the required SubMeshes according the materials assigned to the particles.
  32546. * @returns the solid particle system.
  32547. * Does nothing if called before the SPS mesh is built.
  32548. */
  32549. computeSubMeshes(): SolidParticleSystem;
  32550. /**
  32551. * Sorts the solid particles by material when MultiMaterial is enabled.
  32552. * Updates the indices32 array.
  32553. * Updates the indicesByMaterial array.
  32554. * Updates the mesh indices array.
  32555. * @returns the SPS
  32556. * @hidden
  32557. */
  32558. private _sortParticlesByMaterial;
  32559. /**
  32560. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32561. * @hidden
  32562. */
  32563. private _setMaterialIndexesById;
  32564. /**
  32565. * Returns an array with unique values of Materials from the passed array
  32566. * @param array the material array to be checked and filtered
  32567. * @hidden
  32568. */
  32569. private _filterUniqueMaterialId;
  32570. /**
  32571. * Sets a new Standard Material as _defaultMaterial if not already set.
  32572. * @hidden
  32573. */
  32574. private _setDefaultMaterial;
  32575. /**
  32576. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32577. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32578. * @returns the SPS.
  32579. */
  32580. refreshVisibleSize(): SolidParticleSystem;
  32581. /**
  32582. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32583. * @param size the size (float) of the visibility box
  32584. * note : this doesn't lock the SPS mesh bounding box.
  32585. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32586. */
  32587. setVisibilityBox(size: number): void;
  32588. /**
  32589. * Gets whether the SPS as always visible or not
  32590. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32591. */
  32592. get isAlwaysVisible(): boolean;
  32593. /**
  32594. * Sets the SPS as always visible or not
  32595. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32596. */
  32597. set isAlwaysVisible(val: boolean);
  32598. /**
  32599. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32600. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32601. */
  32602. set isVisibilityBoxLocked(val: boolean);
  32603. /**
  32604. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32605. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32606. */
  32607. get isVisibilityBoxLocked(): boolean;
  32608. /**
  32609. * Tells to `setParticles()` to compute the particle rotations or not.
  32610. * Default value : true. The SPS is faster when it's set to false.
  32611. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32612. */
  32613. set computeParticleRotation(val: boolean);
  32614. /**
  32615. * Tells to `setParticles()` to compute the particle colors or not.
  32616. * Default value : true. The SPS is faster when it's set to false.
  32617. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32618. */
  32619. set computeParticleColor(val: boolean);
  32620. set computeParticleTexture(val: boolean);
  32621. /**
  32622. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32623. * Default value : false. The SPS is faster when it's set to false.
  32624. * Note : the particle custom vertex positions aren't stored values.
  32625. */
  32626. set computeParticleVertex(val: boolean);
  32627. /**
  32628. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32629. */
  32630. set computeBoundingBox(val: boolean);
  32631. /**
  32632. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32633. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32634. * Default : `true`
  32635. */
  32636. set depthSortParticles(val: boolean);
  32637. /**
  32638. * Gets if `setParticles()` computes the particle rotations or not.
  32639. * Default value : true. The SPS is faster when it's set to false.
  32640. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32641. */
  32642. get computeParticleRotation(): boolean;
  32643. /**
  32644. * Gets if `setParticles()` computes the particle colors or not.
  32645. * Default value : true. The SPS is faster when it's set to false.
  32646. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32647. */
  32648. get computeParticleColor(): boolean;
  32649. /**
  32650. * Gets if `setParticles()` computes the particle textures or not.
  32651. * Default value : true. The SPS is faster when it's set to false.
  32652. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32653. */
  32654. get computeParticleTexture(): boolean;
  32655. /**
  32656. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32657. * Default value : false. The SPS is faster when it's set to false.
  32658. * Note : the particle custom vertex positions aren't stored values.
  32659. */
  32660. get computeParticleVertex(): boolean;
  32661. /**
  32662. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32663. */
  32664. get computeBoundingBox(): boolean;
  32665. /**
  32666. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32667. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32668. * Default : `true`
  32669. */
  32670. get depthSortParticles(): boolean;
  32671. /**
  32672. * Gets if the SPS is created as expandable at construction time.
  32673. * Default : `false`
  32674. */
  32675. get expandable(): boolean;
  32676. /**
  32677. * Gets if the SPS supports the Multi Materials
  32678. */
  32679. get multimaterialEnabled(): boolean;
  32680. /**
  32681. * Gets if the SPS uses the model materials for its own multimaterial.
  32682. */
  32683. get useModelMaterial(): boolean;
  32684. /**
  32685. * The SPS used material array.
  32686. */
  32687. get materials(): Material[];
  32688. /**
  32689. * Sets the SPS MultiMaterial from the passed materials.
  32690. * Note : the passed array is internally copied and not used then by reference.
  32691. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32692. */
  32693. setMultiMaterial(materials: Material[]): void;
  32694. /**
  32695. * The SPS computed multimaterial object
  32696. */
  32697. get multimaterial(): MultiMaterial;
  32698. set multimaterial(mm: MultiMaterial);
  32699. /**
  32700. * If the subMeshes must be updated on the next call to setParticles()
  32701. */
  32702. get autoUpdateSubMeshes(): boolean;
  32703. set autoUpdateSubMeshes(val: boolean);
  32704. /**
  32705. * This function does nothing. It may be overwritten to set all the particle first values.
  32706. * The SPS doesn't call this function, you may have to call it by your own.
  32707. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32708. */
  32709. initParticles(): void;
  32710. /**
  32711. * This function does nothing. It may be overwritten to recycle a particle.
  32712. * The SPS doesn't call this function, you may have to call it by your own.
  32713. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32714. * @param particle The particle to recycle
  32715. * @returns the recycled particle
  32716. */
  32717. recycleParticle(particle: SolidParticle): SolidParticle;
  32718. /**
  32719. * Updates a particle : this function should be overwritten by the user.
  32720. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32721. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32722. * @example : just set a particle position or velocity and recycle conditions
  32723. * @param particle The particle to update
  32724. * @returns the updated particle
  32725. */
  32726. updateParticle(particle: SolidParticle): SolidParticle;
  32727. /**
  32728. * Updates a vertex of a particle : it can be overwritten by the user.
  32729. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32730. * @param particle the current particle
  32731. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32732. * @param pt the index of the current vertex in the particle shape
  32733. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32734. * @example : just set a vertex particle position or color
  32735. * @returns the sps
  32736. */
  32737. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32738. /**
  32739. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32740. * This does nothing and may be overwritten by the user.
  32741. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32742. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32743. * @param update the boolean update value actually passed to setParticles()
  32744. */
  32745. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32746. /**
  32747. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32748. * This will be passed three parameters.
  32749. * This does nothing and may be overwritten by the user.
  32750. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32751. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32752. * @param update the boolean update value actually passed to setParticles()
  32753. */
  32754. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32755. }
  32756. }
  32757. declare module "babylonjs/Particles/solidParticle" {
  32758. import { Nullable } from "babylonjs/types";
  32759. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32760. import { Color4 } from "babylonjs/Maths/math.color";
  32761. import { Mesh } from "babylonjs/Meshes/mesh";
  32762. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32763. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32764. import { Plane } from "babylonjs/Maths/math.plane";
  32765. import { Material } from "babylonjs/Materials/material";
  32766. /**
  32767. * Represents one particle of a solid particle system.
  32768. */
  32769. export class SolidParticle {
  32770. /**
  32771. * particle global index
  32772. */
  32773. idx: number;
  32774. /**
  32775. * particle identifier
  32776. */
  32777. id: number;
  32778. /**
  32779. * The color of the particle
  32780. */
  32781. color: Nullable<Color4>;
  32782. /**
  32783. * The world space position of the particle.
  32784. */
  32785. position: Vector3;
  32786. /**
  32787. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32788. */
  32789. rotation: Vector3;
  32790. /**
  32791. * The world space rotation quaternion of the particle.
  32792. */
  32793. rotationQuaternion: Nullable<Quaternion>;
  32794. /**
  32795. * The scaling of the particle.
  32796. */
  32797. scaling: Vector3;
  32798. /**
  32799. * The uvs of the particle.
  32800. */
  32801. uvs: Vector4;
  32802. /**
  32803. * The current speed of the particle.
  32804. */
  32805. velocity: Vector3;
  32806. /**
  32807. * The pivot point in the particle local space.
  32808. */
  32809. pivot: Vector3;
  32810. /**
  32811. * Must the particle be translated from its pivot point in its local space ?
  32812. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32813. * Default : false
  32814. */
  32815. translateFromPivot: boolean;
  32816. /**
  32817. * Is the particle active or not ?
  32818. */
  32819. alive: boolean;
  32820. /**
  32821. * Is the particle visible or not ?
  32822. */
  32823. isVisible: boolean;
  32824. /**
  32825. * Index of this particle in the global "positions" array (Internal use)
  32826. * @hidden
  32827. */
  32828. _pos: number;
  32829. /**
  32830. * @hidden Index of this particle in the global "indices" array (Internal use)
  32831. */
  32832. _ind: number;
  32833. /**
  32834. * @hidden ModelShape of this particle (Internal use)
  32835. */
  32836. _model: ModelShape;
  32837. /**
  32838. * ModelShape id of this particle
  32839. */
  32840. shapeId: number;
  32841. /**
  32842. * Index of the particle in its shape id
  32843. */
  32844. idxInShape: number;
  32845. /**
  32846. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32847. */
  32848. _modelBoundingInfo: BoundingInfo;
  32849. /**
  32850. * @hidden Particle BoundingInfo object (Internal use)
  32851. */
  32852. _boundingInfo: BoundingInfo;
  32853. /**
  32854. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32855. */
  32856. _sps: SolidParticleSystem;
  32857. /**
  32858. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32859. */
  32860. _stillInvisible: boolean;
  32861. /**
  32862. * @hidden Last computed particle rotation matrix
  32863. */
  32864. _rotationMatrix: number[];
  32865. /**
  32866. * Parent particle Id, if any.
  32867. * Default null.
  32868. */
  32869. parentId: Nullable<number>;
  32870. /**
  32871. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32872. */
  32873. materialIndex: Nullable<number>;
  32874. /**
  32875. * Custom object or properties.
  32876. */
  32877. props: Nullable<any>;
  32878. /**
  32879. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32880. * The possible values are :
  32881. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32882. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32883. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32884. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32885. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32886. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32887. * */
  32888. cullingStrategy: number;
  32889. /**
  32890. * @hidden Internal global position in the SPS.
  32891. */
  32892. _globalPosition: Vector3;
  32893. /**
  32894. * Creates a Solid Particle object.
  32895. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32896. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32897. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32898. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32899. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32900. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32901. * @param shapeId (integer) is the model shape identifier in the SPS.
  32902. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32903. * @param sps defines the sps it is associated to
  32904. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32905. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32906. */
  32907. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32908. /**
  32909. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32910. * @param target the particle target
  32911. * @returns the current particle
  32912. */
  32913. copyToRef(target: SolidParticle): SolidParticle;
  32914. /**
  32915. * Legacy support, changed scale to scaling
  32916. */
  32917. get scale(): Vector3;
  32918. /**
  32919. * Legacy support, changed scale to scaling
  32920. */
  32921. set scale(scale: Vector3);
  32922. /**
  32923. * Legacy support, changed quaternion to rotationQuaternion
  32924. */
  32925. get quaternion(): Nullable<Quaternion>;
  32926. /**
  32927. * Legacy support, changed quaternion to rotationQuaternion
  32928. */
  32929. set quaternion(q: Nullable<Quaternion>);
  32930. /**
  32931. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32932. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32933. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32934. * @returns true if it intersects
  32935. */
  32936. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32937. /**
  32938. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32939. * A particle is in the frustum if its bounding box intersects the frustum
  32940. * @param frustumPlanes defines the frustum to test
  32941. * @returns true if the particle is in the frustum planes
  32942. */
  32943. isInFrustum(frustumPlanes: Plane[]): boolean;
  32944. /**
  32945. * get the rotation matrix of the particle
  32946. * @hidden
  32947. */
  32948. getRotationMatrix(m: Matrix): void;
  32949. }
  32950. /**
  32951. * Represents the shape of the model used by one particle of a solid particle system.
  32952. * SPS internal tool, don't use it manually.
  32953. */
  32954. export class ModelShape {
  32955. /**
  32956. * The shape id
  32957. * @hidden
  32958. */
  32959. shapeID: number;
  32960. /**
  32961. * flat array of model positions (internal use)
  32962. * @hidden
  32963. */
  32964. _shape: Vector3[];
  32965. /**
  32966. * flat array of model UVs (internal use)
  32967. * @hidden
  32968. */
  32969. _shapeUV: number[];
  32970. /**
  32971. * color array of the model
  32972. * @hidden
  32973. */
  32974. _shapeColors: number[];
  32975. /**
  32976. * indices array of the model
  32977. * @hidden
  32978. */
  32979. _indices: number[];
  32980. /**
  32981. * normals array of the model
  32982. * @hidden
  32983. */
  32984. _normals: number[];
  32985. /**
  32986. * length of the shape in the model indices array (internal use)
  32987. * @hidden
  32988. */
  32989. _indicesLength: number;
  32990. /**
  32991. * Custom position function (internal use)
  32992. * @hidden
  32993. */
  32994. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32995. /**
  32996. * Custom vertex function (internal use)
  32997. * @hidden
  32998. */
  32999. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  33000. /**
  33001. * Model material (internal use)
  33002. * @hidden
  33003. */
  33004. _material: Nullable<Material>;
  33005. /**
  33006. * 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.
  33007. * SPS internal tool, don't use it manually.
  33008. * @hidden
  33009. */
  33010. 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>);
  33011. }
  33012. /**
  33013. * Represents a Depth Sorted Particle in the solid particle system.
  33014. * @hidden
  33015. */
  33016. export class DepthSortedParticle {
  33017. /**
  33018. * Particle index
  33019. */
  33020. idx: number;
  33021. /**
  33022. * Index of the particle in the "indices" array
  33023. */
  33024. ind: number;
  33025. /**
  33026. * Length of the particle shape in the "indices" array
  33027. */
  33028. indicesLength: number;
  33029. /**
  33030. * Squared distance from the particle to the camera
  33031. */
  33032. sqDistance: number;
  33033. /**
  33034. * Material index when used with MultiMaterials
  33035. */
  33036. materialIndex: number;
  33037. /**
  33038. * Creates a new sorted particle
  33039. * @param materialIndex
  33040. */
  33041. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  33042. }
  33043. /**
  33044. * Represents a solid particle vertex
  33045. */
  33046. export class SolidParticleVertex {
  33047. /**
  33048. * Vertex position
  33049. */
  33050. position: Vector3;
  33051. /**
  33052. * Vertex color
  33053. */
  33054. color: Color4;
  33055. /**
  33056. * Vertex UV
  33057. */
  33058. uv: Vector2;
  33059. /**
  33060. * Creates a new solid particle vertex
  33061. */
  33062. constructor();
  33063. /** Vertex x coordinate */
  33064. get x(): number;
  33065. set x(val: number);
  33066. /** Vertex y coordinate */
  33067. get y(): number;
  33068. set y(val: number);
  33069. /** Vertex z coordinate */
  33070. get z(): number;
  33071. set z(val: number);
  33072. }
  33073. }
  33074. declare module "babylonjs/Collisions/meshCollisionData" {
  33075. import { Collider } from "babylonjs/Collisions/collider";
  33076. import { Vector3 } from "babylonjs/Maths/math.vector";
  33077. import { Nullable } from "babylonjs/types";
  33078. import { Observer } from "babylonjs/Misc/observable";
  33079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33080. /**
  33081. * @hidden
  33082. */
  33083. export class _MeshCollisionData {
  33084. _checkCollisions: boolean;
  33085. _collisionMask: number;
  33086. _collisionGroup: number;
  33087. _surroundingMeshes: Nullable<AbstractMesh[]>;
  33088. _collider: Nullable<Collider>;
  33089. _oldPositionForCollisions: Vector3;
  33090. _diffPositionForCollisions: Vector3;
  33091. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  33092. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  33093. _collisionResponse: boolean;
  33094. }
  33095. }
  33096. declare module "babylonjs/Meshes/abstractMesh" {
  33097. import { Observable } from "babylonjs/Misc/observable";
  33098. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  33099. import { Camera } from "babylonjs/Cameras/camera";
  33100. import { Scene, IDisposable } from "babylonjs/scene";
  33101. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  33102. import { Node } from "babylonjs/node";
  33103. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33104. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33105. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33106. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33107. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33108. import { Material } from "babylonjs/Materials/material";
  33109. import { Light } from "babylonjs/Lights/light";
  33110. import { Skeleton } from "babylonjs/Bones/skeleton";
  33111. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  33112. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  33113. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33114. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  33115. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33116. import { Plane } from "babylonjs/Maths/math.plane";
  33117. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33118. import { Ray } from "babylonjs/Culling/ray";
  33119. import { Collider } from "babylonjs/Collisions/collider";
  33120. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33121. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  33122. /** @hidden */
  33123. class _FacetDataStorage {
  33124. facetPositions: Vector3[];
  33125. facetNormals: Vector3[];
  33126. facetPartitioning: number[][];
  33127. facetNb: number;
  33128. partitioningSubdivisions: number;
  33129. partitioningBBoxRatio: number;
  33130. facetDataEnabled: boolean;
  33131. facetParameters: any;
  33132. bbSize: Vector3;
  33133. subDiv: {
  33134. max: number;
  33135. X: number;
  33136. Y: number;
  33137. Z: number;
  33138. };
  33139. facetDepthSort: boolean;
  33140. facetDepthSortEnabled: boolean;
  33141. depthSortedIndices: IndicesArray;
  33142. depthSortedFacets: {
  33143. ind: number;
  33144. sqDistance: number;
  33145. }[];
  33146. facetDepthSortFunction: (f1: {
  33147. ind: number;
  33148. sqDistance: number;
  33149. }, f2: {
  33150. ind: number;
  33151. sqDistance: number;
  33152. }) => number;
  33153. facetDepthSortFrom: Vector3;
  33154. facetDepthSortOrigin: Vector3;
  33155. invertedMatrix: Matrix;
  33156. }
  33157. /**
  33158. * @hidden
  33159. **/
  33160. class _InternalAbstractMeshDataInfo {
  33161. _hasVertexAlpha: boolean;
  33162. _useVertexColors: boolean;
  33163. _numBoneInfluencers: number;
  33164. _applyFog: boolean;
  33165. _receiveShadows: boolean;
  33166. _facetData: _FacetDataStorage;
  33167. _visibility: number;
  33168. _skeleton: Nullable<Skeleton>;
  33169. _layerMask: number;
  33170. _computeBonesUsingShaders: boolean;
  33171. _isActive: boolean;
  33172. _onlyForInstances: boolean;
  33173. _isActiveIntermediate: boolean;
  33174. _onlyForInstancesIntermediate: boolean;
  33175. _actAsRegularMesh: boolean;
  33176. }
  33177. /**
  33178. * Class used to store all common mesh properties
  33179. */
  33180. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33181. /** No occlusion */
  33182. static OCCLUSION_TYPE_NONE: number;
  33183. /** Occlusion set to optimisitic */
  33184. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33185. /** Occlusion set to strict */
  33186. static OCCLUSION_TYPE_STRICT: number;
  33187. /** Use an accurante occlusion algorithm */
  33188. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33189. /** Use a conservative occlusion algorithm */
  33190. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33191. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33192. * Test order :
  33193. * Is the bounding sphere outside the frustum ?
  33194. * If not, are the bounding box vertices outside the frustum ?
  33195. * It not, then the cullable object is in the frustum.
  33196. */
  33197. static readonly CULLINGSTRATEGY_STANDARD: number;
  33198. /** Culling strategy : Bounding Sphere Only.
  33199. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33200. * It's also less accurate than the standard because some not visible objects can still be selected.
  33201. * Test : is the bounding sphere outside the frustum ?
  33202. * If not, then the cullable object is in the frustum.
  33203. */
  33204. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33205. /** Culling strategy : Optimistic Inclusion.
  33206. * This in an inclusion test first, then the standard exclusion test.
  33207. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33208. * 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.
  33209. * Anyway, it's as accurate as the standard strategy.
  33210. * Test :
  33211. * Is the cullable object bounding sphere center in the frustum ?
  33212. * If not, apply the default culling strategy.
  33213. */
  33214. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33215. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33216. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33217. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33218. * 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.
  33219. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33220. * Test :
  33221. * Is the cullable object bounding sphere center in the frustum ?
  33222. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33223. */
  33224. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33225. /**
  33226. * No billboard
  33227. */
  33228. static get BILLBOARDMODE_NONE(): number;
  33229. /** Billboard on X axis */
  33230. static get BILLBOARDMODE_X(): number;
  33231. /** Billboard on Y axis */
  33232. static get BILLBOARDMODE_Y(): number;
  33233. /** Billboard on Z axis */
  33234. static get BILLBOARDMODE_Z(): number;
  33235. /** Billboard on all axes */
  33236. static get BILLBOARDMODE_ALL(): number;
  33237. /** Billboard on using position instead of orientation */
  33238. static get BILLBOARDMODE_USE_POSITION(): number;
  33239. /** @hidden */
  33240. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33241. /**
  33242. * The culling strategy to use to check whether the mesh must be rendered or not.
  33243. * This value can be changed at any time and will be used on the next render mesh selection.
  33244. * The possible values are :
  33245. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33246. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33247. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33248. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33249. * Please read each static variable documentation to get details about the culling process.
  33250. * */
  33251. cullingStrategy: number;
  33252. /**
  33253. * Gets the number of facets in the mesh
  33254. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33255. */
  33256. get facetNb(): number;
  33257. /**
  33258. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33259. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33260. */
  33261. get partitioningSubdivisions(): number;
  33262. set partitioningSubdivisions(nb: number);
  33263. /**
  33264. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33265. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33266. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33267. */
  33268. get partitioningBBoxRatio(): number;
  33269. set partitioningBBoxRatio(ratio: number);
  33270. /**
  33271. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33272. * Works only for updatable meshes.
  33273. * Doesn't work with multi-materials
  33274. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33275. */
  33276. get mustDepthSortFacets(): boolean;
  33277. set mustDepthSortFacets(sort: boolean);
  33278. /**
  33279. * The location (Vector3) where the facet depth sort must be computed from.
  33280. * By default, the active camera position.
  33281. * Used only when facet depth sort is enabled
  33282. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33283. */
  33284. get facetDepthSortFrom(): Vector3;
  33285. set facetDepthSortFrom(location: Vector3);
  33286. /**
  33287. * gets a boolean indicating if facetData is enabled
  33288. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33289. */
  33290. get isFacetDataEnabled(): boolean;
  33291. /** @hidden */
  33292. _updateNonUniformScalingState(value: boolean): boolean;
  33293. /**
  33294. * An event triggered when this mesh collides with another one
  33295. */
  33296. onCollideObservable: Observable<AbstractMesh>;
  33297. /** Set a function to call when this mesh collides with another one */
  33298. set onCollide(callback: () => void);
  33299. /**
  33300. * An event triggered when the collision's position changes
  33301. */
  33302. onCollisionPositionChangeObservable: Observable<Vector3>;
  33303. /** Set a function to call when the collision's position changes */
  33304. set onCollisionPositionChange(callback: () => void);
  33305. /**
  33306. * An event triggered when material is changed
  33307. */
  33308. onMaterialChangedObservable: Observable<AbstractMesh>;
  33309. /**
  33310. * Gets or sets the orientation for POV movement & rotation
  33311. */
  33312. definedFacingForward: boolean;
  33313. /** @hidden */
  33314. _occlusionQuery: Nullable<WebGLQuery>;
  33315. /** @hidden */
  33316. _renderingGroup: Nullable<RenderingGroup>;
  33317. /**
  33318. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33319. */
  33320. get visibility(): number;
  33321. /**
  33322. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33323. */
  33324. set visibility(value: number);
  33325. /** Gets or sets the alpha index used to sort transparent meshes
  33326. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33327. */
  33328. alphaIndex: number;
  33329. /**
  33330. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33331. */
  33332. isVisible: boolean;
  33333. /**
  33334. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33335. */
  33336. isPickable: boolean;
  33337. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33338. showSubMeshesBoundingBox: boolean;
  33339. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33340. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33341. */
  33342. isBlocker: boolean;
  33343. /**
  33344. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33345. */
  33346. enablePointerMoveEvents: boolean;
  33347. private _renderingGroupId;
  33348. /**
  33349. * Specifies the rendering group id for this mesh (0 by default)
  33350. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33351. */
  33352. get renderingGroupId(): number;
  33353. set renderingGroupId(value: number);
  33354. private _material;
  33355. /** Gets or sets current material */
  33356. get material(): Nullable<Material>;
  33357. set material(value: Nullable<Material>);
  33358. /**
  33359. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33360. * @see https://doc.babylonjs.com/babylon101/shadows
  33361. */
  33362. get receiveShadows(): boolean;
  33363. set receiveShadows(value: boolean);
  33364. /** Defines color to use when rendering outline */
  33365. outlineColor: Color3;
  33366. /** Define width to use when rendering outline */
  33367. outlineWidth: number;
  33368. /** Defines color to use when rendering overlay */
  33369. overlayColor: Color3;
  33370. /** Defines alpha to use when rendering overlay */
  33371. overlayAlpha: number;
  33372. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33373. get hasVertexAlpha(): boolean;
  33374. set hasVertexAlpha(value: boolean);
  33375. /** 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) */
  33376. get useVertexColors(): boolean;
  33377. set useVertexColors(value: boolean);
  33378. /**
  33379. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33380. */
  33381. get computeBonesUsingShaders(): boolean;
  33382. set computeBonesUsingShaders(value: boolean);
  33383. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33384. get numBoneInfluencers(): number;
  33385. set numBoneInfluencers(value: number);
  33386. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33387. get applyFog(): boolean;
  33388. set applyFog(value: boolean);
  33389. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33390. useOctreeForRenderingSelection: boolean;
  33391. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33392. useOctreeForPicking: boolean;
  33393. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33394. useOctreeForCollisions: boolean;
  33395. /**
  33396. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33397. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33398. */
  33399. get layerMask(): number;
  33400. set layerMask(value: number);
  33401. /**
  33402. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33403. */
  33404. alwaysSelectAsActiveMesh: boolean;
  33405. /**
  33406. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33407. */
  33408. doNotSyncBoundingInfo: boolean;
  33409. /**
  33410. * Gets or sets the current action manager
  33411. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33412. */
  33413. actionManager: Nullable<AbstractActionManager>;
  33414. private _meshCollisionData;
  33415. /**
  33416. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33417. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33418. */
  33419. ellipsoid: Vector3;
  33420. /**
  33421. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33422. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33423. */
  33424. ellipsoidOffset: Vector3;
  33425. /**
  33426. * Gets or sets a collision mask used to mask collisions (default is -1).
  33427. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33428. */
  33429. get collisionMask(): number;
  33430. set collisionMask(mask: number);
  33431. /**
  33432. * Gets or sets a collision response flag (default is true).
  33433. * when collisionResponse is false, events are still triggered but colliding entity has no response
  33434. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  33435. * to respond to the collision.
  33436. */
  33437. get collisionResponse(): boolean;
  33438. set collisionResponse(response: boolean);
  33439. /**
  33440. * Gets or sets the current collision group mask (-1 by default).
  33441. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33442. */
  33443. get collisionGroup(): number;
  33444. set collisionGroup(mask: number);
  33445. /**
  33446. * Gets or sets current surrounding meshes (null by default).
  33447. *
  33448. * By default collision detection is tested against every mesh in the scene.
  33449. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33450. * meshes will be tested for the collision.
  33451. *
  33452. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33453. */
  33454. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33455. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33456. /**
  33457. * Defines edge width used when edgesRenderer is enabled
  33458. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33459. */
  33460. edgesWidth: number;
  33461. /**
  33462. * Defines edge color used when edgesRenderer is enabled
  33463. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33464. */
  33465. edgesColor: Color4;
  33466. /** @hidden */
  33467. _edgesRenderer: Nullable<IEdgesRenderer>;
  33468. /** @hidden */
  33469. _masterMesh: Nullable<AbstractMesh>;
  33470. /** @hidden */
  33471. _boundingInfo: Nullable<BoundingInfo>;
  33472. /** @hidden */
  33473. _renderId: number;
  33474. /**
  33475. * Gets or sets the list of subMeshes
  33476. * @see https://doc.babylonjs.com/how_to/multi_materials
  33477. */
  33478. subMeshes: SubMesh[];
  33479. /** @hidden */
  33480. _intersectionsInProgress: AbstractMesh[];
  33481. /** @hidden */
  33482. _unIndexed: boolean;
  33483. /** @hidden */
  33484. _lightSources: Light[];
  33485. /** Gets the list of lights affecting that mesh */
  33486. get lightSources(): Light[];
  33487. /** @hidden */
  33488. get _positions(): Nullable<Vector3[]>;
  33489. /** @hidden */
  33490. _waitingData: {
  33491. lods: Nullable<any>;
  33492. actions: Nullable<any>;
  33493. freezeWorldMatrix: Nullable<boolean>;
  33494. };
  33495. /** @hidden */
  33496. _bonesTransformMatrices: Nullable<Float32Array>;
  33497. /** @hidden */
  33498. _transformMatrixTexture: Nullable<RawTexture>;
  33499. /**
  33500. * Gets or sets a skeleton to apply skining transformations
  33501. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33502. */
  33503. set skeleton(value: Nullable<Skeleton>);
  33504. get skeleton(): Nullable<Skeleton>;
  33505. /**
  33506. * An event triggered when the mesh is rebuilt.
  33507. */
  33508. onRebuildObservable: Observable<AbstractMesh>;
  33509. /**
  33510. * Creates a new AbstractMesh
  33511. * @param name defines the name of the mesh
  33512. * @param scene defines the hosting scene
  33513. */
  33514. constructor(name: string, scene?: Nullable<Scene>);
  33515. /**
  33516. * Returns the string "AbstractMesh"
  33517. * @returns "AbstractMesh"
  33518. */
  33519. getClassName(): string;
  33520. /**
  33521. * Gets a string representation of the current mesh
  33522. * @param fullDetails defines a boolean indicating if full details must be included
  33523. * @returns a string representation of the current mesh
  33524. */
  33525. toString(fullDetails?: boolean): string;
  33526. /**
  33527. * @hidden
  33528. */
  33529. protected _getEffectiveParent(): Nullable<Node>;
  33530. /** @hidden */
  33531. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33532. /** @hidden */
  33533. _rebuild(): void;
  33534. /** @hidden */
  33535. _resyncLightSources(): void;
  33536. /** @hidden */
  33537. _resyncLightSource(light: Light): void;
  33538. /** @hidden */
  33539. _unBindEffect(): void;
  33540. /** @hidden */
  33541. _removeLightSource(light: Light, dispose: boolean): void;
  33542. private _markSubMeshesAsDirty;
  33543. /** @hidden */
  33544. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33545. /** @hidden */
  33546. _markSubMeshesAsAttributesDirty(): void;
  33547. /** @hidden */
  33548. _markSubMeshesAsMiscDirty(): void;
  33549. /**
  33550. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33551. */
  33552. get scaling(): Vector3;
  33553. set scaling(newScaling: Vector3);
  33554. /**
  33555. * Returns true if the mesh is blocked. Implemented by child classes
  33556. */
  33557. get isBlocked(): boolean;
  33558. /**
  33559. * Returns the mesh itself by default. Implemented by child classes
  33560. * @param camera defines the camera to use to pick the right LOD level
  33561. * @returns the currentAbstractMesh
  33562. */
  33563. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33564. /**
  33565. * Returns 0 by default. Implemented by child classes
  33566. * @returns an integer
  33567. */
  33568. getTotalVertices(): number;
  33569. /**
  33570. * Returns a positive integer : the total number of indices in this mesh geometry.
  33571. * @returns the numner of indices or zero if the mesh has no geometry.
  33572. */
  33573. getTotalIndices(): number;
  33574. /**
  33575. * Returns null by default. Implemented by child classes
  33576. * @returns null
  33577. */
  33578. getIndices(): Nullable<IndicesArray>;
  33579. /**
  33580. * Returns the array of the requested vertex data kind. Implemented by child classes
  33581. * @param kind defines the vertex data kind to use
  33582. * @returns null
  33583. */
  33584. getVerticesData(kind: string): Nullable<FloatArray>;
  33585. /**
  33586. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33587. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33588. * Note that a new underlying VertexBuffer object is created each call.
  33589. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33590. * @param kind defines vertex data kind:
  33591. * * VertexBuffer.PositionKind
  33592. * * VertexBuffer.UVKind
  33593. * * VertexBuffer.UV2Kind
  33594. * * VertexBuffer.UV3Kind
  33595. * * VertexBuffer.UV4Kind
  33596. * * VertexBuffer.UV5Kind
  33597. * * VertexBuffer.UV6Kind
  33598. * * VertexBuffer.ColorKind
  33599. * * VertexBuffer.MatricesIndicesKind
  33600. * * VertexBuffer.MatricesIndicesExtraKind
  33601. * * VertexBuffer.MatricesWeightsKind
  33602. * * VertexBuffer.MatricesWeightsExtraKind
  33603. * @param data defines the data source
  33604. * @param updatable defines if the data must be flagged as updatable (or static)
  33605. * @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
  33606. * @returns the current mesh
  33607. */
  33608. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33609. /**
  33610. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33611. * If the mesh has no geometry, it is simply returned as it is.
  33612. * @param kind defines vertex data kind:
  33613. * * VertexBuffer.PositionKind
  33614. * * VertexBuffer.UVKind
  33615. * * VertexBuffer.UV2Kind
  33616. * * VertexBuffer.UV3Kind
  33617. * * VertexBuffer.UV4Kind
  33618. * * VertexBuffer.UV5Kind
  33619. * * VertexBuffer.UV6Kind
  33620. * * VertexBuffer.ColorKind
  33621. * * VertexBuffer.MatricesIndicesKind
  33622. * * VertexBuffer.MatricesIndicesExtraKind
  33623. * * VertexBuffer.MatricesWeightsKind
  33624. * * VertexBuffer.MatricesWeightsExtraKind
  33625. * @param data defines the data source
  33626. * @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
  33627. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33628. * @returns the current mesh
  33629. */
  33630. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33631. /**
  33632. * Sets the mesh indices,
  33633. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33634. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33635. * @param totalVertices Defines the total number of vertices
  33636. * @returns the current mesh
  33637. */
  33638. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33639. /**
  33640. * Gets a boolean indicating if specific vertex data is present
  33641. * @param kind defines the vertex data kind to use
  33642. * @returns true is data kind is present
  33643. */
  33644. isVerticesDataPresent(kind: string): boolean;
  33645. /**
  33646. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33647. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33648. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33649. * @returns a BoundingInfo
  33650. */
  33651. getBoundingInfo(): BoundingInfo;
  33652. /**
  33653. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33654. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33655. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33656. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33657. * @returns the current mesh
  33658. */
  33659. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33660. /**
  33661. * Overwrite the current bounding info
  33662. * @param boundingInfo defines the new bounding info
  33663. * @returns the current mesh
  33664. */
  33665. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33666. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33667. get useBones(): boolean;
  33668. /** @hidden */
  33669. _preActivate(): void;
  33670. /** @hidden */
  33671. _preActivateForIntermediateRendering(renderId: number): void;
  33672. /** @hidden */
  33673. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33674. /** @hidden */
  33675. _postActivate(): void;
  33676. /** @hidden */
  33677. _freeze(): void;
  33678. /** @hidden */
  33679. _unFreeze(): void;
  33680. /**
  33681. * Gets the current world matrix
  33682. * @returns a Matrix
  33683. */
  33684. getWorldMatrix(): Matrix;
  33685. /** @hidden */
  33686. _getWorldMatrixDeterminant(): number;
  33687. /**
  33688. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33689. */
  33690. get isAnInstance(): boolean;
  33691. /**
  33692. * Gets a boolean indicating if this mesh has instances
  33693. */
  33694. get hasInstances(): boolean;
  33695. /**
  33696. * Gets a boolean indicating if this mesh has thin instances
  33697. */
  33698. get hasThinInstances(): boolean;
  33699. /**
  33700. * Perform relative position change from the point of view of behind the front of the mesh.
  33701. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33702. * Supports definition of mesh facing forward or backward
  33703. * @param amountRight defines the distance on the right axis
  33704. * @param amountUp defines the distance on the up axis
  33705. * @param amountForward defines the distance on the forward axis
  33706. * @returns the current mesh
  33707. */
  33708. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33709. /**
  33710. * Calculate relative position change from the point of view of behind the front of the mesh.
  33711. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33712. * Supports definition of mesh facing forward or backward
  33713. * @param amountRight defines the distance on the right axis
  33714. * @param amountUp defines the distance on the up axis
  33715. * @param amountForward defines the distance on the forward axis
  33716. * @returns the new displacement vector
  33717. */
  33718. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33719. /**
  33720. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33721. * Supports definition of mesh facing forward or backward
  33722. * @param flipBack defines the flip
  33723. * @param twirlClockwise defines the twirl
  33724. * @param tiltRight defines the tilt
  33725. * @returns the current mesh
  33726. */
  33727. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33728. /**
  33729. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33730. * Supports definition of mesh facing forward or backward.
  33731. * @param flipBack defines the flip
  33732. * @param twirlClockwise defines the twirl
  33733. * @param tiltRight defines the tilt
  33734. * @returns the new rotation vector
  33735. */
  33736. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33737. /**
  33738. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33739. * This means the mesh underlying bounding box and sphere are recomputed.
  33740. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33741. * @returns the current mesh
  33742. */
  33743. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33744. /** @hidden */
  33745. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33746. /** @hidden */
  33747. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33748. /** @hidden */
  33749. _updateBoundingInfo(): AbstractMesh;
  33750. /** @hidden */
  33751. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33752. /** @hidden */
  33753. protected _afterComputeWorldMatrix(): void;
  33754. /** @hidden */
  33755. get _effectiveMesh(): AbstractMesh;
  33756. /**
  33757. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33758. * A mesh is in the frustum if its bounding box intersects the frustum
  33759. * @param frustumPlanes defines the frustum to test
  33760. * @returns true if the mesh is in the frustum planes
  33761. */
  33762. isInFrustum(frustumPlanes: Plane[]): boolean;
  33763. /**
  33764. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33765. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33766. * @param frustumPlanes defines the frustum to test
  33767. * @returns true if the mesh is completely in the frustum planes
  33768. */
  33769. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33770. /**
  33771. * True if the mesh intersects another mesh or a SolidParticle object
  33772. * @param mesh defines a target mesh or SolidParticle to test
  33773. * @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)
  33774. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33775. * @returns true if there is an intersection
  33776. */
  33777. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33778. /**
  33779. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33780. * @param point defines the point to test
  33781. * @returns true if there is an intersection
  33782. */
  33783. intersectsPoint(point: Vector3): boolean;
  33784. /**
  33785. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33786. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33787. */
  33788. get checkCollisions(): boolean;
  33789. set checkCollisions(collisionEnabled: boolean);
  33790. /**
  33791. * Gets Collider object used to compute collisions (not physics)
  33792. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33793. */
  33794. get collider(): Nullable<Collider>;
  33795. /**
  33796. * Move the mesh using collision engine
  33797. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33798. * @param displacement defines the requested displacement vector
  33799. * @returns the current mesh
  33800. */
  33801. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33802. private _onCollisionPositionChange;
  33803. /** @hidden */
  33804. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33805. /** @hidden */
  33806. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33807. /** @hidden */
  33808. _checkCollision(collider: Collider): AbstractMesh;
  33809. /** @hidden */
  33810. _generatePointsArray(): boolean;
  33811. /**
  33812. * Checks if the passed Ray intersects with the mesh
  33813. * @param ray defines the ray to use
  33814. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33815. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33816. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33817. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33818. * @returns the picking info
  33819. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33820. */
  33821. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33822. /**
  33823. * Clones the current mesh
  33824. * @param name defines the mesh name
  33825. * @param newParent defines the new mesh parent
  33826. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33827. * @returns the new mesh
  33828. */
  33829. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33830. /**
  33831. * Disposes all the submeshes of the current meshnp
  33832. * @returns the current mesh
  33833. */
  33834. releaseSubMeshes(): AbstractMesh;
  33835. /**
  33836. * Releases resources associated with this abstract mesh.
  33837. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33838. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33839. */
  33840. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33841. /**
  33842. * Adds the passed mesh as a child to the current mesh
  33843. * @param mesh defines the child mesh
  33844. * @returns the current mesh
  33845. */
  33846. addChild(mesh: AbstractMesh): AbstractMesh;
  33847. /**
  33848. * Removes the passed mesh from the current mesh children list
  33849. * @param mesh defines the child mesh
  33850. * @returns the current mesh
  33851. */
  33852. removeChild(mesh: AbstractMesh): AbstractMesh;
  33853. /** @hidden */
  33854. private _initFacetData;
  33855. /**
  33856. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33857. * This method can be called within the render loop.
  33858. * 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
  33859. * @returns the current mesh
  33860. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33861. */
  33862. updateFacetData(): AbstractMesh;
  33863. /**
  33864. * Returns the facetLocalNormals array.
  33865. * The normals are expressed in the mesh local spac
  33866. * @returns an array of Vector3
  33867. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33868. */
  33869. getFacetLocalNormals(): Vector3[];
  33870. /**
  33871. * Returns the facetLocalPositions array.
  33872. * The facet positions are expressed in the mesh local space
  33873. * @returns an array of Vector3
  33874. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33875. */
  33876. getFacetLocalPositions(): Vector3[];
  33877. /**
  33878. * Returns the facetLocalPartioning array
  33879. * @returns an array of array of numbers
  33880. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33881. */
  33882. getFacetLocalPartitioning(): number[][];
  33883. /**
  33884. * Returns the i-th facet position in the world system.
  33885. * This method allocates a new Vector3 per call
  33886. * @param i defines the facet index
  33887. * @returns a new Vector3
  33888. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33889. */
  33890. getFacetPosition(i: number): Vector3;
  33891. /**
  33892. * Sets the reference Vector3 with the i-th facet position in the world system
  33893. * @param i defines the facet index
  33894. * @param ref defines the target vector
  33895. * @returns the current mesh
  33896. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33897. */
  33898. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33899. /**
  33900. * Returns the i-th facet normal in the world system.
  33901. * This method allocates a new Vector3 per call
  33902. * @param i defines the facet index
  33903. * @returns a new Vector3
  33904. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33905. */
  33906. getFacetNormal(i: number): Vector3;
  33907. /**
  33908. * Sets the reference Vector3 with the i-th facet normal in the world system
  33909. * @param i defines the facet index
  33910. * @param ref defines the target vector
  33911. * @returns the current mesh
  33912. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33913. */
  33914. getFacetNormalToRef(i: number, ref: Vector3): this;
  33915. /**
  33916. * 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)
  33917. * @param x defines x coordinate
  33918. * @param y defines y coordinate
  33919. * @param z defines z coordinate
  33920. * @returns the array of facet indexes
  33921. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33922. */
  33923. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33924. /**
  33925. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33926. * @param projected sets as the (x,y,z) world projection on the facet
  33927. * @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
  33928. * @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
  33929. * @param x defines x coordinate
  33930. * @param y defines y coordinate
  33931. * @param z defines z coordinate
  33932. * @returns the face index if found (or null instead)
  33933. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33934. */
  33935. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33936. /**
  33937. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33938. * @param projected sets as the (x,y,z) local projection on the facet
  33939. * @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
  33940. * @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
  33941. * @param x defines x coordinate
  33942. * @param y defines y coordinate
  33943. * @param z defines z coordinate
  33944. * @returns the face index if found (or null instead)
  33945. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33946. */
  33947. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33948. /**
  33949. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33950. * @returns the parameters
  33951. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33952. */
  33953. getFacetDataParameters(): any;
  33954. /**
  33955. * Disables the feature FacetData and frees the related memory
  33956. * @returns the current mesh
  33957. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33958. */
  33959. disableFacetData(): AbstractMesh;
  33960. /**
  33961. * Updates the AbstractMesh indices array
  33962. * @param indices defines the data source
  33963. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33964. * @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)
  33965. * @returns the current mesh
  33966. */
  33967. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33968. /**
  33969. * Creates new normals data for the mesh
  33970. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  33971. * @returns the current mesh
  33972. */
  33973. createNormals(updatable: boolean): AbstractMesh;
  33974. /**
  33975. * Align the mesh with a normal
  33976. * @param normal defines the normal to use
  33977. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  33978. * @returns the current mesh
  33979. */
  33980. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  33981. /** @hidden */
  33982. _checkOcclusionQuery(): boolean;
  33983. /**
  33984. * Disables the mesh edge rendering mode
  33985. * @returns the currentAbstractMesh
  33986. */
  33987. disableEdgesRendering(): AbstractMesh;
  33988. /**
  33989. * Enables the edge rendering mode on the mesh.
  33990. * This mode makes the mesh edges visible
  33991. * @param epsilon defines the maximal distance between two angles to detect a face
  33992. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  33993. * @returns the currentAbstractMesh
  33994. * @see https://www.babylonjs-playground.com/#19O9TU#0
  33995. */
  33996. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  33997. /**
  33998. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  33999. * @returns an array of particle systems in the scene that use the mesh as an emitter
  34000. */
  34001. getConnectedParticleSystems(): IParticleSystem[];
  34002. }
  34003. }
  34004. declare module "babylonjs/Actions/actionEvent" {
  34005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34006. import { Nullable } from "babylonjs/types";
  34007. import { Sprite } from "babylonjs/Sprites/sprite";
  34008. import { Scene } from "babylonjs/scene";
  34009. import { Vector2 } from "babylonjs/Maths/math.vector";
  34010. /**
  34011. * Interface used to define ActionEvent
  34012. */
  34013. export interface IActionEvent {
  34014. /** The mesh or sprite that triggered the action */
  34015. source: any;
  34016. /** The X mouse cursor position at the time of the event */
  34017. pointerX: number;
  34018. /** The Y mouse cursor position at the time of the event */
  34019. pointerY: number;
  34020. /** The mesh that is currently pointed at (can be null) */
  34021. meshUnderPointer: Nullable<AbstractMesh>;
  34022. /** the original (browser) event that triggered the ActionEvent */
  34023. sourceEvent?: any;
  34024. /** additional data for the event */
  34025. additionalData?: any;
  34026. }
  34027. /**
  34028. * ActionEvent is the event being sent when an action is triggered.
  34029. */
  34030. export class ActionEvent implements IActionEvent {
  34031. /** The mesh or sprite that triggered the action */
  34032. source: any;
  34033. /** The X mouse cursor position at the time of the event */
  34034. pointerX: number;
  34035. /** The Y mouse cursor position at the time of the event */
  34036. pointerY: number;
  34037. /** The mesh that is currently pointed at (can be null) */
  34038. meshUnderPointer: Nullable<AbstractMesh>;
  34039. /** the original (browser) event that triggered the ActionEvent */
  34040. sourceEvent?: any;
  34041. /** additional data for the event */
  34042. additionalData?: any;
  34043. /**
  34044. * Creates a new ActionEvent
  34045. * @param source The mesh or sprite that triggered the action
  34046. * @param pointerX The X mouse cursor position at the time of the event
  34047. * @param pointerY The Y mouse cursor position at the time of the event
  34048. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  34049. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  34050. * @param additionalData additional data for the event
  34051. */
  34052. constructor(
  34053. /** The mesh or sprite that triggered the action */
  34054. source: any,
  34055. /** The X mouse cursor position at the time of the event */
  34056. pointerX: number,
  34057. /** The Y mouse cursor position at the time of the event */
  34058. pointerY: number,
  34059. /** The mesh that is currently pointed at (can be null) */
  34060. meshUnderPointer: Nullable<AbstractMesh>,
  34061. /** the original (browser) event that triggered the ActionEvent */
  34062. sourceEvent?: any,
  34063. /** additional data for the event */
  34064. additionalData?: any);
  34065. /**
  34066. * Helper function to auto-create an ActionEvent from a source mesh.
  34067. * @param source The source mesh that triggered the event
  34068. * @param evt The original (browser) event
  34069. * @param additionalData additional data for the event
  34070. * @returns the new ActionEvent
  34071. */
  34072. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  34073. /**
  34074. * Helper function to auto-create an ActionEvent from a source sprite
  34075. * @param source The source sprite that triggered the event
  34076. * @param scene Scene associated with the sprite
  34077. * @param evt The original (browser) event
  34078. * @param additionalData additional data for the event
  34079. * @returns the new ActionEvent
  34080. */
  34081. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  34082. /**
  34083. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  34084. * @param scene the scene where the event occurred
  34085. * @param evt The original (browser) event
  34086. * @returns the new ActionEvent
  34087. */
  34088. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  34089. /**
  34090. * Helper function to auto-create an ActionEvent from a primitive
  34091. * @param prim defines the target primitive
  34092. * @param pointerPos defines the pointer position
  34093. * @param evt The original (browser) event
  34094. * @param additionalData additional data for the event
  34095. * @returns the new ActionEvent
  34096. */
  34097. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  34098. }
  34099. }
  34100. declare module "babylonjs/Actions/abstractActionManager" {
  34101. import { IDisposable } from "babylonjs/scene";
  34102. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  34103. import { IAction } from "babylonjs/Actions/action";
  34104. import { Nullable } from "babylonjs/types";
  34105. /**
  34106. * Abstract class used to decouple action Manager from scene and meshes.
  34107. * Do not instantiate.
  34108. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  34109. */
  34110. export abstract class AbstractActionManager implements IDisposable {
  34111. /** Gets the list of active triggers */
  34112. static Triggers: {
  34113. [key: string]: number;
  34114. };
  34115. /** Gets the cursor to use when hovering items */
  34116. hoverCursor: string;
  34117. /** Gets the list of actions */
  34118. actions: IAction[];
  34119. /**
  34120. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  34121. */
  34122. isRecursive: boolean;
  34123. /**
  34124. * Releases all associated resources
  34125. */
  34126. abstract dispose(): void;
  34127. /**
  34128. * Does this action manager has pointer triggers
  34129. */
  34130. abstract get hasPointerTriggers(): boolean;
  34131. /**
  34132. * Does this action manager has pick triggers
  34133. */
  34134. abstract get hasPickTriggers(): boolean;
  34135. /**
  34136. * Process a specific trigger
  34137. * @param trigger defines the trigger to process
  34138. * @param evt defines the event details to be processed
  34139. */
  34140. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  34141. /**
  34142. * Does this action manager handles actions of any of the given triggers
  34143. * @param triggers defines the triggers to be tested
  34144. * @return a boolean indicating whether one (or more) of the triggers is handled
  34145. */
  34146. abstract hasSpecificTriggers(triggers: number[]): boolean;
  34147. /**
  34148. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  34149. * speed.
  34150. * @param triggerA defines the trigger to be tested
  34151. * @param triggerB defines the trigger to be tested
  34152. * @return a boolean indicating whether one (or more) of the triggers is handled
  34153. */
  34154. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  34155. /**
  34156. * Does this action manager handles actions of a given trigger
  34157. * @param trigger defines the trigger to be tested
  34158. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  34159. * @return whether the trigger is handled
  34160. */
  34161. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  34162. /**
  34163. * Serialize this manager to a JSON object
  34164. * @param name defines the property name to store this manager
  34165. * @returns a JSON representation of this manager
  34166. */
  34167. abstract serialize(name: string): any;
  34168. /**
  34169. * Registers an action to this action manager
  34170. * @param action defines the action to be registered
  34171. * @return the action amended (prepared) after registration
  34172. */
  34173. abstract registerAction(action: IAction): Nullable<IAction>;
  34174. /**
  34175. * Unregisters an action to this action manager
  34176. * @param action defines the action to be unregistered
  34177. * @return a boolean indicating whether the action has been unregistered
  34178. */
  34179. abstract unregisterAction(action: IAction): Boolean;
  34180. /**
  34181. * Does exist one action manager with at least one trigger
  34182. **/
  34183. static get HasTriggers(): boolean;
  34184. /**
  34185. * Does exist one action manager with at least one pick trigger
  34186. **/
  34187. static get HasPickTriggers(): boolean;
  34188. /**
  34189. * Does exist one action manager that handles actions of a given trigger
  34190. * @param trigger defines the trigger to be tested
  34191. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34192. **/
  34193. static HasSpecificTrigger(trigger: number): boolean;
  34194. }
  34195. }
  34196. declare module "babylonjs/node" {
  34197. import { Scene } from "babylonjs/scene";
  34198. import { Nullable } from "babylonjs/types";
  34199. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34200. import { Engine } from "babylonjs/Engines/engine";
  34201. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34202. import { Observable } from "babylonjs/Misc/observable";
  34203. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34204. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34205. import { Animatable } from "babylonjs/Animations/animatable";
  34206. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34207. import { Animation } from "babylonjs/Animations/animation";
  34208. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34210. /**
  34211. * Defines how a node can be built from a string name.
  34212. */
  34213. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34214. /**
  34215. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34216. */
  34217. export class Node implements IBehaviorAware<Node> {
  34218. /** @hidden */
  34219. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34220. private static _NodeConstructors;
  34221. /**
  34222. * Add a new node constructor
  34223. * @param type defines the type name of the node to construct
  34224. * @param constructorFunc defines the constructor function
  34225. */
  34226. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34227. /**
  34228. * Returns a node constructor based on type name
  34229. * @param type defines the type name
  34230. * @param name defines the new node name
  34231. * @param scene defines the hosting scene
  34232. * @param options defines optional options to transmit to constructors
  34233. * @returns the new constructor or null
  34234. */
  34235. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34236. /**
  34237. * Gets or sets the name of the node
  34238. */
  34239. name: string;
  34240. /**
  34241. * Gets or sets the id of the node
  34242. */
  34243. id: string;
  34244. /**
  34245. * Gets or sets the unique id of the node
  34246. */
  34247. uniqueId: number;
  34248. /**
  34249. * Gets or sets a string used to store user defined state for the node
  34250. */
  34251. state: string;
  34252. /**
  34253. * Gets or sets an object used to store user defined information for the node
  34254. */
  34255. metadata: any;
  34256. /**
  34257. * For internal use only. Please do not use.
  34258. */
  34259. reservedDataStore: any;
  34260. /**
  34261. * List of inspectable custom properties (used by the Inspector)
  34262. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34263. */
  34264. inspectableCustomProperties: IInspectable[];
  34265. private _doNotSerialize;
  34266. /**
  34267. * Gets or sets a boolean used to define if the node must be serialized
  34268. */
  34269. get doNotSerialize(): boolean;
  34270. set doNotSerialize(value: boolean);
  34271. /** @hidden */
  34272. _isDisposed: boolean;
  34273. /**
  34274. * Gets a list of Animations associated with the node
  34275. */
  34276. animations: import("babylonjs/Animations/animation").Animation[];
  34277. protected _ranges: {
  34278. [name: string]: Nullable<AnimationRange>;
  34279. };
  34280. /**
  34281. * Callback raised when the node is ready to be used
  34282. */
  34283. onReady: Nullable<(node: Node) => void>;
  34284. private _isEnabled;
  34285. private _isParentEnabled;
  34286. private _isReady;
  34287. /** @hidden */
  34288. _currentRenderId: number;
  34289. private _parentUpdateId;
  34290. /** @hidden */
  34291. _childUpdateId: number;
  34292. /** @hidden */
  34293. _waitingParentId: Nullable<string>;
  34294. /** @hidden */
  34295. _scene: Scene;
  34296. /** @hidden */
  34297. _cache: any;
  34298. private _parentNode;
  34299. private _children;
  34300. /** @hidden */
  34301. _worldMatrix: Matrix;
  34302. /** @hidden */
  34303. _worldMatrixDeterminant: number;
  34304. /** @hidden */
  34305. _worldMatrixDeterminantIsDirty: boolean;
  34306. /** @hidden */
  34307. private _sceneRootNodesIndex;
  34308. /**
  34309. * Gets a boolean indicating if the node has been disposed
  34310. * @returns true if the node was disposed
  34311. */
  34312. isDisposed(): boolean;
  34313. /**
  34314. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34315. * @see https://doc.babylonjs.com/how_to/parenting
  34316. */
  34317. set parent(parent: Nullable<Node>);
  34318. get parent(): Nullable<Node>;
  34319. /** @hidden */
  34320. _addToSceneRootNodes(): void;
  34321. /** @hidden */
  34322. _removeFromSceneRootNodes(): void;
  34323. private _animationPropertiesOverride;
  34324. /**
  34325. * Gets or sets the animation properties override
  34326. */
  34327. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34328. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34329. /**
  34330. * Gets a string identifying the name of the class
  34331. * @returns "Node" string
  34332. */
  34333. getClassName(): string;
  34334. /** @hidden */
  34335. readonly _isNode: boolean;
  34336. /**
  34337. * An event triggered when the mesh is disposed
  34338. */
  34339. onDisposeObservable: Observable<Node>;
  34340. private _onDisposeObserver;
  34341. /**
  34342. * Sets a callback that will be raised when the node will be disposed
  34343. */
  34344. set onDispose(callback: () => void);
  34345. /**
  34346. * Creates a new Node
  34347. * @param name the name and id to be given to this node
  34348. * @param scene the scene this node will be added to
  34349. */
  34350. constructor(name: string, scene?: Nullable<Scene>);
  34351. /**
  34352. * Gets the scene of the node
  34353. * @returns a scene
  34354. */
  34355. getScene(): Scene;
  34356. /**
  34357. * Gets the engine of the node
  34358. * @returns a Engine
  34359. */
  34360. getEngine(): Engine;
  34361. private _behaviors;
  34362. /**
  34363. * Attach a behavior to the node
  34364. * @see https://doc.babylonjs.com/features/behaviour
  34365. * @param behavior defines the behavior to attach
  34366. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34367. * @returns the current Node
  34368. */
  34369. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34370. /**
  34371. * Remove an attached behavior
  34372. * @see https://doc.babylonjs.com/features/behaviour
  34373. * @param behavior defines the behavior to attach
  34374. * @returns the current Node
  34375. */
  34376. removeBehavior(behavior: Behavior<Node>): Node;
  34377. /**
  34378. * Gets the list of attached behaviors
  34379. * @see https://doc.babylonjs.com/features/behaviour
  34380. */
  34381. get behaviors(): Behavior<Node>[];
  34382. /**
  34383. * Gets an attached behavior by name
  34384. * @param name defines the name of the behavior to look for
  34385. * @see https://doc.babylonjs.com/features/behaviour
  34386. * @returns null if behavior was not found else the requested behavior
  34387. */
  34388. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34389. /**
  34390. * Returns the latest update of the World matrix
  34391. * @returns a Matrix
  34392. */
  34393. getWorldMatrix(): Matrix;
  34394. /** @hidden */
  34395. _getWorldMatrixDeterminant(): number;
  34396. /**
  34397. * Returns directly the latest state of the mesh World matrix.
  34398. * A Matrix is returned.
  34399. */
  34400. get worldMatrixFromCache(): Matrix;
  34401. /** @hidden */
  34402. _initCache(): void;
  34403. /** @hidden */
  34404. updateCache(force?: boolean): void;
  34405. /** @hidden */
  34406. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34407. /** @hidden */
  34408. _updateCache(ignoreParentClass?: boolean): void;
  34409. /** @hidden */
  34410. _isSynchronized(): boolean;
  34411. /** @hidden */
  34412. _markSyncedWithParent(): void;
  34413. /** @hidden */
  34414. isSynchronizedWithParent(): boolean;
  34415. /** @hidden */
  34416. isSynchronized(): boolean;
  34417. /**
  34418. * Is this node ready to be used/rendered
  34419. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34420. * @return true if the node is ready
  34421. */
  34422. isReady(completeCheck?: boolean): boolean;
  34423. /**
  34424. * Is this node enabled?
  34425. * 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
  34426. * @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
  34427. * @return whether this node (and its parent) is enabled
  34428. */
  34429. isEnabled(checkAncestors?: boolean): boolean;
  34430. /** @hidden */
  34431. protected _syncParentEnabledState(): void;
  34432. /**
  34433. * Set the enabled state of this node
  34434. * @param value defines the new enabled state
  34435. */
  34436. setEnabled(value: boolean): void;
  34437. /**
  34438. * Is this node a descendant of the given node?
  34439. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34440. * @param ancestor defines the parent node to inspect
  34441. * @returns a boolean indicating if this node is a descendant of the given node
  34442. */
  34443. isDescendantOf(ancestor: Node): boolean;
  34444. /** @hidden */
  34445. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34446. /**
  34447. * Will return all nodes that have this node as ascendant
  34448. * @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
  34449. * @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
  34450. * @return all children nodes of all types
  34451. */
  34452. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34453. /**
  34454. * Get all child-meshes of this node
  34455. * @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)
  34456. * @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
  34457. * @returns an array of AbstractMesh
  34458. */
  34459. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34460. /**
  34461. * Get all direct children of this node
  34462. * @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
  34463. * @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)
  34464. * @returns an array of Node
  34465. */
  34466. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34467. /** @hidden */
  34468. _setReady(state: boolean): void;
  34469. /**
  34470. * Get an animation by name
  34471. * @param name defines the name of the animation to look for
  34472. * @returns null if not found else the requested animation
  34473. */
  34474. getAnimationByName(name: string): Nullable<Animation>;
  34475. /**
  34476. * Creates an animation range for this node
  34477. * @param name defines the name of the range
  34478. * @param from defines the starting key
  34479. * @param to defines the end key
  34480. */
  34481. createAnimationRange(name: string, from: number, to: number): void;
  34482. /**
  34483. * Delete a specific animation range
  34484. * @param name defines the name of the range to delete
  34485. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34486. */
  34487. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34488. /**
  34489. * Get an animation range by name
  34490. * @param name defines the name of the animation range to look for
  34491. * @returns null if not found else the requested animation range
  34492. */
  34493. getAnimationRange(name: string): Nullable<AnimationRange>;
  34494. /**
  34495. * Gets the list of all animation ranges defined on this node
  34496. * @returns an array
  34497. */
  34498. getAnimationRanges(): Nullable<AnimationRange>[];
  34499. /**
  34500. * Will start the animation sequence
  34501. * @param name defines the range frames for animation sequence
  34502. * @param loop defines if the animation should loop (false by default)
  34503. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34504. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34505. * @returns the object created for this animation. If range does not exist, it will return null
  34506. */
  34507. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34508. /**
  34509. * Serialize animation ranges into a JSON compatible object
  34510. * @returns serialization object
  34511. */
  34512. serializeAnimationRanges(): any;
  34513. /**
  34514. * Computes the world matrix of the node
  34515. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34516. * @returns the world matrix
  34517. */
  34518. computeWorldMatrix(force?: boolean): Matrix;
  34519. /**
  34520. * Releases resources associated with this node.
  34521. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34522. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34523. */
  34524. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34525. /**
  34526. * Parse animation range data from a serialization object and store them into a given node
  34527. * @param node defines where to store the animation ranges
  34528. * @param parsedNode defines the serialization object to read data from
  34529. * @param scene defines the hosting scene
  34530. */
  34531. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34532. /**
  34533. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34534. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34535. * @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
  34536. * @returns the new bounding vectors
  34537. */
  34538. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34539. min: Vector3;
  34540. max: Vector3;
  34541. };
  34542. }
  34543. }
  34544. declare module "babylonjs/Animations/animation" {
  34545. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34546. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34547. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34548. import { Nullable } from "babylonjs/types";
  34549. import { Scene } from "babylonjs/scene";
  34550. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34551. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34552. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34553. import { Node } from "babylonjs/node";
  34554. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34555. import { Size } from "babylonjs/Maths/math.size";
  34556. import { Animatable } from "babylonjs/Animations/animatable";
  34557. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34558. /**
  34559. * @hidden
  34560. */
  34561. export class _IAnimationState {
  34562. key: number;
  34563. repeatCount: number;
  34564. workValue?: any;
  34565. loopMode?: number;
  34566. offsetValue?: any;
  34567. highLimitValue?: any;
  34568. }
  34569. /**
  34570. * Class used to store any kind of animation
  34571. */
  34572. export class Animation {
  34573. /**Name of the animation */
  34574. name: string;
  34575. /**Property to animate */
  34576. targetProperty: string;
  34577. /**The frames per second of the animation */
  34578. framePerSecond: number;
  34579. /**The data type of the animation */
  34580. dataType: number;
  34581. /**The loop mode of the animation */
  34582. loopMode?: number | undefined;
  34583. /**Specifies if blending should be enabled */
  34584. enableBlending?: boolean | undefined;
  34585. /**
  34586. * Use matrix interpolation instead of using direct key value when animating matrices
  34587. */
  34588. static AllowMatricesInterpolation: boolean;
  34589. /**
  34590. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34591. */
  34592. static AllowMatrixDecomposeForInterpolation: boolean;
  34593. /** Define the Url to load snippets */
  34594. static SnippetUrl: string;
  34595. /** Snippet ID if the animation was created from the snippet server */
  34596. snippetId: string;
  34597. /**
  34598. * Stores the key frames of the animation
  34599. */
  34600. private _keys;
  34601. /**
  34602. * Stores the easing function of the animation
  34603. */
  34604. private _easingFunction;
  34605. /**
  34606. * @hidden Internal use only
  34607. */
  34608. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34609. /**
  34610. * The set of event that will be linked to this animation
  34611. */
  34612. private _events;
  34613. /**
  34614. * Stores an array of target property paths
  34615. */
  34616. targetPropertyPath: string[];
  34617. /**
  34618. * Stores the blending speed of the animation
  34619. */
  34620. blendingSpeed: number;
  34621. /**
  34622. * Stores the animation ranges for the animation
  34623. */
  34624. private _ranges;
  34625. /**
  34626. * @hidden Internal use
  34627. */
  34628. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34629. /**
  34630. * Sets up an animation
  34631. * @param property The property to animate
  34632. * @param animationType The animation type to apply
  34633. * @param framePerSecond The frames per second of the animation
  34634. * @param easingFunction The easing function used in the animation
  34635. * @returns The created animation
  34636. */
  34637. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34638. /**
  34639. * Create and start an animation on a node
  34640. * @param name defines the name of the global animation that will be run on all nodes
  34641. * @param node defines the root node where the animation will take place
  34642. * @param targetProperty defines property to animate
  34643. * @param framePerSecond defines the number of frame per second yo use
  34644. * @param totalFrame defines the number of frames in total
  34645. * @param from defines the initial value
  34646. * @param to defines the final value
  34647. * @param loopMode defines which loop mode you want to use (off by default)
  34648. * @param easingFunction defines the easing function to use (linear by default)
  34649. * @param onAnimationEnd defines the callback to call when animation end
  34650. * @returns the animatable created for this animation
  34651. */
  34652. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34653. /**
  34654. * Create and start an animation on a node and its descendants
  34655. * @param name defines the name of the global animation that will be run on all nodes
  34656. * @param node defines the root node where the animation will take place
  34657. * @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
  34658. * @param targetProperty defines property to animate
  34659. * @param framePerSecond defines the number of frame per second to use
  34660. * @param totalFrame defines the number of frames in total
  34661. * @param from defines the initial value
  34662. * @param to defines the final value
  34663. * @param loopMode defines which loop mode you want to use (off by default)
  34664. * @param easingFunction defines the easing function to use (linear by default)
  34665. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34666. * @returns the list of animatables created for all nodes
  34667. * @example https://www.babylonjs-playground.com/#MH0VLI
  34668. */
  34669. 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[]>;
  34670. /**
  34671. * Creates a new animation, merges it with the existing animations and starts it
  34672. * @param name Name of the animation
  34673. * @param node Node which contains the scene that begins the animations
  34674. * @param targetProperty Specifies which property to animate
  34675. * @param framePerSecond The frames per second of the animation
  34676. * @param totalFrame The total number of frames
  34677. * @param from The frame at the beginning of the animation
  34678. * @param to The frame at the end of the animation
  34679. * @param loopMode Specifies the loop mode of the animation
  34680. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34681. * @param onAnimationEnd Callback to run once the animation is complete
  34682. * @returns Nullable animation
  34683. */
  34684. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34685. /**
  34686. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34687. * @param sourceAnimation defines the Animation containing keyframes to convert
  34688. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34689. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34690. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34691. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34692. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34693. */
  34694. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34695. /**
  34696. * Transition property of an host to the target Value
  34697. * @param property The property to transition
  34698. * @param targetValue The target Value of the property
  34699. * @param host The object where the property to animate belongs
  34700. * @param scene Scene used to run the animation
  34701. * @param frameRate Framerate (in frame/s) to use
  34702. * @param transition The transition type we want to use
  34703. * @param duration The duration of the animation, in milliseconds
  34704. * @param onAnimationEnd Callback trigger at the end of the animation
  34705. * @returns Nullable animation
  34706. */
  34707. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34708. /**
  34709. * Return the array of runtime animations currently using this animation
  34710. */
  34711. get runtimeAnimations(): RuntimeAnimation[];
  34712. /**
  34713. * Specifies if any of the runtime animations are currently running
  34714. */
  34715. get hasRunningRuntimeAnimations(): boolean;
  34716. /**
  34717. * Initializes the animation
  34718. * @param name Name of the animation
  34719. * @param targetProperty Property to animate
  34720. * @param framePerSecond The frames per second of the animation
  34721. * @param dataType The data type of the animation
  34722. * @param loopMode The loop mode of the animation
  34723. * @param enableBlending Specifies if blending should be enabled
  34724. */
  34725. constructor(
  34726. /**Name of the animation */
  34727. name: string,
  34728. /**Property to animate */
  34729. targetProperty: string,
  34730. /**The frames per second of the animation */
  34731. framePerSecond: number,
  34732. /**The data type of the animation */
  34733. dataType: number,
  34734. /**The loop mode of the animation */
  34735. loopMode?: number | undefined,
  34736. /**Specifies if blending should be enabled */
  34737. enableBlending?: boolean | undefined);
  34738. /**
  34739. * Converts the animation to a string
  34740. * @param fullDetails support for multiple levels of logging within scene loading
  34741. * @returns String form of the animation
  34742. */
  34743. toString(fullDetails?: boolean): string;
  34744. /**
  34745. * Add an event to this animation
  34746. * @param event Event to add
  34747. */
  34748. addEvent(event: AnimationEvent): void;
  34749. /**
  34750. * Remove all events found at the given frame
  34751. * @param frame The frame to remove events from
  34752. */
  34753. removeEvents(frame: number): void;
  34754. /**
  34755. * Retrieves all the events from the animation
  34756. * @returns Events from the animation
  34757. */
  34758. getEvents(): AnimationEvent[];
  34759. /**
  34760. * Creates an animation range
  34761. * @param name Name of the animation range
  34762. * @param from Starting frame of the animation range
  34763. * @param to Ending frame of the animation
  34764. */
  34765. createRange(name: string, from: number, to: number): void;
  34766. /**
  34767. * Deletes an animation range by name
  34768. * @param name Name of the animation range to delete
  34769. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34770. */
  34771. deleteRange(name: string, deleteFrames?: boolean): void;
  34772. /**
  34773. * Gets the animation range by name, or null if not defined
  34774. * @param name Name of the animation range
  34775. * @returns Nullable animation range
  34776. */
  34777. getRange(name: string): Nullable<AnimationRange>;
  34778. /**
  34779. * Gets the key frames from the animation
  34780. * @returns The key frames of the animation
  34781. */
  34782. getKeys(): Array<IAnimationKey>;
  34783. /**
  34784. * Gets the highest frame rate of the animation
  34785. * @returns Highest frame rate of the animation
  34786. */
  34787. getHighestFrame(): number;
  34788. /**
  34789. * Gets the easing function of the animation
  34790. * @returns Easing function of the animation
  34791. */
  34792. getEasingFunction(): IEasingFunction;
  34793. /**
  34794. * Sets the easing function of the animation
  34795. * @param easingFunction A custom mathematical formula for animation
  34796. */
  34797. setEasingFunction(easingFunction: EasingFunction): void;
  34798. /**
  34799. * Interpolates a scalar linearly
  34800. * @param startValue Start value of the animation curve
  34801. * @param endValue End value of the animation curve
  34802. * @param gradient Scalar amount to interpolate
  34803. * @returns Interpolated scalar value
  34804. */
  34805. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34806. /**
  34807. * Interpolates a scalar cubically
  34808. * @param startValue Start value of the animation curve
  34809. * @param outTangent End tangent of the animation
  34810. * @param endValue End value of the animation curve
  34811. * @param inTangent Start tangent of the animation curve
  34812. * @param gradient Scalar amount to interpolate
  34813. * @returns Interpolated scalar value
  34814. */
  34815. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34816. /**
  34817. * Interpolates a quaternion using a spherical linear interpolation
  34818. * @param startValue Start value of the animation curve
  34819. * @param endValue End value of the animation curve
  34820. * @param gradient Scalar amount to interpolate
  34821. * @returns Interpolated quaternion value
  34822. */
  34823. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34824. /**
  34825. * Interpolates a quaternion cubically
  34826. * @param startValue Start value of the animation curve
  34827. * @param outTangent End tangent of the animation curve
  34828. * @param endValue End value of the animation curve
  34829. * @param inTangent Start tangent of the animation curve
  34830. * @param gradient Scalar amount to interpolate
  34831. * @returns Interpolated quaternion value
  34832. */
  34833. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34834. /**
  34835. * Interpolates a Vector3 linearl
  34836. * @param startValue Start value of the animation curve
  34837. * @param endValue End value of the animation curve
  34838. * @param gradient Scalar amount to interpolate
  34839. * @returns Interpolated scalar value
  34840. */
  34841. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34842. /**
  34843. * Interpolates a Vector3 cubically
  34844. * @param startValue Start value of the animation curve
  34845. * @param outTangent End tangent of the animation
  34846. * @param endValue End value of the animation curve
  34847. * @param inTangent Start tangent of the animation curve
  34848. * @param gradient Scalar amount to interpolate
  34849. * @returns InterpolatedVector3 value
  34850. */
  34851. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34852. /**
  34853. * Interpolates a Vector2 linearly
  34854. * @param startValue Start value of the animation curve
  34855. * @param endValue End value of the animation curve
  34856. * @param gradient Scalar amount to interpolate
  34857. * @returns Interpolated Vector2 value
  34858. */
  34859. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34860. /**
  34861. * Interpolates a Vector2 cubically
  34862. * @param startValue Start value of the animation curve
  34863. * @param outTangent End tangent of the animation
  34864. * @param endValue End value of the animation curve
  34865. * @param inTangent Start tangent of the animation curve
  34866. * @param gradient Scalar amount to interpolate
  34867. * @returns Interpolated Vector2 value
  34868. */
  34869. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34870. /**
  34871. * Interpolates a size linearly
  34872. * @param startValue Start value of the animation curve
  34873. * @param endValue End value of the animation curve
  34874. * @param gradient Scalar amount to interpolate
  34875. * @returns Interpolated Size value
  34876. */
  34877. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34878. /**
  34879. * Interpolates a Color3 linearly
  34880. * @param startValue Start value of the animation curve
  34881. * @param endValue End value of the animation curve
  34882. * @param gradient Scalar amount to interpolate
  34883. * @returns Interpolated Color3 value
  34884. */
  34885. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34886. /**
  34887. * Interpolates a Color4 linearly
  34888. * @param startValue Start value of the animation curve
  34889. * @param endValue End value of the animation curve
  34890. * @param gradient Scalar amount to interpolate
  34891. * @returns Interpolated Color3 value
  34892. */
  34893. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34894. /**
  34895. * @hidden Internal use only
  34896. */
  34897. _getKeyValue(value: any): any;
  34898. /**
  34899. * @hidden Internal use only
  34900. */
  34901. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34902. /**
  34903. * Defines the function to use to interpolate matrices
  34904. * @param startValue defines the start matrix
  34905. * @param endValue defines the end matrix
  34906. * @param gradient defines the gradient between both matrices
  34907. * @param result defines an optional target matrix where to store the interpolation
  34908. * @returns the interpolated matrix
  34909. */
  34910. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34911. /**
  34912. * Makes a copy of the animation
  34913. * @returns Cloned animation
  34914. */
  34915. clone(): Animation;
  34916. /**
  34917. * Sets the key frames of the animation
  34918. * @param values The animation key frames to set
  34919. */
  34920. setKeys(values: Array<IAnimationKey>): void;
  34921. /**
  34922. * Serializes the animation to an object
  34923. * @returns Serialized object
  34924. */
  34925. serialize(): any;
  34926. /**
  34927. * Float animation type
  34928. */
  34929. static readonly ANIMATIONTYPE_FLOAT: number;
  34930. /**
  34931. * Vector3 animation type
  34932. */
  34933. static readonly ANIMATIONTYPE_VECTOR3: number;
  34934. /**
  34935. * Quaternion animation type
  34936. */
  34937. static readonly ANIMATIONTYPE_QUATERNION: number;
  34938. /**
  34939. * Matrix animation type
  34940. */
  34941. static readonly ANIMATIONTYPE_MATRIX: number;
  34942. /**
  34943. * Color3 animation type
  34944. */
  34945. static readonly ANIMATIONTYPE_COLOR3: number;
  34946. /**
  34947. * Color3 animation type
  34948. */
  34949. static readonly ANIMATIONTYPE_COLOR4: number;
  34950. /**
  34951. * Vector2 animation type
  34952. */
  34953. static readonly ANIMATIONTYPE_VECTOR2: number;
  34954. /**
  34955. * Size animation type
  34956. */
  34957. static readonly ANIMATIONTYPE_SIZE: number;
  34958. /**
  34959. * Relative Loop Mode
  34960. */
  34961. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34962. /**
  34963. * Cycle Loop Mode
  34964. */
  34965. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34966. /**
  34967. * Constant Loop Mode
  34968. */
  34969. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  34970. /** @hidden */
  34971. static _UniversalLerp(left: any, right: any, amount: number): any;
  34972. /**
  34973. * Parses an animation object and creates an animation
  34974. * @param parsedAnimation Parsed animation object
  34975. * @returns Animation object
  34976. */
  34977. static Parse(parsedAnimation: any): Animation;
  34978. /**
  34979. * Appends the serialized animations from the source animations
  34980. * @param source Source containing the animations
  34981. * @param destination Target to store the animations
  34982. */
  34983. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34984. /**
  34985. * Creates a new animation or an array of animations from a snippet saved in a remote file
  34986. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  34987. * @param url defines the url to load from
  34988. * @returns a promise that will resolve to the new animation or an array of animations
  34989. */
  34990. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  34991. /**
  34992. * Creates an animation or an array of animations from a snippet saved by the Inspector
  34993. * @param snippetId defines the snippet to load
  34994. * @returns a promise that will resolve to the new animation or a new array of animations
  34995. */
  34996. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  34997. }
  34998. }
  34999. declare module "babylonjs/Animations/animatable.interface" {
  35000. import { Nullable } from "babylonjs/types";
  35001. import { Animation } from "babylonjs/Animations/animation";
  35002. /**
  35003. * Interface containing an array of animations
  35004. */
  35005. export interface IAnimatable {
  35006. /**
  35007. * Array of animations
  35008. */
  35009. animations: Nullable<Array<Animation>>;
  35010. }
  35011. }
  35012. declare module "babylonjs/Misc/decorators" {
  35013. import { Nullable } from "babylonjs/types";
  35014. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35015. import { Scene } from "babylonjs/scene";
  35016. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35017. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  35018. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  35019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35020. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  35021. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35022. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35023. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35024. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35025. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35026. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35027. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35028. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35029. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35030. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35031. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35032. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35033. /**
  35034. * Decorator used to define property that can be serialized as reference to a camera
  35035. * @param sourceName defines the name of the property to decorate
  35036. */
  35037. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35038. /**
  35039. * Class used to help serialization objects
  35040. */
  35041. export class SerializationHelper {
  35042. /** @hidden */
  35043. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  35044. /** @hidden */
  35045. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  35046. /** @hidden */
  35047. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  35048. /** @hidden */
  35049. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  35050. /**
  35051. * Appends the serialized animations from the source animations
  35052. * @param source Source containing the animations
  35053. * @param destination Target to store the animations
  35054. */
  35055. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35056. /**
  35057. * Static function used to serialized a specific entity
  35058. * @param entity defines the entity to serialize
  35059. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  35060. * @returns a JSON compatible object representing the serialization of the entity
  35061. */
  35062. static Serialize<T>(entity: T, serializationObject?: any): any;
  35063. /**
  35064. * Creates a new entity from a serialization data object
  35065. * @param creationFunction defines a function used to instanciated the new entity
  35066. * @param source defines the source serialization data
  35067. * @param scene defines the hosting scene
  35068. * @param rootUrl defines the root url for resources
  35069. * @returns a new entity
  35070. */
  35071. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  35072. /**
  35073. * Clones an object
  35074. * @param creationFunction defines the function used to instanciate the new object
  35075. * @param source defines the source object
  35076. * @returns the cloned object
  35077. */
  35078. static Clone<T>(creationFunction: () => T, source: T): T;
  35079. /**
  35080. * Instanciates a new object based on a source one (some data will be shared between both object)
  35081. * @param creationFunction defines the function used to instanciate the new object
  35082. * @param source defines the source object
  35083. * @returns the new object
  35084. */
  35085. static Instanciate<T>(creationFunction: () => T, source: T): T;
  35086. }
  35087. }
  35088. declare module "babylonjs/Materials/Textures/baseTexture" {
  35089. import { Observable } from "babylonjs/Misc/observable";
  35090. import { Nullable } from "babylonjs/types";
  35091. import { Scene } from "babylonjs/scene";
  35092. import { Matrix } from "babylonjs/Maths/math.vector";
  35093. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35094. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35095. import { ISize } from "babylonjs/Maths/math.size";
  35096. import "babylonjs/Misc/fileTools";
  35097. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35098. /**
  35099. * Base class of all the textures in babylon.
  35100. * It groups all the common properties the materials, post process, lights... might need
  35101. * in order to make a correct use of the texture.
  35102. */
  35103. export class BaseTexture implements IAnimatable {
  35104. /**
  35105. * Default anisotropic filtering level for the application.
  35106. * It is set to 4 as a good tradeoff between perf and quality.
  35107. */
  35108. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35109. /**
  35110. * Gets or sets the unique id of the texture
  35111. */
  35112. uniqueId: number;
  35113. /**
  35114. * Define the name of the texture.
  35115. */
  35116. name: string;
  35117. /**
  35118. * Gets or sets an object used to store user defined information.
  35119. */
  35120. metadata: any;
  35121. /**
  35122. * For internal use only. Please do not use.
  35123. */
  35124. reservedDataStore: any;
  35125. private _hasAlpha;
  35126. /**
  35127. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  35128. */
  35129. set hasAlpha(value: boolean);
  35130. get hasAlpha(): boolean;
  35131. /**
  35132. * Defines if the alpha value should be determined via the rgb values.
  35133. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  35134. */
  35135. getAlphaFromRGB: boolean;
  35136. /**
  35137. * Intensity or strength of the texture.
  35138. * It is commonly used by materials to fine tune the intensity of the texture
  35139. */
  35140. level: number;
  35141. /**
  35142. * Define the UV chanel to use starting from 0 and defaulting to 0.
  35143. * This is part of the texture as textures usually maps to one uv set.
  35144. */
  35145. coordinatesIndex: number;
  35146. protected _coordinatesMode: number;
  35147. /**
  35148. * How a texture is mapped.
  35149. *
  35150. * | Value | Type | Description |
  35151. * | ----- | ----------------------------------- | ----------- |
  35152. * | 0 | EXPLICIT_MODE | |
  35153. * | 1 | SPHERICAL_MODE | |
  35154. * | 2 | PLANAR_MODE | |
  35155. * | 3 | CUBIC_MODE | |
  35156. * | 4 | PROJECTION_MODE | |
  35157. * | 5 | SKYBOX_MODE | |
  35158. * | 6 | INVCUBIC_MODE | |
  35159. * | 7 | EQUIRECTANGULAR_MODE | |
  35160. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35161. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35162. */
  35163. set coordinatesMode(value: number);
  35164. get coordinatesMode(): number;
  35165. private _wrapU;
  35166. /**
  35167. * | Value | Type | Description |
  35168. * | ----- | ------------------ | ----------- |
  35169. * | 0 | CLAMP_ADDRESSMODE | |
  35170. * | 1 | WRAP_ADDRESSMODE | |
  35171. * | 2 | MIRROR_ADDRESSMODE | |
  35172. */
  35173. get wrapU(): number;
  35174. set wrapU(value: number);
  35175. private _wrapV;
  35176. /**
  35177. * | Value | Type | Description |
  35178. * | ----- | ------------------ | ----------- |
  35179. * | 0 | CLAMP_ADDRESSMODE | |
  35180. * | 1 | WRAP_ADDRESSMODE | |
  35181. * | 2 | MIRROR_ADDRESSMODE | |
  35182. */
  35183. get wrapV(): number;
  35184. set wrapV(value: number);
  35185. /**
  35186. * | Value | Type | Description |
  35187. * | ----- | ------------------ | ----------- |
  35188. * | 0 | CLAMP_ADDRESSMODE | |
  35189. * | 1 | WRAP_ADDRESSMODE | |
  35190. * | 2 | MIRROR_ADDRESSMODE | |
  35191. */
  35192. wrapR: number;
  35193. /**
  35194. * With compliant hardware and browser (supporting anisotropic filtering)
  35195. * this defines the level of anisotropic filtering in the texture.
  35196. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35197. */
  35198. anisotropicFilteringLevel: number;
  35199. /**
  35200. * Define if the texture is a cube texture or if false a 2d texture.
  35201. */
  35202. get isCube(): boolean;
  35203. set isCube(value: boolean);
  35204. /**
  35205. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35206. */
  35207. get is3D(): boolean;
  35208. set is3D(value: boolean);
  35209. /**
  35210. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35211. */
  35212. get is2DArray(): boolean;
  35213. set is2DArray(value: boolean);
  35214. private _gammaSpace;
  35215. /**
  35216. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35217. * HDR texture are usually stored in linear space.
  35218. * This only impacts the PBR and Background materials
  35219. */
  35220. get gammaSpace(): boolean;
  35221. set gammaSpace(gamma: boolean);
  35222. /**
  35223. * Gets or sets whether or not the texture contains RGBD data.
  35224. */
  35225. get isRGBD(): boolean;
  35226. set isRGBD(value: boolean);
  35227. /**
  35228. * Is Z inverted in the texture (useful in a cube texture).
  35229. */
  35230. invertZ: boolean;
  35231. /**
  35232. * Are mip maps generated for this texture or not.
  35233. */
  35234. get noMipmap(): boolean;
  35235. /**
  35236. * @hidden
  35237. */
  35238. lodLevelInAlpha: boolean;
  35239. /**
  35240. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35241. */
  35242. get lodGenerationOffset(): number;
  35243. set lodGenerationOffset(value: number);
  35244. /**
  35245. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35246. */
  35247. get lodGenerationScale(): number;
  35248. set lodGenerationScale(value: number);
  35249. /**
  35250. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35251. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35252. * average roughness values.
  35253. */
  35254. get linearSpecularLOD(): boolean;
  35255. set linearSpecularLOD(value: boolean);
  35256. /**
  35257. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35258. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35259. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35260. */
  35261. get irradianceTexture(): Nullable<BaseTexture>;
  35262. set irradianceTexture(value: Nullable<BaseTexture>);
  35263. /**
  35264. * Define if the texture is a render target.
  35265. */
  35266. isRenderTarget: boolean;
  35267. /**
  35268. * Define the unique id of the texture in the scene.
  35269. */
  35270. get uid(): string;
  35271. /** @hidden */
  35272. _prefiltered: boolean;
  35273. /**
  35274. * Return a string representation of the texture.
  35275. * @returns the texture as a string
  35276. */
  35277. toString(): string;
  35278. /**
  35279. * Get the class name of the texture.
  35280. * @returns "BaseTexture"
  35281. */
  35282. getClassName(): string;
  35283. /**
  35284. * Define the list of animation attached to the texture.
  35285. */
  35286. animations: import("babylonjs/Animations/animation").Animation[];
  35287. /**
  35288. * An event triggered when the texture is disposed.
  35289. */
  35290. onDisposeObservable: Observable<BaseTexture>;
  35291. private _onDisposeObserver;
  35292. /**
  35293. * Callback triggered when the texture has been disposed.
  35294. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35295. */
  35296. set onDispose(callback: () => void);
  35297. /**
  35298. * Define the current state of the loading sequence when in delayed load mode.
  35299. */
  35300. delayLoadState: number;
  35301. protected _scene: Nullable<Scene>;
  35302. protected _engine: Nullable<ThinEngine>;
  35303. /** @hidden */
  35304. _texture: Nullable<InternalTexture>;
  35305. private _uid;
  35306. /**
  35307. * Define if the texture is preventinga material to render or not.
  35308. * If not and the texture is not ready, the engine will use a default black texture instead.
  35309. */
  35310. get isBlocking(): boolean;
  35311. /**
  35312. * Instantiates a new BaseTexture.
  35313. * Base class of all the textures in babylon.
  35314. * It groups all the common properties the materials, post process, lights... might need
  35315. * in order to make a correct use of the texture.
  35316. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35317. */
  35318. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35319. /**
  35320. * Get the scene the texture belongs to.
  35321. * @returns the scene or null if undefined
  35322. */
  35323. getScene(): Nullable<Scene>;
  35324. /** @hidden */
  35325. protected _getEngine(): Nullable<ThinEngine>;
  35326. /**
  35327. * Get the texture transform matrix used to offset tile the texture for istance.
  35328. * @returns the transformation matrix
  35329. */
  35330. getTextureMatrix(): Matrix;
  35331. /**
  35332. * Get the texture reflection matrix used to rotate/transform the reflection.
  35333. * @returns the reflection matrix
  35334. */
  35335. getReflectionTextureMatrix(): Matrix;
  35336. /**
  35337. * Get the underlying lower level texture from Babylon.
  35338. * @returns the insternal texture
  35339. */
  35340. getInternalTexture(): Nullable<InternalTexture>;
  35341. /**
  35342. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35343. * @returns true if ready or not blocking
  35344. */
  35345. isReadyOrNotBlocking(): boolean;
  35346. /**
  35347. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35348. * @returns true if fully ready
  35349. */
  35350. isReady(): boolean;
  35351. private _cachedSize;
  35352. /**
  35353. * Get the size of the texture.
  35354. * @returns the texture size.
  35355. */
  35356. getSize(): ISize;
  35357. /**
  35358. * Get the base size of the texture.
  35359. * It can be different from the size if the texture has been resized for POT for instance
  35360. * @returns the base size
  35361. */
  35362. getBaseSize(): ISize;
  35363. /**
  35364. * Update the sampling mode of the texture.
  35365. * Default is Trilinear mode.
  35366. *
  35367. * | Value | Type | Description |
  35368. * | ----- | ------------------ | ----------- |
  35369. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35370. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35371. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35372. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35373. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35374. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35375. * | 7 | NEAREST_LINEAR | |
  35376. * | 8 | NEAREST_NEAREST | |
  35377. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35378. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35379. * | 11 | LINEAR_LINEAR | |
  35380. * | 12 | LINEAR_NEAREST | |
  35381. *
  35382. * > _mag_: magnification filter (close to the viewer)
  35383. * > _min_: minification filter (far from the viewer)
  35384. * > _mip_: filter used between mip map levels
  35385. *@param samplingMode Define the new sampling mode of the texture
  35386. */
  35387. updateSamplingMode(samplingMode: number): void;
  35388. /**
  35389. * Scales the texture if is `canRescale()`
  35390. * @param ratio the resize factor we want to use to rescale
  35391. */
  35392. scale(ratio: number): void;
  35393. /**
  35394. * Get if the texture can rescale.
  35395. */
  35396. get canRescale(): boolean;
  35397. /** @hidden */
  35398. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35399. /** @hidden */
  35400. _rebuild(): void;
  35401. /**
  35402. * Triggers the load sequence in delayed load mode.
  35403. */
  35404. delayLoad(): void;
  35405. /**
  35406. * Clones the texture.
  35407. * @returns the cloned texture
  35408. */
  35409. clone(): Nullable<BaseTexture>;
  35410. /**
  35411. * Get the texture underlying type (INT, FLOAT...)
  35412. */
  35413. get textureType(): number;
  35414. /**
  35415. * Get the texture underlying format (RGB, RGBA...)
  35416. */
  35417. get textureFormat(): number;
  35418. /**
  35419. * Indicates that textures need to be re-calculated for all materials
  35420. */
  35421. protected _markAllSubMeshesAsTexturesDirty(): void;
  35422. /**
  35423. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35424. * This will returns an RGBA array buffer containing either in values (0-255) or
  35425. * float values (0-1) depending of the underlying buffer type.
  35426. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35427. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35428. * @param buffer defines a user defined buffer to fill with data (can be null)
  35429. * @returns The Array buffer containing the pixels data.
  35430. */
  35431. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35432. /**
  35433. * Release and destroy the underlying lower level texture aka internalTexture.
  35434. */
  35435. releaseInternalTexture(): void;
  35436. /** @hidden */
  35437. get _lodTextureHigh(): Nullable<BaseTexture>;
  35438. /** @hidden */
  35439. get _lodTextureMid(): Nullable<BaseTexture>;
  35440. /** @hidden */
  35441. get _lodTextureLow(): Nullable<BaseTexture>;
  35442. /**
  35443. * Dispose the texture and release its associated resources.
  35444. */
  35445. dispose(): void;
  35446. /**
  35447. * Serialize the texture into a JSON representation that can be parsed later on.
  35448. * @returns the JSON representation of the texture
  35449. */
  35450. serialize(): any;
  35451. /**
  35452. * Helper function to be called back once a list of texture contains only ready textures.
  35453. * @param textures Define the list of textures to wait for
  35454. * @param callback Define the callback triggered once the entire list will be ready
  35455. */
  35456. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35457. private static _isScene;
  35458. }
  35459. }
  35460. declare module "babylonjs/Materials/effect" {
  35461. import { Observable } from "babylonjs/Misc/observable";
  35462. import { Nullable } from "babylonjs/types";
  35463. import { IDisposable } from "babylonjs/scene";
  35464. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35465. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35466. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35467. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35468. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35469. import { Engine } from "babylonjs/Engines/engine";
  35470. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35471. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35472. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35473. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35474. /**
  35475. * Options to be used when creating an effect.
  35476. */
  35477. export interface IEffectCreationOptions {
  35478. /**
  35479. * Atrributes that will be used in the shader.
  35480. */
  35481. attributes: string[];
  35482. /**
  35483. * Uniform varible names that will be set in the shader.
  35484. */
  35485. uniformsNames: string[];
  35486. /**
  35487. * Uniform buffer variable names that will be set in the shader.
  35488. */
  35489. uniformBuffersNames: string[];
  35490. /**
  35491. * Sampler texture variable names that will be set in the shader.
  35492. */
  35493. samplers: string[];
  35494. /**
  35495. * Define statements that will be set in the shader.
  35496. */
  35497. defines: any;
  35498. /**
  35499. * Possible fallbacks for this effect to improve performance when needed.
  35500. */
  35501. fallbacks: Nullable<IEffectFallbacks>;
  35502. /**
  35503. * Callback that will be called when the shader is compiled.
  35504. */
  35505. onCompiled: Nullable<(effect: Effect) => void>;
  35506. /**
  35507. * Callback that will be called if an error occurs during shader compilation.
  35508. */
  35509. onError: Nullable<(effect: Effect, errors: string) => void>;
  35510. /**
  35511. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35512. */
  35513. indexParameters?: any;
  35514. /**
  35515. * Max number of lights that can be used in the shader.
  35516. */
  35517. maxSimultaneousLights?: number;
  35518. /**
  35519. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35520. */
  35521. transformFeedbackVaryings?: Nullable<string[]>;
  35522. /**
  35523. * 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
  35524. */
  35525. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35526. /**
  35527. * Is this effect rendering to several color attachments ?
  35528. */
  35529. multiTarget?: boolean;
  35530. }
  35531. /**
  35532. * Effect containing vertex and fragment shader that can be executed on an object.
  35533. */
  35534. export class Effect implements IDisposable {
  35535. /**
  35536. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35537. */
  35538. static ShadersRepository: string;
  35539. /**
  35540. * Enable logging of the shader code when a compilation error occurs
  35541. */
  35542. static LogShaderCodeOnCompilationError: boolean;
  35543. /**
  35544. * Name of the effect.
  35545. */
  35546. name: any;
  35547. /**
  35548. * String container all the define statements that should be set on the shader.
  35549. */
  35550. defines: string;
  35551. /**
  35552. * Callback that will be called when the shader is compiled.
  35553. */
  35554. onCompiled: Nullable<(effect: Effect) => void>;
  35555. /**
  35556. * Callback that will be called if an error occurs during shader compilation.
  35557. */
  35558. onError: Nullable<(effect: Effect, errors: string) => void>;
  35559. /**
  35560. * Callback that will be called when effect is bound.
  35561. */
  35562. onBind: Nullable<(effect: Effect) => void>;
  35563. /**
  35564. * Unique ID of the effect.
  35565. */
  35566. uniqueId: number;
  35567. /**
  35568. * Observable that will be called when the shader is compiled.
  35569. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35570. */
  35571. onCompileObservable: Observable<Effect>;
  35572. /**
  35573. * Observable that will be called if an error occurs during shader compilation.
  35574. */
  35575. onErrorObservable: Observable<Effect>;
  35576. /** @hidden */
  35577. _onBindObservable: Nullable<Observable<Effect>>;
  35578. /**
  35579. * @hidden
  35580. * Specifies if the effect was previously ready
  35581. */
  35582. _wasPreviouslyReady: boolean;
  35583. /**
  35584. * Observable that will be called when effect is bound.
  35585. */
  35586. get onBindObservable(): Observable<Effect>;
  35587. /** @hidden */
  35588. _bonesComputationForcedToCPU: boolean;
  35589. /** @hidden */
  35590. _multiTarget: boolean;
  35591. private static _uniqueIdSeed;
  35592. private _engine;
  35593. private _uniformBuffersNames;
  35594. private _uniformBuffersNamesList;
  35595. private _uniformsNames;
  35596. private _samplerList;
  35597. private _samplers;
  35598. private _isReady;
  35599. private _compilationError;
  35600. private _allFallbacksProcessed;
  35601. private _attributesNames;
  35602. private _attributes;
  35603. private _attributeLocationByName;
  35604. private _uniforms;
  35605. /**
  35606. * Key for the effect.
  35607. * @hidden
  35608. */
  35609. _key: string;
  35610. private _indexParameters;
  35611. private _fallbacks;
  35612. private _vertexSourceCode;
  35613. private _fragmentSourceCode;
  35614. private _vertexSourceCodeOverride;
  35615. private _fragmentSourceCodeOverride;
  35616. private _transformFeedbackVaryings;
  35617. /**
  35618. * Compiled shader to webGL program.
  35619. * @hidden
  35620. */
  35621. _pipelineContext: Nullable<IPipelineContext>;
  35622. private _valueCache;
  35623. private static _baseCache;
  35624. /**
  35625. * Instantiates an effect.
  35626. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35627. * @param baseName Name of the effect.
  35628. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35629. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35630. * @param samplers List of sampler variables that will be passed to the shader.
  35631. * @param engine Engine to be used to render the effect
  35632. * @param defines Define statements to be added to the shader.
  35633. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35634. * @param onCompiled Callback that will be called when the shader is compiled.
  35635. * @param onError Callback that will be called if an error occurs during shader compilation.
  35636. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35637. */
  35638. 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);
  35639. private _useFinalCode;
  35640. /**
  35641. * Unique key for this effect
  35642. */
  35643. get key(): string;
  35644. /**
  35645. * If the effect has been compiled and prepared.
  35646. * @returns if the effect is compiled and prepared.
  35647. */
  35648. isReady(): boolean;
  35649. private _isReadyInternal;
  35650. /**
  35651. * The engine the effect was initialized with.
  35652. * @returns the engine.
  35653. */
  35654. getEngine(): Engine;
  35655. /**
  35656. * The pipeline context for this effect
  35657. * @returns the associated pipeline context
  35658. */
  35659. getPipelineContext(): Nullable<IPipelineContext>;
  35660. /**
  35661. * The set of names of attribute variables for the shader.
  35662. * @returns An array of attribute names.
  35663. */
  35664. getAttributesNames(): string[];
  35665. /**
  35666. * Returns the attribute at the given index.
  35667. * @param index The index of the attribute.
  35668. * @returns The location of the attribute.
  35669. */
  35670. getAttributeLocation(index: number): number;
  35671. /**
  35672. * Returns the attribute based on the name of the variable.
  35673. * @param name of the attribute to look up.
  35674. * @returns the attribute location.
  35675. */
  35676. getAttributeLocationByName(name: string): number;
  35677. /**
  35678. * The number of attributes.
  35679. * @returns the numnber of attributes.
  35680. */
  35681. getAttributesCount(): number;
  35682. /**
  35683. * Gets the index of a uniform variable.
  35684. * @param uniformName of the uniform to look up.
  35685. * @returns the index.
  35686. */
  35687. getUniformIndex(uniformName: string): number;
  35688. /**
  35689. * Returns the attribute based on the name of the variable.
  35690. * @param uniformName of the uniform to look up.
  35691. * @returns the location of the uniform.
  35692. */
  35693. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35694. /**
  35695. * Returns an array of sampler variable names
  35696. * @returns The array of sampler variable names.
  35697. */
  35698. getSamplers(): string[];
  35699. /**
  35700. * Returns an array of uniform variable names
  35701. * @returns The array of uniform variable names.
  35702. */
  35703. getUniformNames(): string[];
  35704. /**
  35705. * Returns an array of uniform buffer variable names
  35706. * @returns The array of uniform buffer variable names.
  35707. */
  35708. getUniformBuffersNames(): string[];
  35709. /**
  35710. * Returns the index parameters used to create the effect
  35711. * @returns The index parameters object
  35712. */
  35713. getIndexParameters(): any;
  35714. /**
  35715. * The error from the last compilation.
  35716. * @returns the error string.
  35717. */
  35718. getCompilationError(): string;
  35719. /**
  35720. * Gets a boolean indicating that all fallbacks were used during compilation
  35721. * @returns true if all fallbacks were used
  35722. */
  35723. allFallbacksProcessed(): boolean;
  35724. /**
  35725. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35726. * @param func The callback to be used.
  35727. */
  35728. executeWhenCompiled(func: (effect: Effect) => void): void;
  35729. private _checkIsReady;
  35730. private _loadShader;
  35731. /**
  35732. * Gets the vertex shader source code of this effect
  35733. */
  35734. get vertexSourceCode(): string;
  35735. /**
  35736. * Gets the fragment shader source code of this effect
  35737. */
  35738. get fragmentSourceCode(): string;
  35739. /**
  35740. * Recompiles the webGL program
  35741. * @param vertexSourceCode The source code for the vertex shader.
  35742. * @param fragmentSourceCode The source code for the fragment shader.
  35743. * @param onCompiled Callback called when completed.
  35744. * @param onError Callback called on error.
  35745. * @hidden
  35746. */
  35747. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35748. /**
  35749. * Prepares the effect
  35750. * @hidden
  35751. */
  35752. _prepareEffect(): void;
  35753. private _getShaderCodeAndErrorLine;
  35754. private _processCompilationErrors;
  35755. /**
  35756. * Checks if the effect is supported. (Must be called after compilation)
  35757. */
  35758. get isSupported(): boolean;
  35759. /**
  35760. * Binds a texture to the engine to be used as output of the shader.
  35761. * @param channel Name of the output variable.
  35762. * @param texture Texture to bind.
  35763. * @hidden
  35764. */
  35765. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35766. /**
  35767. * Sets a texture on the engine to be used in the shader.
  35768. * @param channel Name of the sampler variable.
  35769. * @param texture Texture to set.
  35770. */
  35771. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35772. /**
  35773. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35774. * @param channel Name of the sampler variable.
  35775. * @param texture Texture to set.
  35776. */
  35777. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35778. /**
  35779. * Sets an array of textures on the engine to be used in the shader.
  35780. * @param channel Name of the variable.
  35781. * @param textures Textures to set.
  35782. */
  35783. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35784. /**
  35785. * 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)
  35786. * @param channel Name of the sampler variable.
  35787. * @param postProcess Post process to get the input texture from.
  35788. */
  35789. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35790. /**
  35791. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35792. * 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)
  35793. * @param channel Name of the sampler variable.
  35794. * @param postProcess Post process to get the output texture from.
  35795. */
  35796. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35797. /** @hidden */
  35798. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35799. /** @hidden */
  35800. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35801. /** @hidden */
  35802. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35803. /** @hidden */
  35804. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35805. /**
  35806. * Binds a buffer to a uniform.
  35807. * @param buffer Buffer to bind.
  35808. * @param name Name of the uniform variable to bind to.
  35809. */
  35810. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35811. /**
  35812. * Binds block to a uniform.
  35813. * @param blockName Name of the block to bind.
  35814. * @param index Index to bind.
  35815. */
  35816. bindUniformBlock(blockName: string, index: number): void;
  35817. /**
  35818. * Sets an interger value on a uniform variable.
  35819. * @param uniformName Name of the variable.
  35820. * @param value Value to be set.
  35821. * @returns this effect.
  35822. */
  35823. setInt(uniformName: string, value: number): Effect;
  35824. /**
  35825. * Sets an int array on a uniform variable.
  35826. * @param uniformName Name of the variable.
  35827. * @param array array to be set.
  35828. * @returns this effect.
  35829. */
  35830. setIntArray(uniformName: string, array: Int32Array): Effect;
  35831. /**
  35832. * 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)
  35833. * @param uniformName Name of the variable.
  35834. * @param array array to be set.
  35835. * @returns this effect.
  35836. */
  35837. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35838. /**
  35839. * 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)
  35840. * @param uniformName Name of the variable.
  35841. * @param array array to be set.
  35842. * @returns this effect.
  35843. */
  35844. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35845. /**
  35846. * 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)
  35847. * @param uniformName Name of the variable.
  35848. * @param array array to be set.
  35849. * @returns this effect.
  35850. */
  35851. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35852. /**
  35853. * Sets an float array on a uniform variable.
  35854. * @param uniformName Name of the variable.
  35855. * @param array array to be set.
  35856. * @returns this effect.
  35857. */
  35858. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35859. /**
  35860. * 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)
  35861. * @param uniformName Name of the variable.
  35862. * @param array array to be set.
  35863. * @returns this effect.
  35864. */
  35865. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35866. /**
  35867. * 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)
  35868. * @param uniformName Name of the variable.
  35869. * @param array array to be set.
  35870. * @returns this effect.
  35871. */
  35872. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35873. /**
  35874. * 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)
  35875. * @param uniformName Name of the variable.
  35876. * @param array array to be set.
  35877. * @returns this effect.
  35878. */
  35879. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35880. /**
  35881. * Sets an array on a uniform variable.
  35882. * @param uniformName Name of the variable.
  35883. * @param array array to be set.
  35884. * @returns this effect.
  35885. */
  35886. setArray(uniformName: string, array: number[]): Effect;
  35887. /**
  35888. * 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)
  35889. * @param uniformName Name of the variable.
  35890. * @param array array to be set.
  35891. * @returns this effect.
  35892. */
  35893. setArray2(uniformName: string, array: number[]): Effect;
  35894. /**
  35895. * 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)
  35896. * @param uniformName Name of the variable.
  35897. * @param array array to be set.
  35898. * @returns this effect.
  35899. */
  35900. setArray3(uniformName: string, array: number[]): Effect;
  35901. /**
  35902. * 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)
  35903. * @param uniformName Name of the variable.
  35904. * @param array array to be set.
  35905. * @returns this effect.
  35906. */
  35907. setArray4(uniformName: string, array: number[]): Effect;
  35908. /**
  35909. * Sets matrices on a uniform variable.
  35910. * @param uniformName Name of the variable.
  35911. * @param matrices matrices to be set.
  35912. * @returns this effect.
  35913. */
  35914. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35915. /**
  35916. * Sets matrix on a uniform variable.
  35917. * @param uniformName Name of the variable.
  35918. * @param matrix matrix to be set.
  35919. * @returns this effect.
  35920. */
  35921. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35922. /**
  35923. * 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)
  35924. * @param uniformName Name of the variable.
  35925. * @param matrix matrix to be set.
  35926. * @returns this effect.
  35927. */
  35928. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35929. /**
  35930. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35931. * @param uniformName Name of the variable.
  35932. * @param matrix matrix to be set.
  35933. * @returns this effect.
  35934. */
  35935. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35936. /**
  35937. * Sets a float on a uniform variable.
  35938. * @param uniformName Name of the variable.
  35939. * @param value value to be set.
  35940. * @returns this effect.
  35941. */
  35942. setFloat(uniformName: string, value: number): Effect;
  35943. /**
  35944. * Sets a boolean on a uniform variable.
  35945. * @param uniformName Name of the variable.
  35946. * @param bool value to be set.
  35947. * @returns this effect.
  35948. */
  35949. setBool(uniformName: string, bool: boolean): Effect;
  35950. /**
  35951. * Sets a Vector2 on a uniform variable.
  35952. * @param uniformName Name of the variable.
  35953. * @param vector2 vector2 to be set.
  35954. * @returns this effect.
  35955. */
  35956. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35957. /**
  35958. * Sets a float2 on a uniform variable.
  35959. * @param uniformName Name of the variable.
  35960. * @param x First float in float2.
  35961. * @param y Second float in float2.
  35962. * @returns this effect.
  35963. */
  35964. setFloat2(uniformName: string, x: number, y: number): Effect;
  35965. /**
  35966. * Sets a Vector3 on a uniform variable.
  35967. * @param uniformName Name of the variable.
  35968. * @param vector3 Value to be set.
  35969. * @returns this effect.
  35970. */
  35971. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  35972. /**
  35973. * Sets a float3 on a uniform variable.
  35974. * @param uniformName Name of the variable.
  35975. * @param x First float in float3.
  35976. * @param y Second float in float3.
  35977. * @param z Third float in float3.
  35978. * @returns this effect.
  35979. */
  35980. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  35981. /**
  35982. * Sets a Vector4 on a uniform variable.
  35983. * @param uniformName Name of the variable.
  35984. * @param vector4 Value to be set.
  35985. * @returns this effect.
  35986. */
  35987. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  35988. /**
  35989. * Sets a float4 on a uniform variable.
  35990. * @param uniformName Name of the variable.
  35991. * @param x First float in float4.
  35992. * @param y Second float in float4.
  35993. * @param z Third float in float4.
  35994. * @param w Fourth float in float4.
  35995. * @returns this effect.
  35996. */
  35997. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  35998. /**
  35999. * Sets a Color3 on a uniform variable.
  36000. * @param uniformName Name of the variable.
  36001. * @param color3 Value to be set.
  36002. * @returns this effect.
  36003. */
  36004. setColor3(uniformName: string, color3: IColor3Like): Effect;
  36005. /**
  36006. * Sets a Color4 on a uniform variable.
  36007. * @param uniformName Name of the variable.
  36008. * @param color3 Value to be set.
  36009. * @param alpha Alpha value to be set.
  36010. * @returns this effect.
  36011. */
  36012. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  36013. /**
  36014. * Sets a Color4 on a uniform variable
  36015. * @param uniformName defines the name of the variable
  36016. * @param color4 defines the value to be set
  36017. * @returns this effect.
  36018. */
  36019. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  36020. /** Release all associated resources */
  36021. dispose(): void;
  36022. /**
  36023. * This function will add a new shader to the shader store
  36024. * @param name the name of the shader
  36025. * @param pixelShader optional pixel shader content
  36026. * @param vertexShader optional vertex shader content
  36027. */
  36028. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  36029. /**
  36030. * Store of each shader (The can be looked up using effect.key)
  36031. */
  36032. static ShadersStore: {
  36033. [key: string]: string;
  36034. };
  36035. /**
  36036. * Store of each included file for a shader (The can be looked up using effect.key)
  36037. */
  36038. static IncludesShadersStore: {
  36039. [key: string]: string;
  36040. };
  36041. /**
  36042. * Resets the cache of effects.
  36043. */
  36044. static ResetCache(): void;
  36045. }
  36046. }
  36047. declare module "babylonjs/Engines/engineCapabilities" {
  36048. /**
  36049. * Interface used to describe the capabilities of the engine relatively to the current browser
  36050. */
  36051. export interface EngineCapabilities {
  36052. /** Maximum textures units per fragment shader */
  36053. maxTexturesImageUnits: number;
  36054. /** Maximum texture units per vertex shader */
  36055. maxVertexTextureImageUnits: number;
  36056. /** Maximum textures units in the entire pipeline */
  36057. maxCombinedTexturesImageUnits: number;
  36058. /** Maximum texture size */
  36059. maxTextureSize: number;
  36060. /** Maximum texture samples */
  36061. maxSamples?: number;
  36062. /** Maximum cube texture size */
  36063. maxCubemapTextureSize: number;
  36064. /** Maximum render texture size */
  36065. maxRenderTextureSize: number;
  36066. /** Maximum number of vertex attributes */
  36067. maxVertexAttribs: number;
  36068. /** Maximum number of varyings */
  36069. maxVaryingVectors: number;
  36070. /** Maximum number of uniforms per vertex shader */
  36071. maxVertexUniformVectors: number;
  36072. /** Maximum number of uniforms per fragment shader */
  36073. maxFragmentUniformVectors: number;
  36074. /** Defines if standard derivates (dx/dy) are supported */
  36075. standardDerivatives: boolean;
  36076. /** Defines if s3tc texture compression is supported */
  36077. s3tc?: WEBGL_compressed_texture_s3tc;
  36078. /** Defines if pvrtc texture compression is supported */
  36079. pvrtc: any;
  36080. /** Defines if etc1 texture compression is supported */
  36081. etc1: any;
  36082. /** Defines if etc2 texture compression is supported */
  36083. etc2: any;
  36084. /** Defines if astc texture compression is supported */
  36085. astc: any;
  36086. /** Defines if bptc texture compression is supported */
  36087. bptc: any;
  36088. /** Defines if float textures are supported */
  36089. textureFloat: boolean;
  36090. /** Defines if vertex array objects are supported */
  36091. vertexArrayObject: boolean;
  36092. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  36093. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  36094. /** Gets the maximum level of anisotropy supported */
  36095. maxAnisotropy: number;
  36096. /** Defines if instancing is supported */
  36097. instancedArrays: boolean;
  36098. /** Defines if 32 bits indices are supported */
  36099. uintIndices: boolean;
  36100. /** Defines if high precision shaders are supported */
  36101. highPrecisionShaderSupported: boolean;
  36102. /** Defines if depth reading in the fragment shader is supported */
  36103. fragmentDepthSupported: boolean;
  36104. /** Defines if float texture linear filtering is supported*/
  36105. textureFloatLinearFiltering: boolean;
  36106. /** Defines if rendering to float textures is supported */
  36107. textureFloatRender: boolean;
  36108. /** Defines if half float textures are supported*/
  36109. textureHalfFloat: boolean;
  36110. /** Defines if half float texture linear filtering is supported*/
  36111. textureHalfFloatLinearFiltering: boolean;
  36112. /** Defines if rendering to half float textures is supported */
  36113. textureHalfFloatRender: boolean;
  36114. /** Defines if textureLOD shader command is supported */
  36115. textureLOD: boolean;
  36116. /** Defines if draw buffers extension is supported */
  36117. drawBuffersExtension: boolean;
  36118. /** Defines if depth textures are supported */
  36119. depthTextureExtension: boolean;
  36120. /** Defines if float color buffer are supported */
  36121. colorBufferFloat: boolean;
  36122. /** Gets disjoint timer query extension (null if not supported) */
  36123. timerQuery?: EXT_disjoint_timer_query;
  36124. /** Defines if timestamp can be used with timer query */
  36125. canUseTimestampForTimerQuery: boolean;
  36126. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  36127. multiview?: any;
  36128. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  36129. oculusMultiview?: any;
  36130. /** Function used to let the system compiles shaders in background */
  36131. parallelShaderCompile?: {
  36132. COMPLETION_STATUS_KHR: number;
  36133. };
  36134. /** Max number of texture samples for MSAA */
  36135. maxMSAASamples: number;
  36136. /** Defines if the blend min max extension is supported */
  36137. blendMinMax: boolean;
  36138. }
  36139. }
  36140. declare module "babylonjs/States/depthCullingState" {
  36141. import { Nullable } from "babylonjs/types";
  36142. /**
  36143. * @hidden
  36144. **/
  36145. export class DepthCullingState {
  36146. private _isDepthTestDirty;
  36147. private _isDepthMaskDirty;
  36148. private _isDepthFuncDirty;
  36149. private _isCullFaceDirty;
  36150. private _isCullDirty;
  36151. private _isZOffsetDirty;
  36152. private _isFrontFaceDirty;
  36153. private _depthTest;
  36154. private _depthMask;
  36155. private _depthFunc;
  36156. private _cull;
  36157. private _cullFace;
  36158. private _zOffset;
  36159. private _frontFace;
  36160. /**
  36161. * Initializes the state.
  36162. */
  36163. constructor();
  36164. get isDirty(): boolean;
  36165. get zOffset(): number;
  36166. set zOffset(value: number);
  36167. get cullFace(): Nullable<number>;
  36168. set cullFace(value: Nullable<number>);
  36169. get cull(): Nullable<boolean>;
  36170. set cull(value: Nullable<boolean>);
  36171. get depthFunc(): Nullable<number>;
  36172. set depthFunc(value: Nullable<number>);
  36173. get depthMask(): boolean;
  36174. set depthMask(value: boolean);
  36175. get depthTest(): boolean;
  36176. set depthTest(value: boolean);
  36177. get frontFace(): Nullable<number>;
  36178. set frontFace(value: Nullable<number>);
  36179. reset(): void;
  36180. apply(gl: WebGLRenderingContext): void;
  36181. }
  36182. }
  36183. declare module "babylonjs/States/stencilState" {
  36184. /**
  36185. * @hidden
  36186. **/
  36187. export class StencilState {
  36188. /** 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 */
  36189. static readonly ALWAYS: number;
  36190. /** Passed to stencilOperation to specify that stencil value must be kept */
  36191. static readonly KEEP: number;
  36192. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36193. static readonly REPLACE: number;
  36194. private _isStencilTestDirty;
  36195. private _isStencilMaskDirty;
  36196. private _isStencilFuncDirty;
  36197. private _isStencilOpDirty;
  36198. private _stencilTest;
  36199. private _stencilMask;
  36200. private _stencilFunc;
  36201. private _stencilFuncRef;
  36202. private _stencilFuncMask;
  36203. private _stencilOpStencilFail;
  36204. private _stencilOpDepthFail;
  36205. private _stencilOpStencilDepthPass;
  36206. get isDirty(): boolean;
  36207. get stencilFunc(): number;
  36208. set stencilFunc(value: number);
  36209. get stencilFuncRef(): number;
  36210. set stencilFuncRef(value: number);
  36211. get stencilFuncMask(): number;
  36212. set stencilFuncMask(value: number);
  36213. get stencilOpStencilFail(): number;
  36214. set stencilOpStencilFail(value: number);
  36215. get stencilOpDepthFail(): number;
  36216. set stencilOpDepthFail(value: number);
  36217. get stencilOpStencilDepthPass(): number;
  36218. set stencilOpStencilDepthPass(value: number);
  36219. get stencilMask(): number;
  36220. set stencilMask(value: number);
  36221. get stencilTest(): boolean;
  36222. set stencilTest(value: boolean);
  36223. constructor();
  36224. reset(): void;
  36225. apply(gl: WebGLRenderingContext): void;
  36226. }
  36227. }
  36228. declare module "babylonjs/States/alphaCullingState" {
  36229. /**
  36230. * @hidden
  36231. **/
  36232. export class AlphaState {
  36233. private _isAlphaBlendDirty;
  36234. private _isBlendFunctionParametersDirty;
  36235. private _isBlendEquationParametersDirty;
  36236. private _isBlendConstantsDirty;
  36237. private _alphaBlend;
  36238. private _blendFunctionParameters;
  36239. private _blendEquationParameters;
  36240. private _blendConstants;
  36241. /**
  36242. * Initializes the state.
  36243. */
  36244. constructor();
  36245. get isDirty(): boolean;
  36246. get alphaBlend(): boolean;
  36247. set alphaBlend(value: boolean);
  36248. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36249. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36250. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36251. reset(): void;
  36252. apply(gl: WebGLRenderingContext): void;
  36253. }
  36254. }
  36255. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36256. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36257. /** @hidden */
  36258. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36259. attributeProcessor(attribute: string): string;
  36260. varyingProcessor(varying: string, isFragment: boolean): string;
  36261. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36262. }
  36263. }
  36264. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36265. /**
  36266. * Interface for attribute information associated with buffer instanciation
  36267. */
  36268. export interface InstancingAttributeInfo {
  36269. /**
  36270. * Name of the GLSL attribute
  36271. * if attribute index is not specified, this is used to retrieve the index from the effect
  36272. */
  36273. attributeName: string;
  36274. /**
  36275. * Index/offset of the attribute in the vertex shader
  36276. * if not specified, this will be computes from the name.
  36277. */
  36278. index?: number;
  36279. /**
  36280. * size of the attribute, 1, 2, 3 or 4
  36281. */
  36282. attributeSize: number;
  36283. /**
  36284. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36285. */
  36286. offset: number;
  36287. /**
  36288. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36289. * default to 1
  36290. */
  36291. divisor?: number;
  36292. /**
  36293. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36294. * default is FLOAT
  36295. */
  36296. attributeType?: number;
  36297. /**
  36298. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36299. */
  36300. normalized?: boolean;
  36301. }
  36302. }
  36303. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36304. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36305. import { Nullable } from "babylonjs/types";
  36306. module "babylonjs/Engines/thinEngine" {
  36307. interface ThinEngine {
  36308. /**
  36309. * Update a video texture
  36310. * @param texture defines the texture to update
  36311. * @param video defines the video element to use
  36312. * @param invertY defines if data must be stored with Y axis inverted
  36313. */
  36314. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36315. }
  36316. }
  36317. }
  36318. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36319. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36320. import { Nullable } from "babylonjs/types";
  36321. module "babylonjs/Engines/thinEngine" {
  36322. interface ThinEngine {
  36323. /**
  36324. * Creates a dynamic texture
  36325. * @param width defines the width of the texture
  36326. * @param height defines the height of the texture
  36327. * @param generateMipMaps defines if the engine should generate the mip levels
  36328. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36329. * @returns the dynamic texture inside an InternalTexture
  36330. */
  36331. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36332. /**
  36333. * Update the content of a dynamic texture
  36334. * @param texture defines the texture to update
  36335. * @param canvas defines the canvas containing the source
  36336. * @param invertY defines if data must be stored with Y axis inverted
  36337. * @param premulAlpha defines if alpha is stored as premultiplied
  36338. * @param format defines the format of the data
  36339. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36340. */
  36341. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36342. }
  36343. }
  36344. }
  36345. declare module "babylonjs/Materials/Textures/videoTexture" {
  36346. import { Observable } from "babylonjs/Misc/observable";
  36347. import { Nullable } from "babylonjs/types";
  36348. import { Scene } from "babylonjs/scene";
  36349. import { Texture } from "babylonjs/Materials/Textures/texture";
  36350. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36351. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36352. /**
  36353. * Settings for finer control over video usage
  36354. */
  36355. export interface VideoTextureSettings {
  36356. /**
  36357. * Applies `autoplay` to video, if specified
  36358. */
  36359. autoPlay?: boolean;
  36360. /**
  36361. * Applies `loop` to video, if specified
  36362. */
  36363. loop?: boolean;
  36364. /**
  36365. * Automatically updates internal texture from video at every frame in the render loop
  36366. */
  36367. autoUpdateTexture: boolean;
  36368. /**
  36369. * Image src displayed during the video loading or until the user interacts with the video.
  36370. */
  36371. poster?: string;
  36372. }
  36373. /**
  36374. * If you want to display a video in your scene, this is the special texture for that.
  36375. * This special texture works similar to other textures, with the exception of a few parameters.
  36376. * @see https://doc.babylonjs.com/how_to/video_texture
  36377. */
  36378. export class VideoTexture extends Texture {
  36379. /**
  36380. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36381. */
  36382. readonly autoUpdateTexture: boolean;
  36383. /**
  36384. * The video instance used by the texture internally
  36385. */
  36386. readonly video: HTMLVideoElement;
  36387. private _onUserActionRequestedObservable;
  36388. /**
  36389. * Event triggerd when a dom action is required by the user to play the video.
  36390. * This happens due to recent changes in browser policies preventing video to auto start.
  36391. */
  36392. get onUserActionRequestedObservable(): Observable<Texture>;
  36393. private _generateMipMaps;
  36394. private _stillImageCaptured;
  36395. private _displayingPosterTexture;
  36396. private _settings;
  36397. private _createInternalTextureOnEvent;
  36398. private _frameId;
  36399. private _currentSrc;
  36400. /**
  36401. * Creates a video texture.
  36402. * If you want to display a video in your scene, this is the special texture for that.
  36403. * This special texture works similar to other textures, with the exception of a few parameters.
  36404. * @see https://doc.babylonjs.com/how_to/video_texture
  36405. * @param name optional name, will detect from video source, if not defined
  36406. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36407. * @param scene is obviously the current scene.
  36408. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36409. * @param invertY is false by default but can be used to invert video on Y axis
  36410. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36411. * @param settings allows finer control over video usage
  36412. */
  36413. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36414. private _getName;
  36415. private _getVideo;
  36416. private _createInternalTexture;
  36417. private reset;
  36418. /**
  36419. * @hidden Internal method to initiate `update`.
  36420. */
  36421. _rebuild(): void;
  36422. /**
  36423. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36424. */
  36425. update(): void;
  36426. /**
  36427. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36428. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36429. */
  36430. updateTexture(isVisible: boolean): void;
  36431. protected _updateInternalTexture: () => void;
  36432. /**
  36433. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36434. * @param url New url.
  36435. */
  36436. updateURL(url: string): void;
  36437. /**
  36438. * Clones the texture.
  36439. * @returns the cloned texture
  36440. */
  36441. clone(): VideoTexture;
  36442. /**
  36443. * Dispose the texture and release its associated resources.
  36444. */
  36445. dispose(): void;
  36446. /**
  36447. * Creates a video texture straight from a stream.
  36448. * @param scene Define the scene the texture should be created in
  36449. * @param stream Define the stream the texture should be created from
  36450. * @returns The created video texture as a promise
  36451. */
  36452. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36453. /**
  36454. * Creates a video texture straight from your WebCam video feed.
  36455. * @param scene Define the scene the texture should be created in
  36456. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36457. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36458. * @returns The created video texture as a promise
  36459. */
  36460. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36461. minWidth: number;
  36462. maxWidth: number;
  36463. minHeight: number;
  36464. maxHeight: number;
  36465. deviceId: string;
  36466. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36467. /**
  36468. * Creates a video texture straight from your WebCam video feed.
  36469. * @param scene Define the scene the texture should be created in
  36470. * @param onReady Define a callback to triggered once the texture will be ready
  36471. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36472. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36473. */
  36474. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36475. minWidth: number;
  36476. maxWidth: number;
  36477. minHeight: number;
  36478. maxHeight: number;
  36479. deviceId: string;
  36480. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36481. }
  36482. }
  36483. declare module "babylonjs/Engines/thinEngine" {
  36484. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36485. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36486. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36487. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36488. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36489. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36490. import { Observable } from "babylonjs/Misc/observable";
  36491. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36492. import { StencilState } from "babylonjs/States/stencilState";
  36493. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36494. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36495. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36496. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36497. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36498. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36499. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36500. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36501. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36502. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36503. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36504. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36505. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36506. import { WebRequest } from "babylonjs/Misc/webRequest";
  36507. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36508. /**
  36509. * Defines the interface used by objects working like Scene
  36510. * @hidden
  36511. */
  36512. export interface ISceneLike {
  36513. _addPendingData(data: any): void;
  36514. _removePendingData(data: any): void;
  36515. offlineProvider: IOfflineProvider;
  36516. }
  36517. /**
  36518. * Information about the current host
  36519. */
  36520. export interface HostInformation {
  36521. /**
  36522. * Defines if the current host is a mobile
  36523. */
  36524. isMobile: boolean;
  36525. }
  36526. /** Interface defining initialization parameters for Engine class */
  36527. export interface EngineOptions extends WebGLContextAttributes {
  36528. /**
  36529. * Defines if the engine should no exceed a specified device ratio
  36530. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36531. */
  36532. limitDeviceRatio?: number;
  36533. /**
  36534. * Defines if webvr should be enabled automatically
  36535. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36536. */
  36537. autoEnableWebVR?: boolean;
  36538. /**
  36539. * Defines if webgl2 should be turned off even if supported
  36540. * @see https://doc.babylonjs.com/features/webgl2
  36541. */
  36542. disableWebGL2Support?: boolean;
  36543. /**
  36544. * Defines if webaudio should be initialized as well
  36545. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36546. */
  36547. audioEngine?: boolean;
  36548. /**
  36549. * Defines if animations should run using a deterministic lock step
  36550. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36551. */
  36552. deterministicLockstep?: boolean;
  36553. /** Defines the maximum steps to use with deterministic lock step mode */
  36554. lockstepMaxSteps?: number;
  36555. /** Defines the seconds between each deterministic lock step */
  36556. timeStep?: number;
  36557. /**
  36558. * Defines that engine should ignore context lost events
  36559. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36560. */
  36561. doNotHandleContextLost?: boolean;
  36562. /**
  36563. * Defines that engine should ignore modifying touch action attribute and style
  36564. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36565. */
  36566. doNotHandleTouchAction?: boolean;
  36567. /**
  36568. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36569. */
  36570. useHighPrecisionFloats?: boolean;
  36571. /**
  36572. * Make the canvas XR Compatible for XR sessions
  36573. */
  36574. xrCompatible?: boolean;
  36575. /**
  36576. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36577. */
  36578. useHighPrecisionMatrix?: boolean;
  36579. }
  36580. /**
  36581. * The base engine class (root of all engines)
  36582. */
  36583. export class ThinEngine {
  36584. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36585. static ExceptionList: ({
  36586. key: string;
  36587. capture: string;
  36588. captureConstraint: number;
  36589. targets: string[];
  36590. } | {
  36591. key: string;
  36592. capture: null;
  36593. captureConstraint: null;
  36594. targets: string[];
  36595. })[];
  36596. /** @hidden */
  36597. static _TextureLoaders: IInternalTextureLoader[];
  36598. /**
  36599. * Returns the current npm package of the sdk
  36600. */
  36601. static get NpmPackage(): string;
  36602. /**
  36603. * Returns the current version of the framework
  36604. */
  36605. static get Version(): string;
  36606. /**
  36607. * Returns a string describing the current engine
  36608. */
  36609. get description(): string;
  36610. /**
  36611. * Gets or sets the epsilon value used by collision engine
  36612. */
  36613. static CollisionsEpsilon: number;
  36614. /**
  36615. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36616. */
  36617. static get ShadersRepository(): string;
  36618. static set ShadersRepository(value: string);
  36619. /** @hidden */
  36620. _shaderProcessor: IShaderProcessor;
  36621. /**
  36622. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36623. */
  36624. forcePOTTextures: boolean;
  36625. /**
  36626. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36627. */
  36628. isFullscreen: boolean;
  36629. /**
  36630. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36631. */
  36632. cullBackFaces: boolean;
  36633. /**
  36634. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36635. */
  36636. renderEvenInBackground: boolean;
  36637. /**
  36638. * Gets or sets a boolean indicating that cache can be kept between frames
  36639. */
  36640. preventCacheWipeBetweenFrames: boolean;
  36641. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36642. validateShaderPrograms: boolean;
  36643. /**
  36644. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36645. * This can provide greater z depth for distant objects.
  36646. */
  36647. useReverseDepthBuffer: boolean;
  36648. /**
  36649. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36650. */
  36651. disableUniformBuffers: boolean;
  36652. /** @hidden */
  36653. _uniformBuffers: UniformBuffer[];
  36654. /**
  36655. * Gets a boolean indicating that the engine supports uniform buffers
  36656. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36657. */
  36658. get supportsUniformBuffers(): boolean;
  36659. /** @hidden */
  36660. _gl: WebGLRenderingContext;
  36661. /** @hidden */
  36662. _webGLVersion: number;
  36663. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36664. protected _windowIsBackground: boolean;
  36665. protected _creationOptions: EngineOptions;
  36666. protected _highPrecisionShadersAllowed: boolean;
  36667. /** @hidden */
  36668. get _shouldUseHighPrecisionShader(): boolean;
  36669. /**
  36670. * Gets a boolean indicating that only power of 2 textures are supported
  36671. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36672. */
  36673. get needPOTTextures(): boolean;
  36674. /** @hidden */
  36675. _badOS: boolean;
  36676. /** @hidden */
  36677. _badDesktopOS: boolean;
  36678. private _hardwareScalingLevel;
  36679. /** @hidden */
  36680. _caps: EngineCapabilities;
  36681. private _isStencilEnable;
  36682. private _glVersion;
  36683. private _glRenderer;
  36684. private _glVendor;
  36685. /** @hidden */
  36686. _videoTextureSupported: boolean;
  36687. protected _renderingQueueLaunched: boolean;
  36688. protected _activeRenderLoops: (() => void)[];
  36689. /**
  36690. * Observable signaled when a context lost event is raised
  36691. */
  36692. onContextLostObservable: Observable<ThinEngine>;
  36693. /**
  36694. * Observable signaled when a context restored event is raised
  36695. */
  36696. onContextRestoredObservable: Observable<ThinEngine>;
  36697. private _onContextLost;
  36698. private _onContextRestored;
  36699. protected _contextWasLost: boolean;
  36700. /** @hidden */
  36701. _doNotHandleContextLost: boolean;
  36702. /**
  36703. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36704. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36705. */
  36706. get doNotHandleContextLost(): boolean;
  36707. set doNotHandleContextLost(value: boolean);
  36708. /**
  36709. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36710. */
  36711. disableVertexArrayObjects: boolean;
  36712. /** @hidden */
  36713. protected _colorWrite: boolean;
  36714. /** @hidden */
  36715. protected _colorWriteChanged: boolean;
  36716. /** @hidden */
  36717. protected _depthCullingState: DepthCullingState;
  36718. /** @hidden */
  36719. protected _stencilState: StencilState;
  36720. /** @hidden */
  36721. _alphaState: AlphaState;
  36722. /** @hidden */
  36723. _alphaMode: number;
  36724. /** @hidden */
  36725. _alphaEquation: number;
  36726. /** @hidden */
  36727. _internalTexturesCache: InternalTexture[];
  36728. /** @hidden */
  36729. protected _activeChannel: number;
  36730. private _currentTextureChannel;
  36731. /** @hidden */
  36732. protected _boundTexturesCache: {
  36733. [key: string]: Nullable<InternalTexture>;
  36734. };
  36735. /** @hidden */
  36736. protected _currentEffect: Nullable<Effect>;
  36737. /** @hidden */
  36738. protected _currentProgram: Nullable<WebGLProgram>;
  36739. private _compiledEffects;
  36740. private _vertexAttribArraysEnabled;
  36741. /** @hidden */
  36742. protected _cachedViewport: Nullable<IViewportLike>;
  36743. private _cachedVertexArrayObject;
  36744. /** @hidden */
  36745. protected _cachedVertexBuffers: any;
  36746. /** @hidden */
  36747. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36748. /** @hidden */
  36749. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36750. /** @hidden */
  36751. _currentRenderTarget: Nullable<InternalTexture>;
  36752. private _uintIndicesCurrentlySet;
  36753. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36754. /** @hidden */
  36755. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36756. /** @hidden */
  36757. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36758. private _currentBufferPointers;
  36759. private _currentInstanceLocations;
  36760. private _currentInstanceBuffers;
  36761. private _textureUnits;
  36762. /** @hidden */
  36763. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36764. /** @hidden */
  36765. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36766. /** @hidden */
  36767. _boundRenderFunction: any;
  36768. private _vaoRecordInProgress;
  36769. private _mustWipeVertexAttributes;
  36770. private _emptyTexture;
  36771. private _emptyCubeTexture;
  36772. private _emptyTexture3D;
  36773. private _emptyTexture2DArray;
  36774. /** @hidden */
  36775. _frameHandler: number;
  36776. private _nextFreeTextureSlots;
  36777. private _maxSimultaneousTextures;
  36778. private _activeRequests;
  36779. /** @hidden */
  36780. _transformTextureUrl: Nullable<(url: string) => string>;
  36781. /**
  36782. * Gets information about the current host
  36783. */
  36784. hostInformation: HostInformation;
  36785. protected get _supportsHardwareTextureRescaling(): boolean;
  36786. private _framebufferDimensionsObject;
  36787. /**
  36788. * sets the object from which width and height will be taken from when getting render width and height
  36789. * Will fallback to the gl object
  36790. * @param dimensions the framebuffer width and height that will be used.
  36791. */
  36792. set framebufferDimensionsObject(dimensions: Nullable<{
  36793. framebufferWidth: number;
  36794. framebufferHeight: number;
  36795. }>);
  36796. /**
  36797. * Gets the current viewport
  36798. */
  36799. get currentViewport(): Nullable<IViewportLike>;
  36800. /**
  36801. * Gets the default empty texture
  36802. */
  36803. get emptyTexture(): InternalTexture;
  36804. /**
  36805. * Gets the default empty 3D texture
  36806. */
  36807. get emptyTexture3D(): InternalTexture;
  36808. /**
  36809. * Gets the default empty 2D array texture
  36810. */
  36811. get emptyTexture2DArray(): InternalTexture;
  36812. /**
  36813. * Gets the default empty cube texture
  36814. */
  36815. get emptyCubeTexture(): InternalTexture;
  36816. /**
  36817. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36818. */
  36819. readonly premultipliedAlpha: boolean;
  36820. /**
  36821. * Observable event triggered before each texture is initialized
  36822. */
  36823. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36824. /**
  36825. * Creates a new engine
  36826. * @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
  36827. * @param antialias defines enable antialiasing (default: false)
  36828. * @param options defines further options to be sent to the getContext() function
  36829. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36830. */
  36831. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36832. private _rebuildInternalTextures;
  36833. private _rebuildEffects;
  36834. /**
  36835. * Gets a boolean indicating if all created effects are ready
  36836. * @returns true if all effects are ready
  36837. */
  36838. areAllEffectsReady(): boolean;
  36839. protected _rebuildBuffers(): void;
  36840. protected _initGLContext(): void;
  36841. /**
  36842. * Gets version of the current webGL context
  36843. */
  36844. get webGLVersion(): number;
  36845. /**
  36846. * Gets a string identifying the name of the class
  36847. * @returns "Engine" string
  36848. */
  36849. getClassName(): string;
  36850. /**
  36851. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36852. */
  36853. get isStencilEnable(): boolean;
  36854. /** @hidden */
  36855. _prepareWorkingCanvas(): void;
  36856. /**
  36857. * Reset the texture cache to empty state
  36858. */
  36859. resetTextureCache(): void;
  36860. /**
  36861. * Gets an object containing information about the current webGL context
  36862. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36863. */
  36864. getGlInfo(): {
  36865. vendor: string;
  36866. renderer: string;
  36867. version: string;
  36868. };
  36869. /**
  36870. * Defines the hardware scaling level.
  36871. * By default the hardware scaling level is computed from the window device ratio.
  36872. * 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.
  36873. * @param level defines the level to use
  36874. */
  36875. setHardwareScalingLevel(level: number): void;
  36876. /**
  36877. * Gets the current hardware scaling level.
  36878. * By default the hardware scaling level is computed from the window device ratio.
  36879. * 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.
  36880. * @returns a number indicating the current hardware scaling level
  36881. */
  36882. getHardwareScalingLevel(): number;
  36883. /**
  36884. * Gets the list of loaded textures
  36885. * @returns an array containing all loaded textures
  36886. */
  36887. getLoadedTexturesCache(): InternalTexture[];
  36888. /**
  36889. * Gets the object containing all engine capabilities
  36890. * @returns the EngineCapabilities object
  36891. */
  36892. getCaps(): EngineCapabilities;
  36893. /**
  36894. * stop executing a render loop function and remove it from the execution array
  36895. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36896. */
  36897. stopRenderLoop(renderFunction?: () => void): void;
  36898. /** @hidden */
  36899. _renderLoop(): void;
  36900. /**
  36901. * Gets the HTML canvas attached with the current webGL context
  36902. * @returns a HTML canvas
  36903. */
  36904. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36905. /**
  36906. * Gets host window
  36907. * @returns the host window object
  36908. */
  36909. getHostWindow(): Nullable<Window>;
  36910. /**
  36911. * Gets the current render width
  36912. * @param useScreen defines if screen size must be used (or the current render target if any)
  36913. * @returns a number defining the current render width
  36914. */
  36915. getRenderWidth(useScreen?: boolean): number;
  36916. /**
  36917. * Gets the current render height
  36918. * @param useScreen defines if screen size must be used (or the current render target if any)
  36919. * @returns a number defining the current render height
  36920. */
  36921. getRenderHeight(useScreen?: boolean): number;
  36922. /**
  36923. * Can be used to override the current requestAnimationFrame requester.
  36924. * @hidden
  36925. */
  36926. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36927. /**
  36928. * Register and execute a render loop. The engine can have more than one render function
  36929. * @param renderFunction defines the function to continuously execute
  36930. */
  36931. runRenderLoop(renderFunction: () => void): void;
  36932. /**
  36933. * Clear the current render buffer or the current render target (if any is set up)
  36934. * @param color defines the color to use
  36935. * @param backBuffer defines if the back buffer must be cleared
  36936. * @param depth defines if the depth buffer must be cleared
  36937. * @param stencil defines if the stencil buffer must be cleared
  36938. */
  36939. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36940. private _viewportCached;
  36941. /** @hidden */
  36942. _viewport(x: number, y: number, width: number, height: number): void;
  36943. /**
  36944. * Set the WebGL's viewport
  36945. * @param viewport defines the viewport element to be used
  36946. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36947. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36948. */
  36949. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36950. /**
  36951. * Begin a new frame
  36952. */
  36953. beginFrame(): void;
  36954. /**
  36955. * Enf the current frame
  36956. */
  36957. endFrame(): void;
  36958. /**
  36959. * Resize the view according to the canvas' size
  36960. */
  36961. resize(): void;
  36962. /**
  36963. * Force a specific size of the canvas
  36964. * @param width defines the new canvas' width
  36965. * @param height defines the new canvas' height
  36966. * @returns true if the size was changed
  36967. */
  36968. setSize(width: number, height: number): boolean;
  36969. /**
  36970. * Binds the frame buffer to the specified texture.
  36971. * @param texture The texture to render to or null for the default canvas
  36972. * @param faceIndex The face of the texture to render to in case of cube texture
  36973. * @param requiredWidth The width of the target to render to
  36974. * @param requiredHeight The height of the target to render to
  36975. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  36976. * @param lodLevel defines the lod level to bind to the frame buffer
  36977. * @param layer defines the 2d array index to bind to frame buffer to
  36978. */
  36979. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  36980. /** @hidden */
  36981. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  36982. /**
  36983. * Unbind the current render target texture from the webGL context
  36984. * @param texture defines the render target texture to unbind
  36985. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  36986. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  36987. */
  36988. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  36989. /**
  36990. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  36991. */
  36992. flushFramebuffer(): void;
  36993. /**
  36994. * Unbind the current render target and bind the default framebuffer
  36995. */
  36996. restoreDefaultFramebuffer(): void;
  36997. /** @hidden */
  36998. protected _resetVertexBufferBinding(): void;
  36999. /**
  37000. * Creates a vertex buffer
  37001. * @param data the data for the vertex buffer
  37002. * @returns the new WebGL static buffer
  37003. */
  37004. createVertexBuffer(data: DataArray): DataBuffer;
  37005. private _createVertexBuffer;
  37006. /**
  37007. * Creates a dynamic vertex buffer
  37008. * @param data the data for the dynamic vertex buffer
  37009. * @returns the new WebGL dynamic buffer
  37010. */
  37011. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  37012. protected _resetIndexBufferBinding(): void;
  37013. /**
  37014. * Creates a new index buffer
  37015. * @param indices defines the content of the index buffer
  37016. * @param updatable defines if the index buffer must be updatable
  37017. * @returns a new webGL buffer
  37018. */
  37019. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  37020. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  37021. /**
  37022. * Bind a webGL buffer to the webGL context
  37023. * @param buffer defines the buffer to bind
  37024. */
  37025. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  37026. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  37027. private bindBuffer;
  37028. /**
  37029. * update the bound buffer with the given data
  37030. * @param data defines the data to update
  37031. */
  37032. updateArrayBuffer(data: Float32Array): void;
  37033. private _vertexAttribPointer;
  37034. /** @hidden */
  37035. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  37036. private _bindVertexBuffersAttributes;
  37037. /**
  37038. * Records a vertex array object
  37039. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37040. * @param vertexBuffers defines the list of vertex buffers to store
  37041. * @param indexBuffer defines the index buffer to store
  37042. * @param effect defines the effect to store
  37043. * @returns the new vertex array object
  37044. */
  37045. recordVertexArrayObject(vertexBuffers: {
  37046. [key: string]: VertexBuffer;
  37047. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  37048. /**
  37049. * Bind a specific vertex array object
  37050. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37051. * @param vertexArrayObject defines the vertex array object to bind
  37052. * @param indexBuffer defines the index buffer to bind
  37053. */
  37054. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  37055. /**
  37056. * Bind webGl buffers directly to the webGL context
  37057. * @param vertexBuffer defines the vertex buffer to bind
  37058. * @param indexBuffer defines the index buffer to bind
  37059. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  37060. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  37061. * @param effect defines the effect associated with the vertex buffer
  37062. */
  37063. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  37064. private _unbindVertexArrayObject;
  37065. /**
  37066. * Bind a list of vertex buffers to the webGL context
  37067. * @param vertexBuffers defines the list of vertex buffers to bind
  37068. * @param indexBuffer defines the index buffer to bind
  37069. * @param effect defines the effect associated with the vertex buffers
  37070. */
  37071. bindBuffers(vertexBuffers: {
  37072. [key: string]: Nullable<VertexBuffer>;
  37073. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  37074. /**
  37075. * Unbind all instance attributes
  37076. */
  37077. unbindInstanceAttributes(): void;
  37078. /**
  37079. * Release and free the memory of a vertex array object
  37080. * @param vao defines the vertex array object to delete
  37081. */
  37082. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  37083. /** @hidden */
  37084. _releaseBuffer(buffer: DataBuffer): boolean;
  37085. protected _deleteBuffer(buffer: DataBuffer): void;
  37086. /**
  37087. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  37088. * @param instancesBuffer defines the webGL buffer to update and bind
  37089. * @param data defines the data to store in the buffer
  37090. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  37091. */
  37092. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  37093. /**
  37094. * Bind the content of a webGL buffer used with instantiation
  37095. * @param instancesBuffer defines the webGL buffer to bind
  37096. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  37097. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  37098. */
  37099. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  37100. /**
  37101. * Disable the instance attribute corresponding to the name in parameter
  37102. * @param name defines the name of the attribute to disable
  37103. */
  37104. disableInstanceAttributeByName(name: string): void;
  37105. /**
  37106. * Disable the instance attribute corresponding to the location in parameter
  37107. * @param attributeLocation defines the attribute location of the attribute to disable
  37108. */
  37109. disableInstanceAttribute(attributeLocation: number): void;
  37110. /**
  37111. * Disable the attribute corresponding to the location in parameter
  37112. * @param attributeLocation defines the attribute location of the attribute to disable
  37113. */
  37114. disableAttributeByIndex(attributeLocation: number): void;
  37115. /**
  37116. * Send a draw order
  37117. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37118. * @param indexStart defines the starting index
  37119. * @param indexCount defines the number of index to draw
  37120. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37121. */
  37122. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37123. /**
  37124. * Draw a list of points
  37125. * @param verticesStart defines the index of first vertex to draw
  37126. * @param verticesCount defines the count of vertices to draw
  37127. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37128. */
  37129. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37130. /**
  37131. * Draw a list of unindexed primitives
  37132. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37133. * @param verticesStart defines the index of first vertex to draw
  37134. * @param verticesCount defines the count of vertices to draw
  37135. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37136. */
  37137. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37138. /**
  37139. * Draw a list of indexed primitives
  37140. * @param fillMode defines the primitive to use
  37141. * @param indexStart defines the starting index
  37142. * @param indexCount defines the number of index to draw
  37143. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37144. */
  37145. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37146. /**
  37147. * Draw a list of unindexed primitives
  37148. * @param fillMode defines the primitive to use
  37149. * @param verticesStart defines the index of first vertex to draw
  37150. * @param verticesCount defines the count of vertices to draw
  37151. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37152. */
  37153. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37154. private _drawMode;
  37155. /** @hidden */
  37156. protected _reportDrawCall(): void;
  37157. /** @hidden */
  37158. _releaseEffect(effect: Effect): void;
  37159. /** @hidden */
  37160. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37161. /**
  37162. * Create a new effect (used to store vertex/fragment shaders)
  37163. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37164. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37165. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37166. * @param samplers defines an array of string used to represent textures
  37167. * @param defines defines the string containing the defines to use to compile the shaders
  37168. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37169. * @param onCompiled defines a function to call when the effect creation is successful
  37170. * @param onError defines a function to call when the effect creation has failed
  37171. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37172. * @returns the new Effect
  37173. */
  37174. 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;
  37175. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37176. private _compileShader;
  37177. private _compileRawShader;
  37178. /** @hidden */
  37179. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37180. /**
  37181. * Directly creates a webGL program
  37182. * @param pipelineContext defines the pipeline context to attach to
  37183. * @param vertexCode defines the vertex shader code to use
  37184. * @param fragmentCode defines the fragment shader code to use
  37185. * @param context defines the webGL context to use (if not set, the current one will be used)
  37186. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37187. * @returns the new webGL program
  37188. */
  37189. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37190. /**
  37191. * Creates a webGL program
  37192. * @param pipelineContext defines the pipeline context to attach to
  37193. * @param vertexCode defines the vertex shader code to use
  37194. * @param fragmentCode defines the fragment shader code to use
  37195. * @param defines defines the string containing the defines to use to compile the shaders
  37196. * @param context defines the webGL context to use (if not set, the current one will be used)
  37197. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37198. * @returns the new webGL program
  37199. */
  37200. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37201. /**
  37202. * Creates a new pipeline context
  37203. * @returns the new pipeline
  37204. */
  37205. createPipelineContext(): IPipelineContext;
  37206. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37207. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37208. /** @hidden */
  37209. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37210. /** @hidden */
  37211. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37212. /** @hidden */
  37213. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37214. /**
  37215. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37216. * @param pipelineContext defines the pipeline context to use
  37217. * @param uniformsNames defines the list of uniform names
  37218. * @returns an array of webGL uniform locations
  37219. */
  37220. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37221. /**
  37222. * Gets the lsit of active attributes for a given webGL program
  37223. * @param pipelineContext defines the pipeline context to use
  37224. * @param attributesNames defines the list of attribute names to get
  37225. * @returns an array of indices indicating the offset of each attribute
  37226. */
  37227. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37228. /**
  37229. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37230. * @param effect defines the effect to activate
  37231. */
  37232. enableEffect(effect: Nullable<Effect>): void;
  37233. /**
  37234. * Set the value of an uniform to a number (int)
  37235. * @param uniform defines the webGL uniform location where to store the value
  37236. * @param value defines the int number to store
  37237. */
  37238. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37239. /**
  37240. * Set the value of an uniform to an array of int32
  37241. * @param uniform defines the webGL uniform location where to store the value
  37242. * @param array defines the array of int32 to store
  37243. */
  37244. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37245. /**
  37246. * Set the value of an uniform to an array of int32 (stored as vec2)
  37247. * @param uniform defines the webGL uniform location where to store the value
  37248. * @param array defines the array of int32 to store
  37249. */
  37250. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37251. /**
  37252. * Set the value of an uniform to an array of int32 (stored as vec3)
  37253. * @param uniform defines the webGL uniform location where to store the value
  37254. * @param array defines the array of int32 to store
  37255. */
  37256. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37257. /**
  37258. * Set the value of an uniform to an array of int32 (stored as vec4)
  37259. * @param uniform defines the webGL uniform location where to store the value
  37260. * @param array defines the array of int32 to store
  37261. */
  37262. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37263. /**
  37264. * Set the value of an uniform to an array of number
  37265. * @param uniform defines the webGL uniform location where to store the value
  37266. * @param array defines the array of number to store
  37267. */
  37268. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37269. /**
  37270. * Set the value of an uniform to an array of number (stored as vec2)
  37271. * @param uniform defines the webGL uniform location where to store the value
  37272. * @param array defines the array of number to store
  37273. */
  37274. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37275. /**
  37276. * Set the value of an uniform to an array of number (stored as vec3)
  37277. * @param uniform defines the webGL uniform location where to store the value
  37278. * @param array defines the array of number to store
  37279. */
  37280. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37281. /**
  37282. * Set the value of an uniform to an array of number (stored as vec4)
  37283. * @param uniform defines the webGL uniform location where to store the value
  37284. * @param array defines the array of number to store
  37285. */
  37286. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37287. /**
  37288. * Set the value of an uniform to an array of float32 (stored as matrices)
  37289. * @param uniform defines the webGL uniform location where to store the value
  37290. * @param matrices defines the array of float32 to store
  37291. */
  37292. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  37293. /**
  37294. * Set the value of an uniform to a matrix (3x3)
  37295. * @param uniform defines the webGL uniform location where to store the value
  37296. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37297. */
  37298. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37299. /**
  37300. * Set the value of an uniform to a matrix (2x2)
  37301. * @param uniform defines the webGL uniform location where to store the value
  37302. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37303. */
  37304. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37305. /**
  37306. * Set the value of an uniform to a number (float)
  37307. * @param uniform defines the webGL uniform location where to store the value
  37308. * @param value defines the float number to store
  37309. */
  37310. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37311. /**
  37312. * Set the value of an uniform to a vec2
  37313. * @param uniform defines the webGL uniform location where to store the value
  37314. * @param x defines the 1st component of the value
  37315. * @param y defines the 2nd component of the value
  37316. */
  37317. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  37318. /**
  37319. * Set the value of an uniform to a vec3
  37320. * @param uniform defines the webGL uniform location where to store the value
  37321. * @param x defines the 1st component of the value
  37322. * @param y defines the 2nd component of the value
  37323. * @param z defines the 3rd component of the value
  37324. */
  37325. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  37326. /**
  37327. * Set the value of an uniform to a vec4
  37328. * @param uniform defines the webGL uniform location where to store the value
  37329. * @param x defines the 1st component of the value
  37330. * @param y defines the 2nd component of the value
  37331. * @param z defines the 3rd component of the value
  37332. * @param w defines the 4th component of the value
  37333. */
  37334. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  37335. /**
  37336. * Apply all cached states (depth, culling, stencil and alpha)
  37337. */
  37338. applyStates(): void;
  37339. /**
  37340. * Enable or disable color writing
  37341. * @param enable defines the state to set
  37342. */
  37343. setColorWrite(enable: boolean): void;
  37344. /**
  37345. * Gets a boolean indicating if color writing is enabled
  37346. * @returns the current color writing state
  37347. */
  37348. getColorWrite(): boolean;
  37349. /**
  37350. * Gets the depth culling state manager
  37351. */
  37352. get depthCullingState(): DepthCullingState;
  37353. /**
  37354. * Gets the alpha state manager
  37355. */
  37356. get alphaState(): AlphaState;
  37357. /**
  37358. * Gets the stencil state manager
  37359. */
  37360. get stencilState(): StencilState;
  37361. /**
  37362. * Clears the list of texture accessible through engine.
  37363. * This can help preventing texture load conflict due to name collision.
  37364. */
  37365. clearInternalTexturesCache(): void;
  37366. /**
  37367. * Force the entire cache to be cleared
  37368. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37369. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37370. */
  37371. wipeCaches(bruteForce?: boolean): void;
  37372. /** @hidden */
  37373. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37374. min: number;
  37375. mag: number;
  37376. };
  37377. /** @hidden */
  37378. _createTexture(): WebGLTexture;
  37379. /**
  37380. * Usually called from Texture.ts.
  37381. * Passed information to create a WebGLTexture
  37382. * @param url defines a value which contains one of the following:
  37383. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37384. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37385. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37386. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37387. * @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)
  37388. * @param scene needed for loading to the correct scene
  37389. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37390. * @param onLoad optional callback to be called upon successful completion
  37391. * @param onError optional callback to be called upon failure
  37392. * @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
  37393. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37394. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37395. * @param forcedExtension defines the extension to use to pick the right loader
  37396. * @param mimeType defines an optional mime type
  37397. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37398. */
  37399. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  37400. /**
  37401. * Loads an image as an HTMLImageElement.
  37402. * @param input url string, ArrayBuffer, or Blob to load
  37403. * @param onLoad callback called when the image successfully loads
  37404. * @param onError callback called when the image fails to load
  37405. * @param offlineProvider offline provider for caching
  37406. * @param mimeType optional mime type
  37407. * @returns the HTMLImageElement of the loaded image
  37408. * @hidden
  37409. */
  37410. 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>;
  37411. /**
  37412. * @hidden
  37413. */
  37414. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37415. private _unpackFlipYCached;
  37416. /**
  37417. * In case you are sharing the context with other applications, it might
  37418. * be interested to not cache the unpack flip y state to ensure a consistent
  37419. * value would be set.
  37420. */
  37421. enableUnpackFlipYCached: boolean;
  37422. /** @hidden */
  37423. _unpackFlipY(value: boolean): void;
  37424. /** @hidden */
  37425. _getUnpackAlignement(): number;
  37426. private _getTextureTarget;
  37427. /**
  37428. * Update the sampling mode of a given texture
  37429. * @param samplingMode defines the required sampling mode
  37430. * @param texture defines the texture to update
  37431. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37432. */
  37433. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37434. /**
  37435. * Update the sampling mode of a given texture
  37436. * @param texture defines the texture to update
  37437. * @param wrapU defines the texture wrap mode of the u coordinates
  37438. * @param wrapV defines the texture wrap mode of the v coordinates
  37439. * @param wrapR defines the texture wrap mode of the r coordinates
  37440. */
  37441. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37442. /** @hidden */
  37443. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37444. width: number;
  37445. height: number;
  37446. layers?: number;
  37447. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37448. /** @hidden */
  37449. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37450. /** @hidden */
  37451. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37452. /**
  37453. * Update a portion of an internal texture
  37454. * @param texture defines the texture to update
  37455. * @param imageData defines the data to store into the texture
  37456. * @param xOffset defines the x coordinates of the update rectangle
  37457. * @param yOffset defines the y coordinates of the update rectangle
  37458. * @param width defines the width of the update rectangle
  37459. * @param height defines the height of the update rectangle
  37460. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37461. * @param lod defines the lod level to update (0 by default)
  37462. */
  37463. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37464. /** @hidden */
  37465. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37466. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37467. private _prepareWebGLTexture;
  37468. /** @hidden */
  37469. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37470. private _getDepthStencilBuffer;
  37471. /** @hidden */
  37472. _releaseFramebufferObjects(texture: InternalTexture): void;
  37473. /** @hidden */
  37474. _releaseTexture(texture: InternalTexture): void;
  37475. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37476. protected _setProgram(program: WebGLProgram): void;
  37477. protected _boundUniforms: {
  37478. [key: number]: WebGLUniformLocation;
  37479. };
  37480. /**
  37481. * Binds an effect to the webGL context
  37482. * @param effect defines the effect to bind
  37483. */
  37484. bindSamplers(effect: Effect): void;
  37485. private _activateCurrentTexture;
  37486. /** @hidden */
  37487. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37488. /** @hidden */
  37489. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37490. /**
  37491. * Unbind all textures from the webGL context
  37492. */
  37493. unbindAllTextures(): void;
  37494. /**
  37495. * Sets a texture to the according uniform.
  37496. * @param channel The texture channel
  37497. * @param uniform The uniform to set
  37498. * @param texture The texture to apply
  37499. */
  37500. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37501. private _bindSamplerUniformToChannel;
  37502. private _getTextureWrapMode;
  37503. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37504. /**
  37505. * Sets an array of texture to the webGL context
  37506. * @param channel defines the channel where the texture array must be set
  37507. * @param uniform defines the associated uniform location
  37508. * @param textures defines the array of textures to bind
  37509. */
  37510. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37511. /** @hidden */
  37512. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37513. private _setTextureParameterFloat;
  37514. private _setTextureParameterInteger;
  37515. /**
  37516. * Unbind all vertex attributes from the webGL context
  37517. */
  37518. unbindAllAttributes(): void;
  37519. /**
  37520. * 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
  37521. */
  37522. releaseEffects(): void;
  37523. /**
  37524. * Dispose and release all associated resources
  37525. */
  37526. dispose(): void;
  37527. /**
  37528. * Attach a new callback raised when context lost event is fired
  37529. * @param callback defines the callback to call
  37530. */
  37531. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37532. /**
  37533. * Attach a new callback raised when context restored event is fired
  37534. * @param callback defines the callback to call
  37535. */
  37536. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37537. /**
  37538. * Get the current error code of the webGL context
  37539. * @returns the error code
  37540. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37541. */
  37542. getError(): number;
  37543. private _canRenderToFloatFramebuffer;
  37544. private _canRenderToHalfFloatFramebuffer;
  37545. private _canRenderToFramebuffer;
  37546. /** @hidden */
  37547. _getWebGLTextureType(type: number): number;
  37548. /** @hidden */
  37549. _getInternalFormat(format: number): number;
  37550. /** @hidden */
  37551. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37552. /** @hidden */
  37553. _getRGBAMultiSampleBufferFormat(type: number): number;
  37554. /** @hidden */
  37555. _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;
  37556. /**
  37557. * Loads a file from a url
  37558. * @param url url to load
  37559. * @param onSuccess callback called when the file successfully loads
  37560. * @param onProgress callback called while file is loading (if the server supports this mode)
  37561. * @param offlineProvider defines the offline provider for caching
  37562. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37563. * @param onError callback called when the file fails to load
  37564. * @returns a file request object
  37565. * @hidden
  37566. */
  37567. 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;
  37568. /**
  37569. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37570. * @param x defines the x coordinate of the rectangle where pixels must be read
  37571. * @param y defines the y coordinate of the rectangle where pixels must be read
  37572. * @param width defines the width of the rectangle where pixels must be read
  37573. * @param height defines the height of the rectangle where pixels must be read
  37574. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37575. * @returns a Uint8Array containing RGBA colors
  37576. */
  37577. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37578. private static _isSupported;
  37579. /**
  37580. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37581. * @returns true if the engine can be created
  37582. * @ignorenaming
  37583. */
  37584. static isSupported(): boolean;
  37585. /**
  37586. * Find the next highest power of two.
  37587. * @param x Number to start search from.
  37588. * @return Next highest power of two.
  37589. */
  37590. static CeilingPOT(x: number): number;
  37591. /**
  37592. * Find the next lowest power of two.
  37593. * @param x Number to start search from.
  37594. * @return Next lowest power of two.
  37595. */
  37596. static FloorPOT(x: number): number;
  37597. /**
  37598. * Find the nearest power of two.
  37599. * @param x Number to start search from.
  37600. * @return Next nearest power of two.
  37601. */
  37602. static NearestPOT(x: number): number;
  37603. /**
  37604. * Get the closest exponent of two
  37605. * @param value defines the value to approximate
  37606. * @param max defines the maximum value to return
  37607. * @param mode defines how to define the closest value
  37608. * @returns closest exponent of two of the given value
  37609. */
  37610. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37611. /**
  37612. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37613. * @param func - the function to be called
  37614. * @param requester - the object that will request the next frame. Falls back to window.
  37615. * @returns frame number
  37616. */
  37617. static QueueNewFrame(func: () => void, requester?: any): number;
  37618. /**
  37619. * Gets host document
  37620. * @returns the host document object
  37621. */
  37622. getHostDocument(): Nullable<Document>;
  37623. }
  37624. }
  37625. declare module "babylonjs/Maths/sphericalPolynomial" {
  37626. import { Vector3 } from "babylonjs/Maths/math.vector";
  37627. import { Color3 } from "babylonjs/Maths/math.color";
  37628. /**
  37629. * Class representing spherical harmonics coefficients to the 3rd degree
  37630. */
  37631. export class SphericalHarmonics {
  37632. /**
  37633. * Defines whether or not the harmonics have been prescaled for rendering.
  37634. */
  37635. preScaled: boolean;
  37636. /**
  37637. * The l0,0 coefficients of the spherical harmonics
  37638. */
  37639. l00: Vector3;
  37640. /**
  37641. * The l1,-1 coefficients of the spherical harmonics
  37642. */
  37643. l1_1: Vector3;
  37644. /**
  37645. * The l1,0 coefficients of the spherical harmonics
  37646. */
  37647. l10: Vector3;
  37648. /**
  37649. * The l1,1 coefficients of the spherical harmonics
  37650. */
  37651. l11: Vector3;
  37652. /**
  37653. * The l2,-2 coefficients of the spherical harmonics
  37654. */
  37655. l2_2: Vector3;
  37656. /**
  37657. * The l2,-1 coefficients of the spherical harmonics
  37658. */
  37659. l2_1: Vector3;
  37660. /**
  37661. * The l2,0 coefficients of the spherical harmonics
  37662. */
  37663. l20: Vector3;
  37664. /**
  37665. * The l2,1 coefficients of the spherical harmonics
  37666. */
  37667. l21: Vector3;
  37668. /**
  37669. * The l2,2 coefficients of the spherical harmonics
  37670. */
  37671. l22: Vector3;
  37672. /**
  37673. * Adds a light to the spherical harmonics
  37674. * @param direction the direction of the light
  37675. * @param color the color of the light
  37676. * @param deltaSolidAngle the delta solid angle of the light
  37677. */
  37678. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37679. /**
  37680. * Scales the spherical harmonics by the given amount
  37681. * @param scale the amount to scale
  37682. */
  37683. scaleInPlace(scale: number): void;
  37684. /**
  37685. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37686. *
  37687. * ```
  37688. * E_lm = A_l * L_lm
  37689. * ```
  37690. *
  37691. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37692. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37693. * the scaling factors are given in equation 9.
  37694. */
  37695. convertIncidentRadianceToIrradiance(): void;
  37696. /**
  37697. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37698. *
  37699. * ```
  37700. * L = (1/pi) * E * rho
  37701. * ```
  37702. *
  37703. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37704. */
  37705. convertIrradianceToLambertianRadiance(): void;
  37706. /**
  37707. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37708. * required operations at run time.
  37709. *
  37710. * This is simply done by scaling back the SH with Ylm constants parameter.
  37711. * The trigonometric part being applied by the shader at run time.
  37712. */
  37713. preScaleForRendering(): void;
  37714. /**
  37715. * Constructs a spherical harmonics from an array.
  37716. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37717. * @returns the spherical harmonics
  37718. */
  37719. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37720. /**
  37721. * Gets the spherical harmonics from polynomial
  37722. * @param polynomial the spherical polynomial
  37723. * @returns the spherical harmonics
  37724. */
  37725. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37726. }
  37727. /**
  37728. * Class representing spherical polynomial coefficients to the 3rd degree
  37729. */
  37730. export class SphericalPolynomial {
  37731. private _harmonics;
  37732. /**
  37733. * The spherical harmonics used to create the polynomials.
  37734. */
  37735. get preScaledHarmonics(): SphericalHarmonics;
  37736. /**
  37737. * The x coefficients of the spherical polynomial
  37738. */
  37739. x: Vector3;
  37740. /**
  37741. * The y coefficients of the spherical polynomial
  37742. */
  37743. y: Vector3;
  37744. /**
  37745. * The z coefficients of the spherical polynomial
  37746. */
  37747. z: Vector3;
  37748. /**
  37749. * The xx coefficients of the spherical polynomial
  37750. */
  37751. xx: Vector3;
  37752. /**
  37753. * The yy coefficients of the spherical polynomial
  37754. */
  37755. yy: Vector3;
  37756. /**
  37757. * The zz coefficients of the spherical polynomial
  37758. */
  37759. zz: Vector3;
  37760. /**
  37761. * The xy coefficients of the spherical polynomial
  37762. */
  37763. xy: Vector3;
  37764. /**
  37765. * The yz coefficients of the spherical polynomial
  37766. */
  37767. yz: Vector3;
  37768. /**
  37769. * The zx coefficients of the spherical polynomial
  37770. */
  37771. zx: Vector3;
  37772. /**
  37773. * Adds an ambient color to the spherical polynomial
  37774. * @param color the color to add
  37775. */
  37776. addAmbient(color: Color3): void;
  37777. /**
  37778. * Scales the spherical polynomial by the given amount
  37779. * @param scale the amount to scale
  37780. */
  37781. scaleInPlace(scale: number): void;
  37782. /**
  37783. * Gets the spherical polynomial from harmonics
  37784. * @param harmonics the spherical harmonics
  37785. * @returns the spherical polynomial
  37786. */
  37787. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37788. /**
  37789. * Constructs a spherical polynomial from an array.
  37790. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37791. * @returns the spherical polynomial
  37792. */
  37793. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37794. }
  37795. }
  37796. declare module "babylonjs/Materials/Textures/internalTexture" {
  37797. import { Observable } from "babylonjs/Misc/observable";
  37798. import { Nullable, int } from "babylonjs/types";
  37799. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37800. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37801. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37802. /**
  37803. * Defines the source of the internal texture
  37804. */
  37805. export enum InternalTextureSource {
  37806. /**
  37807. * The source of the texture data is unknown
  37808. */
  37809. Unknown = 0,
  37810. /**
  37811. * Texture data comes from an URL
  37812. */
  37813. Url = 1,
  37814. /**
  37815. * Texture data is only used for temporary storage
  37816. */
  37817. Temp = 2,
  37818. /**
  37819. * Texture data comes from raw data (ArrayBuffer)
  37820. */
  37821. Raw = 3,
  37822. /**
  37823. * Texture content is dynamic (video or dynamic texture)
  37824. */
  37825. Dynamic = 4,
  37826. /**
  37827. * Texture content is generated by rendering to it
  37828. */
  37829. RenderTarget = 5,
  37830. /**
  37831. * Texture content is part of a multi render target process
  37832. */
  37833. MultiRenderTarget = 6,
  37834. /**
  37835. * Texture data comes from a cube data file
  37836. */
  37837. Cube = 7,
  37838. /**
  37839. * Texture data comes from a raw cube data
  37840. */
  37841. CubeRaw = 8,
  37842. /**
  37843. * Texture data come from a prefiltered cube data file
  37844. */
  37845. CubePrefiltered = 9,
  37846. /**
  37847. * Texture content is raw 3D data
  37848. */
  37849. Raw3D = 10,
  37850. /**
  37851. * Texture content is raw 2D array data
  37852. */
  37853. Raw2DArray = 11,
  37854. /**
  37855. * Texture content is a depth texture
  37856. */
  37857. Depth = 12,
  37858. /**
  37859. * Texture data comes from a raw cube data encoded with RGBD
  37860. */
  37861. CubeRawRGBD = 13
  37862. }
  37863. /**
  37864. * Class used to store data associated with WebGL texture data for the engine
  37865. * This class should not be used directly
  37866. */
  37867. export class InternalTexture {
  37868. /** @hidden */
  37869. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37870. /**
  37871. * Defines if the texture is ready
  37872. */
  37873. isReady: boolean;
  37874. /**
  37875. * Defines if the texture is a cube texture
  37876. */
  37877. isCube: boolean;
  37878. /**
  37879. * Defines if the texture contains 3D data
  37880. */
  37881. is3D: boolean;
  37882. /**
  37883. * Defines if the texture contains 2D array data
  37884. */
  37885. is2DArray: boolean;
  37886. /**
  37887. * Defines if the texture contains multiview data
  37888. */
  37889. isMultiview: boolean;
  37890. /**
  37891. * Gets the URL used to load this texture
  37892. */
  37893. url: string;
  37894. /**
  37895. * Gets the sampling mode of the texture
  37896. */
  37897. samplingMode: number;
  37898. /**
  37899. * Gets a boolean indicating if the texture needs mipmaps generation
  37900. */
  37901. generateMipMaps: boolean;
  37902. /**
  37903. * Gets the number of samples used by the texture (WebGL2+ only)
  37904. */
  37905. samples: number;
  37906. /**
  37907. * Gets the type of the texture (int, float...)
  37908. */
  37909. type: number;
  37910. /**
  37911. * Gets the format of the texture (RGB, RGBA...)
  37912. */
  37913. format: number;
  37914. /**
  37915. * Observable called when the texture is loaded
  37916. */
  37917. onLoadedObservable: Observable<InternalTexture>;
  37918. /**
  37919. * Gets the width of the texture
  37920. */
  37921. width: number;
  37922. /**
  37923. * Gets the height of the texture
  37924. */
  37925. height: number;
  37926. /**
  37927. * Gets the depth of the texture
  37928. */
  37929. depth: number;
  37930. /**
  37931. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37932. */
  37933. baseWidth: number;
  37934. /**
  37935. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37936. */
  37937. baseHeight: number;
  37938. /**
  37939. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37940. */
  37941. baseDepth: number;
  37942. /**
  37943. * Gets a boolean indicating if the texture is inverted on Y axis
  37944. */
  37945. invertY: boolean;
  37946. /** @hidden */
  37947. _invertVScale: boolean;
  37948. /** @hidden */
  37949. _associatedChannel: number;
  37950. /** @hidden */
  37951. _source: InternalTextureSource;
  37952. /** @hidden */
  37953. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  37954. /** @hidden */
  37955. _bufferView: Nullable<ArrayBufferView>;
  37956. /** @hidden */
  37957. _bufferViewArray: Nullable<ArrayBufferView[]>;
  37958. /** @hidden */
  37959. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  37960. /** @hidden */
  37961. _size: number;
  37962. /** @hidden */
  37963. _extension: string;
  37964. /** @hidden */
  37965. _files: Nullable<string[]>;
  37966. /** @hidden */
  37967. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  37968. /** @hidden */
  37969. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  37970. /** @hidden */
  37971. _framebuffer: Nullable<WebGLFramebuffer>;
  37972. /** @hidden */
  37973. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  37974. /** @hidden */
  37975. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  37976. /** @hidden */
  37977. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  37978. /** @hidden */
  37979. _attachments: Nullable<number[]>;
  37980. /** @hidden */
  37981. _textureArray: Nullable<InternalTexture[]>;
  37982. /** @hidden */
  37983. _cachedCoordinatesMode: Nullable<number>;
  37984. /** @hidden */
  37985. _cachedWrapU: Nullable<number>;
  37986. /** @hidden */
  37987. _cachedWrapV: Nullable<number>;
  37988. /** @hidden */
  37989. _cachedWrapR: Nullable<number>;
  37990. /** @hidden */
  37991. _cachedAnisotropicFilteringLevel: Nullable<number>;
  37992. /** @hidden */
  37993. _isDisabled: boolean;
  37994. /** @hidden */
  37995. _compression: Nullable<string>;
  37996. /** @hidden */
  37997. _generateStencilBuffer: boolean;
  37998. /** @hidden */
  37999. _generateDepthBuffer: boolean;
  38000. /** @hidden */
  38001. _comparisonFunction: number;
  38002. /** @hidden */
  38003. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  38004. /** @hidden */
  38005. _lodGenerationScale: number;
  38006. /** @hidden */
  38007. _lodGenerationOffset: number;
  38008. /** @hidden */
  38009. _depthStencilTexture: Nullable<InternalTexture>;
  38010. /** @hidden */
  38011. _colorTextureArray: Nullable<WebGLTexture>;
  38012. /** @hidden */
  38013. _depthStencilTextureArray: Nullable<WebGLTexture>;
  38014. /** @hidden */
  38015. _lodTextureHigh: Nullable<BaseTexture>;
  38016. /** @hidden */
  38017. _lodTextureMid: Nullable<BaseTexture>;
  38018. /** @hidden */
  38019. _lodTextureLow: Nullable<BaseTexture>;
  38020. /** @hidden */
  38021. _isRGBD: boolean;
  38022. /** @hidden */
  38023. _linearSpecularLOD: boolean;
  38024. /** @hidden */
  38025. _irradianceTexture: Nullable<BaseTexture>;
  38026. /** @hidden */
  38027. _webGLTexture: Nullable<WebGLTexture>;
  38028. /** @hidden */
  38029. _references: number;
  38030. /** @hidden */
  38031. _gammaSpace: Nullable<boolean>;
  38032. private _engine;
  38033. /**
  38034. * Gets the Engine the texture belongs to.
  38035. * @returns The babylon engine
  38036. */
  38037. getEngine(): ThinEngine;
  38038. /**
  38039. * Gets the data source type of the texture
  38040. */
  38041. get source(): InternalTextureSource;
  38042. /**
  38043. * Creates a new InternalTexture
  38044. * @param engine defines the engine to use
  38045. * @param source defines the type of data that will be used
  38046. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38047. */
  38048. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  38049. /**
  38050. * Increments the number of references (ie. the number of Texture that point to it)
  38051. */
  38052. incrementReferences(): void;
  38053. /**
  38054. * Change the size of the texture (not the size of the content)
  38055. * @param width defines the new width
  38056. * @param height defines the new height
  38057. * @param depth defines the new depth (1 by default)
  38058. */
  38059. updateSize(width: int, height: int, depth?: int): void;
  38060. /** @hidden */
  38061. _rebuild(): void;
  38062. /** @hidden */
  38063. _swapAndDie(target: InternalTexture): void;
  38064. /**
  38065. * Dispose the current allocated resources
  38066. */
  38067. dispose(): void;
  38068. }
  38069. }
  38070. declare module "babylonjs/Audio/analyser" {
  38071. import { Scene } from "babylonjs/scene";
  38072. /**
  38073. * Class used to work with sound analyzer using fast fourier transform (FFT)
  38074. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38075. */
  38076. export class Analyser {
  38077. /**
  38078. * Gets or sets the smoothing
  38079. * @ignorenaming
  38080. */
  38081. SMOOTHING: number;
  38082. /**
  38083. * Gets or sets the FFT table size
  38084. * @ignorenaming
  38085. */
  38086. FFT_SIZE: number;
  38087. /**
  38088. * Gets or sets the bar graph amplitude
  38089. * @ignorenaming
  38090. */
  38091. BARGRAPHAMPLITUDE: number;
  38092. /**
  38093. * Gets or sets the position of the debug canvas
  38094. * @ignorenaming
  38095. */
  38096. DEBUGCANVASPOS: {
  38097. x: number;
  38098. y: number;
  38099. };
  38100. /**
  38101. * Gets or sets the debug canvas size
  38102. * @ignorenaming
  38103. */
  38104. DEBUGCANVASSIZE: {
  38105. width: number;
  38106. height: number;
  38107. };
  38108. private _byteFreqs;
  38109. private _byteTime;
  38110. private _floatFreqs;
  38111. private _webAudioAnalyser;
  38112. private _debugCanvas;
  38113. private _debugCanvasContext;
  38114. private _scene;
  38115. private _registerFunc;
  38116. private _audioEngine;
  38117. /**
  38118. * Creates a new analyser
  38119. * @param scene defines hosting scene
  38120. */
  38121. constructor(scene: Scene);
  38122. /**
  38123. * Get the number of data values you will have to play with for the visualization
  38124. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38125. * @returns a number
  38126. */
  38127. getFrequencyBinCount(): number;
  38128. /**
  38129. * Gets the current frequency data as a byte array
  38130. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38131. * @returns a Uint8Array
  38132. */
  38133. getByteFrequencyData(): Uint8Array;
  38134. /**
  38135. * Gets the current waveform as a byte array
  38136. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38137. * @returns a Uint8Array
  38138. */
  38139. getByteTimeDomainData(): Uint8Array;
  38140. /**
  38141. * Gets the current frequency data as a float array
  38142. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38143. * @returns a Float32Array
  38144. */
  38145. getFloatFrequencyData(): Float32Array;
  38146. /**
  38147. * Renders the debug canvas
  38148. */
  38149. drawDebugCanvas(): void;
  38150. /**
  38151. * Stops rendering the debug canvas and removes it
  38152. */
  38153. stopDebugCanvas(): void;
  38154. /**
  38155. * Connects two audio nodes
  38156. * @param inputAudioNode defines first node to connect
  38157. * @param outputAudioNode defines second node to connect
  38158. */
  38159. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38160. /**
  38161. * Releases all associated resources
  38162. */
  38163. dispose(): void;
  38164. }
  38165. }
  38166. declare module "babylonjs/Audio/audioEngine" {
  38167. import { IDisposable } from "babylonjs/scene";
  38168. import { Analyser } from "babylonjs/Audio/analyser";
  38169. import { Nullable } from "babylonjs/types";
  38170. import { Observable } from "babylonjs/Misc/observable";
  38171. /**
  38172. * This represents an audio engine and it is responsible
  38173. * to play, synchronize and analyse sounds throughout the application.
  38174. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38175. */
  38176. export interface IAudioEngine extends IDisposable {
  38177. /**
  38178. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38179. */
  38180. readonly canUseWebAudio: boolean;
  38181. /**
  38182. * Gets the current AudioContext if available.
  38183. */
  38184. readonly audioContext: Nullable<AudioContext>;
  38185. /**
  38186. * The master gain node defines the global audio volume of your audio engine.
  38187. */
  38188. readonly masterGain: GainNode;
  38189. /**
  38190. * Gets whether or not mp3 are supported by your browser.
  38191. */
  38192. readonly isMP3supported: boolean;
  38193. /**
  38194. * Gets whether or not ogg are supported by your browser.
  38195. */
  38196. readonly isOGGsupported: boolean;
  38197. /**
  38198. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38199. * @ignoreNaming
  38200. */
  38201. WarnedWebAudioUnsupported: boolean;
  38202. /**
  38203. * Defines if the audio engine relies on a custom unlocked button.
  38204. * In this case, the embedded button will not be displayed.
  38205. */
  38206. useCustomUnlockedButton: boolean;
  38207. /**
  38208. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38209. */
  38210. readonly unlocked: boolean;
  38211. /**
  38212. * Event raised when audio has been unlocked on the browser.
  38213. */
  38214. onAudioUnlockedObservable: Observable<AudioEngine>;
  38215. /**
  38216. * Event raised when audio has been locked on the browser.
  38217. */
  38218. onAudioLockedObservable: Observable<AudioEngine>;
  38219. /**
  38220. * Flags the audio engine in Locked state.
  38221. * This happens due to new browser policies preventing audio to autoplay.
  38222. */
  38223. lock(): void;
  38224. /**
  38225. * Unlocks the audio engine once a user action has been done on the dom.
  38226. * This is helpful to resume play once browser policies have been satisfied.
  38227. */
  38228. unlock(): void;
  38229. /**
  38230. * Gets the global volume sets on the master gain.
  38231. * @returns the global volume if set or -1 otherwise
  38232. */
  38233. getGlobalVolume(): number;
  38234. /**
  38235. * Sets the global volume of your experience (sets on the master gain).
  38236. * @param newVolume Defines the new global volume of the application
  38237. */
  38238. setGlobalVolume(newVolume: number): void;
  38239. /**
  38240. * Connect the audio engine to an audio analyser allowing some amazing
  38241. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38242. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38243. * @param analyser The analyser to connect to the engine
  38244. */
  38245. connectToAnalyser(analyser: Analyser): void;
  38246. }
  38247. /**
  38248. * This represents the default audio engine used in babylon.
  38249. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38250. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38251. */
  38252. export class AudioEngine implements IAudioEngine {
  38253. private _audioContext;
  38254. private _audioContextInitialized;
  38255. private _muteButton;
  38256. private _hostElement;
  38257. /**
  38258. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38259. */
  38260. canUseWebAudio: boolean;
  38261. /**
  38262. * The master gain node defines the global audio volume of your audio engine.
  38263. */
  38264. masterGain: GainNode;
  38265. /**
  38266. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38267. * @ignoreNaming
  38268. */
  38269. WarnedWebAudioUnsupported: boolean;
  38270. /**
  38271. * Gets whether or not mp3 are supported by your browser.
  38272. */
  38273. isMP3supported: boolean;
  38274. /**
  38275. * Gets whether or not ogg are supported by your browser.
  38276. */
  38277. isOGGsupported: boolean;
  38278. /**
  38279. * Gets whether audio has been unlocked on the device.
  38280. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38281. * a user interaction has happened.
  38282. */
  38283. unlocked: boolean;
  38284. /**
  38285. * Defines if the audio engine relies on a custom unlocked button.
  38286. * In this case, the embedded button will not be displayed.
  38287. */
  38288. useCustomUnlockedButton: boolean;
  38289. /**
  38290. * Event raised when audio has been unlocked on the browser.
  38291. */
  38292. onAudioUnlockedObservable: Observable<AudioEngine>;
  38293. /**
  38294. * Event raised when audio has been locked on the browser.
  38295. */
  38296. onAudioLockedObservable: Observable<AudioEngine>;
  38297. /**
  38298. * Gets the current AudioContext if available.
  38299. */
  38300. get audioContext(): Nullable<AudioContext>;
  38301. private _connectedAnalyser;
  38302. /**
  38303. * Instantiates a new audio engine.
  38304. *
  38305. * There should be only one per page as some browsers restrict the number
  38306. * of audio contexts you can create.
  38307. * @param hostElement defines the host element where to display the mute icon if necessary
  38308. */
  38309. constructor(hostElement?: Nullable<HTMLElement>);
  38310. /**
  38311. * Flags the audio engine in Locked state.
  38312. * This happens due to new browser policies preventing audio to autoplay.
  38313. */
  38314. lock(): void;
  38315. /**
  38316. * Unlocks the audio engine once a user action has been done on the dom.
  38317. * This is helpful to resume play once browser policies have been satisfied.
  38318. */
  38319. unlock(): void;
  38320. private _resumeAudioContext;
  38321. private _initializeAudioContext;
  38322. private _tryToRun;
  38323. private _triggerRunningState;
  38324. private _triggerSuspendedState;
  38325. private _displayMuteButton;
  38326. private _moveButtonToTopLeft;
  38327. private _onResize;
  38328. private _hideMuteButton;
  38329. /**
  38330. * Destroy and release the resources associated with the audio ccontext.
  38331. */
  38332. dispose(): void;
  38333. /**
  38334. * Gets the global volume sets on the master gain.
  38335. * @returns the global volume if set or -1 otherwise
  38336. */
  38337. getGlobalVolume(): number;
  38338. /**
  38339. * Sets the global volume of your experience (sets on the master gain).
  38340. * @param newVolume Defines the new global volume of the application
  38341. */
  38342. setGlobalVolume(newVolume: number): void;
  38343. /**
  38344. * Connect the audio engine to an audio analyser allowing some amazing
  38345. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38346. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38347. * @param analyser The analyser to connect to the engine
  38348. */
  38349. connectToAnalyser(analyser: Analyser): void;
  38350. }
  38351. }
  38352. declare module "babylonjs/Loading/loadingScreen" {
  38353. /**
  38354. * Interface used to present a loading screen while loading a scene
  38355. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38356. */
  38357. export interface ILoadingScreen {
  38358. /**
  38359. * Function called to display the loading screen
  38360. */
  38361. displayLoadingUI: () => void;
  38362. /**
  38363. * Function called to hide the loading screen
  38364. */
  38365. hideLoadingUI: () => void;
  38366. /**
  38367. * Gets or sets the color to use for the background
  38368. */
  38369. loadingUIBackgroundColor: string;
  38370. /**
  38371. * Gets or sets the text to display while loading
  38372. */
  38373. loadingUIText: string;
  38374. }
  38375. /**
  38376. * Class used for the default loading screen
  38377. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38378. */
  38379. export class DefaultLoadingScreen implements ILoadingScreen {
  38380. private _renderingCanvas;
  38381. private _loadingText;
  38382. private _loadingDivBackgroundColor;
  38383. private _loadingDiv;
  38384. private _loadingTextDiv;
  38385. /** Gets or sets the logo url to use for the default loading screen */
  38386. static DefaultLogoUrl: string;
  38387. /** Gets or sets the spinner url to use for the default loading screen */
  38388. static DefaultSpinnerUrl: string;
  38389. /**
  38390. * Creates a new default loading screen
  38391. * @param _renderingCanvas defines the canvas used to render the scene
  38392. * @param _loadingText defines the default text to display
  38393. * @param _loadingDivBackgroundColor defines the default background color
  38394. */
  38395. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38396. /**
  38397. * Function called to display the loading screen
  38398. */
  38399. displayLoadingUI(): void;
  38400. /**
  38401. * Function called to hide the loading screen
  38402. */
  38403. hideLoadingUI(): void;
  38404. /**
  38405. * Gets or sets the text to display while loading
  38406. */
  38407. set loadingUIText(text: string);
  38408. get loadingUIText(): string;
  38409. /**
  38410. * Gets or sets the color to use for the background
  38411. */
  38412. get loadingUIBackgroundColor(): string;
  38413. set loadingUIBackgroundColor(color: string);
  38414. private _resizeLoadingUI;
  38415. }
  38416. }
  38417. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38418. /**
  38419. * Interface for any object that can request an animation frame
  38420. */
  38421. export interface ICustomAnimationFrameRequester {
  38422. /**
  38423. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38424. */
  38425. renderFunction?: Function;
  38426. /**
  38427. * Called to request the next frame to render to
  38428. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38429. */
  38430. requestAnimationFrame: Function;
  38431. /**
  38432. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38433. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38434. */
  38435. requestID?: number;
  38436. }
  38437. }
  38438. declare module "babylonjs/Misc/performanceMonitor" {
  38439. /**
  38440. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38441. */
  38442. export class PerformanceMonitor {
  38443. private _enabled;
  38444. private _rollingFrameTime;
  38445. private _lastFrameTimeMs;
  38446. /**
  38447. * constructor
  38448. * @param frameSampleSize The number of samples required to saturate the sliding window
  38449. */
  38450. constructor(frameSampleSize?: number);
  38451. /**
  38452. * Samples current frame
  38453. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38454. */
  38455. sampleFrame(timeMs?: number): void;
  38456. /**
  38457. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38458. */
  38459. get averageFrameTime(): number;
  38460. /**
  38461. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38462. */
  38463. get averageFrameTimeVariance(): number;
  38464. /**
  38465. * Returns the frame time of the most recent frame
  38466. */
  38467. get instantaneousFrameTime(): number;
  38468. /**
  38469. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38470. */
  38471. get averageFPS(): number;
  38472. /**
  38473. * Returns the average framerate in frames per second using the most recent frame time
  38474. */
  38475. get instantaneousFPS(): number;
  38476. /**
  38477. * Returns true if enough samples have been taken to completely fill the sliding window
  38478. */
  38479. get isSaturated(): boolean;
  38480. /**
  38481. * Enables contributions to the sliding window sample set
  38482. */
  38483. enable(): void;
  38484. /**
  38485. * Disables contributions to the sliding window sample set
  38486. * Samples will not be interpolated over the disabled period
  38487. */
  38488. disable(): void;
  38489. /**
  38490. * Returns true if sampling is enabled
  38491. */
  38492. get isEnabled(): boolean;
  38493. /**
  38494. * Resets performance monitor
  38495. */
  38496. reset(): void;
  38497. }
  38498. /**
  38499. * RollingAverage
  38500. *
  38501. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38502. */
  38503. export class RollingAverage {
  38504. /**
  38505. * Current average
  38506. */
  38507. average: number;
  38508. /**
  38509. * Current variance
  38510. */
  38511. variance: number;
  38512. protected _samples: Array<number>;
  38513. protected _sampleCount: number;
  38514. protected _pos: number;
  38515. protected _m2: number;
  38516. /**
  38517. * constructor
  38518. * @param length The number of samples required to saturate the sliding window
  38519. */
  38520. constructor(length: number);
  38521. /**
  38522. * Adds a sample to the sample set
  38523. * @param v The sample value
  38524. */
  38525. add(v: number): void;
  38526. /**
  38527. * Returns previously added values or null if outside of history or outside the sliding window domain
  38528. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38529. * @return Value previously recorded with add() or null if outside of range
  38530. */
  38531. history(i: number): number;
  38532. /**
  38533. * Returns true if enough samples have been taken to completely fill the sliding window
  38534. * @return true if sample-set saturated
  38535. */
  38536. isSaturated(): boolean;
  38537. /**
  38538. * Resets the rolling average (equivalent to 0 samples taken so far)
  38539. */
  38540. reset(): void;
  38541. /**
  38542. * Wraps a value around the sample range boundaries
  38543. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38544. * @return Wrapped position in sample range
  38545. */
  38546. protected _wrapPosition(i: number): number;
  38547. }
  38548. }
  38549. declare module "babylonjs/Misc/perfCounter" {
  38550. /**
  38551. * This class is used to track a performance counter which is number based.
  38552. * The user has access to many properties which give statistics of different nature.
  38553. *
  38554. * The implementer can track two kinds of Performance Counter: time and count.
  38555. * 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.
  38556. * 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.
  38557. */
  38558. export class PerfCounter {
  38559. /**
  38560. * Gets or sets a global boolean to turn on and off all the counters
  38561. */
  38562. static Enabled: boolean;
  38563. /**
  38564. * Returns the smallest value ever
  38565. */
  38566. get min(): number;
  38567. /**
  38568. * Returns the biggest value ever
  38569. */
  38570. get max(): number;
  38571. /**
  38572. * Returns the average value since the performance counter is running
  38573. */
  38574. get average(): number;
  38575. /**
  38576. * Returns the average value of the last second the counter was monitored
  38577. */
  38578. get lastSecAverage(): number;
  38579. /**
  38580. * Returns the current value
  38581. */
  38582. get current(): number;
  38583. /**
  38584. * Gets the accumulated total
  38585. */
  38586. get total(): number;
  38587. /**
  38588. * Gets the total value count
  38589. */
  38590. get count(): number;
  38591. /**
  38592. * Creates a new counter
  38593. */
  38594. constructor();
  38595. /**
  38596. * Call this method to start monitoring a new frame.
  38597. * 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.
  38598. */
  38599. fetchNewFrame(): void;
  38600. /**
  38601. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38602. * @param newCount the count value to add to the monitored count
  38603. * @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.
  38604. */
  38605. addCount(newCount: number, fetchResult: boolean): void;
  38606. /**
  38607. * Start monitoring this performance counter
  38608. */
  38609. beginMonitoring(): void;
  38610. /**
  38611. * Compute the time lapsed since the previous beginMonitoring() call.
  38612. * @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
  38613. */
  38614. endMonitoring(newFrame?: boolean): void;
  38615. private _fetchResult;
  38616. private _startMonitoringTime;
  38617. private _min;
  38618. private _max;
  38619. private _average;
  38620. private _current;
  38621. private _totalValueCount;
  38622. private _totalAccumulated;
  38623. private _lastSecAverage;
  38624. private _lastSecAccumulated;
  38625. private _lastSecTime;
  38626. private _lastSecValueCount;
  38627. }
  38628. }
  38629. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38630. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38631. import { Nullable } from "babylonjs/types";
  38632. module "babylonjs/Engines/thinEngine" {
  38633. interface ThinEngine {
  38634. /** @hidden */
  38635. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38636. }
  38637. }
  38638. }
  38639. declare module "babylonjs/Engines/engine" {
  38640. import { Observable } from "babylonjs/Misc/observable";
  38641. import { Nullable } from "babylonjs/types";
  38642. import { Scene } from "babylonjs/scene";
  38643. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38644. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38645. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38646. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38647. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38648. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38649. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38650. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38651. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38652. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38653. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38654. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38655. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38656. import "babylonjs/Engines/Extensions/engine.alpha";
  38657. import "babylonjs/Engines/Extensions/engine.readTexture";
  38658. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38659. import { Material } from "babylonjs/Materials/material";
  38660. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38661. /**
  38662. * Defines the interface used by display changed events
  38663. */
  38664. export interface IDisplayChangedEventArgs {
  38665. /** Gets the vrDisplay object (if any) */
  38666. vrDisplay: Nullable<any>;
  38667. /** Gets a boolean indicating if webVR is supported */
  38668. vrSupported: boolean;
  38669. }
  38670. /**
  38671. * Defines the interface used by objects containing a viewport (like a camera)
  38672. */
  38673. interface IViewportOwnerLike {
  38674. /**
  38675. * Gets or sets the viewport
  38676. */
  38677. viewport: IViewportLike;
  38678. }
  38679. /**
  38680. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38681. */
  38682. export class Engine extends ThinEngine {
  38683. /** Defines that alpha blending is disabled */
  38684. static readonly ALPHA_DISABLE: number;
  38685. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38686. static readonly ALPHA_ADD: number;
  38687. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38688. static readonly ALPHA_COMBINE: number;
  38689. /** Defines that alpha blending to DEST - SRC * DEST */
  38690. static readonly ALPHA_SUBTRACT: number;
  38691. /** Defines that alpha blending to SRC * DEST */
  38692. static readonly ALPHA_MULTIPLY: number;
  38693. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38694. static readonly ALPHA_MAXIMIZED: number;
  38695. /** Defines that alpha blending to SRC + DEST */
  38696. static readonly ALPHA_ONEONE: number;
  38697. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38698. static readonly ALPHA_PREMULTIPLIED: number;
  38699. /**
  38700. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38701. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38702. */
  38703. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38704. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38705. static readonly ALPHA_INTERPOLATE: number;
  38706. /**
  38707. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38708. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38709. */
  38710. static readonly ALPHA_SCREENMODE: number;
  38711. /** Defines that the ressource is not delayed*/
  38712. static readonly DELAYLOADSTATE_NONE: number;
  38713. /** Defines that the ressource was successfully delay loaded */
  38714. static readonly DELAYLOADSTATE_LOADED: number;
  38715. /** Defines that the ressource is currently delay loading */
  38716. static readonly DELAYLOADSTATE_LOADING: number;
  38717. /** Defines that the ressource is delayed and has not started loading */
  38718. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38719. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38720. static readonly NEVER: number;
  38721. /** 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 */
  38722. static readonly ALWAYS: number;
  38723. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38724. static readonly LESS: number;
  38725. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38726. static readonly EQUAL: number;
  38727. /** 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 */
  38728. static readonly LEQUAL: number;
  38729. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38730. static readonly GREATER: number;
  38731. /** 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 */
  38732. static readonly GEQUAL: number;
  38733. /** 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 */
  38734. static readonly NOTEQUAL: number;
  38735. /** Passed to stencilOperation to specify that stencil value must be kept */
  38736. static readonly KEEP: number;
  38737. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38738. static readonly REPLACE: number;
  38739. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38740. static readonly INCR: number;
  38741. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38742. static readonly DECR: number;
  38743. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38744. static readonly INVERT: number;
  38745. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38746. static readonly INCR_WRAP: number;
  38747. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38748. static readonly DECR_WRAP: number;
  38749. /** Texture is not repeating outside of 0..1 UVs */
  38750. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38751. /** Texture is repeating outside of 0..1 UVs */
  38752. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38753. /** Texture is repeating and mirrored */
  38754. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38755. /** ALPHA */
  38756. static readonly TEXTUREFORMAT_ALPHA: number;
  38757. /** LUMINANCE */
  38758. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38759. /** LUMINANCE_ALPHA */
  38760. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38761. /** RGB */
  38762. static readonly TEXTUREFORMAT_RGB: number;
  38763. /** RGBA */
  38764. static readonly TEXTUREFORMAT_RGBA: number;
  38765. /** RED */
  38766. static readonly TEXTUREFORMAT_RED: number;
  38767. /** RED (2nd reference) */
  38768. static readonly TEXTUREFORMAT_R: number;
  38769. /** RG */
  38770. static readonly TEXTUREFORMAT_RG: number;
  38771. /** RED_INTEGER */
  38772. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38773. /** RED_INTEGER (2nd reference) */
  38774. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38775. /** RG_INTEGER */
  38776. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38777. /** RGB_INTEGER */
  38778. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38779. /** RGBA_INTEGER */
  38780. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38781. /** UNSIGNED_BYTE */
  38782. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38783. /** UNSIGNED_BYTE (2nd reference) */
  38784. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38785. /** FLOAT */
  38786. static readonly TEXTURETYPE_FLOAT: number;
  38787. /** HALF_FLOAT */
  38788. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38789. /** BYTE */
  38790. static readonly TEXTURETYPE_BYTE: number;
  38791. /** SHORT */
  38792. static readonly TEXTURETYPE_SHORT: number;
  38793. /** UNSIGNED_SHORT */
  38794. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38795. /** INT */
  38796. static readonly TEXTURETYPE_INT: number;
  38797. /** UNSIGNED_INT */
  38798. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38799. /** UNSIGNED_SHORT_4_4_4_4 */
  38800. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38801. /** UNSIGNED_SHORT_5_5_5_1 */
  38802. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38803. /** UNSIGNED_SHORT_5_6_5 */
  38804. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38805. /** UNSIGNED_INT_2_10_10_10_REV */
  38806. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38807. /** UNSIGNED_INT_24_8 */
  38808. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38809. /** UNSIGNED_INT_10F_11F_11F_REV */
  38810. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38811. /** UNSIGNED_INT_5_9_9_9_REV */
  38812. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38813. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38814. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38815. /** nearest is mag = nearest and min = nearest and mip = linear */
  38816. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38817. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38818. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38819. /** Trilinear is mag = linear and min = linear and mip = linear */
  38820. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38821. /** nearest is mag = nearest and min = nearest and mip = linear */
  38822. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38823. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38824. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38825. /** Trilinear is mag = linear and min = linear and mip = linear */
  38826. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38827. /** mag = nearest and min = nearest and mip = nearest */
  38828. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38829. /** mag = nearest and min = linear and mip = nearest */
  38830. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38831. /** mag = nearest and min = linear and mip = linear */
  38832. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38833. /** mag = nearest and min = linear and mip = none */
  38834. static readonly TEXTURE_NEAREST_LINEAR: number;
  38835. /** mag = nearest and min = nearest and mip = none */
  38836. static readonly TEXTURE_NEAREST_NEAREST: number;
  38837. /** mag = linear and min = nearest and mip = nearest */
  38838. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38839. /** mag = linear and min = nearest and mip = linear */
  38840. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38841. /** mag = linear and min = linear and mip = none */
  38842. static readonly TEXTURE_LINEAR_LINEAR: number;
  38843. /** mag = linear and min = nearest and mip = none */
  38844. static readonly TEXTURE_LINEAR_NEAREST: number;
  38845. /** Explicit coordinates mode */
  38846. static readonly TEXTURE_EXPLICIT_MODE: number;
  38847. /** Spherical coordinates mode */
  38848. static readonly TEXTURE_SPHERICAL_MODE: number;
  38849. /** Planar coordinates mode */
  38850. static readonly TEXTURE_PLANAR_MODE: number;
  38851. /** Cubic coordinates mode */
  38852. static readonly TEXTURE_CUBIC_MODE: number;
  38853. /** Projection coordinates mode */
  38854. static readonly TEXTURE_PROJECTION_MODE: number;
  38855. /** Skybox coordinates mode */
  38856. static readonly TEXTURE_SKYBOX_MODE: number;
  38857. /** Inverse Cubic coordinates mode */
  38858. static readonly TEXTURE_INVCUBIC_MODE: number;
  38859. /** Equirectangular coordinates mode */
  38860. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38861. /** Equirectangular Fixed coordinates mode */
  38862. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38863. /** Equirectangular Fixed Mirrored coordinates mode */
  38864. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38865. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38866. static readonly SCALEMODE_FLOOR: number;
  38867. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38868. static readonly SCALEMODE_NEAREST: number;
  38869. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38870. static readonly SCALEMODE_CEILING: number;
  38871. /**
  38872. * Returns the current npm package of the sdk
  38873. */
  38874. static get NpmPackage(): string;
  38875. /**
  38876. * Returns the current version of the framework
  38877. */
  38878. static get Version(): string;
  38879. /** Gets the list of created engines */
  38880. static get Instances(): Engine[];
  38881. /**
  38882. * Gets the latest created engine
  38883. */
  38884. static get LastCreatedEngine(): Nullable<Engine>;
  38885. /**
  38886. * Gets the latest created scene
  38887. */
  38888. static get LastCreatedScene(): Nullable<Scene>;
  38889. /**
  38890. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38891. * @param flag defines which part of the materials must be marked as dirty
  38892. * @param predicate defines a predicate used to filter which materials should be affected
  38893. */
  38894. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38895. /**
  38896. * Method called to create the default loading screen.
  38897. * This can be overriden in your own app.
  38898. * @param canvas The rendering canvas element
  38899. * @returns The loading screen
  38900. */
  38901. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38902. /**
  38903. * Method called to create the default rescale post process on each engine.
  38904. */
  38905. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38906. /**
  38907. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38908. **/
  38909. enableOfflineSupport: boolean;
  38910. /**
  38911. * 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)
  38912. **/
  38913. disableManifestCheck: boolean;
  38914. /**
  38915. * Gets the list of created scenes
  38916. */
  38917. scenes: Scene[];
  38918. /**
  38919. * Event raised when a new scene is created
  38920. */
  38921. onNewSceneAddedObservable: Observable<Scene>;
  38922. /**
  38923. * Gets the list of created postprocesses
  38924. */
  38925. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38926. /**
  38927. * Gets a boolean indicating if the pointer is currently locked
  38928. */
  38929. isPointerLock: boolean;
  38930. /**
  38931. * Observable event triggered each time the rendering canvas is resized
  38932. */
  38933. onResizeObservable: Observable<Engine>;
  38934. /**
  38935. * Observable event triggered each time the canvas loses focus
  38936. */
  38937. onCanvasBlurObservable: Observable<Engine>;
  38938. /**
  38939. * Observable event triggered each time the canvas gains focus
  38940. */
  38941. onCanvasFocusObservable: Observable<Engine>;
  38942. /**
  38943. * Observable event triggered each time the canvas receives pointerout event
  38944. */
  38945. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38946. /**
  38947. * Observable raised when the engine begins a new frame
  38948. */
  38949. onBeginFrameObservable: Observable<Engine>;
  38950. /**
  38951. * If set, will be used to request the next animation frame for the render loop
  38952. */
  38953. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  38954. /**
  38955. * Observable raised when the engine ends the current frame
  38956. */
  38957. onEndFrameObservable: Observable<Engine>;
  38958. /**
  38959. * Observable raised when the engine is about to compile a shader
  38960. */
  38961. onBeforeShaderCompilationObservable: Observable<Engine>;
  38962. /**
  38963. * Observable raised when the engine has jsut compiled a shader
  38964. */
  38965. onAfterShaderCompilationObservable: Observable<Engine>;
  38966. /**
  38967. * Gets the audio engine
  38968. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38969. * @ignorenaming
  38970. */
  38971. static audioEngine: IAudioEngine;
  38972. /**
  38973. * Default AudioEngine factory responsible of creating the Audio Engine.
  38974. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  38975. */
  38976. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  38977. /**
  38978. * Default offline support factory responsible of creating a tool used to store data locally.
  38979. * By default, this will create a Database object if the workload has been embedded.
  38980. */
  38981. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  38982. private _loadingScreen;
  38983. private _pointerLockRequested;
  38984. private _rescalePostProcess;
  38985. private _deterministicLockstep;
  38986. private _lockstepMaxSteps;
  38987. private _timeStep;
  38988. protected get _supportsHardwareTextureRescaling(): boolean;
  38989. private _fps;
  38990. private _deltaTime;
  38991. /** @hidden */
  38992. _drawCalls: PerfCounter;
  38993. /** 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 */
  38994. canvasTabIndex: number;
  38995. /**
  38996. * Turn this value on if you want to pause FPS computation when in background
  38997. */
  38998. disablePerformanceMonitorInBackground: boolean;
  38999. private _performanceMonitor;
  39000. /**
  39001. * Gets the performance monitor attached to this engine
  39002. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39003. */
  39004. get performanceMonitor(): PerformanceMonitor;
  39005. private _onFocus;
  39006. private _onBlur;
  39007. private _onCanvasPointerOut;
  39008. private _onCanvasBlur;
  39009. private _onCanvasFocus;
  39010. private _onFullscreenChange;
  39011. private _onPointerLockChange;
  39012. /**
  39013. * Gets the HTML element used to attach event listeners
  39014. * @returns a HTML element
  39015. */
  39016. getInputElement(): Nullable<HTMLElement>;
  39017. /**
  39018. * Creates a new engine
  39019. * @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
  39020. * @param antialias defines enable antialiasing (default: false)
  39021. * @param options defines further options to be sent to the getContext() function
  39022. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39023. */
  39024. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39025. /**
  39026. * Gets current aspect ratio
  39027. * @param viewportOwner defines the camera to use to get the aspect ratio
  39028. * @param useScreen defines if screen size must be used (or the current render target if any)
  39029. * @returns a number defining the aspect ratio
  39030. */
  39031. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  39032. /**
  39033. * Gets current screen aspect ratio
  39034. * @returns a number defining the aspect ratio
  39035. */
  39036. getScreenAspectRatio(): number;
  39037. /**
  39038. * Gets the client rect of the HTML canvas attached with the current webGL context
  39039. * @returns a client rectanglee
  39040. */
  39041. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  39042. /**
  39043. * Gets the client rect of the HTML element used for events
  39044. * @returns a client rectanglee
  39045. */
  39046. getInputElementClientRect(): Nullable<ClientRect>;
  39047. /**
  39048. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  39049. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39050. * @returns true if engine is in deterministic lock step mode
  39051. */
  39052. isDeterministicLockStep(): boolean;
  39053. /**
  39054. * Gets the max steps when engine is running in deterministic lock step
  39055. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39056. * @returns the max steps
  39057. */
  39058. getLockstepMaxSteps(): number;
  39059. /**
  39060. * Returns the time in ms between steps when using deterministic lock step.
  39061. * @returns time step in (ms)
  39062. */
  39063. getTimeStep(): number;
  39064. /**
  39065. * Force the mipmap generation for the given render target texture
  39066. * @param texture defines the render target texture to use
  39067. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  39068. */
  39069. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  39070. /** States */
  39071. /**
  39072. * Set various states to the webGL context
  39073. * @param culling defines backface culling state
  39074. * @param zOffset defines the value to apply to zOffset (0 by default)
  39075. * @param force defines if states must be applied even if cache is up to date
  39076. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  39077. */
  39078. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39079. /**
  39080. * Set the z offset to apply to current rendering
  39081. * @param value defines the offset to apply
  39082. */
  39083. setZOffset(value: number): void;
  39084. /**
  39085. * Gets the current value of the zOffset
  39086. * @returns the current zOffset state
  39087. */
  39088. getZOffset(): number;
  39089. /**
  39090. * Enable or disable depth buffering
  39091. * @param enable defines the state to set
  39092. */
  39093. setDepthBuffer(enable: boolean): void;
  39094. /**
  39095. * Gets a boolean indicating if depth writing is enabled
  39096. * @returns the current depth writing state
  39097. */
  39098. getDepthWrite(): boolean;
  39099. /**
  39100. * Enable or disable depth writing
  39101. * @param enable defines the state to set
  39102. */
  39103. setDepthWrite(enable: boolean): void;
  39104. /**
  39105. * Gets a boolean indicating if stencil buffer is enabled
  39106. * @returns the current stencil buffer state
  39107. */
  39108. getStencilBuffer(): boolean;
  39109. /**
  39110. * Enable or disable the stencil buffer
  39111. * @param enable defines if the stencil buffer must be enabled or disabled
  39112. */
  39113. setStencilBuffer(enable: boolean): void;
  39114. /**
  39115. * Gets the current stencil mask
  39116. * @returns a number defining the new stencil mask to use
  39117. */
  39118. getStencilMask(): number;
  39119. /**
  39120. * Sets the current stencil mask
  39121. * @param mask defines the new stencil mask to use
  39122. */
  39123. setStencilMask(mask: number): void;
  39124. /**
  39125. * Gets the current stencil function
  39126. * @returns a number defining the stencil function to use
  39127. */
  39128. getStencilFunction(): number;
  39129. /**
  39130. * Gets the current stencil reference value
  39131. * @returns a number defining the stencil reference value to use
  39132. */
  39133. getStencilFunctionReference(): number;
  39134. /**
  39135. * Gets the current stencil mask
  39136. * @returns a number defining the stencil mask to use
  39137. */
  39138. getStencilFunctionMask(): number;
  39139. /**
  39140. * Sets the current stencil function
  39141. * @param stencilFunc defines the new stencil function to use
  39142. */
  39143. setStencilFunction(stencilFunc: number): void;
  39144. /**
  39145. * Sets the current stencil reference
  39146. * @param reference defines the new stencil reference to use
  39147. */
  39148. setStencilFunctionReference(reference: number): void;
  39149. /**
  39150. * Sets the current stencil mask
  39151. * @param mask defines the new stencil mask to use
  39152. */
  39153. setStencilFunctionMask(mask: number): void;
  39154. /**
  39155. * Gets the current stencil operation when stencil fails
  39156. * @returns a number defining stencil operation to use when stencil fails
  39157. */
  39158. getStencilOperationFail(): number;
  39159. /**
  39160. * Gets the current stencil operation when depth fails
  39161. * @returns a number defining stencil operation to use when depth fails
  39162. */
  39163. getStencilOperationDepthFail(): number;
  39164. /**
  39165. * Gets the current stencil operation when stencil passes
  39166. * @returns a number defining stencil operation to use when stencil passes
  39167. */
  39168. getStencilOperationPass(): number;
  39169. /**
  39170. * Sets the stencil operation to use when stencil fails
  39171. * @param operation defines the stencil operation to use when stencil fails
  39172. */
  39173. setStencilOperationFail(operation: number): void;
  39174. /**
  39175. * Sets the stencil operation to use when depth fails
  39176. * @param operation defines the stencil operation to use when depth fails
  39177. */
  39178. setStencilOperationDepthFail(operation: number): void;
  39179. /**
  39180. * Sets the stencil operation to use when stencil passes
  39181. * @param operation defines the stencil operation to use when stencil passes
  39182. */
  39183. setStencilOperationPass(operation: number): void;
  39184. /**
  39185. * Sets a boolean indicating if the dithering state is enabled or disabled
  39186. * @param value defines the dithering state
  39187. */
  39188. setDitheringState(value: boolean): void;
  39189. /**
  39190. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39191. * @param value defines the rasterizer state
  39192. */
  39193. setRasterizerState(value: boolean): void;
  39194. /**
  39195. * Gets the current depth function
  39196. * @returns a number defining the depth function
  39197. */
  39198. getDepthFunction(): Nullable<number>;
  39199. /**
  39200. * Sets the current depth function
  39201. * @param depthFunc defines the function to use
  39202. */
  39203. setDepthFunction(depthFunc: number): void;
  39204. /**
  39205. * Sets the current depth function to GREATER
  39206. */
  39207. setDepthFunctionToGreater(): void;
  39208. /**
  39209. * Sets the current depth function to GEQUAL
  39210. */
  39211. setDepthFunctionToGreaterOrEqual(): void;
  39212. /**
  39213. * Sets the current depth function to LESS
  39214. */
  39215. setDepthFunctionToLess(): void;
  39216. /**
  39217. * Sets the current depth function to LEQUAL
  39218. */
  39219. setDepthFunctionToLessOrEqual(): void;
  39220. private _cachedStencilBuffer;
  39221. private _cachedStencilFunction;
  39222. private _cachedStencilMask;
  39223. private _cachedStencilOperationPass;
  39224. private _cachedStencilOperationFail;
  39225. private _cachedStencilOperationDepthFail;
  39226. private _cachedStencilReference;
  39227. /**
  39228. * Caches the the state of the stencil buffer
  39229. */
  39230. cacheStencilState(): void;
  39231. /**
  39232. * Restores the state of the stencil buffer
  39233. */
  39234. restoreStencilState(): void;
  39235. /**
  39236. * Directly set the WebGL Viewport
  39237. * @param x defines the x coordinate of the viewport (in screen space)
  39238. * @param y defines the y coordinate of the viewport (in screen space)
  39239. * @param width defines the width of the viewport (in screen space)
  39240. * @param height defines the height of the viewport (in screen space)
  39241. * @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
  39242. */
  39243. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39244. /**
  39245. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39246. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39247. * @param y defines the y-coordinate of the corner of the clear rectangle
  39248. * @param width defines the width of the clear rectangle
  39249. * @param height defines the height of the clear rectangle
  39250. * @param clearColor defines the clear color
  39251. */
  39252. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39253. /**
  39254. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39255. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39256. * @param y defines the y-coordinate of the corner of the clear rectangle
  39257. * @param width defines the width of the clear rectangle
  39258. * @param height defines the height of the clear rectangle
  39259. */
  39260. enableScissor(x: number, y: number, width: number, height: number): void;
  39261. /**
  39262. * Disable previously set scissor test rectangle
  39263. */
  39264. disableScissor(): void;
  39265. protected _reportDrawCall(): void;
  39266. /**
  39267. * Initializes a webVR display and starts listening to display change events
  39268. * The onVRDisplayChangedObservable will be notified upon these changes
  39269. * @returns The onVRDisplayChangedObservable
  39270. */
  39271. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39272. /** @hidden */
  39273. _prepareVRComponent(): void;
  39274. /** @hidden */
  39275. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39276. /** @hidden */
  39277. _submitVRFrame(): void;
  39278. /**
  39279. * Call this function to leave webVR mode
  39280. * Will do nothing if webVR is not supported or if there is no webVR device
  39281. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39282. */
  39283. disableVR(): void;
  39284. /**
  39285. * Gets a boolean indicating that the system is in VR mode and is presenting
  39286. * @returns true if VR mode is engaged
  39287. */
  39288. isVRPresenting(): boolean;
  39289. /** @hidden */
  39290. _requestVRFrame(): void;
  39291. /** @hidden */
  39292. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39293. /**
  39294. * Gets the source code of the vertex shader associated with a specific webGL program
  39295. * @param program defines the program to use
  39296. * @returns a string containing the source code of the vertex shader associated with the program
  39297. */
  39298. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39299. /**
  39300. * Gets the source code of the fragment shader associated with a specific webGL program
  39301. * @param program defines the program to use
  39302. * @returns a string containing the source code of the fragment shader associated with the program
  39303. */
  39304. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39305. /**
  39306. * Sets a depth stencil texture from a render target to the according uniform.
  39307. * @param channel The texture channel
  39308. * @param uniform The uniform to set
  39309. * @param texture The render target texture containing the depth stencil texture to apply
  39310. */
  39311. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39312. /**
  39313. * Sets a texture to the webGL context from a postprocess
  39314. * @param channel defines the channel to use
  39315. * @param postProcess defines the source postprocess
  39316. */
  39317. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39318. /**
  39319. * Binds the output of the passed in post process to the texture channel specified
  39320. * @param channel The channel the texture should be bound to
  39321. * @param postProcess The post process which's output should be bound
  39322. */
  39323. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39324. protected _rebuildBuffers(): void;
  39325. /** @hidden */
  39326. _renderFrame(): void;
  39327. _renderLoop(): void;
  39328. /** @hidden */
  39329. _renderViews(): boolean;
  39330. /**
  39331. * Toggle full screen mode
  39332. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39333. */
  39334. switchFullscreen(requestPointerLock: boolean): void;
  39335. /**
  39336. * Enters full screen mode
  39337. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39338. */
  39339. enterFullscreen(requestPointerLock: boolean): void;
  39340. /**
  39341. * Exits full screen mode
  39342. */
  39343. exitFullscreen(): void;
  39344. /**
  39345. * Enters Pointerlock mode
  39346. */
  39347. enterPointerlock(): void;
  39348. /**
  39349. * Exits Pointerlock mode
  39350. */
  39351. exitPointerlock(): void;
  39352. /**
  39353. * Begin a new frame
  39354. */
  39355. beginFrame(): void;
  39356. /**
  39357. * Enf the current frame
  39358. */
  39359. endFrame(): void;
  39360. resize(): void;
  39361. /**
  39362. * Force a specific size of the canvas
  39363. * @param width defines the new canvas' width
  39364. * @param height defines the new canvas' height
  39365. * @returns true if the size was changed
  39366. */
  39367. setSize(width: number, height: number): boolean;
  39368. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39369. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39370. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39371. _releaseTexture(texture: InternalTexture): void;
  39372. /**
  39373. * @hidden
  39374. * Rescales a texture
  39375. * @param source input texutre
  39376. * @param destination destination texture
  39377. * @param scene scene to use to render the resize
  39378. * @param internalFormat format to use when resizing
  39379. * @param onComplete callback to be called when resize has completed
  39380. */
  39381. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39382. /**
  39383. * Gets the current framerate
  39384. * @returns a number representing the framerate
  39385. */
  39386. getFps(): number;
  39387. /**
  39388. * Gets the time spent between current and previous frame
  39389. * @returns a number representing the delta time in ms
  39390. */
  39391. getDeltaTime(): number;
  39392. private _measureFps;
  39393. /** @hidden */
  39394. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39395. /**
  39396. * Updates the sample count of a render target texture
  39397. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39398. * @param texture defines the texture to update
  39399. * @param samples defines the sample count to set
  39400. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39401. */
  39402. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39403. /**
  39404. * Updates a depth texture Comparison Mode and Function.
  39405. * If the comparison Function is equal to 0, the mode will be set to none.
  39406. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39407. * @param texture The texture to set the comparison function for
  39408. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39409. */
  39410. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39411. /**
  39412. * Creates a webGL buffer to use with instanciation
  39413. * @param capacity defines the size of the buffer
  39414. * @returns the webGL buffer
  39415. */
  39416. createInstancesBuffer(capacity: number): DataBuffer;
  39417. /**
  39418. * Delete a webGL buffer used with instanciation
  39419. * @param buffer defines the webGL buffer to delete
  39420. */
  39421. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39422. private _clientWaitAsync;
  39423. /** @hidden */
  39424. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39425. dispose(): void;
  39426. private _disableTouchAction;
  39427. /**
  39428. * Display the loading screen
  39429. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39430. */
  39431. displayLoadingUI(): void;
  39432. /**
  39433. * Hide the loading screen
  39434. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39435. */
  39436. hideLoadingUI(): void;
  39437. /**
  39438. * Gets the current loading screen object
  39439. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39440. */
  39441. get loadingScreen(): ILoadingScreen;
  39442. /**
  39443. * Sets the current loading screen object
  39444. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39445. */
  39446. set loadingScreen(loadingScreen: ILoadingScreen);
  39447. /**
  39448. * Sets the current loading screen text
  39449. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39450. */
  39451. set loadingUIText(text: string);
  39452. /**
  39453. * Sets the current loading screen background color
  39454. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39455. */
  39456. set loadingUIBackgroundColor(color: string);
  39457. /** Pointerlock and fullscreen */
  39458. /**
  39459. * Ask the browser to promote the current element to pointerlock mode
  39460. * @param element defines the DOM element to promote
  39461. */
  39462. static _RequestPointerlock(element: HTMLElement): void;
  39463. /**
  39464. * Asks the browser to exit pointerlock mode
  39465. */
  39466. static _ExitPointerlock(): void;
  39467. /**
  39468. * Ask the browser to promote the current element to fullscreen rendering mode
  39469. * @param element defines the DOM element to promote
  39470. */
  39471. static _RequestFullscreen(element: HTMLElement): void;
  39472. /**
  39473. * Asks the browser to exit fullscreen mode
  39474. */
  39475. static _ExitFullscreen(): void;
  39476. }
  39477. }
  39478. declare module "babylonjs/Engines/engineStore" {
  39479. import { Nullable } from "babylonjs/types";
  39480. import { Engine } from "babylonjs/Engines/engine";
  39481. import { Scene } from "babylonjs/scene";
  39482. /**
  39483. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39484. * during the life time of the application.
  39485. */
  39486. export class EngineStore {
  39487. /** Gets the list of created engines */
  39488. static Instances: import("babylonjs/Engines/engine").Engine[];
  39489. /** @hidden */
  39490. static _LastCreatedScene: Nullable<Scene>;
  39491. /**
  39492. * Gets the latest created engine
  39493. */
  39494. static get LastCreatedEngine(): Nullable<Engine>;
  39495. /**
  39496. * Gets the latest created scene
  39497. */
  39498. static get LastCreatedScene(): Nullable<Scene>;
  39499. /**
  39500. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39501. * @ignorenaming
  39502. */
  39503. static UseFallbackTexture: boolean;
  39504. /**
  39505. * Texture content used if a texture cannot loaded
  39506. * @ignorenaming
  39507. */
  39508. static FallbackTexture: string;
  39509. }
  39510. }
  39511. declare module "babylonjs/Misc/promise" {
  39512. /**
  39513. * Helper class that provides a small promise polyfill
  39514. */
  39515. export class PromisePolyfill {
  39516. /**
  39517. * Static function used to check if the polyfill is required
  39518. * If this is the case then the function will inject the polyfill to window.Promise
  39519. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39520. */
  39521. static Apply(force?: boolean): void;
  39522. }
  39523. }
  39524. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39525. /**
  39526. * Interface for screenshot methods with describe argument called `size` as object with options
  39527. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39528. */
  39529. export interface IScreenshotSize {
  39530. /**
  39531. * number in pixels for canvas height
  39532. */
  39533. height?: number;
  39534. /**
  39535. * multiplier allowing render at a higher or lower resolution
  39536. * If value is defined then height and width will be ignored and taken from camera
  39537. */
  39538. precision?: number;
  39539. /**
  39540. * number in pixels for canvas width
  39541. */
  39542. width?: number;
  39543. }
  39544. }
  39545. declare module "babylonjs/Misc/tools" {
  39546. import { Nullable, float } from "babylonjs/types";
  39547. import { DomManagement } from "babylonjs/Misc/domManagement";
  39548. import { WebRequest } from "babylonjs/Misc/webRequest";
  39549. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39550. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39551. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39552. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39553. import { Camera } from "babylonjs/Cameras/camera";
  39554. import { Engine } from "babylonjs/Engines/engine";
  39555. interface IColor4Like {
  39556. r: float;
  39557. g: float;
  39558. b: float;
  39559. a: float;
  39560. }
  39561. /**
  39562. * Class containing a set of static utilities functions
  39563. */
  39564. export class Tools {
  39565. /**
  39566. * Gets or sets the base URL to use to load assets
  39567. */
  39568. static get BaseUrl(): string;
  39569. static set BaseUrl(value: string);
  39570. /**
  39571. * Enable/Disable Custom HTTP Request Headers globally.
  39572. * default = false
  39573. * @see CustomRequestHeaders
  39574. */
  39575. static UseCustomRequestHeaders: boolean;
  39576. /**
  39577. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39578. * i.e. when loading files, where the server/service expects an Authorization header
  39579. */
  39580. static CustomRequestHeaders: {
  39581. [key: string]: string;
  39582. };
  39583. /**
  39584. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39585. */
  39586. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39587. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39588. /**
  39589. * Default behaviour for cors in the application.
  39590. * It can be a string if the expected behavior is identical in the entire app.
  39591. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39592. */
  39593. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39594. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39595. /**
  39596. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39597. * @ignorenaming
  39598. */
  39599. static get UseFallbackTexture(): boolean;
  39600. static set UseFallbackTexture(value: boolean);
  39601. /**
  39602. * Use this object to register external classes like custom textures or material
  39603. * to allow the laoders to instantiate them
  39604. */
  39605. static get RegisteredExternalClasses(): {
  39606. [key: string]: Object;
  39607. };
  39608. static set RegisteredExternalClasses(classes: {
  39609. [key: string]: Object;
  39610. });
  39611. /**
  39612. * Texture content used if a texture cannot loaded
  39613. * @ignorenaming
  39614. */
  39615. static get fallbackTexture(): string;
  39616. static set fallbackTexture(value: string);
  39617. /**
  39618. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39619. * @param u defines the coordinate on X axis
  39620. * @param v defines the coordinate on Y axis
  39621. * @param width defines the width of the source data
  39622. * @param height defines the height of the source data
  39623. * @param pixels defines the source byte array
  39624. * @param color defines the output color
  39625. */
  39626. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39627. /**
  39628. * Interpolates between a and b via alpha
  39629. * @param a The lower value (returned when alpha = 0)
  39630. * @param b The upper value (returned when alpha = 1)
  39631. * @param alpha The interpolation-factor
  39632. * @return The mixed value
  39633. */
  39634. static Mix(a: number, b: number, alpha: number): number;
  39635. /**
  39636. * Tries to instantiate a new object from a given class name
  39637. * @param className defines the class name to instantiate
  39638. * @returns the new object or null if the system was not able to do the instantiation
  39639. */
  39640. static Instantiate(className: string): any;
  39641. /**
  39642. * Provides a slice function that will work even on IE
  39643. * @param data defines the array to slice
  39644. * @param start defines the start of the data (optional)
  39645. * @param end defines the end of the data (optional)
  39646. * @returns the new sliced array
  39647. */
  39648. static Slice<T>(data: T, start?: number, end?: number): T;
  39649. /**
  39650. * Polyfill for setImmediate
  39651. * @param action defines the action to execute after the current execution block
  39652. */
  39653. static SetImmediate(action: () => void): void;
  39654. /**
  39655. * Function indicating if a number is an exponent of 2
  39656. * @param value defines the value to test
  39657. * @returns true if the value is an exponent of 2
  39658. */
  39659. static IsExponentOfTwo(value: number): boolean;
  39660. private static _tmpFloatArray;
  39661. /**
  39662. * Returns the nearest 32-bit single precision float representation of a Number
  39663. * @param value A Number. If the parameter is of a different type, it will get converted
  39664. * to a number or to NaN if it cannot be converted
  39665. * @returns number
  39666. */
  39667. static FloatRound(value: number): number;
  39668. /**
  39669. * Extracts the filename from a path
  39670. * @param path defines the path to use
  39671. * @returns the filename
  39672. */
  39673. static GetFilename(path: string): string;
  39674. /**
  39675. * Extracts the "folder" part of a path (everything before the filename).
  39676. * @param uri The URI to extract the info from
  39677. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39678. * @returns The "folder" part of the path
  39679. */
  39680. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39681. /**
  39682. * Extracts text content from a DOM element hierarchy
  39683. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39684. */
  39685. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39686. /**
  39687. * Convert an angle in radians to degrees
  39688. * @param angle defines the angle to convert
  39689. * @returns the angle in degrees
  39690. */
  39691. static ToDegrees(angle: number): number;
  39692. /**
  39693. * Convert an angle in degrees to radians
  39694. * @param angle defines the angle to convert
  39695. * @returns the angle in radians
  39696. */
  39697. static ToRadians(angle: number): number;
  39698. /**
  39699. * Returns an array if obj is not an array
  39700. * @param obj defines the object to evaluate as an array
  39701. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39702. * @returns either obj directly if obj is an array or a new array containing obj
  39703. */
  39704. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39705. /**
  39706. * Gets the pointer prefix to use
  39707. * @param engine defines the engine we are finding the prefix for
  39708. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39709. */
  39710. static GetPointerPrefix(engine: Engine): string;
  39711. /**
  39712. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39713. * @param url define the url we are trying
  39714. * @param element define the dom element where to configure the cors policy
  39715. */
  39716. static SetCorsBehavior(url: string | string[], element: {
  39717. crossOrigin: string | null;
  39718. }): void;
  39719. /**
  39720. * Removes unwanted characters from an url
  39721. * @param url defines the url to clean
  39722. * @returns the cleaned url
  39723. */
  39724. static CleanUrl(url: string): string;
  39725. /**
  39726. * Gets or sets a function used to pre-process url before using them to load assets
  39727. */
  39728. static get PreprocessUrl(): (url: string) => string;
  39729. static set PreprocessUrl(processor: (url: string) => string);
  39730. /**
  39731. * Loads an image as an HTMLImageElement.
  39732. * @param input url string, ArrayBuffer, or Blob to load
  39733. * @param onLoad callback called when the image successfully loads
  39734. * @param onError callback called when the image fails to load
  39735. * @param offlineProvider offline provider for caching
  39736. * @param mimeType optional mime type
  39737. * @returns the HTMLImageElement of the loaded image
  39738. */
  39739. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39740. /**
  39741. * Loads a file from a url
  39742. * @param url url string, ArrayBuffer, or Blob to load
  39743. * @param onSuccess callback called when the file successfully loads
  39744. * @param onProgress callback called while file is loading (if the server supports this mode)
  39745. * @param offlineProvider defines the offline provider for caching
  39746. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39747. * @param onError callback called when the file fails to load
  39748. * @returns a file request object
  39749. */
  39750. 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;
  39751. /**
  39752. * Loads a file from a url
  39753. * @param url the file url to load
  39754. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39755. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39756. */
  39757. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39758. /**
  39759. * Load a script (identified by an url). When the url returns, the
  39760. * content of this file is added into a new script element, attached to the DOM (body element)
  39761. * @param scriptUrl defines the url of the script to laod
  39762. * @param onSuccess defines the callback called when the script is loaded
  39763. * @param onError defines the callback to call if an error occurs
  39764. * @param scriptId defines the id of the script element
  39765. */
  39766. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39767. /**
  39768. * Load an asynchronous script (identified by an url). When the url returns, the
  39769. * content of this file is added into a new script element, attached to the DOM (body element)
  39770. * @param scriptUrl defines the url of the script to laod
  39771. * @param scriptId defines the id of the script element
  39772. * @returns a promise request object
  39773. */
  39774. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39775. /**
  39776. * Loads a file from a blob
  39777. * @param fileToLoad defines the blob to use
  39778. * @param callback defines the callback to call when data is loaded
  39779. * @param progressCallback defines the callback to call during loading process
  39780. * @returns a file request object
  39781. */
  39782. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39783. /**
  39784. * Reads a file from a File object
  39785. * @param file defines the file to load
  39786. * @param onSuccess defines the callback to call when data is loaded
  39787. * @param onProgress defines the callback to call during loading process
  39788. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39789. * @param onError defines the callback to call when an error occurs
  39790. * @returns a file request object
  39791. */
  39792. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39793. /**
  39794. * Creates a data url from a given string content
  39795. * @param content defines the content to convert
  39796. * @returns the new data url link
  39797. */
  39798. static FileAsURL(content: string): string;
  39799. /**
  39800. * Format the given number to a specific decimal format
  39801. * @param value defines the number to format
  39802. * @param decimals defines the number of decimals to use
  39803. * @returns the formatted string
  39804. */
  39805. static Format(value: number, decimals?: number): string;
  39806. /**
  39807. * Tries to copy an object by duplicating every property
  39808. * @param source defines the source object
  39809. * @param destination defines the target object
  39810. * @param doNotCopyList defines a list of properties to avoid
  39811. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39812. */
  39813. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39814. /**
  39815. * Gets a boolean indicating if the given object has no own property
  39816. * @param obj defines the object to test
  39817. * @returns true if object has no own property
  39818. */
  39819. static IsEmpty(obj: any): boolean;
  39820. /**
  39821. * Function used to register events at window level
  39822. * @param windowElement defines the Window object to use
  39823. * @param events defines the events to register
  39824. */
  39825. static RegisterTopRootEvents(windowElement: Window, events: {
  39826. name: string;
  39827. handler: Nullable<(e: FocusEvent) => any>;
  39828. }[]): void;
  39829. /**
  39830. * Function used to unregister events from window level
  39831. * @param windowElement defines the Window object to use
  39832. * @param events defines the events to unregister
  39833. */
  39834. static UnregisterTopRootEvents(windowElement: Window, events: {
  39835. name: string;
  39836. handler: Nullable<(e: FocusEvent) => any>;
  39837. }[]): void;
  39838. /**
  39839. * @ignore
  39840. */
  39841. static _ScreenshotCanvas: HTMLCanvasElement;
  39842. /**
  39843. * Dumps the current bound framebuffer
  39844. * @param width defines the rendering width
  39845. * @param height defines the rendering height
  39846. * @param engine defines the hosting engine
  39847. * @param successCallback defines the callback triggered once the data are available
  39848. * @param mimeType defines the mime type of the result
  39849. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39850. */
  39851. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39852. /**
  39853. * Converts the canvas data to blob.
  39854. * This acts as a polyfill for browsers not supporting the to blob function.
  39855. * @param canvas Defines the canvas to extract the data from
  39856. * @param successCallback Defines the callback triggered once the data are available
  39857. * @param mimeType Defines the mime type of the result
  39858. */
  39859. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39860. /**
  39861. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39862. * @param successCallback defines the callback triggered once the data are available
  39863. * @param mimeType defines the mime type of the result
  39864. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39865. */
  39866. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39867. /**
  39868. * Downloads a blob in the browser
  39869. * @param blob defines the blob to download
  39870. * @param fileName defines the name of the downloaded file
  39871. */
  39872. static Download(blob: Blob, fileName: string): void;
  39873. /**
  39874. * Captures a screenshot of the current rendering
  39875. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39876. * @param engine defines the rendering engine
  39877. * @param camera defines the source camera
  39878. * @param size This parameter can be set to a single number or to an object with the
  39879. * following (optional) properties: precision, width, height. If a single number is passed,
  39880. * it will be used for both width and height. If an object is passed, the screenshot size
  39881. * will be derived from the parameters. The precision property is a multiplier allowing
  39882. * rendering at a higher or lower resolution
  39883. * @param successCallback defines the callback receives a single parameter which contains the
  39884. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39885. * src parameter of an <img> to display it
  39886. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39887. * Check your browser for supported MIME types
  39888. */
  39889. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39890. /**
  39891. * Captures a screenshot of the current rendering
  39892. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39893. * @param engine defines the rendering engine
  39894. * @param camera defines the source camera
  39895. * @param size This parameter can be set to a single number or to an object with the
  39896. * following (optional) properties: precision, width, height. If a single number is passed,
  39897. * it will be used for both width and height. If an object is passed, the screenshot size
  39898. * will be derived from the parameters. The precision property is a multiplier allowing
  39899. * rendering at a higher or lower resolution
  39900. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39901. * Check your browser for supported MIME types
  39902. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39903. * to the src parameter of an <img> to display it
  39904. */
  39905. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39906. /**
  39907. * Generates an image screenshot from the specified camera.
  39908. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39909. * @param engine The engine to use for rendering
  39910. * @param camera The camera to use for rendering
  39911. * @param size This parameter can be set to a single number or to an object with the
  39912. * following (optional) properties: precision, width, height. If a single number is passed,
  39913. * it will be used for both width and height. If an object is passed, the screenshot size
  39914. * will be derived from the parameters. The precision property is a multiplier allowing
  39915. * rendering at a higher or lower resolution
  39916. * @param successCallback The callback receives a single parameter which contains the
  39917. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39918. * src parameter of an <img> to display it
  39919. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39920. * Check your browser for supported MIME types
  39921. * @param samples Texture samples (default: 1)
  39922. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39923. * @param fileName A name for for the downloaded file.
  39924. */
  39925. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39926. /**
  39927. * Generates an image screenshot from the specified camera.
  39928. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39929. * @param engine The engine to use for rendering
  39930. * @param camera The camera to use for rendering
  39931. * @param size This parameter can be set to a single number or to an object with the
  39932. * following (optional) properties: precision, width, height. If a single number is passed,
  39933. * it will be used for both width and height. If an object is passed, the screenshot size
  39934. * will be derived from the parameters. The precision property is a multiplier allowing
  39935. * rendering at a higher or lower resolution
  39936. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39937. * Check your browser for supported MIME types
  39938. * @param samples Texture samples (default: 1)
  39939. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39940. * @param fileName A name for for the downloaded file.
  39941. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39942. * to the src parameter of an <img> to display it
  39943. */
  39944. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39945. /**
  39946. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39947. * Be aware Math.random() could cause collisions, but:
  39948. * "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"
  39949. * @returns a pseudo random id
  39950. */
  39951. static RandomId(): string;
  39952. /**
  39953. * Test if the given uri is a base64 string
  39954. * @param uri The uri to test
  39955. * @return True if the uri is a base64 string or false otherwise
  39956. */
  39957. static IsBase64(uri: string): boolean;
  39958. /**
  39959. * Decode the given base64 uri.
  39960. * @param uri The uri to decode
  39961. * @return The decoded base64 data.
  39962. */
  39963. static DecodeBase64(uri: string): ArrayBuffer;
  39964. /**
  39965. * Gets the absolute url.
  39966. * @param url the input url
  39967. * @return the absolute url
  39968. */
  39969. static GetAbsoluteUrl(url: string): string;
  39970. /**
  39971. * No log
  39972. */
  39973. static readonly NoneLogLevel: number;
  39974. /**
  39975. * Only message logs
  39976. */
  39977. static readonly MessageLogLevel: number;
  39978. /**
  39979. * Only warning logs
  39980. */
  39981. static readonly WarningLogLevel: number;
  39982. /**
  39983. * Only error logs
  39984. */
  39985. static readonly ErrorLogLevel: number;
  39986. /**
  39987. * All logs
  39988. */
  39989. static readonly AllLogLevel: number;
  39990. /**
  39991. * Gets a value indicating the number of loading errors
  39992. * @ignorenaming
  39993. */
  39994. static get errorsCount(): number;
  39995. /**
  39996. * Callback called when a new log is added
  39997. */
  39998. static OnNewCacheEntry: (entry: string) => void;
  39999. /**
  40000. * Log a message to the console
  40001. * @param message defines the message to log
  40002. */
  40003. static Log(message: string): void;
  40004. /**
  40005. * Write a warning message to the console
  40006. * @param message defines the message to log
  40007. */
  40008. static Warn(message: string): void;
  40009. /**
  40010. * Write an error message to the console
  40011. * @param message defines the message to log
  40012. */
  40013. static Error(message: string): void;
  40014. /**
  40015. * Gets current log cache (list of logs)
  40016. */
  40017. static get LogCache(): string;
  40018. /**
  40019. * Clears the log cache
  40020. */
  40021. static ClearLogCache(): void;
  40022. /**
  40023. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40024. */
  40025. static set LogLevels(level: number);
  40026. /**
  40027. * Checks if the window object exists
  40028. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  40029. */
  40030. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  40031. /**
  40032. * No performance log
  40033. */
  40034. static readonly PerformanceNoneLogLevel: number;
  40035. /**
  40036. * Use user marks to log performance
  40037. */
  40038. static readonly PerformanceUserMarkLogLevel: number;
  40039. /**
  40040. * Log performance to the console
  40041. */
  40042. static readonly PerformanceConsoleLogLevel: number;
  40043. private static _performance;
  40044. /**
  40045. * Sets the current performance log level
  40046. */
  40047. static set PerformanceLogLevel(level: number);
  40048. private static _StartPerformanceCounterDisabled;
  40049. private static _EndPerformanceCounterDisabled;
  40050. private static _StartUserMark;
  40051. private static _EndUserMark;
  40052. private static _StartPerformanceConsole;
  40053. private static _EndPerformanceConsole;
  40054. /**
  40055. * Starts a performance counter
  40056. */
  40057. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40058. /**
  40059. * Ends a specific performance coutner
  40060. */
  40061. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40062. /**
  40063. * Gets either window.performance.now() if supported or Date.now() else
  40064. */
  40065. static get Now(): number;
  40066. /**
  40067. * This method will return the name of the class used to create the instance of the given object.
  40068. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40069. * @param object the object to get the class name from
  40070. * @param isType defines if the object is actually a type
  40071. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40072. */
  40073. static GetClassName(object: any, isType?: boolean): string;
  40074. /**
  40075. * Gets the first element of an array satisfying a given predicate
  40076. * @param array defines the array to browse
  40077. * @param predicate defines the predicate to use
  40078. * @returns null if not found or the element
  40079. */
  40080. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40081. /**
  40082. * This method will return the name of the full name of the class, including its owning module (if any).
  40083. * 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).
  40084. * @param object the object to get the class name from
  40085. * @param isType defines if the object is actually a type
  40086. * @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.
  40087. * @ignorenaming
  40088. */
  40089. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40090. /**
  40091. * Returns a promise that resolves after the given amount of time.
  40092. * @param delay Number of milliseconds to delay
  40093. * @returns Promise that resolves after the given amount of time
  40094. */
  40095. static DelayAsync(delay: number): Promise<void>;
  40096. /**
  40097. * Utility function to detect if the current user agent is Safari
  40098. * @returns whether or not the current user agent is safari
  40099. */
  40100. static IsSafari(): boolean;
  40101. }
  40102. /**
  40103. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40104. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40105. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40106. * @param name The name of the class, case should be preserved
  40107. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40108. */
  40109. export function className(name: string, module?: string): (target: Object) => void;
  40110. /**
  40111. * An implementation of a loop for asynchronous functions.
  40112. */
  40113. export class AsyncLoop {
  40114. /**
  40115. * Defines the number of iterations for the loop
  40116. */
  40117. iterations: number;
  40118. /**
  40119. * Defines the current index of the loop.
  40120. */
  40121. index: number;
  40122. private _done;
  40123. private _fn;
  40124. private _successCallback;
  40125. /**
  40126. * Constructor.
  40127. * @param iterations the number of iterations.
  40128. * @param func the function to run each iteration
  40129. * @param successCallback the callback that will be called upon succesful execution
  40130. * @param offset starting offset.
  40131. */
  40132. constructor(
  40133. /**
  40134. * Defines the number of iterations for the loop
  40135. */
  40136. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40137. /**
  40138. * Execute the next iteration. Must be called after the last iteration was finished.
  40139. */
  40140. executeNext(): void;
  40141. /**
  40142. * Break the loop and run the success callback.
  40143. */
  40144. breakLoop(): void;
  40145. /**
  40146. * Create and run an async loop.
  40147. * @param iterations the number of iterations.
  40148. * @param fn the function to run each iteration
  40149. * @param successCallback the callback that will be called upon succesful execution
  40150. * @param offset starting offset.
  40151. * @returns the created async loop object
  40152. */
  40153. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40154. /**
  40155. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40156. * @param iterations total number of iterations
  40157. * @param syncedIterations number of synchronous iterations in each async iteration.
  40158. * @param fn the function to call each iteration.
  40159. * @param callback a success call back that will be called when iterating stops.
  40160. * @param breakFunction a break condition (optional)
  40161. * @param timeout timeout settings for the setTimeout function. default - 0.
  40162. * @returns the created async loop object
  40163. */
  40164. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40165. }
  40166. }
  40167. declare module "babylonjs/Misc/stringDictionary" {
  40168. import { Nullable } from "babylonjs/types";
  40169. /**
  40170. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40171. * The underlying implementation relies on an associative array to ensure the best performances.
  40172. * The value can be anything including 'null' but except 'undefined'
  40173. */
  40174. export class StringDictionary<T> {
  40175. /**
  40176. * This will clear this dictionary and copy the content from the 'source' one.
  40177. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40178. * @param source the dictionary to take the content from and copy to this dictionary
  40179. */
  40180. copyFrom(source: StringDictionary<T>): void;
  40181. /**
  40182. * Get a value based from its key
  40183. * @param key the given key to get the matching value from
  40184. * @return the value if found, otherwise undefined is returned
  40185. */
  40186. get(key: string): T | undefined;
  40187. /**
  40188. * Get a value from its key or add it if it doesn't exist.
  40189. * This method will ensure you that a given key/data will be present in the dictionary.
  40190. * @param key the given key to get the matching value from
  40191. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40192. * The factory will only be invoked if there's no data for the given key.
  40193. * @return the value corresponding to the key.
  40194. */
  40195. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40196. /**
  40197. * Get a value from its key if present in the dictionary otherwise add it
  40198. * @param key the key to get the value from
  40199. * @param val if there's no such key/value pair in the dictionary add it with this value
  40200. * @return the value corresponding to the key
  40201. */
  40202. getOrAdd(key: string, val: T): T;
  40203. /**
  40204. * Check if there's a given key in the dictionary
  40205. * @param key the key to check for
  40206. * @return true if the key is present, false otherwise
  40207. */
  40208. contains(key: string): boolean;
  40209. /**
  40210. * Add a new key and its corresponding value
  40211. * @param key the key to add
  40212. * @param value the value corresponding to the key
  40213. * @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
  40214. */
  40215. add(key: string, value: T): boolean;
  40216. /**
  40217. * Update a specific value associated to a key
  40218. * @param key defines the key to use
  40219. * @param value defines the value to store
  40220. * @returns true if the value was updated (or false if the key was not found)
  40221. */
  40222. set(key: string, value: T): boolean;
  40223. /**
  40224. * Get the element of the given key and remove it from the dictionary
  40225. * @param key defines the key to search
  40226. * @returns the value associated with the key or null if not found
  40227. */
  40228. getAndRemove(key: string): Nullable<T>;
  40229. /**
  40230. * Remove a key/value from the dictionary.
  40231. * @param key the key to remove
  40232. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40233. */
  40234. remove(key: string): boolean;
  40235. /**
  40236. * Clear the whole content of the dictionary
  40237. */
  40238. clear(): void;
  40239. /**
  40240. * Gets the current count
  40241. */
  40242. get count(): number;
  40243. /**
  40244. * Execute a callback on each key/val of the dictionary.
  40245. * Note that you can remove any element in this dictionary in the callback implementation
  40246. * @param callback the callback to execute on a given key/value pair
  40247. */
  40248. forEach(callback: (key: string, val: T) => void): void;
  40249. /**
  40250. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40251. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40252. * Note that you can remove any element in this dictionary in the callback implementation
  40253. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40254. * @returns the first item
  40255. */
  40256. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40257. private _count;
  40258. private _data;
  40259. }
  40260. }
  40261. declare module "babylonjs/Collisions/collisionCoordinator" {
  40262. import { Nullable } from "babylonjs/types";
  40263. import { Scene } from "babylonjs/scene";
  40264. import { Vector3 } from "babylonjs/Maths/math.vector";
  40265. import { Collider } from "babylonjs/Collisions/collider";
  40266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40267. /** @hidden */
  40268. export interface ICollisionCoordinator {
  40269. createCollider(): Collider;
  40270. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40271. init(scene: Scene): void;
  40272. }
  40273. /** @hidden */
  40274. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40275. private _scene;
  40276. private _scaledPosition;
  40277. private _scaledVelocity;
  40278. private _finalPosition;
  40279. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40280. createCollider(): Collider;
  40281. init(scene: Scene): void;
  40282. private _collideWithWorld;
  40283. }
  40284. }
  40285. declare module "babylonjs/Inputs/scene.inputManager" {
  40286. import { Nullable } from "babylonjs/types";
  40287. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40288. import { Vector2 } from "babylonjs/Maths/math.vector";
  40289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40290. import { Scene } from "babylonjs/scene";
  40291. /**
  40292. * Class used to manage all inputs for the scene.
  40293. */
  40294. export class InputManager {
  40295. /** The distance in pixel that you have to move to prevent some events */
  40296. static DragMovementThreshold: number;
  40297. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40298. static LongPressDelay: number;
  40299. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40300. static DoubleClickDelay: number;
  40301. /** If you need to check double click without raising a single click at first click, enable this flag */
  40302. static ExclusiveDoubleClickMode: boolean;
  40303. /** 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. */
  40304. private _alreadyAttached;
  40305. private _wheelEventName;
  40306. private _onPointerMove;
  40307. private _onPointerDown;
  40308. private _onPointerUp;
  40309. private _initClickEvent;
  40310. private _initActionManager;
  40311. private _delayedSimpleClick;
  40312. private _delayedSimpleClickTimeout;
  40313. private _previousDelayedSimpleClickTimeout;
  40314. private _meshPickProceed;
  40315. private _previousButtonPressed;
  40316. private _currentPickResult;
  40317. private _previousPickResult;
  40318. private _totalPointersPressed;
  40319. private _doubleClickOccured;
  40320. private _pointerOverMesh;
  40321. private _pickedDownMesh;
  40322. private _pickedUpMesh;
  40323. private _pointerX;
  40324. private _pointerY;
  40325. private _unTranslatedPointerX;
  40326. private _unTranslatedPointerY;
  40327. private _startingPointerPosition;
  40328. private _previousStartingPointerPosition;
  40329. private _startingPointerTime;
  40330. private _previousStartingPointerTime;
  40331. private _pointerCaptures;
  40332. private _meshUnderPointerId;
  40333. private _onKeyDown;
  40334. private _onKeyUp;
  40335. private _onCanvasFocusObserver;
  40336. private _onCanvasBlurObserver;
  40337. private _scene;
  40338. /**
  40339. * Creates a new InputManager
  40340. * @param scene defines the hosting scene
  40341. */
  40342. constructor(scene: Scene);
  40343. /**
  40344. * Gets the mesh that is currently under the pointer
  40345. */
  40346. get meshUnderPointer(): Nullable<AbstractMesh>;
  40347. /**
  40348. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  40349. * @param pointerId the pointer id to use
  40350. * @returns The mesh under this pointer id or null if not found
  40351. */
  40352. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  40353. /**
  40354. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40355. */
  40356. get unTranslatedPointer(): Vector2;
  40357. /**
  40358. * Gets or sets the current on-screen X position of the pointer
  40359. */
  40360. get pointerX(): number;
  40361. set pointerX(value: number);
  40362. /**
  40363. * Gets or sets the current on-screen Y position of the pointer
  40364. */
  40365. get pointerY(): number;
  40366. set pointerY(value: number);
  40367. private _updatePointerPosition;
  40368. private _processPointerMove;
  40369. private _setRayOnPointerInfo;
  40370. private _checkPrePointerObservable;
  40371. /**
  40372. * Use this method to simulate a pointer move on a mesh
  40373. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40374. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40375. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40376. */
  40377. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40378. /**
  40379. * Use this method to simulate a pointer down on a mesh
  40380. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40381. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40382. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40383. */
  40384. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40385. private _processPointerDown;
  40386. /** @hidden */
  40387. _isPointerSwiping(): boolean;
  40388. /**
  40389. * Use this method to simulate a pointer up on a mesh
  40390. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40391. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40392. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40393. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40394. */
  40395. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40396. private _processPointerUp;
  40397. /**
  40398. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40399. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40400. * @returns true if the pointer was captured
  40401. */
  40402. isPointerCaptured(pointerId?: number): boolean;
  40403. /**
  40404. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40405. * @param attachUp defines if you want to attach events to pointerup
  40406. * @param attachDown defines if you want to attach events to pointerdown
  40407. * @param attachMove defines if you want to attach events to pointermove
  40408. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40409. */
  40410. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40411. /**
  40412. * Detaches all event handlers
  40413. */
  40414. detachControl(): void;
  40415. /**
  40416. * Force the value of meshUnderPointer
  40417. * @param mesh defines the mesh to use
  40418. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  40419. */
  40420. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  40421. /**
  40422. * Gets the mesh under the pointer
  40423. * @returns a Mesh or null if no mesh is under the pointer
  40424. */
  40425. getPointerOverMesh(): Nullable<AbstractMesh>;
  40426. }
  40427. }
  40428. declare module "babylonjs/Animations/animationGroup" {
  40429. import { Animatable } from "babylonjs/Animations/animatable";
  40430. import { Animation } from "babylonjs/Animations/animation";
  40431. import { Scene, IDisposable } from "babylonjs/scene";
  40432. import { Observable } from "babylonjs/Misc/observable";
  40433. import { Nullable } from "babylonjs/types";
  40434. import "babylonjs/Animations/animatable";
  40435. /**
  40436. * This class defines the direct association between an animation and a target
  40437. */
  40438. export class TargetedAnimation {
  40439. /**
  40440. * Animation to perform
  40441. */
  40442. animation: Animation;
  40443. /**
  40444. * Target to animate
  40445. */
  40446. target: any;
  40447. /**
  40448. * Returns the string "TargetedAnimation"
  40449. * @returns "TargetedAnimation"
  40450. */
  40451. getClassName(): string;
  40452. /**
  40453. * Serialize the object
  40454. * @returns the JSON object representing the current entity
  40455. */
  40456. serialize(): any;
  40457. }
  40458. /**
  40459. * Use this class to create coordinated animations on multiple targets
  40460. */
  40461. export class AnimationGroup implements IDisposable {
  40462. /** The name of the animation group */
  40463. name: string;
  40464. private _scene;
  40465. private _targetedAnimations;
  40466. private _animatables;
  40467. private _from;
  40468. private _to;
  40469. private _isStarted;
  40470. private _isPaused;
  40471. private _speedRatio;
  40472. private _loopAnimation;
  40473. private _isAdditive;
  40474. /**
  40475. * Gets or sets the unique id of the node
  40476. */
  40477. uniqueId: number;
  40478. /**
  40479. * This observable will notify when one animation have ended
  40480. */
  40481. onAnimationEndObservable: Observable<TargetedAnimation>;
  40482. /**
  40483. * Observer raised when one animation loops
  40484. */
  40485. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40486. /**
  40487. * Observer raised when all animations have looped
  40488. */
  40489. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40490. /**
  40491. * This observable will notify when all animations have ended.
  40492. */
  40493. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40494. /**
  40495. * This observable will notify when all animations have paused.
  40496. */
  40497. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40498. /**
  40499. * This observable will notify when all animations are playing.
  40500. */
  40501. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40502. /**
  40503. * Gets the first frame
  40504. */
  40505. get from(): number;
  40506. /**
  40507. * Gets the last frame
  40508. */
  40509. get to(): number;
  40510. /**
  40511. * Define if the animations are started
  40512. */
  40513. get isStarted(): boolean;
  40514. /**
  40515. * Gets a value indicating that the current group is playing
  40516. */
  40517. get isPlaying(): boolean;
  40518. /**
  40519. * Gets or sets the speed ratio to use for all animations
  40520. */
  40521. get speedRatio(): number;
  40522. /**
  40523. * Gets or sets the speed ratio to use for all animations
  40524. */
  40525. set speedRatio(value: number);
  40526. /**
  40527. * Gets or sets if all animations should loop or not
  40528. */
  40529. get loopAnimation(): boolean;
  40530. set loopAnimation(value: boolean);
  40531. /**
  40532. * Gets or sets if all animations should be evaluated additively
  40533. */
  40534. get isAdditive(): boolean;
  40535. set isAdditive(value: boolean);
  40536. /**
  40537. * Gets the targeted animations for this animation group
  40538. */
  40539. get targetedAnimations(): Array<TargetedAnimation>;
  40540. /**
  40541. * returning the list of animatables controlled by this animation group.
  40542. */
  40543. get animatables(): Array<Animatable>;
  40544. /**
  40545. * Gets the list of target animations
  40546. */
  40547. get children(): TargetedAnimation[];
  40548. /**
  40549. * Instantiates a new Animation Group.
  40550. * This helps managing several animations at once.
  40551. * @see https://doc.babylonjs.com/how_to/group
  40552. * @param name Defines the name of the group
  40553. * @param scene Defines the scene the group belongs to
  40554. */
  40555. constructor(
  40556. /** The name of the animation group */
  40557. name: string, scene?: Nullable<Scene>);
  40558. /**
  40559. * Add an animation (with its target) in the group
  40560. * @param animation defines the animation we want to add
  40561. * @param target defines the target of the animation
  40562. * @returns the TargetedAnimation object
  40563. */
  40564. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40565. /**
  40566. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40567. * It can add constant keys at begin or end
  40568. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40569. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40570. * @returns the animation group
  40571. */
  40572. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40573. private _animationLoopCount;
  40574. private _animationLoopFlags;
  40575. private _processLoop;
  40576. /**
  40577. * Start all animations on given targets
  40578. * @param loop defines if animations must loop
  40579. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40580. * @param from defines the from key (optional)
  40581. * @param to defines the to key (optional)
  40582. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40583. * @returns the current animation group
  40584. */
  40585. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40586. /**
  40587. * Pause all animations
  40588. * @returns the animation group
  40589. */
  40590. pause(): AnimationGroup;
  40591. /**
  40592. * Play all animations to initial state
  40593. * This function will start() the animations if they were not started or will restart() them if they were paused
  40594. * @param loop defines if animations must loop
  40595. * @returns the animation group
  40596. */
  40597. play(loop?: boolean): AnimationGroup;
  40598. /**
  40599. * Reset all animations to initial state
  40600. * @returns the animation group
  40601. */
  40602. reset(): AnimationGroup;
  40603. /**
  40604. * Restart animations from key 0
  40605. * @returns the animation group
  40606. */
  40607. restart(): AnimationGroup;
  40608. /**
  40609. * Stop all animations
  40610. * @returns the animation group
  40611. */
  40612. stop(): AnimationGroup;
  40613. /**
  40614. * Set animation weight for all animatables
  40615. * @param weight defines the weight to use
  40616. * @return the animationGroup
  40617. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40618. */
  40619. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40620. /**
  40621. * Synchronize and normalize all animatables with a source animatable
  40622. * @param root defines the root animatable to synchronize with
  40623. * @return the animationGroup
  40624. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40625. */
  40626. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40627. /**
  40628. * Goes to a specific frame in this animation group
  40629. * @param frame the frame number to go to
  40630. * @return the animationGroup
  40631. */
  40632. goToFrame(frame: number): AnimationGroup;
  40633. /**
  40634. * Dispose all associated resources
  40635. */
  40636. dispose(): void;
  40637. private _checkAnimationGroupEnded;
  40638. /**
  40639. * Clone the current animation group and returns a copy
  40640. * @param newName defines the name of the new group
  40641. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40642. * @returns the new aniamtion group
  40643. */
  40644. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40645. /**
  40646. * Serializes the animationGroup to an object
  40647. * @returns Serialized object
  40648. */
  40649. serialize(): any;
  40650. /**
  40651. * Returns a new AnimationGroup object parsed from the source provided.
  40652. * @param parsedAnimationGroup defines the source
  40653. * @param scene defines the scene that will receive the animationGroup
  40654. * @returns a new AnimationGroup
  40655. */
  40656. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40657. /**
  40658. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40659. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40660. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40661. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40662. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40663. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40664. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40665. */
  40666. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40667. /**
  40668. * Returns the string "AnimationGroup"
  40669. * @returns "AnimationGroup"
  40670. */
  40671. getClassName(): string;
  40672. /**
  40673. * Creates a detailled string about the object
  40674. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40675. * @returns a string representing the object
  40676. */
  40677. toString(fullDetails?: boolean): string;
  40678. }
  40679. }
  40680. declare module "babylonjs/scene" {
  40681. import { Nullable } from "babylonjs/types";
  40682. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40683. import { Observable } from "babylonjs/Misc/observable";
  40684. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40685. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40686. import { Geometry } from "babylonjs/Meshes/geometry";
  40687. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40688. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40690. import { Mesh } from "babylonjs/Meshes/mesh";
  40691. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40692. import { Bone } from "babylonjs/Bones/bone";
  40693. import { Skeleton } from "babylonjs/Bones/skeleton";
  40694. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40695. import { Camera } from "babylonjs/Cameras/camera";
  40696. import { AbstractScene } from "babylonjs/abstractScene";
  40697. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40698. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40699. import { Material } from "babylonjs/Materials/material";
  40700. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40701. import { Effect } from "babylonjs/Materials/effect";
  40702. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40703. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40704. import { Light } from "babylonjs/Lights/light";
  40705. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40706. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40707. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40708. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40709. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40710. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40711. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40712. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40713. import { Engine } from "babylonjs/Engines/engine";
  40714. import { Node } from "babylonjs/node";
  40715. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40716. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40717. import { WebRequest } from "babylonjs/Misc/webRequest";
  40718. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40719. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40720. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40721. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40722. import { Plane } from "babylonjs/Maths/math.plane";
  40723. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40724. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40725. import { Ray } from "babylonjs/Culling/ray";
  40726. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40727. import { Animation } from "babylonjs/Animations/animation";
  40728. import { Animatable } from "babylonjs/Animations/animatable";
  40729. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40730. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40731. import { Collider } from "babylonjs/Collisions/collider";
  40732. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40733. /**
  40734. * Define an interface for all classes that will hold resources
  40735. */
  40736. export interface IDisposable {
  40737. /**
  40738. * Releases all held resources
  40739. */
  40740. dispose(): void;
  40741. }
  40742. /** Interface defining initialization parameters for Scene class */
  40743. export interface SceneOptions {
  40744. /**
  40745. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40746. * It will improve performance when the number of geometries becomes important.
  40747. */
  40748. useGeometryUniqueIdsMap?: boolean;
  40749. /**
  40750. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40751. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40752. */
  40753. useMaterialMeshMap?: boolean;
  40754. /**
  40755. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40756. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40757. */
  40758. useClonedMeshMap?: boolean;
  40759. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40760. virtual?: boolean;
  40761. }
  40762. /**
  40763. * Represents a scene to be rendered by the engine.
  40764. * @see https://doc.babylonjs.com/features/scene
  40765. */
  40766. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40767. /** The fog is deactivated */
  40768. static readonly FOGMODE_NONE: number;
  40769. /** The fog density is following an exponential function */
  40770. static readonly FOGMODE_EXP: number;
  40771. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40772. static readonly FOGMODE_EXP2: number;
  40773. /** The fog density is following a linear function. */
  40774. static readonly FOGMODE_LINEAR: number;
  40775. /**
  40776. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40777. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40778. */
  40779. static MinDeltaTime: number;
  40780. /**
  40781. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40782. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40783. */
  40784. static MaxDeltaTime: number;
  40785. /**
  40786. * Factory used to create the default material.
  40787. * @param name The name of the material to create
  40788. * @param scene The scene to create the material for
  40789. * @returns The default material
  40790. */
  40791. static DefaultMaterialFactory(scene: Scene): Material;
  40792. /**
  40793. * Factory used to create the a collision coordinator.
  40794. * @returns The collision coordinator
  40795. */
  40796. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40797. /** @hidden */
  40798. _inputManager: InputManager;
  40799. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40800. cameraToUseForPointers: Nullable<Camera>;
  40801. /** @hidden */
  40802. readonly _isScene: boolean;
  40803. /** @hidden */
  40804. _blockEntityCollection: boolean;
  40805. /**
  40806. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40807. */
  40808. autoClear: boolean;
  40809. /**
  40810. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40811. */
  40812. autoClearDepthAndStencil: boolean;
  40813. /**
  40814. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40815. */
  40816. clearColor: Color4;
  40817. /**
  40818. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40819. */
  40820. ambientColor: Color3;
  40821. /**
  40822. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40823. * It should only be one of the following (if not the default embedded one):
  40824. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40825. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40826. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40827. * The material properties need to be setup according to the type of texture in use.
  40828. */
  40829. environmentBRDFTexture: BaseTexture;
  40830. /**
  40831. * Texture used in all pbr material as the reflection texture.
  40832. * As in the majority of the scene they are the same (exception for multi room and so on),
  40833. * this is easier to reference from here than from all the materials.
  40834. */
  40835. get environmentTexture(): Nullable<BaseTexture>;
  40836. /**
  40837. * Texture used in all pbr material as the reflection texture.
  40838. * As in the majority of the scene they are the same (exception for multi room and so on),
  40839. * this is easier to set here than in all the materials.
  40840. */
  40841. set environmentTexture(value: Nullable<BaseTexture>);
  40842. /** @hidden */
  40843. protected _environmentIntensity: number;
  40844. /**
  40845. * Intensity of the environment in all pbr material.
  40846. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40847. * As in the majority of the scene they are the same (exception for multi room and so on),
  40848. * this is easier to reference from here than from all the materials.
  40849. */
  40850. get environmentIntensity(): number;
  40851. /**
  40852. * Intensity of the environment in all pbr material.
  40853. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40854. * As in the majority of the scene they are the same (exception for multi room and so on),
  40855. * this is easier to set here than in all the materials.
  40856. */
  40857. set environmentIntensity(value: number);
  40858. /** @hidden */
  40859. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40860. /**
  40861. * Default image processing configuration used either in the rendering
  40862. * Forward main pass or through the imageProcessingPostProcess if present.
  40863. * As in the majority of the scene they are the same (exception for multi camera),
  40864. * this is easier to reference from here than from all the materials and post process.
  40865. *
  40866. * No setter as we it is a shared configuration, you can set the values instead.
  40867. */
  40868. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40869. private _forceWireframe;
  40870. /**
  40871. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40872. */
  40873. set forceWireframe(value: boolean);
  40874. get forceWireframe(): boolean;
  40875. private _skipFrustumClipping;
  40876. /**
  40877. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40878. */
  40879. set skipFrustumClipping(value: boolean);
  40880. get skipFrustumClipping(): boolean;
  40881. private _forcePointsCloud;
  40882. /**
  40883. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40884. */
  40885. set forcePointsCloud(value: boolean);
  40886. get forcePointsCloud(): boolean;
  40887. /**
  40888. * Gets or sets the active clipplane 1
  40889. */
  40890. clipPlane: Nullable<Plane>;
  40891. /**
  40892. * Gets or sets the active clipplane 2
  40893. */
  40894. clipPlane2: Nullable<Plane>;
  40895. /**
  40896. * Gets or sets the active clipplane 3
  40897. */
  40898. clipPlane3: Nullable<Plane>;
  40899. /**
  40900. * Gets or sets the active clipplane 4
  40901. */
  40902. clipPlane4: Nullable<Plane>;
  40903. /**
  40904. * Gets or sets the active clipplane 5
  40905. */
  40906. clipPlane5: Nullable<Plane>;
  40907. /**
  40908. * Gets or sets the active clipplane 6
  40909. */
  40910. clipPlane6: Nullable<Plane>;
  40911. /**
  40912. * Gets or sets a boolean indicating if animations are enabled
  40913. */
  40914. animationsEnabled: boolean;
  40915. private _animationPropertiesOverride;
  40916. /**
  40917. * Gets or sets the animation properties override
  40918. */
  40919. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40920. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40921. /**
  40922. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40923. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40924. */
  40925. useConstantAnimationDeltaTime: boolean;
  40926. /**
  40927. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40928. * Please note that it requires to run a ray cast through the scene on every frame
  40929. */
  40930. constantlyUpdateMeshUnderPointer: boolean;
  40931. /**
  40932. * Defines the HTML cursor to use when hovering over interactive elements
  40933. */
  40934. hoverCursor: string;
  40935. /**
  40936. * Defines the HTML default cursor to use (empty by default)
  40937. */
  40938. defaultCursor: string;
  40939. /**
  40940. * Defines whether cursors are handled by the scene.
  40941. */
  40942. doNotHandleCursors: boolean;
  40943. /**
  40944. * This is used to call preventDefault() on pointer down
  40945. * in order to block unwanted artifacts like system double clicks
  40946. */
  40947. preventDefaultOnPointerDown: boolean;
  40948. /**
  40949. * This is used to call preventDefault() on pointer up
  40950. * in order to block unwanted artifacts like system double clicks
  40951. */
  40952. preventDefaultOnPointerUp: boolean;
  40953. /**
  40954. * Gets or sets user defined metadata
  40955. */
  40956. metadata: any;
  40957. /**
  40958. * For internal use only. Please do not use.
  40959. */
  40960. reservedDataStore: any;
  40961. /**
  40962. * Gets the name of the plugin used to load this scene (null by default)
  40963. */
  40964. loadingPluginName: string;
  40965. /**
  40966. * Use this array to add regular expressions used to disable offline support for specific urls
  40967. */
  40968. disableOfflineSupportExceptionRules: RegExp[];
  40969. /**
  40970. * An event triggered when the scene is disposed.
  40971. */
  40972. onDisposeObservable: Observable<Scene>;
  40973. private _onDisposeObserver;
  40974. /** Sets a function to be executed when this scene is disposed. */
  40975. set onDispose(callback: () => void);
  40976. /**
  40977. * An event triggered before rendering the scene (right after animations and physics)
  40978. */
  40979. onBeforeRenderObservable: Observable<Scene>;
  40980. private _onBeforeRenderObserver;
  40981. /** Sets a function to be executed before rendering this scene */
  40982. set beforeRender(callback: Nullable<() => void>);
  40983. /**
  40984. * An event triggered after rendering the scene
  40985. */
  40986. onAfterRenderObservable: Observable<Scene>;
  40987. /**
  40988. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  40989. */
  40990. onAfterRenderCameraObservable: Observable<Camera>;
  40991. private _onAfterRenderObserver;
  40992. /** Sets a function to be executed after rendering this scene */
  40993. set afterRender(callback: Nullable<() => void>);
  40994. /**
  40995. * An event triggered before animating the scene
  40996. */
  40997. onBeforeAnimationsObservable: Observable<Scene>;
  40998. /**
  40999. * An event triggered after animations processing
  41000. */
  41001. onAfterAnimationsObservable: Observable<Scene>;
  41002. /**
  41003. * An event triggered before draw calls are ready to be sent
  41004. */
  41005. onBeforeDrawPhaseObservable: Observable<Scene>;
  41006. /**
  41007. * An event triggered after draw calls have been sent
  41008. */
  41009. onAfterDrawPhaseObservable: Observable<Scene>;
  41010. /**
  41011. * An event triggered when the scene is ready
  41012. */
  41013. onReadyObservable: Observable<Scene>;
  41014. /**
  41015. * An event triggered before rendering a camera
  41016. */
  41017. onBeforeCameraRenderObservable: Observable<Camera>;
  41018. private _onBeforeCameraRenderObserver;
  41019. /** Sets a function to be executed before rendering a camera*/
  41020. set beforeCameraRender(callback: () => void);
  41021. /**
  41022. * An event triggered after rendering a camera
  41023. */
  41024. onAfterCameraRenderObservable: Observable<Camera>;
  41025. private _onAfterCameraRenderObserver;
  41026. /** Sets a function to be executed after rendering a camera*/
  41027. set afterCameraRender(callback: () => void);
  41028. /**
  41029. * An event triggered when active meshes evaluation is about to start
  41030. */
  41031. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  41032. /**
  41033. * An event triggered when active meshes evaluation is done
  41034. */
  41035. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  41036. /**
  41037. * An event triggered when particles rendering is about to start
  41038. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41039. */
  41040. onBeforeParticlesRenderingObservable: Observable<Scene>;
  41041. /**
  41042. * An event triggered when particles rendering is done
  41043. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41044. */
  41045. onAfterParticlesRenderingObservable: Observable<Scene>;
  41046. /**
  41047. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  41048. */
  41049. onDataLoadedObservable: Observable<Scene>;
  41050. /**
  41051. * An event triggered when a camera is created
  41052. */
  41053. onNewCameraAddedObservable: Observable<Camera>;
  41054. /**
  41055. * An event triggered when a camera is removed
  41056. */
  41057. onCameraRemovedObservable: Observable<Camera>;
  41058. /**
  41059. * An event triggered when a light is created
  41060. */
  41061. onNewLightAddedObservable: Observable<Light>;
  41062. /**
  41063. * An event triggered when a light is removed
  41064. */
  41065. onLightRemovedObservable: Observable<Light>;
  41066. /**
  41067. * An event triggered when a geometry is created
  41068. */
  41069. onNewGeometryAddedObservable: Observable<Geometry>;
  41070. /**
  41071. * An event triggered when a geometry is removed
  41072. */
  41073. onGeometryRemovedObservable: Observable<Geometry>;
  41074. /**
  41075. * An event triggered when a transform node is created
  41076. */
  41077. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  41078. /**
  41079. * An event triggered when a transform node is removed
  41080. */
  41081. onTransformNodeRemovedObservable: Observable<TransformNode>;
  41082. /**
  41083. * An event triggered when a mesh is created
  41084. */
  41085. onNewMeshAddedObservable: Observable<AbstractMesh>;
  41086. /**
  41087. * An event triggered when a mesh is removed
  41088. */
  41089. onMeshRemovedObservable: Observable<AbstractMesh>;
  41090. /**
  41091. * An event triggered when a skeleton is created
  41092. */
  41093. onNewSkeletonAddedObservable: Observable<Skeleton>;
  41094. /**
  41095. * An event triggered when a skeleton is removed
  41096. */
  41097. onSkeletonRemovedObservable: Observable<Skeleton>;
  41098. /**
  41099. * An event triggered when a material is created
  41100. */
  41101. onNewMaterialAddedObservable: Observable<Material>;
  41102. /**
  41103. * An event triggered when a material is removed
  41104. */
  41105. onMaterialRemovedObservable: Observable<Material>;
  41106. /**
  41107. * An event triggered when a texture is created
  41108. */
  41109. onNewTextureAddedObservable: Observable<BaseTexture>;
  41110. /**
  41111. * An event triggered when a texture is removed
  41112. */
  41113. onTextureRemovedObservable: Observable<BaseTexture>;
  41114. /**
  41115. * An event triggered when render targets are about to be rendered
  41116. * Can happen multiple times per frame.
  41117. */
  41118. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  41119. /**
  41120. * An event triggered when render targets were rendered.
  41121. * Can happen multiple times per frame.
  41122. */
  41123. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41124. /**
  41125. * An event triggered before calculating deterministic simulation step
  41126. */
  41127. onBeforeStepObservable: Observable<Scene>;
  41128. /**
  41129. * An event triggered after calculating deterministic simulation step
  41130. */
  41131. onAfterStepObservable: Observable<Scene>;
  41132. /**
  41133. * An event triggered when the activeCamera property is updated
  41134. */
  41135. onActiveCameraChanged: Observable<Scene>;
  41136. /**
  41137. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41138. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41139. * 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)
  41140. */
  41141. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41142. /**
  41143. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41144. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41145. * 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)
  41146. */
  41147. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41148. /**
  41149. * This Observable will when a mesh has been imported into the scene.
  41150. */
  41151. onMeshImportedObservable: Observable<AbstractMesh>;
  41152. /**
  41153. * This Observable will when an animation file has been imported into the scene.
  41154. */
  41155. onAnimationFileImportedObservable: Observable<Scene>;
  41156. /**
  41157. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41158. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41159. */
  41160. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41161. /** @hidden */
  41162. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41163. /**
  41164. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41165. */
  41166. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41167. /**
  41168. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41169. */
  41170. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41171. /**
  41172. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41173. */
  41174. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41175. /** Callback called when a pointer move is detected */
  41176. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41177. /** Callback called when a pointer down is detected */
  41178. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41179. /** Callback called when a pointer up is detected */
  41180. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41181. /** Callback called when a pointer pick is detected */
  41182. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41183. /**
  41184. * 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).
  41185. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41186. */
  41187. onPrePointerObservable: Observable<PointerInfoPre>;
  41188. /**
  41189. * Observable event triggered each time an input event is received from the rendering canvas
  41190. */
  41191. onPointerObservable: Observable<PointerInfo>;
  41192. /**
  41193. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41194. */
  41195. get unTranslatedPointer(): Vector2;
  41196. /**
  41197. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41198. */
  41199. static get DragMovementThreshold(): number;
  41200. static set DragMovementThreshold(value: number);
  41201. /**
  41202. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41203. */
  41204. static get LongPressDelay(): number;
  41205. static set LongPressDelay(value: number);
  41206. /**
  41207. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41208. */
  41209. static get DoubleClickDelay(): number;
  41210. static set DoubleClickDelay(value: number);
  41211. /** If you need to check double click without raising a single click at first click, enable this flag */
  41212. static get ExclusiveDoubleClickMode(): boolean;
  41213. static set ExclusiveDoubleClickMode(value: boolean);
  41214. /** @hidden */
  41215. _mirroredCameraPosition: Nullable<Vector3>;
  41216. /**
  41217. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41218. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41219. */
  41220. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41221. /**
  41222. * Observable event triggered each time an keyboard event is received from the hosting window
  41223. */
  41224. onKeyboardObservable: Observable<KeyboardInfo>;
  41225. private _useRightHandedSystem;
  41226. /**
  41227. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41228. */
  41229. set useRightHandedSystem(value: boolean);
  41230. get useRightHandedSystem(): boolean;
  41231. private _timeAccumulator;
  41232. private _currentStepId;
  41233. private _currentInternalStep;
  41234. /**
  41235. * Sets the step Id used by deterministic lock step
  41236. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41237. * @param newStepId defines the step Id
  41238. */
  41239. setStepId(newStepId: number): void;
  41240. /**
  41241. * Gets the step Id used by deterministic lock step
  41242. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41243. * @returns the step Id
  41244. */
  41245. getStepId(): number;
  41246. /**
  41247. * Gets the internal step used by deterministic lock step
  41248. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41249. * @returns the internal step
  41250. */
  41251. getInternalStep(): number;
  41252. private _fogEnabled;
  41253. /**
  41254. * Gets or sets a boolean indicating if fog is enabled on this scene
  41255. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41256. * (Default is true)
  41257. */
  41258. set fogEnabled(value: boolean);
  41259. get fogEnabled(): boolean;
  41260. private _fogMode;
  41261. /**
  41262. * Gets or sets the fog mode to use
  41263. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41264. * | mode | value |
  41265. * | --- | --- |
  41266. * | FOGMODE_NONE | 0 |
  41267. * | FOGMODE_EXP | 1 |
  41268. * | FOGMODE_EXP2 | 2 |
  41269. * | FOGMODE_LINEAR | 3 |
  41270. */
  41271. set fogMode(value: number);
  41272. get fogMode(): number;
  41273. /**
  41274. * Gets or sets the fog color to use
  41275. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41276. * (Default is Color3(0.2, 0.2, 0.3))
  41277. */
  41278. fogColor: Color3;
  41279. /**
  41280. * Gets or sets the fog density to use
  41281. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41282. * (Default is 0.1)
  41283. */
  41284. fogDensity: number;
  41285. /**
  41286. * Gets or sets the fog start distance to use
  41287. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41288. * (Default is 0)
  41289. */
  41290. fogStart: number;
  41291. /**
  41292. * Gets or sets the fog end distance to use
  41293. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41294. * (Default is 1000)
  41295. */
  41296. fogEnd: number;
  41297. /**
  41298. * Flag indicating that the frame buffer binding is handled by another component
  41299. */
  41300. prePass: boolean;
  41301. private _shadowsEnabled;
  41302. /**
  41303. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41304. */
  41305. set shadowsEnabled(value: boolean);
  41306. get shadowsEnabled(): boolean;
  41307. private _lightsEnabled;
  41308. /**
  41309. * Gets or sets a boolean indicating if lights are enabled on this scene
  41310. */
  41311. set lightsEnabled(value: boolean);
  41312. get lightsEnabled(): boolean;
  41313. /** All of the active cameras added to this scene. */
  41314. activeCameras: Camera[];
  41315. /** @hidden */
  41316. _activeCamera: Nullable<Camera>;
  41317. /** Gets or sets the current active camera */
  41318. get activeCamera(): Nullable<Camera>;
  41319. set activeCamera(value: Nullable<Camera>);
  41320. private _defaultMaterial;
  41321. /** The default material used on meshes when no material is affected */
  41322. get defaultMaterial(): Material;
  41323. /** The default material used on meshes when no material is affected */
  41324. set defaultMaterial(value: Material);
  41325. private _texturesEnabled;
  41326. /**
  41327. * Gets or sets a boolean indicating if textures are enabled on this scene
  41328. */
  41329. set texturesEnabled(value: boolean);
  41330. get texturesEnabled(): boolean;
  41331. /**
  41332. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41333. */
  41334. physicsEnabled: boolean;
  41335. /**
  41336. * Gets or sets a boolean indicating if particles are enabled on this scene
  41337. */
  41338. particlesEnabled: boolean;
  41339. /**
  41340. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41341. */
  41342. spritesEnabled: boolean;
  41343. private _skeletonsEnabled;
  41344. /**
  41345. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41346. */
  41347. set skeletonsEnabled(value: boolean);
  41348. get skeletonsEnabled(): boolean;
  41349. /**
  41350. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41351. */
  41352. lensFlaresEnabled: boolean;
  41353. /**
  41354. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41355. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41356. */
  41357. collisionsEnabled: boolean;
  41358. private _collisionCoordinator;
  41359. /** @hidden */
  41360. get collisionCoordinator(): ICollisionCoordinator;
  41361. /**
  41362. * Defines the gravity applied to this scene (used only for collisions)
  41363. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41364. */
  41365. gravity: Vector3;
  41366. /**
  41367. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41368. */
  41369. postProcessesEnabled: boolean;
  41370. /**
  41371. * Gets the current postprocess manager
  41372. */
  41373. postProcessManager: PostProcessManager;
  41374. /**
  41375. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41376. */
  41377. renderTargetsEnabled: boolean;
  41378. /**
  41379. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41380. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41381. */
  41382. dumpNextRenderTargets: boolean;
  41383. /**
  41384. * The list of user defined render targets added to the scene
  41385. */
  41386. customRenderTargets: RenderTargetTexture[];
  41387. /**
  41388. * Defines if texture loading must be delayed
  41389. * If true, textures will only be loaded when they need to be rendered
  41390. */
  41391. useDelayedTextureLoading: boolean;
  41392. /**
  41393. * Gets the list of meshes imported to the scene through SceneLoader
  41394. */
  41395. importedMeshesFiles: String[];
  41396. /**
  41397. * Gets or sets a boolean indicating if probes are enabled on this scene
  41398. */
  41399. probesEnabled: boolean;
  41400. /**
  41401. * Gets or sets the current offline provider to use to store scene data
  41402. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41403. */
  41404. offlineProvider: IOfflineProvider;
  41405. /**
  41406. * Gets or sets the action manager associated with the scene
  41407. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41408. */
  41409. actionManager: AbstractActionManager;
  41410. private _meshesForIntersections;
  41411. /**
  41412. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41413. */
  41414. proceduralTexturesEnabled: boolean;
  41415. private _engine;
  41416. private _totalVertices;
  41417. /** @hidden */
  41418. _activeIndices: PerfCounter;
  41419. /** @hidden */
  41420. _activeParticles: PerfCounter;
  41421. /** @hidden */
  41422. _activeBones: PerfCounter;
  41423. private _animationRatio;
  41424. /** @hidden */
  41425. _animationTimeLast: number;
  41426. /** @hidden */
  41427. _animationTime: number;
  41428. /**
  41429. * Gets or sets a general scale for animation speed
  41430. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41431. */
  41432. animationTimeScale: number;
  41433. /** @hidden */
  41434. _cachedMaterial: Nullable<Material>;
  41435. /** @hidden */
  41436. _cachedEffect: Nullable<Effect>;
  41437. /** @hidden */
  41438. _cachedVisibility: Nullable<number>;
  41439. private _renderId;
  41440. private _frameId;
  41441. private _executeWhenReadyTimeoutId;
  41442. private _intermediateRendering;
  41443. private _viewUpdateFlag;
  41444. private _projectionUpdateFlag;
  41445. /** @hidden */
  41446. _toBeDisposed: Nullable<IDisposable>[];
  41447. private _activeRequests;
  41448. /** @hidden */
  41449. _pendingData: any[];
  41450. private _isDisposed;
  41451. /**
  41452. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41453. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41454. */
  41455. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41456. private _activeMeshes;
  41457. private _processedMaterials;
  41458. private _renderTargets;
  41459. /** @hidden */
  41460. _activeParticleSystems: SmartArray<IParticleSystem>;
  41461. private _activeSkeletons;
  41462. private _softwareSkinnedMeshes;
  41463. private _renderingManager;
  41464. /** @hidden */
  41465. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41466. private _transformMatrix;
  41467. private _sceneUbo;
  41468. /** @hidden */
  41469. _viewMatrix: Matrix;
  41470. private _projectionMatrix;
  41471. /** @hidden */
  41472. _forcedViewPosition: Nullable<Vector3>;
  41473. /** @hidden */
  41474. _frustumPlanes: Plane[];
  41475. /**
  41476. * Gets the list of frustum planes (built from the active camera)
  41477. */
  41478. get frustumPlanes(): Plane[];
  41479. /**
  41480. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41481. * This is useful if there are more lights that the maximum simulteanous authorized
  41482. */
  41483. requireLightSorting: boolean;
  41484. /** @hidden */
  41485. readonly useMaterialMeshMap: boolean;
  41486. /** @hidden */
  41487. readonly useClonedMeshMap: boolean;
  41488. private _externalData;
  41489. private _uid;
  41490. /**
  41491. * @hidden
  41492. * Backing store of defined scene components.
  41493. */
  41494. _components: ISceneComponent[];
  41495. /**
  41496. * @hidden
  41497. * Backing store of defined scene components.
  41498. */
  41499. _serializableComponents: ISceneSerializableComponent[];
  41500. /**
  41501. * List of components to register on the next registration step.
  41502. */
  41503. private _transientComponents;
  41504. /**
  41505. * Registers the transient components if needed.
  41506. */
  41507. private _registerTransientComponents;
  41508. /**
  41509. * @hidden
  41510. * Add a component to the scene.
  41511. * Note that the ccomponent could be registered on th next frame if this is called after
  41512. * the register component stage.
  41513. * @param component Defines the component to add to the scene
  41514. */
  41515. _addComponent(component: ISceneComponent): void;
  41516. /**
  41517. * @hidden
  41518. * Gets a component from the scene.
  41519. * @param name defines the name of the component to retrieve
  41520. * @returns the component or null if not present
  41521. */
  41522. _getComponent(name: string): Nullable<ISceneComponent>;
  41523. /**
  41524. * @hidden
  41525. * Defines the actions happening before camera updates.
  41526. */
  41527. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41528. /**
  41529. * @hidden
  41530. * Defines the actions happening before clear the canvas.
  41531. */
  41532. _beforeClearStage: Stage<SimpleStageAction>;
  41533. /**
  41534. * @hidden
  41535. * Defines the actions when collecting render targets for the frame.
  41536. */
  41537. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41538. /**
  41539. * @hidden
  41540. * Defines the actions happening for one camera in the frame.
  41541. */
  41542. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41543. /**
  41544. * @hidden
  41545. * Defines the actions happening during the per mesh ready checks.
  41546. */
  41547. _isReadyForMeshStage: Stage<MeshStageAction>;
  41548. /**
  41549. * @hidden
  41550. * Defines the actions happening before evaluate active mesh checks.
  41551. */
  41552. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41553. /**
  41554. * @hidden
  41555. * Defines the actions happening during the evaluate sub mesh checks.
  41556. */
  41557. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41558. /**
  41559. * @hidden
  41560. * Defines the actions happening during the active mesh stage.
  41561. */
  41562. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41563. /**
  41564. * @hidden
  41565. * Defines the actions happening during the per camera render target step.
  41566. */
  41567. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41568. /**
  41569. * @hidden
  41570. * Defines the actions happening just before the active camera is drawing.
  41571. */
  41572. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41573. /**
  41574. * @hidden
  41575. * Defines the actions happening just before a render target is drawing.
  41576. */
  41577. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41578. /**
  41579. * @hidden
  41580. * Defines the actions happening just before a rendering group is drawing.
  41581. */
  41582. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41583. /**
  41584. * @hidden
  41585. * Defines the actions happening just before a mesh is drawing.
  41586. */
  41587. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41588. /**
  41589. * @hidden
  41590. * Defines the actions happening just after a mesh has been drawn.
  41591. */
  41592. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41593. /**
  41594. * @hidden
  41595. * Defines the actions happening just after a rendering group has been drawn.
  41596. */
  41597. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41598. /**
  41599. * @hidden
  41600. * Defines the actions happening just after the active camera has been drawn.
  41601. */
  41602. _afterCameraDrawStage: Stage<CameraStageAction>;
  41603. /**
  41604. * @hidden
  41605. * Defines the actions happening just after a render target has been drawn.
  41606. */
  41607. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41608. /**
  41609. * @hidden
  41610. * Defines the actions happening just after rendering all cameras and computing intersections.
  41611. */
  41612. _afterRenderStage: Stage<SimpleStageAction>;
  41613. /**
  41614. * @hidden
  41615. * Defines the actions happening when a pointer move event happens.
  41616. */
  41617. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41618. /**
  41619. * @hidden
  41620. * Defines the actions happening when a pointer down event happens.
  41621. */
  41622. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41623. /**
  41624. * @hidden
  41625. * Defines the actions happening when a pointer up event happens.
  41626. */
  41627. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41628. /**
  41629. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41630. */
  41631. private geometriesByUniqueId;
  41632. /**
  41633. * Creates a new Scene
  41634. * @param engine defines the engine to use to render this scene
  41635. * @param options defines the scene options
  41636. */
  41637. constructor(engine: Engine, options?: SceneOptions);
  41638. /**
  41639. * Gets a string identifying the name of the class
  41640. * @returns "Scene" string
  41641. */
  41642. getClassName(): string;
  41643. private _defaultMeshCandidates;
  41644. /**
  41645. * @hidden
  41646. */
  41647. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41648. private _defaultSubMeshCandidates;
  41649. /**
  41650. * @hidden
  41651. */
  41652. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41653. /**
  41654. * Sets the default candidate providers for the scene.
  41655. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41656. * and getCollidingSubMeshCandidates to their default function
  41657. */
  41658. setDefaultCandidateProviders(): void;
  41659. /**
  41660. * Gets the mesh that is currently under the pointer
  41661. */
  41662. get meshUnderPointer(): Nullable<AbstractMesh>;
  41663. /**
  41664. * Gets or sets the current on-screen X position of the pointer
  41665. */
  41666. get pointerX(): number;
  41667. set pointerX(value: number);
  41668. /**
  41669. * Gets or sets the current on-screen Y position of the pointer
  41670. */
  41671. get pointerY(): number;
  41672. set pointerY(value: number);
  41673. /**
  41674. * Gets the cached material (ie. the latest rendered one)
  41675. * @returns the cached material
  41676. */
  41677. getCachedMaterial(): Nullable<Material>;
  41678. /**
  41679. * Gets the cached effect (ie. the latest rendered one)
  41680. * @returns the cached effect
  41681. */
  41682. getCachedEffect(): Nullable<Effect>;
  41683. /**
  41684. * Gets the cached visibility state (ie. the latest rendered one)
  41685. * @returns the cached visibility state
  41686. */
  41687. getCachedVisibility(): Nullable<number>;
  41688. /**
  41689. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41690. * @param material defines the current material
  41691. * @param effect defines the current effect
  41692. * @param visibility defines the current visibility state
  41693. * @returns true if one parameter is not cached
  41694. */
  41695. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41696. /**
  41697. * Gets the engine associated with the scene
  41698. * @returns an Engine
  41699. */
  41700. getEngine(): Engine;
  41701. /**
  41702. * Gets the total number of vertices rendered per frame
  41703. * @returns the total number of vertices rendered per frame
  41704. */
  41705. getTotalVertices(): number;
  41706. /**
  41707. * Gets the performance counter for total vertices
  41708. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41709. */
  41710. get totalVerticesPerfCounter(): PerfCounter;
  41711. /**
  41712. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41713. * @returns the total number of active indices rendered per frame
  41714. */
  41715. getActiveIndices(): number;
  41716. /**
  41717. * Gets the performance counter for active indices
  41718. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41719. */
  41720. get totalActiveIndicesPerfCounter(): PerfCounter;
  41721. /**
  41722. * Gets the total number of active particles rendered per frame
  41723. * @returns the total number of active particles rendered per frame
  41724. */
  41725. getActiveParticles(): number;
  41726. /**
  41727. * Gets the performance counter for active particles
  41728. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41729. */
  41730. get activeParticlesPerfCounter(): PerfCounter;
  41731. /**
  41732. * Gets the total number of active bones rendered per frame
  41733. * @returns the total number of active bones rendered per frame
  41734. */
  41735. getActiveBones(): number;
  41736. /**
  41737. * Gets the performance counter for active bones
  41738. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41739. */
  41740. get activeBonesPerfCounter(): PerfCounter;
  41741. /**
  41742. * Gets the array of active meshes
  41743. * @returns an array of AbstractMesh
  41744. */
  41745. getActiveMeshes(): SmartArray<AbstractMesh>;
  41746. /**
  41747. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41748. * @returns a number
  41749. */
  41750. getAnimationRatio(): number;
  41751. /**
  41752. * Gets an unique Id for the current render phase
  41753. * @returns a number
  41754. */
  41755. getRenderId(): number;
  41756. /**
  41757. * Gets an unique Id for the current frame
  41758. * @returns a number
  41759. */
  41760. getFrameId(): number;
  41761. /** Call this function if you want to manually increment the render Id*/
  41762. incrementRenderId(): void;
  41763. private _createUbo;
  41764. /**
  41765. * Use this method to simulate a pointer move on a mesh
  41766. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41767. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41768. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41769. * @returns the current scene
  41770. */
  41771. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41772. /**
  41773. * Use this method to simulate a pointer down on a mesh
  41774. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41775. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41776. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41777. * @returns the current scene
  41778. */
  41779. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41780. /**
  41781. * Use this method to simulate a pointer up on a mesh
  41782. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41783. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41784. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41785. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41786. * @returns the current scene
  41787. */
  41788. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41789. /**
  41790. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41791. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41792. * @returns true if the pointer was captured
  41793. */
  41794. isPointerCaptured(pointerId?: number): boolean;
  41795. /**
  41796. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41797. * @param attachUp defines if you want to attach events to pointerup
  41798. * @param attachDown defines if you want to attach events to pointerdown
  41799. * @param attachMove defines if you want to attach events to pointermove
  41800. */
  41801. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41802. /** Detaches all event handlers*/
  41803. detachControl(): void;
  41804. /**
  41805. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41806. * Delay loaded resources are not taking in account
  41807. * @return true if all required resources are ready
  41808. */
  41809. isReady(): boolean;
  41810. /** Resets all cached information relative to material (including effect and visibility) */
  41811. resetCachedMaterial(): void;
  41812. /**
  41813. * Registers a function to be called before every frame render
  41814. * @param func defines the function to register
  41815. */
  41816. registerBeforeRender(func: () => void): void;
  41817. /**
  41818. * Unregisters a function called before every frame render
  41819. * @param func defines the function to unregister
  41820. */
  41821. unregisterBeforeRender(func: () => void): void;
  41822. /**
  41823. * Registers a function to be called after every frame render
  41824. * @param func defines the function to register
  41825. */
  41826. registerAfterRender(func: () => void): void;
  41827. /**
  41828. * Unregisters a function called after every frame render
  41829. * @param func defines the function to unregister
  41830. */
  41831. unregisterAfterRender(func: () => void): void;
  41832. private _executeOnceBeforeRender;
  41833. /**
  41834. * The provided function will run before render once and will be disposed afterwards.
  41835. * A timeout delay can be provided so that the function will be executed in N ms.
  41836. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41837. * @param func The function to be executed.
  41838. * @param timeout optional delay in ms
  41839. */
  41840. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41841. /** @hidden */
  41842. _addPendingData(data: any): void;
  41843. /** @hidden */
  41844. _removePendingData(data: any): void;
  41845. /**
  41846. * Returns the number of items waiting to be loaded
  41847. * @returns the number of items waiting to be loaded
  41848. */
  41849. getWaitingItemsCount(): number;
  41850. /**
  41851. * Returns a boolean indicating if the scene is still loading data
  41852. */
  41853. get isLoading(): boolean;
  41854. /**
  41855. * Registers a function to be executed when the scene is ready
  41856. * @param {Function} func - the function to be executed
  41857. */
  41858. executeWhenReady(func: () => void): void;
  41859. /**
  41860. * Returns a promise that resolves when the scene is ready
  41861. * @returns A promise that resolves when the scene is ready
  41862. */
  41863. whenReadyAsync(): Promise<void>;
  41864. /** @hidden */
  41865. _checkIsReady(): void;
  41866. /**
  41867. * Gets all animatable attached to the scene
  41868. */
  41869. get animatables(): Animatable[];
  41870. /**
  41871. * Resets the last animation time frame.
  41872. * Useful to override when animations start running when loading a scene for the first time.
  41873. */
  41874. resetLastAnimationTimeFrame(): void;
  41875. /**
  41876. * Gets the current view matrix
  41877. * @returns a Matrix
  41878. */
  41879. getViewMatrix(): Matrix;
  41880. /**
  41881. * Gets the current projection matrix
  41882. * @returns a Matrix
  41883. */
  41884. getProjectionMatrix(): Matrix;
  41885. /**
  41886. * Gets the current transform matrix
  41887. * @returns a Matrix made of View * Projection
  41888. */
  41889. getTransformMatrix(): Matrix;
  41890. /**
  41891. * Sets the current transform matrix
  41892. * @param viewL defines the View matrix to use
  41893. * @param projectionL defines the Projection matrix to use
  41894. * @param viewR defines the right View matrix to use (if provided)
  41895. * @param projectionR defines the right Projection matrix to use (if provided)
  41896. */
  41897. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41898. /**
  41899. * Gets the uniform buffer used to store scene data
  41900. * @returns a UniformBuffer
  41901. */
  41902. getSceneUniformBuffer(): UniformBuffer;
  41903. /**
  41904. * Gets an unique (relatively to the current scene) Id
  41905. * @returns an unique number for the scene
  41906. */
  41907. getUniqueId(): number;
  41908. /**
  41909. * Add a mesh to the list of scene's meshes
  41910. * @param newMesh defines the mesh to add
  41911. * @param recursive if all child meshes should also be added to the scene
  41912. */
  41913. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41914. /**
  41915. * Remove a mesh for the list of scene's meshes
  41916. * @param toRemove defines the mesh to remove
  41917. * @param recursive if all child meshes should also be removed from the scene
  41918. * @returns the index where the mesh was in the mesh list
  41919. */
  41920. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41921. /**
  41922. * Add a transform node to the list of scene's transform nodes
  41923. * @param newTransformNode defines the transform node to add
  41924. */
  41925. addTransformNode(newTransformNode: TransformNode): void;
  41926. /**
  41927. * Remove a transform node for the list of scene's transform nodes
  41928. * @param toRemove defines the transform node to remove
  41929. * @returns the index where the transform node was in the transform node list
  41930. */
  41931. removeTransformNode(toRemove: TransformNode): number;
  41932. /**
  41933. * Remove a skeleton for the list of scene's skeletons
  41934. * @param toRemove defines the skeleton to remove
  41935. * @returns the index where the skeleton was in the skeleton list
  41936. */
  41937. removeSkeleton(toRemove: Skeleton): number;
  41938. /**
  41939. * Remove a morph target for the list of scene's morph targets
  41940. * @param toRemove defines the morph target to remove
  41941. * @returns the index where the morph target was in the morph target list
  41942. */
  41943. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41944. /**
  41945. * Remove a light for the list of scene's lights
  41946. * @param toRemove defines the light to remove
  41947. * @returns the index where the light was in the light list
  41948. */
  41949. removeLight(toRemove: Light): number;
  41950. /**
  41951. * Remove a camera for the list of scene's cameras
  41952. * @param toRemove defines the camera to remove
  41953. * @returns the index where the camera was in the camera list
  41954. */
  41955. removeCamera(toRemove: Camera): number;
  41956. /**
  41957. * Remove a particle system for the list of scene's particle systems
  41958. * @param toRemove defines the particle system to remove
  41959. * @returns the index where the particle system was in the particle system list
  41960. */
  41961. removeParticleSystem(toRemove: IParticleSystem): number;
  41962. /**
  41963. * Remove a animation for the list of scene's animations
  41964. * @param toRemove defines the animation to remove
  41965. * @returns the index where the animation was in the animation list
  41966. */
  41967. removeAnimation(toRemove: Animation): number;
  41968. /**
  41969. * Will stop the animation of the given target
  41970. * @param target - the target
  41971. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  41972. * @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)
  41973. */
  41974. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  41975. /**
  41976. * Removes the given animation group from this scene.
  41977. * @param toRemove The animation group to remove
  41978. * @returns The index of the removed animation group
  41979. */
  41980. removeAnimationGroup(toRemove: AnimationGroup): number;
  41981. /**
  41982. * Removes the given multi-material from this scene.
  41983. * @param toRemove The multi-material to remove
  41984. * @returns The index of the removed multi-material
  41985. */
  41986. removeMultiMaterial(toRemove: MultiMaterial): number;
  41987. /**
  41988. * Removes the given material from this scene.
  41989. * @param toRemove The material to remove
  41990. * @returns The index of the removed material
  41991. */
  41992. removeMaterial(toRemove: Material): number;
  41993. /**
  41994. * Removes the given action manager from this scene.
  41995. * @param toRemove The action manager to remove
  41996. * @returns The index of the removed action manager
  41997. */
  41998. removeActionManager(toRemove: AbstractActionManager): number;
  41999. /**
  42000. * Removes the given texture from this scene.
  42001. * @param toRemove The texture to remove
  42002. * @returns The index of the removed texture
  42003. */
  42004. removeTexture(toRemove: BaseTexture): number;
  42005. /**
  42006. * Adds the given light to this scene
  42007. * @param newLight The light to add
  42008. */
  42009. addLight(newLight: Light): void;
  42010. /**
  42011. * Sorts the list list based on light priorities
  42012. */
  42013. sortLightsByPriority(): void;
  42014. /**
  42015. * Adds the given camera to this scene
  42016. * @param newCamera The camera to add
  42017. */
  42018. addCamera(newCamera: Camera): void;
  42019. /**
  42020. * Adds the given skeleton to this scene
  42021. * @param newSkeleton The skeleton to add
  42022. */
  42023. addSkeleton(newSkeleton: Skeleton): void;
  42024. /**
  42025. * Adds the given particle system to this scene
  42026. * @param newParticleSystem The particle system to add
  42027. */
  42028. addParticleSystem(newParticleSystem: IParticleSystem): void;
  42029. /**
  42030. * Adds the given animation to this scene
  42031. * @param newAnimation The animation to add
  42032. */
  42033. addAnimation(newAnimation: Animation): void;
  42034. /**
  42035. * Adds the given animation group to this scene.
  42036. * @param newAnimationGroup The animation group to add
  42037. */
  42038. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  42039. /**
  42040. * Adds the given multi-material to this scene
  42041. * @param newMultiMaterial The multi-material to add
  42042. */
  42043. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  42044. /**
  42045. * Adds the given material to this scene
  42046. * @param newMaterial The material to add
  42047. */
  42048. addMaterial(newMaterial: Material): void;
  42049. /**
  42050. * Adds the given morph target to this scene
  42051. * @param newMorphTargetManager The morph target to add
  42052. */
  42053. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  42054. /**
  42055. * Adds the given geometry to this scene
  42056. * @param newGeometry The geometry to add
  42057. */
  42058. addGeometry(newGeometry: Geometry): void;
  42059. /**
  42060. * Adds the given action manager to this scene
  42061. * @param newActionManager The action manager to add
  42062. */
  42063. addActionManager(newActionManager: AbstractActionManager): void;
  42064. /**
  42065. * Adds the given texture to this scene.
  42066. * @param newTexture The texture to add
  42067. */
  42068. addTexture(newTexture: BaseTexture): void;
  42069. /**
  42070. * Switch active camera
  42071. * @param newCamera defines the new active camera
  42072. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  42073. */
  42074. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  42075. /**
  42076. * sets the active camera of the scene using its ID
  42077. * @param id defines the camera's ID
  42078. * @return the new active camera or null if none found.
  42079. */
  42080. setActiveCameraByID(id: string): Nullable<Camera>;
  42081. /**
  42082. * sets the active camera of the scene using its name
  42083. * @param name defines the camera's name
  42084. * @returns the new active camera or null if none found.
  42085. */
  42086. setActiveCameraByName(name: string): Nullable<Camera>;
  42087. /**
  42088. * get an animation group using its name
  42089. * @param name defines the material's name
  42090. * @return the animation group or null if none found.
  42091. */
  42092. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  42093. /**
  42094. * Get a material using its unique id
  42095. * @param uniqueId defines the material's unique id
  42096. * @return the material or null if none found.
  42097. */
  42098. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  42099. /**
  42100. * get a material using its id
  42101. * @param id defines the material's ID
  42102. * @return the material or null if none found.
  42103. */
  42104. getMaterialByID(id: string): Nullable<Material>;
  42105. /**
  42106. * Gets a the last added material using a given id
  42107. * @param id defines the material's ID
  42108. * @return the last material with the given id or null if none found.
  42109. */
  42110. getLastMaterialByID(id: string): Nullable<Material>;
  42111. /**
  42112. * Gets a material using its name
  42113. * @param name defines the material's name
  42114. * @return the material or null if none found.
  42115. */
  42116. getMaterialByName(name: string): Nullable<Material>;
  42117. /**
  42118. * Get a texture using its unique id
  42119. * @param uniqueId defines the texture's unique id
  42120. * @return the texture or null if none found.
  42121. */
  42122. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42123. /**
  42124. * Gets a camera using its id
  42125. * @param id defines the id to look for
  42126. * @returns the camera or null if not found
  42127. */
  42128. getCameraByID(id: string): Nullable<Camera>;
  42129. /**
  42130. * Gets a camera using its unique id
  42131. * @param uniqueId defines the unique id to look for
  42132. * @returns the camera or null if not found
  42133. */
  42134. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42135. /**
  42136. * Gets a camera using its name
  42137. * @param name defines the camera's name
  42138. * @return the camera or null if none found.
  42139. */
  42140. getCameraByName(name: string): Nullable<Camera>;
  42141. /**
  42142. * Gets a bone using its id
  42143. * @param id defines the bone's id
  42144. * @return the bone or null if not found
  42145. */
  42146. getBoneByID(id: string): Nullable<Bone>;
  42147. /**
  42148. * Gets a bone using its id
  42149. * @param name defines the bone's name
  42150. * @return the bone or null if not found
  42151. */
  42152. getBoneByName(name: string): Nullable<Bone>;
  42153. /**
  42154. * Gets a light node using its name
  42155. * @param name defines the the light's name
  42156. * @return the light or null if none found.
  42157. */
  42158. getLightByName(name: string): Nullable<Light>;
  42159. /**
  42160. * Gets a light node using its id
  42161. * @param id defines the light's id
  42162. * @return the light or null if none found.
  42163. */
  42164. getLightByID(id: string): Nullable<Light>;
  42165. /**
  42166. * Gets a light node using its scene-generated unique ID
  42167. * @param uniqueId defines the light's unique id
  42168. * @return the light or null if none found.
  42169. */
  42170. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42171. /**
  42172. * Gets a particle system by id
  42173. * @param id defines the particle system id
  42174. * @return the corresponding system or null if none found
  42175. */
  42176. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42177. /**
  42178. * Gets a geometry using its ID
  42179. * @param id defines the geometry's id
  42180. * @return the geometry or null if none found.
  42181. */
  42182. getGeometryByID(id: string): Nullable<Geometry>;
  42183. private _getGeometryByUniqueID;
  42184. /**
  42185. * Add a new geometry to this scene
  42186. * @param geometry defines the geometry to be added to the scene.
  42187. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42188. * @return a boolean defining if the geometry was added or not
  42189. */
  42190. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42191. /**
  42192. * Removes an existing geometry
  42193. * @param geometry defines the geometry to be removed from the scene
  42194. * @return a boolean defining if the geometry was removed or not
  42195. */
  42196. removeGeometry(geometry: Geometry): boolean;
  42197. /**
  42198. * Gets the list of geometries attached to the scene
  42199. * @returns an array of Geometry
  42200. */
  42201. getGeometries(): Geometry[];
  42202. /**
  42203. * Gets the first added mesh found of a given ID
  42204. * @param id defines the id to search for
  42205. * @return the mesh found or null if not found at all
  42206. */
  42207. getMeshByID(id: string): Nullable<AbstractMesh>;
  42208. /**
  42209. * Gets a list of meshes using their id
  42210. * @param id defines the id to search for
  42211. * @returns a list of meshes
  42212. */
  42213. getMeshesByID(id: string): Array<AbstractMesh>;
  42214. /**
  42215. * Gets the first added transform node found of a given ID
  42216. * @param id defines the id to search for
  42217. * @return the found transform node or null if not found at all.
  42218. */
  42219. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42220. /**
  42221. * Gets a transform node with its auto-generated unique id
  42222. * @param uniqueId efines the unique id to search for
  42223. * @return the found transform node or null if not found at all.
  42224. */
  42225. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42226. /**
  42227. * Gets a list of transform nodes using their id
  42228. * @param id defines the id to search for
  42229. * @returns a list of transform nodes
  42230. */
  42231. getTransformNodesByID(id: string): Array<TransformNode>;
  42232. /**
  42233. * Gets a mesh with its auto-generated unique id
  42234. * @param uniqueId defines the unique id to search for
  42235. * @return the found mesh or null if not found at all.
  42236. */
  42237. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42238. /**
  42239. * Gets a the last added mesh using a given id
  42240. * @param id defines the id to search for
  42241. * @return the found mesh or null if not found at all.
  42242. */
  42243. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42244. /**
  42245. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42246. * @param id defines the id to search for
  42247. * @return the found node or null if not found at all
  42248. */
  42249. getLastEntryByID(id: string): Nullable<Node>;
  42250. /**
  42251. * Gets a node (Mesh, Camera, Light) using a given id
  42252. * @param id defines the id to search for
  42253. * @return the found node or null if not found at all
  42254. */
  42255. getNodeByID(id: string): Nullable<Node>;
  42256. /**
  42257. * Gets a node (Mesh, Camera, Light) using a given name
  42258. * @param name defines the name to search for
  42259. * @return the found node or null if not found at all.
  42260. */
  42261. getNodeByName(name: string): Nullable<Node>;
  42262. /**
  42263. * Gets a mesh using a given name
  42264. * @param name defines the name to search for
  42265. * @return the found mesh or null if not found at all.
  42266. */
  42267. getMeshByName(name: string): Nullable<AbstractMesh>;
  42268. /**
  42269. * Gets a transform node using a given name
  42270. * @param name defines the name to search for
  42271. * @return the found transform node or null if not found at all.
  42272. */
  42273. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42274. /**
  42275. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42276. * @param id defines the id to search for
  42277. * @return the found skeleton or null if not found at all.
  42278. */
  42279. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42280. /**
  42281. * Gets a skeleton using a given auto generated unique id
  42282. * @param uniqueId defines the unique id to search for
  42283. * @return the found skeleton or null if not found at all.
  42284. */
  42285. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42286. /**
  42287. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42288. * @param id defines the id to search for
  42289. * @return the found skeleton or null if not found at all.
  42290. */
  42291. getSkeletonById(id: string): Nullable<Skeleton>;
  42292. /**
  42293. * Gets a skeleton using a given name
  42294. * @param name defines the name to search for
  42295. * @return the found skeleton or null if not found at all.
  42296. */
  42297. getSkeletonByName(name: string): Nullable<Skeleton>;
  42298. /**
  42299. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42300. * @param id defines the id to search for
  42301. * @return the found morph target manager or null if not found at all.
  42302. */
  42303. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42304. /**
  42305. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42306. * @param id defines the id to search for
  42307. * @return the found morph target or null if not found at all.
  42308. */
  42309. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42310. /**
  42311. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42312. * @param name defines the name to search for
  42313. * @return the found morph target or null if not found at all.
  42314. */
  42315. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42316. /**
  42317. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42318. * @param name defines the name to search for
  42319. * @return the found post process or null if not found at all.
  42320. */
  42321. getPostProcessByName(name: string): Nullable<PostProcess>;
  42322. /**
  42323. * Gets a boolean indicating if the given mesh is active
  42324. * @param mesh defines the mesh to look for
  42325. * @returns true if the mesh is in the active list
  42326. */
  42327. isActiveMesh(mesh: AbstractMesh): boolean;
  42328. /**
  42329. * Return a unique id as a string which can serve as an identifier for the scene
  42330. */
  42331. get uid(): string;
  42332. /**
  42333. * Add an externaly attached data from its key.
  42334. * This method call will fail and return false, if such key already exists.
  42335. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42336. * @param key the unique key that identifies the data
  42337. * @param data the data object to associate to the key for this Engine instance
  42338. * @return true if no such key were already present and the data was added successfully, false otherwise
  42339. */
  42340. addExternalData<T>(key: string, data: T): boolean;
  42341. /**
  42342. * Get an externaly attached data from its key
  42343. * @param key the unique key that identifies the data
  42344. * @return the associated data, if present (can be null), or undefined if not present
  42345. */
  42346. getExternalData<T>(key: string): Nullable<T>;
  42347. /**
  42348. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42349. * @param key the unique key that identifies the data
  42350. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42351. * @return the associated data, can be null if the factory returned null.
  42352. */
  42353. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42354. /**
  42355. * Remove an externaly attached data from the Engine instance
  42356. * @param key the unique key that identifies the data
  42357. * @return true if the data was successfully removed, false if it doesn't exist
  42358. */
  42359. removeExternalData(key: string): boolean;
  42360. private _evaluateSubMesh;
  42361. /**
  42362. * Clear the processed materials smart array preventing retention point in material dispose.
  42363. */
  42364. freeProcessedMaterials(): void;
  42365. private _preventFreeActiveMeshesAndRenderingGroups;
  42366. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42367. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42368. * when disposing several meshes in a row or a hierarchy of meshes.
  42369. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42370. */
  42371. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42372. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42373. /**
  42374. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42375. */
  42376. freeActiveMeshes(): void;
  42377. /**
  42378. * Clear the info related to rendering groups preventing retention points during dispose.
  42379. */
  42380. freeRenderingGroups(): void;
  42381. /** @hidden */
  42382. _isInIntermediateRendering(): boolean;
  42383. /**
  42384. * Lambda returning the list of potentially active meshes.
  42385. */
  42386. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42387. /**
  42388. * Lambda returning the list of potentially active sub meshes.
  42389. */
  42390. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42391. /**
  42392. * Lambda returning the list of potentially intersecting sub meshes.
  42393. */
  42394. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42395. /**
  42396. * Lambda returning the list of potentially colliding sub meshes.
  42397. */
  42398. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42399. private _activeMeshesFrozen;
  42400. private _skipEvaluateActiveMeshesCompletely;
  42401. /**
  42402. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42403. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42404. * @returns the current scene
  42405. */
  42406. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42407. /**
  42408. * Use this function to restart evaluating active meshes on every frame
  42409. * @returns the current scene
  42410. */
  42411. unfreezeActiveMeshes(): Scene;
  42412. private _evaluateActiveMeshes;
  42413. private _activeMesh;
  42414. /**
  42415. * Update the transform matrix to update from the current active camera
  42416. * @param force defines a boolean used to force the update even if cache is up to date
  42417. */
  42418. updateTransformMatrix(force?: boolean): void;
  42419. private _bindFrameBuffer;
  42420. /** @hidden */
  42421. _allowPostProcessClearColor: boolean;
  42422. /** @hidden */
  42423. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42424. private _processSubCameras;
  42425. private _checkIntersections;
  42426. /** @hidden */
  42427. _advancePhysicsEngineStep(step: number): void;
  42428. /**
  42429. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42430. */
  42431. getDeterministicFrameTime: () => number;
  42432. /** @hidden */
  42433. _animate(): void;
  42434. /** Execute all animations (for a frame) */
  42435. animate(): void;
  42436. /**
  42437. * Render the scene
  42438. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42439. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42440. */
  42441. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42442. /**
  42443. * Freeze all materials
  42444. * A frozen material will not be updatable but should be faster to render
  42445. */
  42446. freezeMaterials(): void;
  42447. /**
  42448. * Unfreeze all materials
  42449. * A frozen material will not be updatable but should be faster to render
  42450. */
  42451. unfreezeMaterials(): void;
  42452. /**
  42453. * Releases all held ressources
  42454. */
  42455. dispose(): void;
  42456. /**
  42457. * Gets if the scene is already disposed
  42458. */
  42459. get isDisposed(): boolean;
  42460. /**
  42461. * Call this function to reduce memory footprint of the scene.
  42462. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42463. */
  42464. clearCachedVertexData(): void;
  42465. /**
  42466. * This function will remove the local cached buffer data from texture.
  42467. * It will save memory but will prevent the texture from being rebuilt
  42468. */
  42469. cleanCachedTextureBuffer(): void;
  42470. /**
  42471. * Get the world extend vectors with an optional filter
  42472. *
  42473. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42474. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42475. */
  42476. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42477. min: Vector3;
  42478. max: Vector3;
  42479. };
  42480. /**
  42481. * Creates a ray that can be used to pick in the scene
  42482. * @param x defines the x coordinate of the origin (on-screen)
  42483. * @param y defines the y coordinate of the origin (on-screen)
  42484. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42485. * @param camera defines the camera to use for the picking
  42486. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42487. * @returns a Ray
  42488. */
  42489. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42490. /**
  42491. * Creates a ray that can be used to pick in the scene
  42492. * @param x defines the x coordinate of the origin (on-screen)
  42493. * @param y defines the y coordinate of the origin (on-screen)
  42494. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42495. * @param result defines the ray where to store the picking ray
  42496. * @param camera defines the camera to use for the picking
  42497. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42498. * @returns the current scene
  42499. */
  42500. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42501. /**
  42502. * Creates a ray that can be used to pick in the scene
  42503. * @param x defines the x coordinate of the origin (on-screen)
  42504. * @param y defines the y coordinate of the origin (on-screen)
  42505. * @param camera defines the camera to use for the picking
  42506. * @returns a Ray
  42507. */
  42508. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42509. /**
  42510. * Creates a ray that can be used to pick in the scene
  42511. * @param x defines the x coordinate of the origin (on-screen)
  42512. * @param y defines the y coordinate of the origin (on-screen)
  42513. * @param result defines the ray where to store the picking ray
  42514. * @param camera defines the camera to use for the picking
  42515. * @returns the current scene
  42516. */
  42517. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42518. /** Launch a ray to try to pick a mesh in the scene
  42519. * @param x position on screen
  42520. * @param y position on screen
  42521. * @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
  42522. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42523. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42524. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42525. * @returns a PickingInfo
  42526. */
  42527. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42528. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42529. * @param x position on screen
  42530. * @param y position on screen
  42531. * @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
  42532. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42533. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42534. * @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)
  42535. */
  42536. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42537. /** Use the given ray to pick a mesh in the scene
  42538. * @param ray The ray to use to pick meshes
  42539. * @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
  42540. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42541. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42542. * @returns a PickingInfo
  42543. */
  42544. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42545. /**
  42546. * Launch a ray to try to pick a mesh in the scene
  42547. * @param x X position on screen
  42548. * @param y Y position on screen
  42549. * @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
  42550. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42551. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42552. * @returns an array of PickingInfo
  42553. */
  42554. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42555. /**
  42556. * Launch a ray to try to pick a mesh in the scene
  42557. * @param ray Ray to use
  42558. * @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
  42559. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42560. * @returns an array of PickingInfo
  42561. */
  42562. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42563. /**
  42564. * Force the value of meshUnderPointer
  42565. * @param mesh defines the mesh to use
  42566. * @param pointerId optional pointer id when using more than one pointer
  42567. */
  42568. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42569. /**
  42570. * Gets the mesh under the pointer
  42571. * @returns a Mesh or null if no mesh is under the pointer
  42572. */
  42573. getPointerOverMesh(): Nullable<AbstractMesh>;
  42574. /** @hidden */
  42575. _rebuildGeometries(): void;
  42576. /** @hidden */
  42577. _rebuildTextures(): void;
  42578. private _getByTags;
  42579. /**
  42580. * Get a list of meshes by tags
  42581. * @param tagsQuery defines the tags query to use
  42582. * @param forEach defines a predicate used to filter results
  42583. * @returns an array of Mesh
  42584. */
  42585. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42586. /**
  42587. * Get a list of cameras by tags
  42588. * @param tagsQuery defines the tags query to use
  42589. * @param forEach defines a predicate used to filter results
  42590. * @returns an array of Camera
  42591. */
  42592. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42593. /**
  42594. * Get a list of lights by tags
  42595. * @param tagsQuery defines the tags query to use
  42596. * @param forEach defines a predicate used to filter results
  42597. * @returns an array of Light
  42598. */
  42599. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42600. /**
  42601. * Get a list of materials by tags
  42602. * @param tagsQuery defines the tags query to use
  42603. * @param forEach defines a predicate used to filter results
  42604. * @returns an array of Material
  42605. */
  42606. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42607. /**
  42608. * Get a list of transform nodes by tags
  42609. * @param tagsQuery defines the tags query to use
  42610. * @param forEach defines a predicate used to filter results
  42611. * @returns an array of TransformNode
  42612. */
  42613. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  42614. /**
  42615. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42616. * This allowed control for front to back rendering or reversly depending of the special needs.
  42617. *
  42618. * @param renderingGroupId The rendering group id corresponding to its index
  42619. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42620. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42621. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42622. */
  42623. 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;
  42624. /**
  42625. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42626. *
  42627. * @param renderingGroupId The rendering group id corresponding to its index
  42628. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42629. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42630. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42631. */
  42632. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42633. /**
  42634. * Gets the current auto clear configuration for one rendering group of the rendering
  42635. * manager.
  42636. * @param index the rendering group index to get the information for
  42637. * @returns The auto clear setup for the requested rendering group
  42638. */
  42639. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42640. private _blockMaterialDirtyMechanism;
  42641. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42642. get blockMaterialDirtyMechanism(): boolean;
  42643. set blockMaterialDirtyMechanism(value: boolean);
  42644. /**
  42645. * Will flag all materials as dirty to trigger new shader compilation
  42646. * @param flag defines the flag used to specify which material part must be marked as dirty
  42647. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42648. */
  42649. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42650. /** @hidden */
  42651. _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;
  42652. /** @hidden */
  42653. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42654. /** @hidden */
  42655. _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;
  42656. /** @hidden */
  42657. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42658. /** @hidden */
  42659. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42660. /** @hidden */
  42661. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42662. }
  42663. }
  42664. declare module "babylonjs/assetContainer" {
  42665. import { AbstractScene } from "babylonjs/abstractScene";
  42666. import { Scene } from "babylonjs/scene";
  42667. import { Mesh } from "babylonjs/Meshes/mesh";
  42668. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42669. import { Skeleton } from "babylonjs/Bones/skeleton";
  42670. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42671. import { Animatable } from "babylonjs/Animations/animatable";
  42672. import { Nullable } from "babylonjs/types";
  42673. import { Node } from "babylonjs/node";
  42674. /**
  42675. * Set of assets to keep when moving a scene into an asset container.
  42676. */
  42677. export class KeepAssets extends AbstractScene {
  42678. }
  42679. /**
  42680. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42681. */
  42682. export class InstantiatedEntries {
  42683. /**
  42684. * List of new root nodes (eg. nodes with no parent)
  42685. */
  42686. rootNodes: TransformNode[];
  42687. /**
  42688. * List of new skeletons
  42689. */
  42690. skeletons: Skeleton[];
  42691. /**
  42692. * List of new animation groups
  42693. */
  42694. animationGroups: AnimationGroup[];
  42695. }
  42696. /**
  42697. * Container with a set of assets that can be added or removed from a scene.
  42698. */
  42699. export class AssetContainer extends AbstractScene {
  42700. private _wasAddedToScene;
  42701. /**
  42702. * The scene the AssetContainer belongs to.
  42703. */
  42704. scene: Scene;
  42705. /**
  42706. * Instantiates an AssetContainer.
  42707. * @param scene The scene the AssetContainer belongs to.
  42708. */
  42709. constructor(scene: Scene);
  42710. /**
  42711. * Instantiate or clone all meshes and add the new ones to the scene.
  42712. * Skeletons and animation groups will all be cloned
  42713. * @param nameFunction defines an optional function used to get new names for clones
  42714. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42715. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42716. */
  42717. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42718. /**
  42719. * Adds all the assets from the container to the scene.
  42720. */
  42721. addAllToScene(): void;
  42722. /**
  42723. * Removes all the assets in the container from the scene
  42724. */
  42725. removeAllFromScene(): void;
  42726. /**
  42727. * Disposes all the assets in the container
  42728. */
  42729. dispose(): void;
  42730. private _moveAssets;
  42731. /**
  42732. * Removes all the assets contained in the scene and adds them to the container.
  42733. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42734. */
  42735. moveAllFromScene(keepAssets?: KeepAssets): void;
  42736. /**
  42737. * 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.
  42738. * @returns the root mesh
  42739. */
  42740. createRootMesh(): Mesh;
  42741. /**
  42742. * Merge animations (direct and animation groups) from this asset container into a scene
  42743. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42744. * @param animatables set of animatables to retarget to a node from the scene
  42745. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42746. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42747. */
  42748. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42749. }
  42750. }
  42751. declare module "babylonjs/abstractScene" {
  42752. import { Scene } from "babylonjs/scene";
  42753. import { Nullable } from "babylonjs/types";
  42754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42755. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42756. import { Geometry } from "babylonjs/Meshes/geometry";
  42757. import { Skeleton } from "babylonjs/Bones/skeleton";
  42758. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42759. import { AssetContainer } from "babylonjs/assetContainer";
  42760. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42761. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42762. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42763. import { Material } from "babylonjs/Materials/material";
  42764. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42765. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42766. import { Camera } from "babylonjs/Cameras/camera";
  42767. import { Light } from "babylonjs/Lights/light";
  42768. import { Node } from "babylonjs/node";
  42769. import { Animation } from "babylonjs/Animations/animation";
  42770. /**
  42771. * Defines how the parser contract is defined.
  42772. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42773. */
  42774. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42775. /**
  42776. * Defines how the individual parser contract is defined.
  42777. * These parser can parse an individual asset
  42778. */
  42779. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42780. /**
  42781. * Base class of the scene acting as a container for the different elements composing a scene.
  42782. * This class is dynamically extended by the different components of the scene increasing
  42783. * flexibility and reducing coupling
  42784. */
  42785. export abstract class AbstractScene {
  42786. /**
  42787. * Stores the list of available parsers in the application.
  42788. */
  42789. private static _BabylonFileParsers;
  42790. /**
  42791. * Stores the list of available individual parsers in the application.
  42792. */
  42793. private static _IndividualBabylonFileParsers;
  42794. /**
  42795. * Adds a parser in the list of available ones
  42796. * @param name Defines the name of the parser
  42797. * @param parser Defines the parser to add
  42798. */
  42799. static AddParser(name: string, parser: BabylonFileParser): void;
  42800. /**
  42801. * Gets a general parser from the list of avaialble ones
  42802. * @param name Defines the name of the parser
  42803. * @returns the requested parser or null
  42804. */
  42805. static GetParser(name: string): Nullable<BabylonFileParser>;
  42806. /**
  42807. * Adds n individual parser in the list of available ones
  42808. * @param name Defines the name of the parser
  42809. * @param parser Defines the parser to add
  42810. */
  42811. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42812. /**
  42813. * Gets an individual parser from the list of avaialble ones
  42814. * @param name Defines the name of the parser
  42815. * @returns the requested parser or null
  42816. */
  42817. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42818. /**
  42819. * Parser json data and populate both a scene and its associated container object
  42820. * @param jsonData Defines the data to parse
  42821. * @param scene Defines the scene to parse the data for
  42822. * @param container Defines the container attached to the parsing sequence
  42823. * @param rootUrl Defines the root url of the data
  42824. */
  42825. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42826. /**
  42827. * Gets the list of root nodes (ie. nodes with no parent)
  42828. */
  42829. rootNodes: Node[];
  42830. /** All of the cameras added to this scene
  42831. * @see https://doc.babylonjs.com/babylon101/cameras
  42832. */
  42833. cameras: Camera[];
  42834. /**
  42835. * All of the lights added to this scene
  42836. * @see https://doc.babylonjs.com/babylon101/lights
  42837. */
  42838. lights: Light[];
  42839. /**
  42840. * All of the (abstract) meshes added to this scene
  42841. */
  42842. meshes: AbstractMesh[];
  42843. /**
  42844. * The list of skeletons added to the scene
  42845. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42846. */
  42847. skeletons: Skeleton[];
  42848. /**
  42849. * All of the particle systems added to this scene
  42850. * @see https://doc.babylonjs.com/babylon101/particles
  42851. */
  42852. particleSystems: IParticleSystem[];
  42853. /**
  42854. * Gets a list of Animations associated with the scene
  42855. */
  42856. animations: Animation[];
  42857. /**
  42858. * All of the animation groups added to this scene
  42859. * @see https://doc.babylonjs.com/how_to/group
  42860. */
  42861. animationGroups: AnimationGroup[];
  42862. /**
  42863. * All of the multi-materials added to this scene
  42864. * @see https://doc.babylonjs.com/how_to/multi_materials
  42865. */
  42866. multiMaterials: MultiMaterial[];
  42867. /**
  42868. * All of the materials added to this scene
  42869. * In the context of a Scene, it is not supposed to be modified manually.
  42870. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42871. * Note also that the order of the Material within the array is not significant and might change.
  42872. * @see https://doc.babylonjs.com/babylon101/materials
  42873. */
  42874. materials: Material[];
  42875. /**
  42876. * The list of morph target managers added to the scene
  42877. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42878. */
  42879. morphTargetManagers: MorphTargetManager[];
  42880. /**
  42881. * The list of geometries used in the scene.
  42882. */
  42883. geometries: Geometry[];
  42884. /**
  42885. * All of the tranform nodes added to this scene
  42886. * In the context of a Scene, it is not supposed to be modified manually.
  42887. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42888. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42889. * @see https://doc.babylonjs.com/how_to/transformnode
  42890. */
  42891. transformNodes: TransformNode[];
  42892. /**
  42893. * ActionManagers available on the scene.
  42894. */
  42895. actionManagers: AbstractActionManager[];
  42896. /**
  42897. * Textures to keep.
  42898. */
  42899. textures: BaseTexture[];
  42900. /** @hidden */
  42901. protected _environmentTexture: Nullable<BaseTexture>;
  42902. /**
  42903. * Texture used in all pbr material as the reflection texture.
  42904. * As in the majority of the scene they are the same (exception for multi room and so on),
  42905. * this is easier to reference from here than from all the materials.
  42906. */
  42907. get environmentTexture(): Nullable<BaseTexture>;
  42908. set environmentTexture(value: Nullable<BaseTexture>);
  42909. /**
  42910. * The list of postprocesses added to the scene
  42911. */
  42912. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42913. /**
  42914. * @returns all meshes, lights, cameras, transformNodes and bones
  42915. */
  42916. getNodes(): Array<Node>;
  42917. }
  42918. }
  42919. declare module "babylonjs/Audio/sound" {
  42920. import { Observable } from "babylonjs/Misc/observable";
  42921. import { Vector3 } from "babylonjs/Maths/math.vector";
  42922. import { Nullable } from "babylonjs/types";
  42923. import { Scene } from "babylonjs/scene";
  42924. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42925. /**
  42926. * Interface used to define options for Sound class
  42927. */
  42928. export interface ISoundOptions {
  42929. /**
  42930. * Does the sound autoplay once loaded.
  42931. */
  42932. autoplay?: boolean;
  42933. /**
  42934. * Does the sound loop after it finishes playing once.
  42935. */
  42936. loop?: boolean;
  42937. /**
  42938. * Sound's volume
  42939. */
  42940. volume?: number;
  42941. /**
  42942. * Is it a spatial sound?
  42943. */
  42944. spatialSound?: boolean;
  42945. /**
  42946. * Maximum distance to hear that sound
  42947. */
  42948. maxDistance?: number;
  42949. /**
  42950. * Uses user defined attenuation function
  42951. */
  42952. useCustomAttenuation?: boolean;
  42953. /**
  42954. * Define the roll off factor of spatial sounds.
  42955. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42956. */
  42957. rolloffFactor?: number;
  42958. /**
  42959. * Define the reference distance the sound should be heard perfectly.
  42960. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42961. */
  42962. refDistance?: number;
  42963. /**
  42964. * Define the distance attenuation model the sound will follow.
  42965. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42966. */
  42967. distanceModel?: string;
  42968. /**
  42969. * Defines the playback speed (1 by default)
  42970. */
  42971. playbackRate?: number;
  42972. /**
  42973. * Defines if the sound is from a streaming source
  42974. */
  42975. streaming?: boolean;
  42976. /**
  42977. * Defines an optional length (in seconds) inside the sound file
  42978. */
  42979. length?: number;
  42980. /**
  42981. * Defines an optional offset (in seconds) inside the sound file
  42982. */
  42983. offset?: number;
  42984. /**
  42985. * If true, URLs will not be required to state the audio file codec to use.
  42986. */
  42987. skipCodecCheck?: boolean;
  42988. }
  42989. /**
  42990. * Defines a sound that can be played in the application.
  42991. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  42992. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42993. */
  42994. export class Sound {
  42995. /**
  42996. * The name of the sound in the scene.
  42997. */
  42998. name: string;
  42999. /**
  43000. * Does the sound autoplay once loaded.
  43001. */
  43002. autoplay: boolean;
  43003. /**
  43004. * Does the sound loop after it finishes playing once.
  43005. */
  43006. loop: boolean;
  43007. /**
  43008. * Does the sound use a custom attenuation curve to simulate the falloff
  43009. * happening when the source gets further away from the camera.
  43010. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43011. */
  43012. useCustomAttenuation: boolean;
  43013. /**
  43014. * The sound track id this sound belongs to.
  43015. */
  43016. soundTrackId: number;
  43017. /**
  43018. * Is this sound currently played.
  43019. */
  43020. isPlaying: boolean;
  43021. /**
  43022. * Is this sound currently paused.
  43023. */
  43024. isPaused: boolean;
  43025. /**
  43026. * Does this sound enables spatial sound.
  43027. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43028. */
  43029. spatialSound: boolean;
  43030. /**
  43031. * Define the reference distance the sound should be heard perfectly.
  43032. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43033. */
  43034. refDistance: number;
  43035. /**
  43036. * Define the roll off factor of spatial sounds.
  43037. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43038. */
  43039. rolloffFactor: number;
  43040. /**
  43041. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  43042. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43043. */
  43044. maxDistance: number;
  43045. /**
  43046. * Define the distance attenuation model the sound will follow.
  43047. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43048. */
  43049. distanceModel: string;
  43050. /**
  43051. * @hidden
  43052. * Back Compat
  43053. **/
  43054. onended: () => any;
  43055. /**
  43056. * Gets or sets an object used to store user defined information for the sound.
  43057. */
  43058. metadata: any;
  43059. /**
  43060. * Observable event when the current playing sound finishes.
  43061. */
  43062. onEndedObservable: Observable<Sound>;
  43063. private _panningModel;
  43064. private _playbackRate;
  43065. private _streaming;
  43066. private _startTime;
  43067. private _startOffset;
  43068. private _position;
  43069. /** @hidden */
  43070. _positionInEmitterSpace: boolean;
  43071. private _localDirection;
  43072. private _volume;
  43073. private _isReadyToPlay;
  43074. private _isDirectional;
  43075. private _readyToPlayCallback;
  43076. private _audioBuffer;
  43077. private _soundSource;
  43078. private _streamingSource;
  43079. private _soundPanner;
  43080. private _soundGain;
  43081. private _inputAudioNode;
  43082. private _outputAudioNode;
  43083. private _coneInnerAngle;
  43084. private _coneOuterAngle;
  43085. private _coneOuterGain;
  43086. private _scene;
  43087. private _connectedTransformNode;
  43088. private _customAttenuationFunction;
  43089. private _registerFunc;
  43090. private _isOutputConnected;
  43091. private _htmlAudioElement;
  43092. private _urlType;
  43093. private _length?;
  43094. private _offset?;
  43095. /** @hidden */
  43096. static _SceneComponentInitialization: (scene: Scene) => void;
  43097. /**
  43098. * Create a sound and attach it to a scene
  43099. * @param name Name of your sound
  43100. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  43101. * @param scene defines the scene the sound belongs to
  43102. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  43103. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  43104. */
  43105. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  43106. /**
  43107. * Release the sound and its associated resources
  43108. */
  43109. dispose(): void;
  43110. /**
  43111. * Gets if the sounds is ready to be played or not.
  43112. * @returns true if ready, otherwise false
  43113. */
  43114. isReady(): boolean;
  43115. private _soundLoaded;
  43116. /**
  43117. * Sets the data of the sound from an audiobuffer
  43118. * @param audioBuffer The audioBuffer containing the data
  43119. */
  43120. setAudioBuffer(audioBuffer: AudioBuffer): void;
  43121. /**
  43122. * Updates the current sounds options such as maxdistance, loop...
  43123. * @param options A JSON object containing values named as the object properties
  43124. */
  43125. updateOptions(options: ISoundOptions): void;
  43126. private _createSpatialParameters;
  43127. private _updateSpatialParameters;
  43128. /**
  43129. * Switch the panning model to HRTF:
  43130. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43131. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43132. */
  43133. switchPanningModelToHRTF(): void;
  43134. /**
  43135. * Switch the panning model to Equal Power:
  43136. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43137. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43138. */
  43139. switchPanningModelToEqualPower(): void;
  43140. private _switchPanningModel;
  43141. /**
  43142. * Connect this sound to a sound track audio node like gain...
  43143. * @param soundTrackAudioNode the sound track audio node to connect to
  43144. */
  43145. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43146. /**
  43147. * Transform this sound into a directional source
  43148. * @param coneInnerAngle Size of the inner cone in degree
  43149. * @param coneOuterAngle Size of the outer cone in degree
  43150. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43151. */
  43152. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43153. /**
  43154. * Gets or sets the inner angle for the directional cone.
  43155. */
  43156. get directionalConeInnerAngle(): number;
  43157. /**
  43158. * Gets or sets the inner angle for the directional cone.
  43159. */
  43160. set directionalConeInnerAngle(value: number);
  43161. /**
  43162. * Gets or sets the outer angle for the directional cone.
  43163. */
  43164. get directionalConeOuterAngle(): number;
  43165. /**
  43166. * Gets or sets the outer angle for the directional cone.
  43167. */
  43168. set directionalConeOuterAngle(value: number);
  43169. /**
  43170. * Sets the position of the emitter if spatial sound is enabled
  43171. * @param newPosition Defines the new posisiton
  43172. */
  43173. setPosition(newPosition: Vector3): void;
  43174. /**
  43175. * Sets the local direction of the emitter if spatial sound is enabled
  43176. * @param newLocalDirection Defines the new local direction
  43177. */
  43178. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43179. private _updateDirection;
  43180. /** @hidden */
  43181. updateDistanceFromListener(): void;
  43182. /**
  43183. * Sets a new custom attenuation function for the sound.
  43184. * @param callback Defines the function used for the attenuation
  43185. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43186. */
  43187. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43188. /**
  43189. * Play the sound
  43190. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43191. * @param offset (optional) Start the sound at a specific time in seconds
  43192. * @param length (optional) Sound duration (in seconds)
  43193. */
  43194. play(time?: number, offset?: number, length?: number): void;
  43195. private _onended;
  43196. /**
  43197. * Stop the sound
  43198. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43199. */
  43200. stop(time?: number): void;
  43201. /**
  43202. * Put the sound in pause
  43203. */
  43204. pause(): void;
  43205. /**
  43206. * Sets a dedicated volume for this sounds
  43207. * @param newVolume Define the new volume of the sound
  43208. * @param time Define time for gradual change to new volume
  43209. */
  43210. setVolume(newVolume: number, time?: number): void;
  43211. /**
  43212. * Set the sound play back rate
  43213. * @param newPlaybackRate Define the playback rate the sound should be played at
  43214. */
  43215. setPlaybackRate(newPlaybackRate: number): void;
  43216. /**
  43217. * Gets the volume of the sound.
  43218. * @returns the volume of the sound
  43219. */
  43220. getVolume(): number;
  43221. /**
  43222. * Attach the sound to a dedicated mesh
  43223. * @param transformNode The transform node to connect the sound with
  43224. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43225. */
  43226. attachToMesh(transformNode: TransformNode): void;
  43227. /**
  43228. * Detach the sound from the previously attached mesh
  43229. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43230. */
  43231. detachFromMesh(): void;
  43232. private _onRegisterAfterWorldMatrixUpdate;
  43233. /**
  43234. * Clone the current sound in the scene.
  43235. * @returns the new sound clone
  43236. */
  43237. clone(): Nullable<Sound>;
  43238. /**
  43239. * Gets the current underlying audio buffer containing the data
  43240. * @returns the audio buffer
  43241. */
  43242. getAudioBuffer(): Nullable<AudioBuffer>;
  43243. /**
  43244. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43245. * @returns the source node
  43246. */
  43247. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43248. /**
  43249. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43250. * @returns the gain node
  43251. */
  43252. getSoundGain(): Nullable<GainNode>;
  43253. /**
  43254. * Serializes the Sound in a JSON representation
  43255. * @returns the JSON representation of the sound
  43256. */
  43257. serialize(): any;
  43258. /**
  43259. * Parse a JSON representation of a sound to innstantiate in a given scene
  43260. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43261. * @param scene Define the scene the new parsed sound should be created in
  43262. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43263. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43264. * @returns the newly parsed sound
  43265. */
  43266. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43267. }
  43268. }
  43269. declare module "babylonjs/Actions/directAudioActions" {
  43270. import { Action } from "babylonjs/Actions/action";
  43271. import { Condition } from "babylonjs/Actions/condition";
  43272. import { Sound } from "babylonjs/Audio/sound";
  43273. /**
  43274. * This defines an action helpful to play a defined sound on a triggered action.
  43275. */
  43276. export class PlaySoundAction extends Action {
  43277. private _sound;
  43278. /**
  43279. * Instantiate the action
  43280. * @param triggerOptions defines the trigger options
  43281. * @param sound defines the sound to play
  43282. * @param condition defines the trigger related conditions
  43283. */
  43284. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43285. /** @hidden */
  43286. _prepare(): void;
  43287. /**
  43288. * Execute the action and play the sound.
  43289. */
  43290. execute(): void;
  43291. /**
  43292. * Serializes the actions and its related information.
  43293. * @param parent defines the object to serialize in
  43294. * @returns the serialized object
  43295. */
  43296. serialize(parent: any): any;
  43297. }
  43298. /**
  43299. * This defines an action helpful to stop a defined sound on a triggered action.
  43300. */
  43301. export class StopSoundAction extends Action {
  43302. private _sound;
  43303. /**
  43304. * Instantiate the action
  43305. * @param triggerOptions defines the trigger options
  43306. * @param sound defines the sound to stop
  43307. * @param condition defines the trigger related conditions
  43308. */
  43309. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43310. /** @hidden */
  43311. _prepare(): void;
  43312. /**
  43313. * Execute the action and stop the sound.
  43314. */
  43315. execute(): void;
  43316. /**
  43317. * Serializes the actions and its related information.
  43318. * @param parent defines the object to serialize in
  43319. * @returns the serialized object
  43320. */
  43321. serialize(parent: any): any;
  43322. }
  43323. }
  43324. declare module "babylonjs/Actions/interpolateValueAction" {
  43325. import { Action } from "babylonjs/Actions/action";
  43326. import { Condition } from "babylonjs/Actions/condition";
  43327. import { Observable } from "babylonjs/Misc/observable";
  43328. /**
  43329. * This defines an action responsible to change the value of a property
  43330. * by interpolating between its current value and the newly set one once triggered.
  43331. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43332. */
  43333. export class InterpolateValueAction extends Action {
  43334. /**
  43335. * Defines the path of the property where the value should be interpolated
  43336. */
  43337. propertyPath: string;
  43338. /**
  43339. * Defines the target value at the end of the interpolation.
  43340. */
  43341. value: any;
  43342. /**
  43343. * Defines the time it will take for the property to interpolate to the value.
  43344. */
  43345. duration: number;
  43346. /**
  43347. * Defines if the other scene animations should be stopped when the action has been triggered
  43348. */
  43349. stopOtherAnimations?: boolean;
  43350. /**
  43351. * Defines a callback raised once the interpolation animation has been done.
  43352. */
  43353. onInterpolationDone?: () => void;
  43354. /**
  43355. * Observable triggered once the interpolation animation has been done.
  43356. */
  43357. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43358. private _target;
  43359. private _effectiveTarget;
  43360. private _property;
  43361. /**
  43362. * Instantiate the action
  43363. * @param triggerOptions defines the trigger options
  43364. * @param target defines the object containing the value to interpolate
  43365. * @param propertyPath defines the path to the property in the target object
  43366. * @param value defines the target value at the end of the interpolation
  43367. * @param duration deines the time it will take for the property to interpolate to the value.
  43368. * @param condition defines the trigger related conditions
  43369. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43370. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43371. */
  43372. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43373. /** @hidden */
  43374. _prepare(): void;
  43375. /**
  43376. * Execute the action starts the value interpolation.
  43377. */
  43378. execute(): void;
  43379. /**
  43380. * Serializes the actions and its related information.
  43381. * @param parent defines the object to serialize in
  43382. * @returns the serialized object
  43383. */
  43384. serialize(parent: any): any;
  43385. }
  43386. }
  43387. declare module "babylonjs/Actions/index" {
  43388. export * from "babylonjs/Actions/abstractActionManager";
  43389. export * from "babylonjs/Actions/action";
  43390. export * from "babylonjs/Actions/actionEvent";
  43391. export * from "babylonjs/Actions/actionManager";
  43392. export * from "babylonjs/Actions/condition";
  43393. export * from "babylonjs/Actions/directActions";
  43394. export * from "babylonjs/Actions/directAudioActions";
  43395. export * from "babylonjs/Actions/interpolateValueAction";
  43396. }
  43397. declare module "babylonjs/Animations/index" {
  43398. export * from "babylonjs/Animations/animatable";
  43399. export * from "babylonjs/Animations/animation";
  43400. export * from "babylonjs/Animations/animationGroup";
  43401. export * from "babylonjs/Animations/animationPropertiesOverride";
  43402. export * from "babylonjs/Animations/easing";
  43403. export * from "babylonjs/Animations/runtimeAnimation";
  43404. export * from "babylonjs/Animations/animationEvent";
  43405. export * from "babylonjs/Animations/animationGroup";
  43406. export * from "babylonjs/Animations/animationKey";
  43407. export * from "babylonjs/Animations/animationRange";
  43408. export * from "babylonjs/Animations/animatable.interface";
  43409. }
  43410. declare module "babylonjs/Audio/soundTrack" {
  43411. import { Sound } from "babylonjs/Audio/sound";
  43412. import { Analyser } from "babylonjs/Audio/analyser";
  43413. import { Scene } from "babylonjs/scene";
  43414. /**
  43415. * Options allowed during the creation of a sound track.
  43416. */
  43417. export interface ISoundTrackOptions {
  43418. /**
  43419. * The volume the sound track should take during creation
  43420. */
  43421. volume?: number;
  43422. /**
  43423. * Define if the sound track is the main sound track of the scene
  43424. */
  43425. mainTrack?: boolean;
  43426. }
  43427. /**
  43428. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43429. * It will be also used in a future release to apply effects on a specific track.
  43430. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43431. */
  43432. export class SoundTrack {
  43433. /**
  43434. * The unique identifier of the sound track in the scene.
  43435. */
  43436. id: number;
  43437. /**
  43438. * The list of sounds included in the sound track.
  43439. */
  43440. soundCollection: Array<Sound>;
  43441. private _outputAudioNode;
  43442. private _scene;
  43443. private _connectedAnalyser;
  43444. private _options;
  43445. private _isInitialized;
  43446. /**
  43447. * Creates a new sound track.
  43448. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43449. * @param scene Define the scene the sound track belongs to
  43450. * @param options
  43451. */
  43452. constructor(scene: Scene, options?: ISoundTrackOptions);
  43453. private _initializeSoundTrackAudioGraph;
  43454. /**
  43455. * Release the sound track and its associated resources
  43456. */
  43457. dispose(): void;
  43458. /**
  43459. * Adds a sound to this sound track
  43460. * @param sound define the cound to add
  43461. * @ignoreNaming
  43462. */
  43463. AddSound(sound: Sound): void;
  43464. /**
  43465. * Removes a sound to this sound track
  43466. * @param sound define the cound to remove
  43467. * @ignoreNaming
  43468. */
  43469. RemoveSound(sound: Sound): void;
  43470. /**
  43471. * Set a global volume for the full sound track.
  43472. * @param newVolume Define the new volume of the sound track
  43473. */
  43474. setVolume(newVolume: number): void;
  43475. /**
  43476. * Switch the panning model to HRTF:
  43477. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43478. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43479. */
  43480. switchPanningModelToHRTF(): void;
  43481. /**
  43482. * Switch the panning model to Equal Power:
  43483. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43484. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43485. */
  43486. switchPanningModelToEqualPower(): void;
  43487. /**
  43488. * Connect the sound track to an audio analyser allowing some amazing
  43489. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43490. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43491. * @param analyser The analyser to connect to the engine
  43492. */
  43493. connectToAnalyser(analyser: Analyser): void;
  43494. }
  43495. }
  43496. declare module "babylonjs/Audio/audioSceneComponent" {
  43497. import { Sound } from "babylonjs/Audio/sound";
  43498. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43499. import { Nullable } from "babylonjs/types";
  43500. import { Vector3 } from "babylonjs/Maths/math.vector";
  43501. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43502. import { Scene } from "babylonjs/scene";
  43503. import { AbstractScene } from "babylonjs/abstractScene";
  43504. import "babylonjs/Audio/audioEngine";
  43505. module "babylonjs/abstractScene" {
  43506. interface AbstractScene {
  43507. /**
  43508. * The list of sounds used in the scene.
  43509. */
  43510. sounds: Nullable<Array<Sound>>;
  43511. }
  43512. }
  43513. module "babylonjs/scene" {
  43514. interface Scene {
  43515. /**
  43516. * @hidden
  43517. * Backing field
  43518. */
  43519. _mainSoundTrack: SoundTrack;
  43520. /**
  43521. * The main sound track played by the scene.
  43522. * It cotains your primary collection of sounds.
  43523. */
  43524. mainSoundTrack: SoundTrack;
  43525. /**
  43526. * The list of sound tracks added to the scene
  43527. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43528. */
  43529. soundTracks: Nullable<Array<SoundTrack>>;
  43530. /**
  43531. * Gets a sound using a given name
  43532. * @param name defines the name to search for
  43533. * @return the found sound or null if not found at all.
  43534. */
  43535. getSoundByName(name: string): Nullable<Sound>;
  43536. /**
  43537. * Gets or sets if audio support is enabled
  43538. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43539. */
  43540. audioEnabled: boolean;
  43541. /**
  43542. * Gets or sets if audio will be output to headphones
  43543. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43544. */
  43545. headphone: boolean;
  43546. /**
  43547. * Gets or sets custom audio listener position provider
  43548. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43549. */
  43550. audioListenerPositionProvider: Nullable<() => Vector3>;
  43551. /**
  43552. * Gets or sets a refresh rate when using 3D audio positioning
  43553. */
  43554. audioPositioningRefreshRate: number;
  43555. }
  43556. }
  43557. /**
  43558. * Defines the sound scene component responsible to manage any sounds
  43559. * in a given scene.
  43560. */
  43561. export class AudioSceneComponent implements ISceneSerializableComponent {
  43562. private static _CameraDirectionLH;
  43563. private static _CameraDirectionRH;
  43564. /**
  43565. * The component name helpfull to identify the component in the list of scene components.
  43566. */
  43567. readonly name: string;
  43568. /**
  43569. * The scene the component belongs to.
  43570. */
  43571. scene: Scene;
  43572. private _audioEnabled;
  43573. /**
  43574. * Gets whether audio is enabled or not.
  43575. * Please use related enable/disable method to switch state.
  43576. */
  43577. get audioEnabled(): boolean;
  43578. private _headphone;
  43579. /**
  43580. * Gets whether audio is outputing to headphone or not.
  43581. * Please use the according Switch methods to change output.
  43582. */
  43583. get headphone(): boolean;
  43584. /**
  43585. * Gets or sets a refresh rate when using 3D audio positioning
  43586. */
  43587. audioPositioningRefreshRate: number;
  43588. private _audioListenerPositionProvider;
  43589. /**
  43590. * Gets the current audio listener position provider
  43591. */
  43592. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43593. /**
  43594. * Sets a custom listener position for all sounds in the scene
  43595. * By default, this is the position of the first active camera
  43596. */
  43597. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43598. /**
  43599. * Creates a new instance of the component for the given scene
  43600. * @param scene Defines the scene to register the component in
  43601. */
  43602. constructor(scene: Scene);
  43603. /**
  43604. * Registers the component in a given scene
  43605. */
  43606. register(): void;
  43607. /**
  43608. * Rebuilds the elements related to this component in case of
  43609. * context lost for instance.
  43610. */
  43611. rebuild(): void;
  43612. /**
  43613. * Serializes the component data to the specified json object
  43614. * @param serializationObject The object to serialize to
  43615. */
  43616. serialize(serializationObject: any): void;
  43617. /**
  43618. * Adds all the elements from the container to the scene
  43619. * @param container the container holding the elements
  43620. */
  43621. addFromContainer(container: AbstractScene): void;
  43622. /**
  43623. * Removes all the elements in the container from the scene
  43624. * @param container contains the elements to remove
  43625. * @param dispose if the removed element should be disposed (default: false)
  43626. */
  43627. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43628. /**
  43629. * Disposes the component and the associated ressources.
  43630. */
  43631. dispose(): void;
  43632. /**
  43633. * Disables audio in the associated scene.
  43634. */
  43635. disableAudio(): void;
  43636. /**
  43637. * Enables audio in the associated scene.
  43638. */
  43639. enableAudio(): void;
  43640. /**
  43641. * Switch audio to headphone output.
  43642. */
  43643. switchAudioModeForHeadphones(): void;
  43644. /**
  43645. * Switch audio to normal speakers.
  43646. */
  43647. switchAudioModeForNormalSpeakers(): void;
  43648. private _cachedCameraDirection;
  43649. private _cachedCameraPosition;
  43650. private _lastCheck;
  43651. private _afterRender;
  43652. }
  43653. }
  43654. declare module "babylonjs/Audio/weightedsound" {
  43655. import { Sound } from "babylonjs/Audio/sound";
  43656. /**
  43657. * Wraps one or more Sound objects and selects one with random weight for playback.
  43658. */
  43659. export class WeightedSound {
  43660. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43661. loop: boolean;
  43662. private _coneInnerAngle;
  43663. private _coneOuterAngle;
  43664. private _volume;
  43665. /** A Sound is currently playing. */
  43666. isPlaying: boolean;
  43667. /** A Sound is currently paused. */
  43668. isPaused: boolean;
  43669. private _sounds;
  43670. private _weights;
  43671. private _currentIndex?;
  43672. /**
  43673. * Creates a new WeightedSound from the list of sounds given.
  43674. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43675. * @param sounds Array of Sounds that will be selected from.
  43676. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43677. */
  43678. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43679. /**
  43680. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43681. */
  43682. get directionalConeInnerAngle(): number;
  43683. /**
  43684. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43685. */
  43686. set directionalConeInnerAngle(value: number);
  43687. /**
  43688. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43689. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43690. */
  43691. get directionalConeOuterAngle(): number;
  43692. /**
  43693. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43694. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43695. */
  43696. set directionalConeOuterAngle(value: number);
  43697. /**
  43698. * Playback volume.
  43699. */
  43700. get volume(): number;
  43701. /**
  43702. * Playback volume.
  43703. */
  43704. set volume(value: number);
  43705. private _onended;
  43706. /**
  43707. * Suspend playback
  43708. */
  43709. pause(): void;
  43710. /**
  43711. * Stop playback
  43712. */
  43713. stop(): void;
  43714. /**
  43715. * Start playback.
  43716. * @param startOffset Position the clip head at a specific time in seconds.
  43717. */
  43718. play(startOffset?: number): void;
  43719. }
  43720. }
  43721. declare module "babylonjs/Audio/index" {
  43722. export * from "babylonjs/Audio/analyser";
  43723. export * from "babylonjs/Audio/audioEngine";
  43724. export * from "babylonjs/Audio/audioSceneComponent";
  43725. export * from "babylonjs/Audio/sound";
  43726. export * from "babylonjs/Audio/soundTrack";
  43727. export * from "babylonjs/Audio/weightedsound";
  43728. }
  43729. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43730. import { Behavior } from "babylonjs/Behaviors/behavior";
  43731. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43732. import { BackEase } from "babylonjs/Animations/easing";
  43733. /**
  43734. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43735. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43736. */
  43737. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43738. /**
  43739. * Gets the name of the behavior.
  43740. */
  43741. get name(): string;
  43742. /**
  43743. * The easing function used by animations
  43744. */
  43745. static EasingFunction: BackEase;
  43746. /**
  43747. * The easing mode used by animations
  43748. */
  43749. static EasingMode: number;
  43750. /**
  43751. * The duration of the animation, in milliseconds
  43752. */
  43753. transitionDuration: number;
  43754. /**
  43755. * Length of the distance animated by the transition when lower radius is reached
  43756. */
  43757. lowerRadiusTransitionRange: number;
  43758. /**
  43759. * Length of the distance animated by the transition when upper radius is reached
  43760. */
  43761. upperRadiusTransitionRange: number;
  43762. private _autoTransitionRange;
  43763. /**
  43764. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43765. */
  43766. get autoTransitionRange(): boolean;
  43767. /**
  43768. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43769. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43770. */
  43771. set autoTransitionRange(value: boolean);
  43772. private _attachedCamera;
  43773. private _onAfterCheckInputsObserver;
  43774. private _onMeshTargetChangedObserver;
  43775. /**
  43776. * Initializes the behavior.
  43777. */
  43778. init(): void;
  43779. /**
  43780. * Attaches the behavior to its arc rotate camera.
  43781. * @param camera Defines the camera to attach the behavior to
  43782. */
  43783. attach(camera: ArcRotateCamera): void;
  43784. /**
  43785. * Detaches the behavior from its current arc rotate camera.
  43786. */
  43787. detach(): void;
  43788. private _radiusIsAnimating;
  43789. private _radiusBounceTransition;
  43790. private _animatables;
  43791. private _cachedWheelPrecision;
  43792. /**
  43793. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43794. * @param radiusLimit The limit to check against.
  43795. * @return Bool to indicate if at limit.
  43796. */
  43797. private _isRadiusAtLimit;
  43798. /**
  43799. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43800. * @param radiusDelta The delta by which to animate to. Can be negative.
  43801. */
  43802. private _applyBoundRadiusAnimation;
  43803. /**
  43804. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43805. */
  43806. protected _clearAnimationLocks(): void;
  43807. /**
  43808. * Stops and removes all animations that have been applied to the camera
  43809. */
  43810. stopAllAnimations(): void;
  43811. }
  43812. }
  43813. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43814. import { Behavior } from "babylonjs/Behaviors/behavior";
  43815. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43816. import { ExponentialEase } from "babylonjs/Animations/easing";
  43817. import { Nullable } from "babylonjs/types";
  43818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43819. import { Vector3 } from "babylonjs/Maths/math.vector";
  43820. /**
  43821. * 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.
  43822. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43823. */
  43824. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43825. /**
  43826. * Gets the name of the behavior.
  43827. */
  43828. get name(): string;
  43829. private _mode;
  43830. private _radiusScale;
  43831. private _positionScale;
  43832. private _defaultElevation;
  43833. private _elevationReturnTime;
  43834. private _elevationReturnWaitTime;
  43835. private _zoomStopsAnimation;
  43836. private _framingTime;
  43837. /**
  43838. * The easing function used by animations
  43839. */
  43840. static EasingFunction: ExponentialEase;
  43841. /**
  43842. * The easing mode used by animations
  43843. */
  43844. static EasingMode: number;
  43845. /**
  43846. * Sets the current mode used by the behavior
  43847. */
  43848. set mode(mode: number);
  43849. /**
  43850. * Gets current mode used by the behavior.
  43851. */
  43852. get mode(): number;
  43853. /**
  43854. * Sets the scale applied to the radius (1 by default)
  43855. */
  43856. set radiusScale(radius: number);
  43857. /**
  43858. * Gets the scale applied to the radius
  43859. */
  43860. get radiusScale(): number;
  43861. /**
  43862. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43863. */
  43864. set positionScale(scale: number);
  43865. /**
  43866. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43867. */
  43868. get positionScale(): number;
  43869. /**
  43870. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43871. * behaviour is triggered, in radians.
  43872. */
  43873. set defaultElevation(elevation: number);
  43874. /**
  43875. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43876. * behaviour is triggered, in radians.
  43877. */
  43878. get defaultElevation(): number;
  43879. /**
  43880. * Sets the time (in milliseconds) taken to return to the default beta position.
  43881. * Negative value indicates camera should not return to default.
  43882. */
  43883. set elevationReturnTime(speed: number);
  43884. /**
  43885. * Gets the time (in milliseconds) taken to return to the default beta position.
  43886. * Negative value indicates camera should not return to default.
  43887. */
  43888. get elevationReturnTime(): number;
  43889. /**
  43890. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43891. */
  43892. set elevationReturnWaitTime(time: number);
  43893. /**
  43894. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43895. */
  43896. get elevationReturnWaitTime(): number;
  43897. /**
  43898. * Sets the flag that indicates if user zooming should stop animation.
  43899. */
  43900. set zoomStopsAnimation(flag: boolean);
  43901. /**
  43902. * Gets the flag that indicates if user zooming should stop animation.
  43903. */
  43904. get zoomStopsAnimation(): boolean;
  43905. /**
  43906. * Sets the transition time when framing the mesh, in milliseconds
  43907. */
  43908. set framingTime(time: number);
  43909. /**
  43910. * Gets the transition time when framing the mesh, in milliseconds
  43911. */
  43912. get framingTime(): number;
  43913. /**
  43914. * Define if the behavior should automatically change the configured
  43915. * camera limits and sensibilities.
  43916. */
  43917. autoCorrectCameraLimitsAndSensibility: boolean;
  43918. private _onPrePointerObservableObserver;
  43919. private _onAfterCheckInputsObserver;
  43920. private _onMeshTargetChangedObserver;
  43921. private _attachedCamera;
  43922. private _isPointerDown;
  43923. private _lastInteractionTime;
  43924. /**
  43925. * Initializes the behavior.
  43926. */
  43927. init(): void;
  43928. /**
  43929. * Attaches the behavior to its arc rotate camera.
  43930. * @param camera Defines the camera to attach the behavior to
  43931. */
  43932. attach(camera: ArcRotateCamera): void;
  43933. /**
  43934. * Detaches the behavior from its current arc rotate camera.
  43935. */
  43936. detach(): void;
  43937. private _animatables;
  43938. private _betaIsAnimating;
  43939. private _betaTransition;
  43940. private _radiusTransition;
  43941. private _vectorTransition;
  43942. /**
  43943. * Targets the given mesh and updates zoom level accordingly.
  43944. * @param mesh The mesh to target.
  43945. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43946. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43947. */
  43948. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43949. /**
  43950. * Targets the given mesh with its children and updates zoom level accordingly.
  43951. * @param mesh The mesh to target.
  43952. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43953. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43954. */
  43955. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43956. /**
  43957. * Targets the given meshes with their children and updates zoom level accordingly.
  43958. * @param meshes The mesh to target.
  43959. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43960. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43961. */
  43962. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43963. /**
  43964. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  43965. * @param minimumWorld Determines the smaller position of the bounding box extend
  43966. * @param maximumWorld Determines the bigger position of the bounding box extend
  43967. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43968. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43969. */
  43970. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43971. /**
  43972. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  43973. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  43974. * frustum width.
  43975. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  43976. * to fully enclose the mesh in the viewing frustum.
  43977. */
  43978. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  43979. /**
  43980. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  43981. * is automatically returned to its default position (expected to be above ground plane).
  43982. */
  43983. private _maintainCameraAboveGround;
  43984. /**
  43985. * Returns the frustum slope based on the canvas ratio and camera FOV
  43986. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  43987. */
  43988. private _getFrustumSlope;
  43989. /**
  43990. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  43991. */
  43992. private _clearAnimationLocks;
  43993. /**
  43994. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43995. */
  43996. private _applyUserInteraction;
  43997. /**
  43998. * Stops and removes all animations that have been applied to the camera
  43999. */
  44000. stopAllAnimations(): void;
  44001. /**
  44002. * Gets a value indicating if the user is moving the camera
  44003. */
  44004. get isUserIsMoving(): boolean;
  44005. /**
  44006. * The camera can move all the way towards the mesh.
  44007. */
  44008. static IgnoreBoundsSizeMode: number;
  44009. /**
  44010. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  44011. */
  44012. static FitFrustumSidesMode: number;
  44013. }
  44014. }
  44015. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  44016. import { Nullable } from "babylonjs/types";
  44017. import { Camera } from "babylonjs/Cameras/camera";
  44018. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44019. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44020. /**
  44021. * Base class for Camera Pointer Inputs.
  44022. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  44023. * for example usage.
  44024. */
  44025. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  44026. /**
  44027. * Defines the camera the input is attached to.
  44028. */
  44029. abstract camera: Camera;
  44030. /**
  44031. * Whether keyboard modifier keys are pressed at time of last mouse event.
  44032. */
  44033. protected _altKey: boolean;
  44034. protected _ctrlKey: boolean;
  44035. protected _metaKey: boolean;
  44036. protected _shiftKey: boolean;
  44037. /**
  44038. * Which mouse buttons were pressed at time of last mouse event.
  44039. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  44040. */
  44041. protected _buttonsPressed: number;
  44042. /**
  44043. * Defines the buttons associated with the input to handle camera move.
  44044. */
  44045. buttons: number[];
  44046. /**
  44047. * Attach the input controls to a specific dom element to get the input from.
  44048. * @param element Defines the element the controls should be listened from
  44049. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44050. */
  44051. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44052. /**
  44053. * Detach the current controls from the specified dom element.
  44054. * @param element Defines the element to stop listening the inputs from
  44055. */
  44056. detachControl(element: Nullable<HTMLElement>): void;
  44057. /**
  44058. * Gets the class name of the current input.
  44059. * @returns the class name
  44060. */
  44061. getClassName(): string;
  44062. /**
  44063. * Get the friendly name associated with the input class.
  44064. * @returns the input friendly name
  44065. */
  44066. getSimpleName(): string;
  44067. /**
  44068. * Called on pointer POINTERDOUBLETAP event.
  44069. * Override this method to provide functionality on POINTERDOUBLETAP event.
  44070. */
  44071. protected onDoubleTap(type: string): void;
  44072. /**
  44073. * Called on pointer POINTERMOVE event if only a single touch is active.
  44074. * Override this method to provide functionality.
  44075. */
  44076. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44077. /**
  44078. * Called on pointer POINTERMOVE event if multiple touches are active.
  44079. * Override this method to provide functionality.
  44080. */
  44081. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44082. /**
  44083. * Called on JS contextmenu event.
  44084. * Override this method to provide functionality.
  44085. */
  44086. protected onContextMenu(evt: PointerEvent): void;
  44087. /**
  44088. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44089. * press.
  44090. * Override this method to provide functionality.
  44091. */
  44092. protected onButtonDown(evt: PointerEvent): void;
  44093. /**
  44094. * Called each time a new POINTERUP event occurs. Ie, for each button
  44095. * release.
  44096. * Override this method to provide functionality.
  44097. */
  44098. protected onButtonUp(evt: PointerEvent): void;
  44099. /**
  44100. * Called when window becomes inactive.
  44101. * Override this method to provide functionality.
  44102. */
  44103. protected onLostFocus(): void;
  44104. private _pointerInput;
  44105. private _observer;
  44106. private _onLostFocus;
  44107. private pointA;
  44108. private pointB;
  44109. }
  44110. }
  44111. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  44112. import { Nullable } from "babylonjs/types";
  44113. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44114. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44115. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44116. /**
  44117. * Manage the pointers inputs to control an arc rotate camera.
  44118. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44119. */
  44120. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  44121. /**
  44122. * Defines the camera the input is attached to.
  44123. */
  44124. camera: ArcRotateCamera;
  44125. /**
  44126. * Gets the class name of the current input.
  44127. * @returns the class name
  44128. */
  44129. getClassName(): string;
  44130. /**
  44131. * Defines the buttons associated with the input to handle camera move.
  44132. */
  44133. buttons: number[];
  44134. /**
  44135. * Defines the pointer angular sensibility along the X axis or how fast is
  44136. * the camera rotating.
  44137. */
  44138. angularSensibilityX: number;
  44139. /**
  44140. * Defines the pointer angular sensibility along the Y axis or how fast is
  44141. * the camera rotating.
  44142. */
  44143. angularSensibilityY: number;
  44144. /**
  44145. * Defines the pointer pinch precision or how fast is the camera zooming.
  44146. */
  44147. pinchPrecision: number;
  44148. /**
  44149. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44150. * from 0.
  44151. * It defines the percentage of current camera.radius to use as delta when
  44152. * pinch zoom is used.
  44153. */
  44154. pinchDeltaPercentage: number;
  44155. /**
  44156. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44157. * that any object in the plane at the camera's target point will scale
  44158. * perfectly with finger motion.
  44159. * Overrides pinchDeltaPercentage and pinchPrecision.
  44160. */
  44161. useNaturalPinchZoom: boolean;
  44162. /**
  44163. * Defines the pointer panning sensibility or how fast is the camera moving.
  44164. */
  44165. panningSensibility: number;
  44166. /**
  44167. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44168. */
  44169. multiTouchPanning: boolean;
  44170. /**
  44171. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44172. * zoom (pinch) through multitouch.
  44173. */
  44174. multiTouchPanAndZoom: boolean;
  44175. /**
  44176. * Revers pinch action direction.
  44177. */
  44178. pinchInwards: boolean;
  44179. private _isPanClick;
  44180. private _twoFingerActivityCount;
  44181. private _isPinching;
  44182. /**
  44183. * Called on pointer POINTERMOVE event if only a single touch is active.
  44184. */
  44185. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44186. /**
  44187. * Called on pointer POINTERDOUBLETAP event.
  44188. */
  44189. protected onDoubleTap(type: string): void;
  44190. /**
  44191. * Called on pointer POINTERMOVE event if multiple touches are active.
  44192. */
  44193. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44194. /**
  44195. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44196. * press.
  44197. */
  44198. protected onButtonDown(evt: PointerEvent): void;
  44199. /**
  44200. * Called each time a new POINTERUP event occurs. Ie, for each button
  44201. * release.
  44202. */
  44203. protected onButtonUp(evt: PointerEvent): void;
  44204. /**
  44205. * Called when window becomes inactive.
  44206. */
  44207. protected onLostFocus(): void;
  44208. }
  44209. }
  44210. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44211. import { Nullable } from "babylonjs/types";
  44212. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44213. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44214. /**
  44215. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44216. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44217. */
  44218. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44219. /**
  44220. * Defines the camera the input is attached to.
  44221. */
  44222. camera: ArcRotateCamera;
  44223. /**
  44224. * Defines the list of key codes associated with the up action (increase alpha)
  44225. */
  44226. keysUp: number[];
  44227. /**
  44228. * Defines the list of key codes associated with the down action (decrease alpha)
  44229. */
  44230. keysDown: number[];
  44231. /**
  44232. * Defines the list of key codes associated with the left action (increase beta)
  44233. */
  44234. keysLeft: number[];
  44235. /**
  44236. * Defines the list of key codes associated with the right action (decrease beta)
  44237. */
  44238. keysRight: number[];
  44239. /**
  44240. * Defines the list of key codes associated with the reset action.
  44241. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44242. */
  44243. keysReset: number[];
  44244. /**
  44245. * Defines the panning sensibility of the inputs.
  44246. * (How fast is the camera panning)
  44247. */
  44248. panningSensibility: number;
  44249. /**
  44250. * Defines the zooming sensibility of the inputs.
  44251. * (How fast is the camera zooming)
  44252. */
  44253. zoomingSensibility: number;
  44254. /**
  44255. * Defines whether maintaining the alt key down switch the movement mode from
  44256. * orientation to zoom.
  44257. */
  44258. useAltToZoom: boolean;
  44259. /**
  44260. * Rotation speed of the camera
  44261. */
  44262. angularSpeed: number;
  44263. private _keys;
  44264. private _ctrlPressed;
  44265. private _altPressed;
  44266. private _onCanvasBlurObserver;
  44267. private _onKeyboardObserver;
  44268. private _engine;
  44269. private _scene;
  44270. /**
  44271. * Attach the input controls to a specific dom element to get the input from.
  44272. * @param element Defines the element the controls should be listened from
  44273. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44274. */
  44275. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44276. /**
  44277. * Detach the current controls from the specified dom element.
  44278. * @param element Defines the element to stop listening the inputs from
  44279. */
  44280. detachControl(element: Nullable<HTMLElement>): void;
  44281. /**
  44282. * Update the current camera state depending on the inputs that have been used this frame.
  44283. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44284. */
  44285. checkInputs(): void;
  44286. /**
  44287. * Gets the class name of the current intput.
  44288. * @returns the class name
  44289. */
  44290. getClassName(): string;
  44291. /**
  44292. * Get the friendly name associated with the input class.
  44293. * @returns the input friendly name
  44294. */
  44295. getSimpleName(): string;
  44296. }
  44297. }
  44298. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44299. import { Nullable } from "babylonjs/types";
  44300. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44301. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44302. /**
  44303. * Manage the mouse wheel inputs to control an arc rotate camera.
  44304. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44305. */
  44306. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44307. /**
  44308. * Defines the camera the input is attached to.
  44309. */
  44310. camera: ArcRotateCamera;
  44311. /**
  44312. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44313. */
  44314. wheelPrecision: number;
  44315. /**
  44316. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44317. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44318. */
  44319. wheelDeltaPercentage: number;
  44320. private _wheel;
  44321. private _observer;
  44322. private computeDeltaFromMouseWheelLegacyEvent;
  44323. /**
  44324. * Attach the input controls to a specific dom element to get the input from.
  44325. * @param element Defines the element the controls should be listened from
  44326. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44327. */
  44328. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44329. /**
  44330. * Detach the current controls from the specified dom element.
  44331. * @param element Defines the element to stop listening the inputs from
  44332. */
  44333. detachControl(element: Nullable<HTMLElement>): void;
  44334. /**
  44335. * Gets the class name of the current intput.
  44336. * @returns the class name
  44337. */
  44338. getClassName(): string;
  44339. /**
  44340. * Get the friendly name associated with the input class.
  44341. * @returns the input friendly name
  44342. */
  44343. getSimpleName(): string;
  44344. }
  44345. }
  44346. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44347. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44348. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44349. /**
  44350. * Default Inputs manager for the ArcRotateCamera.
  44351. * It groups all the default supported inputs for ease of use.
  44352. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44353. */
  44354. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44355. /**
  44356. * Instantiates a new ArcRotateCameraInputsManager.
  44357. * @param camera Defines the camera the inputs belong to
  44358. */
  44359. constructor(camera: ArcRotateCamera);
  44360. /**
  44361. * Add mouse wheel input support to the input manager.
  44362. * @returns the current input manager
  44363. */
  44364. addMouseWheel(): ArcRotateCameraInputsManager;
  44365. /**
  44366. * Add pointers input support to the input manager.
  44367. * @returns the current input manager
  44368. */
  44369. addPointers(): ArcRotateCameraInputsManager;
  44370. /**
  44371. * Add keyboard input support to the input manager.
  44372. * @returns the current input manager
  44373. */
  44374. addKeyboard(): ArcRotateCameraInputsManager;
  44375. }
  44376. }
  44377. declare module "babylonjs/Cameras/arcRotateCamera" {
  44378. import { Observable } from "babylonjs/Misc/observable";
  44379. import { Nullable } from "babylonjs/types";
  44380. import { Scene } from "babylonjs/scene";
  44381. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44383. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44384. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44385. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44386. import { Camera } from "babylonjs/Cameras/camera";
  44387. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44388. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44389. import { Collider } from "babylonjs/Collisions/collider";
  44390. /**
  44391. * This represents an orbital type of camera.
  44392. *
  44393. * 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.
  44394. * 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.
  44395. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44396. */
  44397. export class ArcRotateCamera extends TargetCamera {
  44398. /**
  44399. * Defines the rotation angle of the camera along the longitudinal axis.
  44400. */
  44401. alpha: number;
  44402. /**
  44403. * Defines the rotation angle of the camera along the latitudinal axis.
  44404. */
  44405. beta: number;
  44406. /**
  44407. * Defines the radius of the camera from it s target point.
  44408. */
  44409. radius: number;
  44410. protected _target: Vector3;
  44411. protected _targetHost: Nullable<AbstractMesh>;
  44412. /**
  44413. * Defines the target point of the camera.
  44414. * The camera looks towards it form the radius distance.
  44415. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44416. */
  44417. get target(): Vector3;
  44418. set target(value: Vector3);
  44419. /**
  44420. * Define the current local position of the camera in the scene
  44421. */
  44422. get position(): Vector3;
  44423. set position(newPosition: Vector3);
  44424. protected _upToYMatrix: Matrix;
  44425. protected _YToUpMatrix: Matrix;
  44426. /**
  44427. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44428. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44429. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44430. */
  44431. set upVector(vec: Vector3);
  44432. get upVector(): Vector3;
  44433. /**
  44434. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44435. */
  44436. setMatUp(): void;
  44437. /**
  44438. * Current inertia value on the longitudinal axis.
  44439. * The bigger this number the longer it will take for the camera to stop.
  44440. */
  44441. inertialAlphaOffset: number;
  44442. /**
  44443. * Current inertia value on the latitudinal axis.
  44444. * The bigger this number the longer it will take for the camera to stop.
  44445. */
  44446. inertialBetaOffset: number;
  44447. /**
  44448. * Current inertia value on the radius axis.
  44449. * The bigger this number the longer it will take for the camera to stop.
  44450. */
  44451. inertialRadiusOffset: number;
  44452. /**
  44453. * Minimum allowed angle on the longitudinal axis.
  44454. * This can help limiting how the Camera is able to move in the scene.
  44455. */
  44456. lowerAlphaLimit: Nullable<number>;
  44457. /**
  44458. * Maximum allowed angle on the longitudinal axis.
  44459. * This can help limiting how the Camera is able to move in the scene.
  44460. */
  44461. upperAlphaLimit: Nullable<number>;
  44462. /**
  44463. * Minimum allowed angle on the latitudinal axis.
  44464. * This can help limiting how the Camera is able to move in the scene.
  44465. */
  44466. lowerBetaLimit: number;
  44467. /**
  44468. * Maximum allowed angle on the latitudinal axis.
  44469. * This can help limiting how the Camera is able to move in the scene.
  44470. */
  44471. upperBetaLimit: number;
  44472. /**
  44473. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44474. * This can help limiting how the Camera is able to move in the scene.
  44475. */
  44476. lowerRadiusLimit: Nullable<number>;
  44477. /**
  44478. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44479. * This can help limiting how the Camera is able to move in the scene.
  44480. */
  44481. upperRadiusLimit: Nullable<number>;
  44482. /**
  44483. * Defines the current inertia value used during panning of the camera along the X axis.
  44484. */
  44485. inertialPanningX: number;
  44486. /**
  44487. * Defines the current inertia value used during panning of the camera along the Y axis.
  44488. */
  44489. inertialPanningY: number;
  44490. /**
  44491. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44492. * Basically if your fingers moves away from more than this distance you will be considered
  44493. * in pinch mode.
  44494. */
  44495. pinchToPanMaxDistance: number;
  44496. /**
  44497. * Defines the maximum distance the camera can pan.
  44498. * This could help keeping the cammera always in your scene.
  44499. */
  44500. panningDistanceLimit: Nullable<number>;
  44501. /**
  44502. * Defines the target of the camera before paning.
  44503. */
  44504. panningOriginTarget: Vector3;
  44505. /**
  44506. * Defines the value of the inertia used during panning.
  44507. * 0 would mean stop inertia and one would mean no decelleration at all.
  44508. */
  44509. panningInertia: number;
  44510. /**
  44511. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44512. */
  44513. get angularSensibilityX(): number;
  44514. set angularSensibilityX(value: number);
  44515. /**
  44516. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44517. */
  44518. get angularSensibilityY(): number;
  44519. set angularSensibilityY(value: number);
  44520. /**
  44521. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44522. */
  44523. get pinchPrecision(): number;
  44524. set pinchPrecision(value: number);
  44525. /**
  44526. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44527. * It will be used instead of pinchDeltaPrecision if different from 0.
  44528. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44529. */
  44530. get pinchDeltaPercentage(): number;
  44531. set pinchDeltaPercentage(value: number);
  44532. /**
  44533. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44534. * and pinch delta percentage.
  44535. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44536. * that any object in the plane at the camera's target point will scale
  44537. * perfectly with finger motion.
  44538. */
  44539. get useNaturalPinchZoom(): boolean;
  44540. set useNaturalPinchZoom(value: boolean);
  44541. /**
  44542. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44543. */
  44544. get panningSensibility(): number;
  44545. set panningSensibility(value: number);
  44546. /**
  44547. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44548. */
  44549. get keysUp(): number[];
  44550. set keysUp(value: number[]);
  44551. /**
  44552. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44553. */
  44554. get keysDown(): number[];
  44555. set keysDown(value: number[]);
  44556. /**
  44557. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44558. */
  44559. get keysLeft(): number[];
  44560. set keysLeft(value: number[]);
  44561. /**
  44562. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44563. */
  44564. get keysRight(): number[];
  44565. set keysRight(value: number[]);
  44566. /**
  44567. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44568. */
  44569. get wheelPrecision(): number;
  44570. set wheelPrecision(value: number);
  44571. /**
  44572. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44573. * It will be used instead of pinchDeltaPrecision if different from 0.
  44574. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44575. */
  44576. get wheelDeltaPercentage(): number;
  44577. set wheelDeltaPercentage(value: number);
  44578. /**
  44579. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44580. */
  44581. zoomOnFactor: number;
  44582. /**
  44583. * Defines a screen offset for the camera position.
  44584. */
  44585. targetScreenOffset: Vector2;
  44586. /**
  44587. * Allows the camera to be completely reversed.
  44588. * If false the camera can not arrive upside down.
  44589. */
  44590. allowUpsideDown: boolean;
  44591. /**
  44592. * Define if double tap/click is used to restore the previously saved state of the camera.
  44593. */
  44594. useInputToRestoreState: boolean;
  44595. /** @hidden */
  44596. _viewMatrix: Matrix;
  44597. /** @hidden */
  44598. _useCtrlForPanning: boolean;
  44599. /** @hidden */
  44600. _panningMouseButton: number;
  44601. /**
  44602. * Defines the input associated to the camera.
  44603. */
  44604. inputs: ArcRotateCameraInputsManager;
  44605. /** @hidden */
  44606. _reset: () => void;
  44607. /**
  44608. * Defines the allowed panning axis.
  44609. */
  44610. panningAxis: Vector3;
  44611. protected _localDirection: Vector3;
  44612. protected _transformedDirection: Vector3;
  44613. private _bouncingBehavior;
  44614. /**
  44615. * Gets the bouncing behavior of the camera if it has been enabled.
  44616. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44617. */
  44618. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44619. /**
  44620. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44621. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44622. */
  44623. get useBouncingBehavior(): boolean;
  44624. set useBouncingBehavior(value: boolean);
  44625. private _framingBehavior;
  44626. /**
  44627. * Gets the framing behavior of the camera if it has been enabled.
  44628. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44629. */
  44630. get framingBehavior(): Nullable<FramingBehavior>;
  44631. /**
  44632. * Defines if the framing behavior of the camera is enabled on the camera.
  44633. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44634. */
  44635. get useFramingBehavior(): boolean;
  44636. set useFramingBehavior(value: boolean);
  44637. private _autoRotationBehavior;
  44638. /**
  44639. * Gets the auto rotation behavior of the camera if it has been enabled.
  44640. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44641. */
  44642. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44643. /**
  44644. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44645. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44646. */
  44647. get useAutoRotationBehavior(): boolean;
  44648. set useAutoRotationBehavior(value: boolean);
  44649. /**
  44650. * Observable triggered when the mesh target has been changed on the camera.
  44651. */
  44652. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44653. /**
  44654. * Event raised when the camera is colliding with a mesh.
  44655. */
  44656. onCollide: (collidedMesh: AbstractMesh) => void;
  44657. /**
  44658. * Defines whether the camera should check collision with the objects oh the scene.
  44659. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44660. */
  44661. checkCollisions: boolean;
  44662. /**
  44663. * Defines the collision radius of the camera.
  44664. * This simulates a sphere around the camera.
  44665. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44666. */
  44667. collisionRadius: Vector3;
  44668. protected _collider: Collider;
  44669. protected _previousPosition: Vector3;
  44670. protected _collisionVelocity: Vector3;
  44671. protected _newPosition: Vector3;
  44672. protected _previousAlpha: number;
  44673. protected _previousBeta: number;
  44674. protected _previousRadius: number;
  44675. protected _collisionTriggered: boolean;
  44676. protected _targetBoundingCenter: Nullable<Vector3>;
  44677. private _computationVector;
  44678. /**
  44679. * Instantiates a new ArcRotateCamera in a given scene
  44680. * @param name Defines the name of the camera
  44681. * @param alpha Defines the camera rotation along the logitudinal axis
  44682. * @param beta Defines the camera rotation along the latitudinal axis
  44683. * @param radius Defines the camera distance from its target
  44684. * @param target Defines the camera target
  44685. * @param scene Defines the scene the camera belongs to
  44686. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44687. */
  44688. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44689. /** @hidden */
  44690. _initCache(): void;
  44691. /** @hidden */
  44692. _updateCache(ignoreParentClass?: boolean): void;
  44693. protected _getTargetPosition(): Vector3;
  44694. private _storedAlpha;
  44695. private _storedBeta;
  44696. private _storedRadius;
  44697. private _storedTarget;
  44698. private _storedTargetScreenOffset;
  44699. /**
  44700. * Stores the current state of the camera (alpha, beta, radius and target)
  44701. * @returns the camera itself
  44702. */
  44703. storeState(): Camera;
  44704. /**
  44705. * @hidden
  44706. * Restored camera state. You must call storeState() first
  44707. */
  44708. _restoreStateValues(): boolean;
  44709. /** @hidden */
  44710. _isSynchronizedViewMatrix(): boolean;
  44711. /**
  44712. * Attached controls to the current camera.
  44713. * @param element Defines the element the controls should be listened from
  44714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44715. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44716. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44717. */
  44718. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44719. /**
  44720. * Detach the current controls from the camera.
  44721. * The camera will stop reacting to inputs.
  44722. * @param element Defines the element to stop listening the inputs from
  44723. */
  44724. detachControl(element: HTMLElement): void;
  44725. /** @hidden */
  44726. _checkInputs(): void;
  44727. protected _checkLimits(): void;
  44728. /**
  44729. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44730. */
  44731. rebuildAnglesAndRadius(): void;
  44732. /**
  44733. * Use a position to define the current camera related information like alpha, beta and radius
  44734. * @param position Defines the position to set the camera at
  44735. */
  44736. setPosition(position: Vector3): void;
  44737. /**
  44738. * Defines the target the camera should look at.
  44739. * This will automatically adapt alpha beta and radius to fit within the new target.
  44740. * @param target Defines the new target as a Vector or a mesh
  44741. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44742. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44743. */
  44744. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44745. /** @hidden */
  44746. _getViewMatrix(): Matrix;
  44747. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44748. /**
  44749. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44750. * @param meshes Defines the mesh to zoom on
  44751. * @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)
  44752. */
  44753. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44754. /**
  44755. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44756. * The target will be changed but the radius
  44757. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44758. * @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)
  44759. */
  44760. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44761. min: Vector3;
  44762. max: Vector3;
  44763. distance: number;
  44764. }, doNotUpdateMaxZ?: boolean): void;
  44765. /**
  44766. * @override
  44767. * Override Camera.createRigCamera
  44768. */
  44769. createRigCamera(name: string, cameraIndex: number): Camera;
  44770. /**
  44771. * @hidden
  44772. * @override
  44773. * Override Camera._updateRigCameras
  44774. */
  44775. _updateRigCameras(): void;
  44776. /**
  44777. * Destroy the camera and release the current resources hold by it.
  44778. */
  44779. dispose(): void;
  44780. /**
  44781. * Gets the current object class name.
  44782. * @return the class name
  44783. */
  44784. getClassName(): string;
  44785. }
  44786. }
  44787. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44788. import { Behavior } from "babylonjs/Behaviors/behavior";
  44789. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44790. /**
  44791. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44792. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44793. */
  44794. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44795. /**
  44796. * Gets the name of the behavior.
  44797. */
  44798. get name(): string;
  44799. private _zoomStopsAnimation;
  44800. private _idleRotationSpeed;
  44801. private _idleRotationWaitTime;
  44802. private _idleRotationSpinupTime;
  44803. /**
  44804. * Sets the flag that indicates if user zooming should stop animation.
  44805. */
  44806. set zoomStopsAnimation(flag: boolean);
  44807. /**
  44808. * Gets the flag that indicates if user zooming should stop animation.
  44809. */
  44810. get zoomStopsAnimation(): boolean;
  44811. /**
  44812. * Sets the default speed at which the camera rotates around the model.
  44813. */
  44814. set idleRotationSpeed(speed: number);
  44815. /**
  44816. * Gets the default speed at which the camera rotates around the model.
  44817. */
  44818. get idleRotationSpeed(): number;
  44819. /**
  44820. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44821. */
  44822. set idleRotationWaitTime(time: number);
  44823. /**
  44824. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44825. */
  44826. get idleRotationWaitTime(): number;
  44827. /**
  44828. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44829. */
  44830. set idleRotationSpinupTime(time: number);
  44831. /**
  44832. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44833. */
  44834. get idleRotationSpinupTime(): number;
  44835. /**
  44836. * Gets a value indicating if the camera is currently rotating because of this behavior
  44837. */
  44838. get rotationInProgress(): boolean;
  44839. private _onPrePointerObservableObserver;
  44840. private _onAfterCheckInputsObserver;
  44841. private _attachedCamera;
  44842. private _isPointerDown;
  44843. private _lastFrameTime;
  44844. private _lastInteractionTime;
  44845. private _cameraRotationSpeed;
  44846. /**
  44847. * Initializes the behavior.
  44848. */
  44849. init(): void;
  44850. /**
  44851. * Attaches the behavior to its arc rotate camera.
  44852. * @param camera Defines the camera to attach the behavior to
  44853. */
  44854. attach(camera: ArcRotateCamera): void;
  44855. /**
  44856. * Detaches the behavior from its current arc rotate camera.
  44857. */
  44858. detach(): void;
  44859. /**
  44860. * Returns true if user is scrolling.
  44861. * @return true if user is scrolling.
  44862. */
  44863. private _userIsZooming;
  44864. private _lastFrameRadius;
  44865. private _shouldAnimationStopForInteraction;
  44866. /**
  44867. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44868. */
  44869. private _applyUserInteraction;
  44870. private _userIsMoving;
  44871. }
  44872. }
  44873. declare module "babylonjs/Behaviors/Cameras/index" {
  44874. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44875. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44876. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44877. }
  44878. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44879. import { Mesh } from "babylonjs/Meshes/mesh";
  44880. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44881. import { Behavior } from "babylonjs/Behaviors/behavior";
  44882. /**
  44883. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44884. */
  44885. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44886. private ui;
  44887. /**
  44888. * The name of the behavior
  44889. */
  44890. name: string;
  44891. /**
  44892. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44893. */
  44894. distanceAwayFromFace: number;
  44895. /**
  44896. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44897. */
  44898. distanceAwayFromBottomOfFace: number;
  44899. private _faceVectors;
  44900. private _target;
  44901. private _scene;
  44902. private _onRenderObserver;
  44903. private _tmpMatrix;
  44904. private _tmpVector;
  44905. /**
  44906. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44907. * @param ui The transform node that should be attched to the mesh
  44908. */
  44909. constructor(ui: TransformNode);
  44910. /**
  44911. * Initializes the behavior
  44912. */
  44913. init(): void;
  44914. private _closestFace;
  44915. private _zeroVector;
  44916. private _lookAtTmpMatrix;
  44917. private _lookAtToRef;
  44918. /**
  44919. * Attaches the AttachToBoxBehavior to the passed in mesh
  44920. * @param target The mesh that the specified node will be attached to
  44921. */
  44922. attach(target: Mesh): void;
  44923. /**
  44924. * Detaches the behavior from the mesh
  44925. */
  44926. detach(): void;
  44927. }
  44928. }
  44929. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44930. import { Behavior } from "babylonjs/Behaviors/behavior";
  44931. import { Mesh } from "babylonjs/Meshes/mesh";
  44932. /**
  44933. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44934. */
  44935. export class FadeInOutBehavior implements Behavior<Mesh> {
  44936. /**
  44937. * Time in milliseconds to delay before fading in (Default: 0)
  44938. */
  44939. delay: number;
  44940. /**
  44941. * Time in milliseconds for the mesh to fade in (Default: 300)
  44942. */
  44943. fadeInTime: number;
  44944. private _millisecondsPerFrame;
  44945. private _hovered;
  44946. private _hoverValue;
  44947. private _ownerNode;
  44948. /**
  44949. * Instatiates the FadeInOutBehavior
  44950. */
  44951. constructor();
  44952. /**
  44953. * The name of the behavior
  44954. */
  44955. get name(): string;
  44956. /**
  44957. * Initializes the behavior
  44958. */
  44959. init(): void;
  44960. /**
  44961. * Attaches the fade behavior on the passed in mesh
  44962. * @param ownerNode The mesh that will be faded in/out once attached
  44963. */
  44964. attach(ownerNode: Mesh): void;
  44965. /**
  44966. * Detaches the behavior from the mesh
  44967. */
  44968. detach(): void;
  44969. /**
  44970. * Triggers the mesh to begin fading in or out
  44971. * @param value if the object should fade in or out (true to fade in)
  44972. */
  44973. fadeIn(value: boolean): void;
  44974. private _update;
  44975. private _setAllVisibility;
  44976. }
  44977. }
  44978. declare module "babylonjs/Misc/pivotTools" {
  44979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44980. /**
  44981. * Class containing a set of static utilities functions for managing Pivots
  44982. * @hidden
  44983. */
  44984. export class PivotTools {
  44985. private static _PivotCached;
  44986. private static _OldPivotPoint;
  44987. private static _PivotTranslation;
  44988. private static _PivotTmpVector;
  44989. private static _PivotPostMultiplyPivotMatrix;
  44990. /** @hidden */
  44991. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  44992. /** @hidden */
  44993. static _RestorePivotPoint(mesh: AbstractMesh): void;
  44994. }
  44995. }
  44996. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  44997. import { Scene } from "babylonjs/scene";
  44998. import { Vector4 } from "babylonjs/Maths/math.vector";
  44999. import { Mesh } from "babylonjs/Meshes/mesh";
  45000. import { Nullable } from "babylonjs/types";
  45001. import { Plane } from "babylonjs/Maths/math.plane";
  45002. /**
  45003. * Class containing static functions to help procedurally build meshes
  45004. */
  45005. export class PlaneBuilder {
  45006. /**
  45007. * Creates a plane mesh
  45008. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  45009. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  45010. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  45011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45014. * @param name defines the name of the mesh
  45015. * @param options defines the options used to create the mesh
  45016. * @param scene defines the hosting scene
  45017. * @returns the plane mesh
  45018. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  45019. */
  45020. static CreatePlane(name: string, options: {
  45021. size?: number;
  45022. width?: number;
  45023. height?: number;
  45024. sideOrientation?: number;
  45025. frontUVs?: Vector4;
  45026. backUVs?: Vector4;
  45027. updatable?: boolean;
  45028. sourcePlane?: Plane;
  45029. }, scene?: Nullable<Scene>): Mesh;
  45030. }
  45031. }
  45032. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  45033. import { Behavior } from "babylonjs/Behaviors/behavior";
  45034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45035. import { Observable } from "babylonjs/Misc/observable";
  45036. import { Vector3 } from "babylonjs/Maths/math.vector";
  45037. import { Ray } from "babylonjs/Culling/ray";
  45038. import "babylonjs/Meshes/Builders/planeBuilder";
  45039. /**
  45040. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  45041. */
  45042. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  45043. private static _AnyMouseID;
  45044. /**
  45045. * Abstract mesh the behavior is set on
  45046. */
  45047. attachedNode: AbstractMesh;
  45048. private _dragPlane;
  45049. private _scene;
  45050. private _pointerObserver;
  45051. private _beforeRenderObserver;
  45052. private static _planeScene;
  45053. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  45054. /**
  45055. * 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)
  45056. */
  45057. maxDragAngle: number;
  45058. /**
  45059. * @hidden
  45060. */
  45061. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  45062. /**
  45063. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45064. */
  45065. currentDraggingPointerID: number;
  45066. /**
  45067. * The last position where the pointer hit the drag plane in world space
  45068. */
  45069. lastDragPosition: Vector3;
  45070. /**
  45071. * If the behavior is currently in a dragging state
  45072. */
  45073. dragging: boolean;
  45074. /**
  45075. * 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)
  45076. */
  45077. dragDeltaRatio: number;
  45078. /**
  45079. * If the drag plane orientation should be updated during the dragging (Default: true)
  45080. */
  45081. updateDragPlane: boolean;
  45082. private _debugMode;
  45083. private _moving;
  45084. /**
  45085. * Fires each time the attached mesh is dragged with the pointer
  45086. * * delta between last drag position and current drag position in world space
  45087. * * dragDistance along the drag axis
  45088. * * dragPlaneNormal normal of the current drag plane used during the drag
  45089. * * dragPlanePoint in world space where the drag intersects the drag plane
  45090. */
  45091. onDragObservable: Observable<{
  45092. delta: Vector3;
  45093. dragPlanePoint: Vector3;
  45094. dragPlaneNormal: Vector3;
  45095. dragDistance: number;
  45096. pointerId: number;
  45097. }>;
  45098. /**
  45099. * Fires each time a drag begins (eg. mouse down on mesh)
  45100. */
  45101. onDragStartObservable: Observable<{
  45102. dragPlanePoint: Vector3;
  45103. pointerId: number;
  45104. }>;
  45105. /**
  45106. * Fires each time a drag ends (eg. mouse release after drag)
  45107. */
  45108. onDragEndObservable: Observable<{
  45109. dragPlanePoint: Vector3;
  45110. pointerId: number;
  45111. }>;
  45112. /**
  45113. * If the attached mesh should be moved when dragged
  45114. */
  45115. moveAttached: boolean;
  45116. /**
  45117. * If the drag behavior will react to drag events (Default: true)
  45118. */
  45119. enabled: boolean;
  45120. /**
  45121. * If pointer events should start and release the drag (Default: true)
  45122. */
  45123. startAndReleaseDragOnPointerEvents: boolean;
  45124. /**
  45125. * If camera controls should be detached during the drag
  45126. */
  45127. detachCameraControls: boolean;
  45128. /**
  45129. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  45130. */
  45131. useObjectOrientationForDragging: boolean;
  45132. private _options;
  45133. /**
  45134. * Gets the options used by the behavior
  45135. */
  45136. get options(): {
  45137. dragAxis?: Vector3;
  45138. dragPlaneNormal?: Vector3;
  45139. };
  45140. /**
  45141. * Sets the options used by the behavior
  45142. */
  45143. set options(options: {
  45144. dragAxis?: Vector3;
  45145. dragPlaneNormal?: Vector3;
  45146. });
  45147. /**
  45148. * Creates a pointer drag behavior that can be attached to a mesh
  45149. * @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)
  45150. */
  45151. constructor(options?: {
  45152. dragAxis?: Vector3;
  45153. dragPlaneNormal?: Vector3;
  45154. });
  45155. /**
  45156. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45157. */
  45158. validateDrag: (targetPosition: Vector3) => boolean;
  45159. /**
  45160. * The name of the behavior
  45161. */
  45162. get name(): string;
  45163. /**
  45164. * Initializes the behavior
  45165. */
  45166. init(): void;
  45167. private _tmpVector;
  45168. private _alternatePickedPoint;
  45169. private _worldDragAxis;
  45170. private _targetPosition;
  45171. private _attachedElement;
  45172. /**
  45173. * Attaches the drag behavior the passed in mesh
  45174. * @param ownerNode The mesh that will be dragged around once attached
  45175. * @param predicate Predicate to use for pick filtering
  45176. */
  45177. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45178. /**
  45179. * Force relase the drag action by code.
  45180. */
  45181. releaseDrag(): void;
  45182. private _startDragRay;
  45183. private _lastPointerRay;
  45184. /**
  45185. * Simulates the start of a pointer drag event on the behavior
  45186. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45187. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45188. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45189. */
  45190. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45191. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45192. private _dragDelta;
  45193. protected _moveDrag(ray: Ray): void;
  45194. private _pickWithRayOnDragPlane;
  45195. private _pointA;
  45196. private _pointC;
  45197. private _localAxis;
  45198. private _lookAt;
  45199. private _updateDragPlanePosition;
  45200. /**
  45201. * Detaches the behavior from the mesh
  45202. */
  45203. detach(): void;
  45204. }
  45205. }
  45206. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45207. import { Mesh } from "babylonjs/Meshes/mesh";
  45208. import { Behavior } from "babylonjs/Behaviors/behavior";
  45209. /**
  45210. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45211. */
  45212. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45213. private _dragBehaviorA;
  45214. private _dragBehaviorB;
  45215. private _startDistance;
  45216. private _initialScale;
  45217. private _targetScale;
  45218. private _ownerNode;
  45219. private _sceneRenderObserver;
  45220. /**
  45221. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45222. */
  45223. constructor();
  45224. /**
  45225. * The name of the behavior
  45226. */
  45227. get name(): string;
  45228. /**
  45229. * Initializes the behavior
  45230. */
  45231. init(): void;
  45232. private _getCurrentDistance;
  45233. /**
  45234. * Attaches the scale behavior the passed in mesh
  45235. * @param ownerNode The mesh that will be scaled around once attached
  45236. */
  45237. attach(ownerNode: Mesh): void;
  45238. /**
  45239. * Detaches the behavior from the mesh
  45240. */
  45241. detach(): void;
  45242. }
  45243. }
  45244. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45245. import { Behavior } from "babylonjs/Behaviors/behavior";
  45246. import { Mesh } from "babylonjs/Meshes/mesh";
  45247. import { Observable } from "babylonjs/Misc/observable";
  45248. /**
  45249. * 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
  45250. */
  45251. export class SixDofDragBehavior implements Behavior<Mesh> {
  45252. private static _virtualScene;
  45253. private _ownerNode;
  45254. private _sceneRenderObserver;
  45255. private _scene;
  45256. private _targetPosition;
  45257. private _virtualOriginMesh;
  45258. private _virtualDragMesh;
  45259. private _pointerObserver;
  45260. private _moving;
  45261. private _startingOrientation;
  45262. private _attachedElement;
  45263. /**
  45264. * 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)
  45265. */
  45266. private zDragFactor;
  45267. /**
  45268. * If the object should rotate to face the drag origin
  45269. */
  45270. rotateDraggedObject: boolean;
  45271. /**
  45272. * If the behavior is currently in a dragging state
  45273. */
  45274. dragging: boolean;
  45275. /**
  45276. * 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)
  45277. */
  45278. dragDeltaRatio: number;
  45279. /**
  45280. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45281. */
  45282. currentDraggingPointerID: number;
  45283. /**
  45284. * If camera controls should be detached during the drag
  45285. */
  45286. detachCameraControls: boolean;
  45287. /**
  45288. * Fires each time a drag starts
  45289. */
  45290. onDragStartObservable: Observable<{}>;
  45291. /**
  45292. * Fires each time a drag ends (eg. mouse release after drag)
  45293. */
  45294. onDragEndObservable: Observable<{}>;
  45295. /**
  45296. * 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
  45297. */
  45298. constructor();
  45299. /**
  45300. * The name of the behavior
  45301. */
  45302. get name(): string;
  45303. /**
  45304. * Initializes the behavior
  45305. */
  45306. init(): void;
  45307. /**
  45308. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45309. */
  45310. private get _pointerCamera();
  45311. /**
  45312. * Attaches the scale behavior the passed in mesh
  45313. * @param ownerNode The mesh that will be scaled around once attached
  45314. */
  45315. attach(ownerNode: Mesh): void;
  45316. /**
  45317. * Detaches the behavior from the mesh
  45318. */
  45319. detach(): void;
  45320. }
  45321. }
  45322. declare module "babylonjs/Behaviors/Meshes/index" {
  45323. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45324. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45325. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45326. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45327. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45328. }
  45329. declare module "babylonjs/Behaviors/index" {
  45330. export * from "babylonjs/Behaviors/behavior";
  45331. export * from "babylonjs/Behaviors/Cameras/index";
  45332. export * from "babylonjs/Behaviors/Meshes/index";
  45333. }
  45334. declare module "babylonjs/Bones/boneIKController" {
  45335. import { Bone } from "babylonjs/Bones/bone";
  45336. import { Vector3 } from "babylonjs/Maths/math.vector";
  45337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45338. import { Nullable } from "babylonjs/types";
  45339. /**
  45340. * Class used to apply inverse kinematics to bones
  45341. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45342. */
  45343. export class BoneIKController {
  45344. private static _tmpVecs;
  45345. private static _tmpQuat;
  45346. private static _tmpMats;
  45347. /**
  45348. * Gets or sets the target mesh
  45349. */
  45350. targetMesh: AbstractMesh;
  45351. /** Gets or sets the mesh used as pole */
  45352. poleTargetMesh: AbstractMesh;
  45353. /**
  45354. * Gets or sets the bone used as pole
  45355. */
  45356. poleTargetBone: Nullable<Bone>;
  45357. /**
  45358. * Gets or sets the target position
  45359. */
  45360. targetPosition: Vector3;
  45361. /**
  45362. * Gets or sets the pole target position
  45363. */
  45364. poleTargetPosition: Vector3;
  45365. /**
  45366. * Gets or sets the pole target local offset
  45367. */
  45368. poleTargetLocalOffset: Vector3;
  45369. /**
  45370. * Gets or sets the pole angle
  45371. */
  45372. poleAngle: number;
  45373. /**
  45374. * Gets or sets the mesh associated with the controller
  45375. */
  45376. mesh: AbstractMesh;
  45377. /**
  45378. * 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)
  45379. */
  45380. slerpAmount: number;
  45381. private _bone1Quat;
  45382. private _bone1Mat;
  45383. private _bone2Ang;
  45384. private _bone1;
  45385. private _bone2;
  45386. private _bone1Length;
  45387. private _bone2Length;
  45388. private _maxAngle;
  45389. private _maxReach;
  45390. private _rightHandedSystem;
  45391. private _bendAxis;
  45392. private _slerping;
  45393. private _adjustRoll;
  45394. /**
  45395. * Gets or sets maximum allowed angle
  45396. */
  45397. get maxAngle(): number;
  45398. set maxAngle(value: number);
  45399. /**
  45400. * Creates a new BoneIKController
  45401. * @param mesh defines the mesh to control
  45402. * @param bone defines the bone to control
  45403. * @param options defines options to set up the controller
  45404. */
  45405. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45406. targetMesh?: AbstractMesh;
  45407. poleTargetMesh?: AbstractMesh;
  45408. poleTargetBone?: Bone;
  45409. poleTargetLocalOffset?: Vector3;
  45410. poleAngle?: number;
  45411. bendAxis?: Vector3;
  45412. maxAngle?: number;
  45413. slerpAmount?: number;
  45414. });
  45415. private _setMaxAngle;
  45416. /**
  45417. * Force the controller to update the bones
  45418. */
  45419. update(): void;
  45420. }
  45421. }
  45422. declare module "babylonjs/Bones/boneLookController" {
  45423. import { Vector3 } from "babylonjs/Maths/math.vector";
  45424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45425. import { Bone } from "babylonjs/Bones/bone";
  45426. import { Space } from "babylonjs/Maths/math.axis";
  45427. /**
  45428. * Class used to make a bone look toward a point in space
  45429. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45430. */
  45431. export class BoneLookController {
  45432. private static _tmpVecs;
  45433. private static _tmpQuat;
  45434. private static _tmpMats;
  45435. /**
  45436. * The target Vector3 that the bone will look at
  45437. */
  45438. target: Vector3;
  45439. /**
  45440. * The mesh that the bone is attached to
  45441. */
  45442. mesh: AbstractMesh;
  45443. /**
  45444. * The bone that will be looking to the target
  45445. */
  45446. bone: Bone;
  45447. /**
  45448. * The up axis of the coordinate system that is used when the bone is rotated
  45449. */
  45450. upAxis: Vector3;
  45451. /**
  45452. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45453. */
  45454. upAxisSpace: Space;
  45455. /**
  45456. * Used to make an adjustment to the yaw of the bone
  45457. */
  45458. adjustYaw: number;
  45459. /**
  45460. * Used to make an adjustment to the pitch of the bone
  45461. */
  45462. adjustPitch: number;
  45463. /**
  45464. * Used to make an adjustment to the roll of the bone
  45465. */
  45466. adjustRoll: number;
  45467. /**
  45468. * 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)
  45469. */
  45470. slerpAmount: number;
  45471. private _minYaw;
  45472. private _maxYaw;
  45473. private _minPitch;
  45474. private _maxPitch;
  45475. private _minYawSin;
  45476. private _minYawCos;
  45477. private _maxYawSin;
  45478. private _maxYawCos;
  45479. private _midYawConstraint;
  45480. private _minPitchTan;
  45481. private _maxPitchTan;
  45482. private _boneQuat;
  45483. private _slerping;
  45484. private _transformYawPitch;
  45485. private _transformYawPitchInv;
  45486. private _firstFrameSkipped;
  45487. private _yawRange;
  45488. private _fowardAxis;
  45489. /**
  45490. * Gets or sets the minimum yaw angle that the bone can look to
  45491. */
  45492. get minYaw(): number;
  45493. set minYaw(value: number);
  45494. /**
  45495. * Gets or sets the maximum yaw angle that the bone can look to
  45496. */
  45497. get maxYaw(): number;
  45498. set maxYaw(value: number);
  45499. /**
  45500. * Gets or sets the minimum pitch angle that the bone can look to
  45501. */
  45502. get minPitch(): number;
  45503. set minPitch(value: number);
  45504. /**
  45505. * Gets or sets the maximum pitch angle that the bone can look to
  45506. */
  45507. get maxPitch(): number;
  45508. set maxPitch(value: number);
  45509. /**
  45510. * Create a BoneLookController
  45511. * @param mesh the mesh that the bone belongs to
  45512. * @param bone the bone that will be looking to the target
  45513. * @param target the target Vector3 to look at
  45514. * @param options optional settings:
  45515. * * maxYaw: the maximum angle the bone will yaw to
  45516. * * minYaw: the minimum angle the bone will yaw to
  45517. * * maxPitch: the maximum angle the bone will pitch to
  45518. * * minPitch: the minimum angle the bone will yaw to
  45519. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45520. * * upAxis: the up axis of the coordinate system
  45521. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45522. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45523. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45524. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45525. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45526. * * adjustRoll: used to make an adjustment to the roll of the bone
  45527. **/
  45528. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45529. maxYaw?: number;
  45530. minYaw?: number;
  45531. maxPitch?: number;
  45532. minPitch?: number;
  45533. slerpAmount?: number;
  45534. upAxis?: Vector3;
  45535. upAxisSpace?: Space;
  45536. yawAxis?: Vector3;
  45537. pitchAxis?: Vector3;
  45538. adjustYaw?: number;
  45539. adjustPitch?: number;
  45540. adjustRoll?: number;
  45541. });
  45542. /**
  45543. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45544. */
  45545. update(): void;
  45546. private _getAngleDiff;
  45547. private _getAngleBetween;
  45548. private _isAngleBetween;
  45549. }
  45550. }
  45551. declare module "babylonjs/Bones/index" {
  45552. export * from "babylonjs/Bones/bone";
  45553. export * from "babylonjs/Bones/boneIKController";
  45554. export * from "babylonjs/Bones/boneLookController";
  45555. export * from "babylonjs/Bones/skeleton";
  45556. }
  45557. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45558. import { Nullable } from "babylonjs/types";
  45559. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45560. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45561. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45562. /**
  45563. * Manage the gamepad inputs to control an arc rotate camera.
  45564. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45565. */
  45566. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45567. /**
  45568. * Defines the camera the input is attached to.
  45569. */
  45570. camera: ArcRotateCamera;
  45571. /**
  45572. * Defines the gamepad the input is gathering event from.
  45573. */
  45574. gamepad: Nullable<Gamepad>;
  45575. /**
  45576. * Defines the gamepad rotation sensiblity.
  45577. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45578. */
  45579. gamepadRotationSensibility: number;
  45580. /**
  45581. * Defines the gamepad move sensiblity.
  45582. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45583. */
  45584. gamepadMoveSensibility: number;
  45585. private _yAxisScale;
  45586. /**
  45587. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45588. */
  45589. get invertYAxis(): boolean;
  45590. set invertYAxis(value: boolean);
  45591. private _onGamepadConnectedObserver;
  45592. private _onGamepadDisconnectedObserver;
  45593. /**
  45594. * Attach the input controls to a specific dom element to get the input from.
  45595. * @param element Defines the element the controls should be listened from
  45596. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45597. */
  45598. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45599. /**
  45600. * Detach the current controls from the specified dom element.
  45601. * @param element Defines the element to stop listening the inputs from
  45602. */
  45603. detachControl(element: Nullable<HTMLElement>): void;
  45604. /**
  45605. * Update the current camera state depending on the inputs that have been used this frame.
  45606. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45607. */
  45608. checkInputs(): void;
  45609. /**
  45610. * Gets the class name of the current intput.
  45611. * @returns the class name
  45612. */
  45613. getClassName(): string;
  45614. /**
  45615. * Get the friendly name associated with the input class.
  45616. * @returns the input friendly name
  45617. */
  45618. getSimpleName(): string;
  45619. }
  45620. }
  45621. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45622. import { Nullable } from "babylonjs/types";
  45623. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45624. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45625. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45626. interface ArcRotateCameraInputsManager {
  45627. /**
  45628. * Add orientation input support to the input manager.
  45629. * @returns the current input manager
  45630. */
  45631. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45632. }
  45633. }
  45634. /**
  45635. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45636. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45637. */
  45638. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45639. /**
  45640. * Defines the camera the input is attached to.
  45641. */
  45642. camera: ArcRotateCamera;
  45643. /**
  45644. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45645. */
  45646. alphaCorrection: number;
  45647. /**
  45648. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45649. */
  45650. gammaCorrection: number;
  45651. private _alpha;
  45652. private _gamma;
  45653. private _dirty;
  45654. private _deviceOrientationHandler;
  45655. /**
  45656. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45657. */
  45658. constructor();
  45659. /**
  45660. * Attach the input controls to a specific dom element to get the input from.
  45661. * @param element Defines the element the controls should be listened from
  45662. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45663. */
  45664. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45665. /** @hidden */
  45666. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45667. /**
  45668. * Update the current camera state depending on the inputs that have been used this frame.
  45669. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45670. */
  45671. checkInputs(): void;
  45672. /**
  45673. * Detach the current controls from the specified dom element.
  45674. * @param element Defines the element to stop listening the inputs from
  45675. */
  45676. detachControl(element: Nullable<HTMLElement>): void;
  45677. /**
  45678. * Gets the class name of the current intput.
  45679. * @returns the class name
  45680. */
  45681. getClassName(): string;
  45682. /**
  45683. * Get the friendly name associated with the input class.
  45684. * @returns the input friendly name
  45685. */
  45686. getSimpleName(): string;
  45687. }
  45688. }
  45689. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45690. import { Nullable } from "babylonjs/types";
  45691. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45692. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45693. /**
  45694. * Listen to mouse events to control the camera.
  45695. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45696. */
  45697. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45698. /**
  45699. * Defines the camera the input is attached to.
  45700. */
  45701. camera: FlyCamera;
  45702. /**
  45703. * Defines if touch is enabled. (Default is true.)
  45704. */
  45705. touchEnabled: boolean;
  45706. /**
  45707. * Defines the buttons associated with the input to handle camera rotation.
  45708. */
  45709. buttons: number[];
  45710. /**
  45711. * Assign buttons for Yaw control.
  45712. */
  45713. buttonsYaw: number[];
  45714. /**
  45715. * Assign buttons for Pitch control.
  45716. */
  45717. buttonsPitch: number[];
  45718. /**
  45719. * Assign buttons for Roll control.
  45720. */
  45721. buttonsRoll: number[];
  45722. /**
  45723. * Detect if any button is being pressed while mouse is moved.
  45724. * -1 = Mouse locked.
  45725. * 0 = Left button.
  45726. * 1 = Middle Button.
  45727. * 2 = Right Button.
  45728. */
  45729. activeButton: number;
  45730. /**
  45731. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45732. * Higher values reduce its sensitivity.
  45733. */
  45734. angularSensibility: number;
  45735. private _mousemoveCallback;
  45736. private _observer;
  45737. private _rollObserver;
  45738. private previousPosition;
  45739. private noPreventDefault;
  45740. private element;
  45741. /**
  45742. * Listen to mouse events to control the camera.
  45743. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45744. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45745. */
  45746. constructor(touchEnabled?: boolean);
  45747. /**
  45748. * Attach the mouse control to the HTML DOM element.
  45749. * @param element Defines the element that listens to the input events.
  45750. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45751. */
  45752. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45753. /**
  45754. * Detach the current controls from the specified dom element.
  45755. * @param element Defines the element to stop listening the inputs from
  45756. */
  45757. detachControl(element: Nullable<HTMLElement>): void;
  45758. /**
  45759. * Gets the class name of the current input.
  45760. * @returns the class name.
  45761. */
  45762. getClassName(): string;
  45763. /**
  45764. * Get the friendly name associated with the input class.
  45765. * @returns the input's friendly name.
  45766. */
  45767. getSimpleName(): string;
  45768. private _pointerInput;
  45769. private _onMouseMove;
  45770. /**
  45771. * Rotate camera by mouse offset.
  45772. */
  45773. private rotateCamera;
  45774. }
  45775. }
  45776. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45777. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45778. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45779. /**
  45780. * Default Inputs manager for the FlyCamera.
  45781. * It groups all the default supported inputs for ease of use.
  45782. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45783. */
  45784. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45785. /**
  45786. * Instantiates a new FlyCameraInputsManager.
  45787. * @param camera Defines the camera the inputs belong to.
  45788. */
  45789. constructor(camera: FlyCamera);
  45790. /**
  45791. * Add keyboard input support to the input manager.
  45792. * @returns the new FlyCameraKeyboardMoveInput().
  45793. */
  45794. addKeyboard(): FlyCameraInputsManager;
  45795. /**
  45796. * Add mouse input support to the input manager.
  45797. * @param touchEnabled Enable touch screen support.
  45798. * @returns the new FlyCameraMouseInput().
  45799. */
  45800. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45801. }
  45802. }
  45803. declare module "babylonjs/Cameras/flyCamera" {
  45804. import { Scene } from "babylonjs/scene";
  45805. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45807. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45808. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45809. /**
  45810. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45811. * such as in a 3D Space Shooter or a Flight Simulator.
  45812. */
  45813. export class FlyCamera extends TargetCamera {
  45814. /**
  45815. * Define the collision ellipsoid of the camera.
  45816. * This is helpful for simulating a camera body, like a player's body.
  45817. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45818. */
  45819. ellipsoid: Vector3;
  45820. /**
  45821. * Define an offset for the position of the ellipsoid around the camera.
  45822. * This can be helpful if the camera is attached away from the player's body center,
  45823. * such as at its head.
  45824. */
  45825. ellipsoidOffset: Vector3;
  45826. /**
  45827. * Enable or disable collisions of the camera with the rest of the scene objects.
  45828. */
  45829. checkCollisions: boolean;
  45830. /**
  45831. * Enable or disable gravity on the camera.
  45832. */
  45833. applyGravity: boolean;
  45834. /**
  45835. * Define the current direction the camera is moving to.
  45836. */
  45837. cameraDirection: Vector3;
  45838. /**
  45839. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45840. * This overrides and empties cameraRotation.
  45841. */
  45842. rotationQuaternion: Quaternion;
  45843. /**
  45844. * Track Roll to maintain the wanted Rolling when looking around.
  45845. */
  45846. _trackRoll: number;
  45847. /**
  45848. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45849. */
  45850. rollCorrect: number;
  45851. /**
  45852. * Mimic a banked turn, Rolling the camera when Yawing.
  45853. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45854. */
  45855. bankedTurn: boolean;
  45856. /**
  45857. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45858. */
  45859. bankedTurnLimit: number;
  45860. /**
  45861. * Value of 0 disables the banked Roll.
  45862. * Value of 1 is equal to the Yaw angle in radians.
  45863. */
  45864. bankedTurnMultiplier: number;
  45865. /**
  45866. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45867. */
  45868. inputs: FlyCameraInputsManager;
  45869. /**
  45870. * Gets the input sensibility for mouse input.
  45871. * Higher values reduce sensitivity.
  45872. */
  45873. get angularSensibility(): number;
  45874. /**
  45875. * Sets the input sensibility for a mouse input.
  45876. * Higher values reduce sensitivity.
  45877. */
  45878. set angularSensibility(value: number);
  45879. /**
  45880. * Get the keys for camera movement forward.
  45881. */
  45882. get keysForward(): number[];
  45883. /**
  45884. * Set the keys for camera movement forward.
  45885. */
  45886. set keysForward(value: number[]);
  45887. /**
  45888. * Get the keys for camera movement backward.
  45889. */
  45890. get keysBackward(): number[];
  45891. set keysBackward(value: number[]);
  45892. /**
  45893. * Get the keys for camera movement up.
  45894. */
  45895. get keysUp(): number[];
  45896. /**
  45897. * Set the keys for camera movement up.
  45898. */
  45899. set keysUp(value: number[]);
  45900. /**
  45901. * Get the keys for camera movement down.
  45902. */
  45903. get keysDown(): number[];
  45904. /**
  45905. * Set the keys for camera movement down.
  45906. */
  45907. set keysDown(value: number[]);
  45908. /**
  45909. * Get the keys for camera movement left.
  45910. */
  45911. get keysLeft(): number[];
  45912. /**
  45913. * Set the keys for camera movement left.
  45914. */
  45915. set keysLeft(value: number[]);
  45916. /**
  45917. * Set the keys for camera movement right.
  45918. */
  45919. get keysRight(): number[];
  45920. /**
  45921. * Set the keys for camera movement right.
  45922. */
  45923. set keysRight(value: number[]);
  45924. /**
  45925. * Event raised when the camera collides with a mesh in the scene.
  45926. */
  45927. onCollide: (collidedMesh: AbstractMesh) => void;
  45928. private _collider;
  45929. private _needMoveForGravity;
  45930. private _oldPosition;
  45931. private _diffPosition;
  45932. private _newPosition;
  45933. /** @hidden */
  45934. _localDirection: Vector3;
  45935. /** @hidden */
  45936. _transformedDirection: Vector3;
  45937. /**
  45938. * Instantiates a FlyCamera.
  45939. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45940. * such as in a 3D Space Shooter or a Flight Simulator.
  45941. * @param name Define the name of the camera in the scene.
  45942. * @param position Define the starting position of the camera in the scene.
  45943. * @param scene Define the scene the camera belongs to.
  45944. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45945. */
  45946. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45947. /**
  45948. * Attach a control to the HTML DOM element.
  45949. * @param element Defines the element that listens to the input events.
  45950. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45951. */
  45952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45953. /**
  45954. * Detach a control from the HTML DOM element.
  45955. * The camera will stop reacting to that input.
  45956. * @param element Defines the element that listens to the input events.
  45957. */
  45958. detachControl(element: HTMLElement): void;
  45959. private _collisionMask;
  45960. /**
  45961. * Get the mask that the camera ignores in collision events.
  45962. */
  45963. get collisionMask(): number;
  45964. /**
  45965. * Set the mask that the camera ignores in collision events.
  45966. */
  45967. set collisionMask(mask: number);
  45968. /** @hidden */
  45969. _collideWithWorld(displacement: Vector3): void;
  45970. /** @hidden */
  45971. private _onCollisionPositionChange;
  45972. /** @hidden */
  45973. _checkInputs(): void;
  45974. /** @hidden */
  45975. _decideIfNeedsToMove(): boolean;
  45976. /** @hidden */
  45977. _updatePosition(): void;
  45978. /**
  45979. * Restore the Roll to its target value at the rate specified.
  45980. * @param rate - Higher means slower restoring.
  45981. * @hidden
  45982. */
  45983. restoreRoll(rate: number): void;
  45984. /**
  45985. * Destroy the camera and release the current resources held by it.
  45986. */
  45987. dispose(): void;
  45988. /**
  45989. * Get the current object class name.
  45990. * @returns the class name.
  45991. */
  45992. getClassName(): string;
  45993. }
  45994. }
  45995. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  45996. import { Nullable } from "babylonjs/types";
  45997. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45998. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45999. /**
  46000. * Listen to keyboard events to control the camera.
  46001. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46002. */
  46003. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  46004. /**
  46005. * Defines the camera the input is attached to.
  46006. */
  46007. camera: FlyCamera;
  46008. /**
  46009. * The list of keyboard keys used to control the forward move of the camera.
  46010. */
  46011. keysForward: number[];
  46012. /**
  46013. * The list of keyboard keys used to control the backward move of the camera.
  46014. */
  46015. keysBackward: number[];
  46016. /**
  46017. * The list of keyboard keys used to control the forward move of the camera.
  46018. */
  46019. keysUp: number[];
  46020. /**
  46021. * The list of keyboard keys used to control the backward move of the camera.
  46022. */
  46023. keysDown: number[];
  46024. /**
  46025. * The list of keyboard keys used to control the right strafe move of the camera.
  46026. */
  46027. keysRight: number[];
  46028. /**
  46029. * The list of keyboard keys used to control the left strafe move of the camera.
  46030. */
  46031. keysLeft: number[];
  46032. private _keys;
  46033. private _onCanvasBlurObserver;
  46034. private _onKeyboardObserver;
  46035. private _engine;
  46036. private _scene;
  46037. /**
  46038. * Attach the input controls to a specific dom element to get the input from.
  46039. * @param element Defines the element the controls should be listened from
  46040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46041. */
  46042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46043. /**
  46044. * Detach the current controls from the specified dom element.
  46045. * @param element Defines the element to stop listening the inputs from
  46046. */
  46047. detachControl(element: Nullable<HTMLElement>): void;
  46048. /**
  46049. * Gets the class name of the current intput.
  46050. * @returns the class name
  46051. */
  46052. getClassName(): string;
  46053. /** @hidden */
  46054. _onLostFocus(e: FocusEvent): void;
  46055. /**
  46056. * Get the friendly name associated with the input class.
  46057. * @returns the input friendly name
  46058. */
  46059. getSimpleName(): string;
  46060. /**
  46061. * Update the current camera state depending on the inputs that have been used this frame.
  46062. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46063. */
  46064. checkInputs(): void;
  46065. }
  46066. }
  46067. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  46068. import { Nullable } from "babylonjs/types";
  46069. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46070. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46071. /**
  46072. * Manage the mouse wheel inputs to control a follow camera.
  46073. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46074. */
  46075. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  46076. /**
  46077. * Defines the camera the input is attached to.
  46078. */
  46079. camera: FollowCamera;
  46080. /**
  46081. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  46082. */
  46083. axisControlRadius: boolean;
  46084. /**
  46085. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  46086. */
  46087. axisControlHeight: boolean;
  46088. /**
  46089. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  46090. */
  46091. axisControlRotation: boolean;
  46092. /**
  46093. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  46094. * relation to mouseWheel events.
  46095. */
  46096. wheelPrecision: number;
  46097. /**
  46098. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46099. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46100. */
  46101. wheelDeltaPercentage: number;
  46102. private _wheel;
  46103. private _observer;
  46104. /**
  46105. * Attach the input controls to a specific dom element to get the input from.
  46106. * @param element Defines the element the controls should be listened from
  46107. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46108. */
  46109. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46110. /**
  46111. * Detach the current controls from the specified dom element.
  46112. * @param element Defines the element to stop listening the inputs from
  46113. */
  46114. detachControl(element: Nullable<HTMLElement>): void;
  46115. /**
  46116. * Gets the class name of the current intput.
  46117. * @returns the class name
  46118. */
  46119. getClassName(): string;
  46120. /**
  46121. * Get the friendly name associated with the input class.
  46122. * @returns the input friendly name
  46123. */
  46124. getSimpleName(): string;
  46125. }
  46126. }
  46127. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  46128. import { Nullable } from "babylonjs/types";
  46129. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46130. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  46131. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  46132. /**
  46133. * Manage the pointers inputs to control an follow camera.
  46134. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46135. */
  46136. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46137. /**
  46138. * Defines the camera the input is attached to.
  46139. */
  46140. camera: FollowCamera;
  46141. /**
  46142. * Gets the class name of the current input.
  46143. * @returns the class name
  46144. */
  46145. getClassName(): string;
  46146. /**
  46147. * Defines the pointer angular sensibility along the X axis or how fast is
  46148. * the camera rotating.
  46149. * A negative number will reverse the axis direction.
  46150. */
  46151. angularSensibilityX: number;
  46152. /**
  46153. * Defines the pointer angular sensibility along the Y axis or how fast is
  46154. * the camera rotating.
  46155. * A negative number will reverse the axis direction.
  46156. */
  46157. angularSensibilityY: number;
  46158. /**
  46159. * Defines the pointer pinch precision or how fast is the camera zooming.
  46160. * A negative number will reverse the axis direction.
  46161. */
  46162. pinchPrecision: number;
  46163. /**
  46164. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46165. * from 0.
  46166. * It defines the percentage of current camera.radius to use as delta when
  46167. * pinch zoom is used.
  46168. */
  46169. pinchDeltaPercentage: number;
  46170. /**
  46171. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46172. */
  46173. axisXControlRadius: boolean;
  46174. /**
  46175. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46176. */
  46177. axisXControlHeight: boolean;
  46178. /**
  46179. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46180. */
  46181. axisXControlRotation: boolean;
  46182. /**
  46183. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46184. */
  46185. axisYControlRadius: boolean;
  46186. /**
  46187. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46188. */
  46189. axisYControlHeight: boolean;
  46190. /**
  46191. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46192. */
  46193. axisYControlRotation: boolean;
  46194. /**
  46195. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46196. */
  46197. axisPinchControlRadius: boolean;
  46198. /**
  46199. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46200. */
  46201. axisPinchControlHeight: boolean;
  46202. /**
  46203. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46204. */
  46205. axisPinchControlRotation: boolean;
  46206. /**
  46207. * Log error messages if basic misconfiguration has occurred.
  46208. */
  46209. warningEnable: boolean;
  46210. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46211. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46212. private _warningCounter;
  46213. private _warning;
  46214. }
  46215. }
  46216. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46217. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46218. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46219. /**
  46220. * Default Inputs manager for the FollowCamera.
  46221. * It groups all the default supported inputs for ease of use.
  46222. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46223. */
  46224. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46225. /**
  46226. * Instantiates a new FollowCameraInputsManager.
  46227. * @param camera Defines the camera the inputs belong to
  46228. */
  46229. constructor(camera: FollowCamera);
  46230. /**
  46231. * Add keyboard input support to the input manager.
  46232. * @returns the current input manager
  46233. */
  46234. addKeyboard(): FollowCameraInputsManager;
  46235. /**
  46236. * Add mouse wheel input support to the input manager.
  46237. * @returns the current input manager
  46238. */
  46239. addMouseWheel(): FollowCameraInputsManager;
  46240. /**
  46241. * Add pointers input support to the input manager.
  46242. * @returns the current input manager
  46243. */
  46244. addPointers(): FollowCameraInputsManager;
  46245. /**
  46246. * Add orientation input support to the input manager.
  46247. * @returns the current input manager
  46248. */
  46249. addVRDeviceOrientation(): FollowCameraInputsManager;
  46250. }
  46251. }
  46252. declare module "babylonjs/Cameras/followCamera" {
  46253. import { Nullable } from "babylonjs/types";
  46254. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46255. import { Scene } from "babylonjs/scene";
  46256. import { Vector3 } from "babylonjs/Maths/math.vector";
  46257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46258. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46259. /**
  46260. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46261. * an arc rotate version arcFollowCamera are available.
  46262. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46263. */
  46264. export class FollowCamera extends TargetCamera {
  46265. /**
  46266. * Distance the follow camera should follow an object at
  46267. */
  46268. radius: number;
  46269. /**
  46270. * Minimum allowed distance of the camera to the axis of rotation
  46271. * (The camera can not get closer).
  46272. * This can help limiting how the Camera is able to move in the scene.
  46273. */
  46274. lowerRadiusLimit: Nullable<number>;
  46275. /**
  46276. * Maximum allowed distance of the camera to the axis of rotation
  46277. * (The camera can not get further).
  46278. * This can help limiting how the Camera is able to move in the scene.
  46279. */
  46280. upperRadiusLimit: Nullable<number>;
  46281. /**
  46282. * Define a rotation offset between the camera and the object it follows
  46283. */
  46284. rotationOffset: number;
  46285. /**
  46286. * Minimum allowed angle to camera position relative to target object.
  46287. * This can help limiting how the Camera is able to move in the scene.
  46288. */
  46289. lowerRotationOffsetLimit: Nullable<number>;
  46290. /**
  46291. * Maximum allowed angle to camera position relative to target object.
  46292. * This can help limiting how the Camera is able to move in the scene.
  46293. */
  46294. upperRotationOffsetLimit: Nullable<number>;
  46295. /**
  46296. * Define a height offset between the camera and the object it follows.
  46297. * It can help following an object from the top (like a car chaing a plane)
  46298. */
  46299. heightOffset: number;
  46300. /**
  46301. * Minimum allowed height of camera position relative to target object.
  46302. * This can help limiting how the Camera is able to move in the scene.
  46303. */
  46304. lowerHeightOffsetLimit: Nullable<number>;
  46305. /**
  46306. * Maximum allowed height of camera position relative to target object.
  46307. * This can help limiting how the Camera is able to move in the scene.
  46308. */
  46309. upperHeightOffsetLimit: Nullable<number>;
  46310. /**
  46311. * Define how fast the camera can accelerate to follow it s target.
  46312. */
  46313. cameraAcceleration: number;
  46314. /**
  46315. * Define the speed limit of the camera following an object.
  46316. */
  46317. maxCameraSpeed: number;
  46318. /**
  46319. * Define the target of the camera.
  46320. */
  46321. lockedTarget: Nullable<AbstractMesh>;
  46322. /**
  46323. * Defines the input associated with the camera.
  46324. */
  46325. inputs: FollowCameraInputsManager;
  46326. /**
  46327. * Instantiates the follow camera.
  46328. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46329. * @param name Define the name of the camera in the scene
  46330. * @param position Define the position of the camera
  46331. * @param scene Define the scene the camera belong to
  46332. * @param lockedTarget Define the target of the camera
  46333. */
  46334. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46335. private _follow;
  46336. /**
  46337. * Attached controls to the current camera.
  46338. * @param element Defines the element the controls should be listened from
  46339. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46340. */
  46341. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46342. /**
  46343. * Detach the current controls from the camera.
  46344. * The camera will stop reacting to inputs.
  46345. * @param element Defines the element to stop listening the inputs from
  46346. */
  46347. detachControl(element: HTMLElement): void;
  46348. /** @hidden */
  46349. _checkInputs(): void;
  46350. private _checkLimits;
  46351. /**
  46352. * Gets the camera class name.
  46353. * @returns the class name
  46354. */
  46355. getClassName(): string;
  46356. }
  46357. /**
  46358. * Arc Rotate version of the follow camera.
  46359. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46360. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46361. */
  46362. export class ArcFollowCamera extends TargetCamera {
  46363. /** The longitudinal angle of the camera */
  46364. alpha: number;
  46365. /** The latitudinal angle of the camera */
  46366. beta: number;
  46367. /** The radius of the camera from its target */
  46368. radius: number;
  46369. private _cartesianCoordinates;
  46370. /** Define the camera target (the mesh it should follow) */
  46371. private _meshTarget;
  46372. /**
  46373. * Instantiates a new ArcFollowCamera
  46374. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46375. * @param name Define the name of the camera
  46376. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46377. * @param beta Define the rotation angle of the camera around the elevation axis
  46378. * @param radius Define the radius of the camera from its target point
  46379. * @param target Define the target of the camera
  46380. * @param scene Define the scene the camera belongs to
  46381. */
  46382. constructor(name: string,
  46383. /** The longitudinal angle of the camera */
  46384. alpha: number,
  46385. /** The latitudinal angle of the camera */
  46386. beta: number,
  46387. /** The radius of the camera from its target */
  46388. radius: number,
  46389. /** Define the camera target (the mesh it should follow) */
  46390. target: Nullable<AbstractMesh>, scene: Scene);
  46391. private _follow;
  46392. /** @hidden */
  46393. _checkInputs(): void;
  46394. /**
  46395. * Returns the class name of the object.
  46396. * It is mostly used internally for serialization purposes.
  46397. */
  46398. getClassName(): string;
  46399. }
  46400. }
  46401. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46402. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46403. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46404. import { Nullable } from "babylonjs/types";
  46405. /**
  46406. * Manage the keyboard inputs to control the movement of a follow camera.
  46407. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46408. */
  46409. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46410. /**
  46411. * Defines the camera the input is attached to.
  46412. */
  46413. camera: FollowCamera;
  46414. /**
  46415. * Defines the list of key codes associated with the up action (increase heightOffset)
  46416. */
  46417. keysHeightOffsetIncr: number[];
  46418. /**
  46419. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46420. */
  46421. keysHeightOffsetDecr: number[];
  46422. /**
  46423. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46424. */
  46425. keysHeightOffsetModifierAlt: boolean;
  46426. /**
  46427. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46428. */
  46429. keysHeightOffsetModifierCtrl: boolean;
  46430. /**
  46431. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46432. */
  46433. keysHeightOffsetModifierShift: boolean;
  46434. /**
  46435. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46436. */
  46437. keysRotationOffsetIncr: number[];
  46438. /**
  46439. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46440. */
  46441. keysRotationOffsetDecr: number[];
  46442. /**
  46443. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46444. */
  46445. keysRotationOffsetModifierAlt: boolean;
  46446. /**
  46447. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46448. */
  46449. keysRotationOffsetModifierCtrl: boolean;
  46450. /**
  46451. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46452. */
  46453. keysRotationOffsetModifierShift: boolean;
  46454. /**
  46455. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46456. */
  46457. keysRadiusIncr: number[];
  46458. /**
  46459. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46460. */
  46461. keysRadiusDecr: number[];
  46462. /**
  46463. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46464. */
  46465. keysRadiusModifierAlt: boolean;
  46466. /**
  46467. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46468. */
  46469. keysRadiusModifierCtrl: boolean;
  46470. /**
  46471. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46472. */
  46473. keysRadiusModifierShift: boolean;
  46474. /**
  46475. * Defines the rate of change of heightOffset.
  46476. */
  46477. heightSensibility: number;
  46478. /**
  46479. * Defines the rate of change of rotationOffset.
  46480. */
  46481. rotationSensibility: number;
  46482. /**
  46483. * Defines the rate of change of radius.
  46484. */
  46485. radiusSensibility: number;
  46486. private _keys;
  46487. private _ctrlPressed;
  46488. private _altPressed;
  46489. private _shiftPressed;
  46490. private _onCanvasBlurObserver;
  46491. private _onKeyboardObserver;
  46492. private _engine;
  46493. private _scene;
  46494. /**
  46495. * Attach the input controls to a specific dom element to get the input from.
  46496. * @param element Defines the element the controls should be listened from
  46497. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46498. */
  46499. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46500. /**
  46501. * Detach the current controls from the specified dom element.
  46502. * @param element Defines the element to stop listening the inputs from
  46503. */
  46504. detachControl(element: Nullable<HTMLElement>): void;
  46505. /**
  46506. * Update the current camera state depending on the inputs that have been used this frame.
  46507. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46508. */
  46509. checkInputs(): void;
  46510. /**
  46511. * Gets the class name of the current input.
  46512. * @returns the class name
  46513. */
  46514. getClassName(): string;
  46515. /**
  46516. * Get the friendly name associated with the input class.
  46517. * @returns the input friendly name
  46518. */
  46519. getSimpleName(): string;
  46520. /**
  46521. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46522. * allow modification of the heightOffset value.
  46523. */
  46524. private _modifierHeightOffset;
  46525. /**
  46526. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46527. * allow modification of the rotationOffset value.
  46528. */
  46529. private _modifierRotationOffset;
  46530. /**
  46531. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46532. * allow modification of the radius value.
  46533. */
  46534. private _modifierRadius;
  46535. }
  46536. }
  46537. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46538. import { Nullable } from "babylonjs/types";
  46539. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46540. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46541. import { Observable } from "babylonjs/Misc/observable";
  46542. module "babylonjs/Cameras/freeCameraInputsManager" {
  46543. interface FreeCameraInputsManager {
  46544. /**
  46545. * @hidden
  46546. */
  46547. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46548. /**
  46549. * Add orientation input support to the input manager.
  46550. * @returns the current input manager
  46551. */
  46552. addDeviceOrientation(): FreeCameraInputsManager;
  46553. }
  46554. }
  46555. /**
  46556. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46557. * Screen rotation is taken into account.
  46558. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46559. */
  46560. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46561. private _camera;
  46562. private _screenOrientationAngle;
  46563. private _constantTranform;
  46564. private _screenQuaternion;
  46565. private _alpha;
  46566. private _beta;
  46567. private _gamma;
  46568. /**
  46569. * Can be used to detect if a device orientation sensor is available on a device
  46570. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46571. * @returns a promise that will resolve on orientation change
  46572. */
  46573. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46574. /**
  46575. * @hidden
  46576. */
  46577. _onDeviceOrientationChangedObservable: Observable<void>;
  46578. /**
  46579. * Instantiates a new input
  46580. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46581. */
  46582. constructor();
  46583. /**
  46584. * Define the camera controlled by the input.
  46585. */
  46586. get camera(): FreeCamera;
  46587. set camera(camera: FreeCamera);
  46588. /**
  46589. * Attach the input controls to a specific dom element to get the input from.
  46590. * @param element Defines the element the controls should be listened from
  46591. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46592. */
  46593. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46594. private _orientationChanged;
  46595. private _deviceOrientation;
  46596. /**
  46597. * Detach the current controls from the specified dom element.
  46598. * @param element Defines the element to stop listening the inputs from
  46599. */
  46600. detachControl(element: Nullable<HTMLElement>): void;
  46601. /**
  46602. * Update the current camera state depending on the inputs that have been used this frame.
  46603. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46604. */
  46605. checkInputs(): void;
  46606. /**
  46607. * Gets the class name of the current intput.
  46608. * @returns the class name
  46609. */
  46610. getClassName(): string;
  46611. /**
  46612. * Get the friendly name associated with the input class.
  46613. * @returns the input friendly name
  46614. */
  46615. getSimpleName(): string;
  46616. }
  46617. }
  46618. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46619. import { Nullable } from "babylonjs/types";
  46620. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46621. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46622. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46623. /**
  46624. * Manage the gamepad inputs to control a free camera.
  46625. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46626. */
  46627. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46628. /**
  46629. * Define the camera the input is attached to.
  46630. */
  46631. camera: FreeCamera;
  46632. /**
  46633. * Define the Gamepad controlling the input
  46634. */
  46635. gamepad: Nullable<Gamepad>;
  46636. /**
  46637. * Defines the gamepad rotation sensiblity.
  46638. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46639. */
  46640. gamepadAngularSensibility: number;
  46641. /**
  46642. * Defines the gamepad move sensiblity.
  46643. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46644. */
  46645. gamepadMoveSensibility: number;
  46646. private _yAxisScale;
  46647. /**
  46648. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46649. */
  46650. get invertYAxis(): boolean;
  46651. set invertYAxis(value: boolean);
  46652. private _onGamepadConnectedObserver;
  46653. private _onGamepadDisconnectedObserver;
  46654. private _cameraTransform;
  46655. private _deltaTransform;
  46656. private _vector3;
  46657. private _vector2;
  46658. /**
  46659. * Attach the input controls to a specific dom element to get the input from.
  46660. * @param element Defines the element the controls should be listened from
  46661. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46662. */
  46663. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46664. /**
  46665. * Detach the current controls from the specified dom element.
  46666. * @param element Defines the element to stop listening the inputs from
  46667. */
  46668. detachControl(element: Nullable<HTMLElement>): void;
  46669. /**
  46670. * Update the current camera state depending on the inputs that have been used this frame.
  46671. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46672. */
  46673. checkInputs(): void;
  46674. /**
  46675. * Gets the class name of the current intput.
  46676. * @returns the class name
  46677. */
  46678. getClassName(): string;
  46679. /**
  46680. * Get the friendly name associated with the input class.
  46681. * @returns the input friendly name
  46682. */
  46683. getSimpleName(): string;
  46684. }
  46685. }
  46686. declare module "babylonjs/Misc/virtualJoystick" {
  46687. import { Nullable } from "babylonjs/types";
  46688. import { Vector3 } from "babylonjs/Maths/math.vector";
  46689. /**
  46690. * Defines the potential axis of a Joystick
  46691. */
  46692. export enum JoystickAxis {
  46693. /** X axis */
  46694. X = 0,
  46695. /** Y axis */
  46696. Y = 1,
  46697. /** Z axis */
  46698. Z = 2
  46699. }
  46700. /**
  46701. * Represents the different customization options available
  46702. * for VirtualJoystick
  46703. */
  46704. interface VirtualJoystickCustomizations {
  46705. /**
  46706. * Size of the joystick's puck
  46707. */
  46708. puckSize: number;
  46709. /**
  46710. * Size of the joystick's container
  46711. */
  46712. containerSize: number;
  46713. /**
  46714. * Color of the joystick && puck
  46715. */
  46716. color: string;
  46717. /**
  46718. * Image URL for the joystick's puck
  46719. */
  46720. puckImage?: string;
  46721. /**
  46722. * Image URL for the joystick's container
  46723. */
  46724. containerImage?: string;
  46725. /**
  46726. * Defines the unmoving position of the joystick container
  46727. */
  46728. position?: {
  46729. x: number;
  46730. y: number;
  46731. };
  46732. /**
  46733. * Defines whether or not the joystick container is always visible
  46734. */
  46735. alwaysVisible: boolean;
  46736. /**
  46737. * Defines whether or not to limit the movement of the puck to the joystick's container
  46738. */
  46739. limitToContainer: boolean;
  46740. }
  46741. /**
  46742. * Class used to define virtual joystick (used in touch mode)
  46743. */
  46744. export class VirtualJoystick {
  46745. /**
  46746. * Gets or sets a boolean indicating that left and right values must be inverted
  46747. */
  46748. reverseLeftRight: boolean;
  46749. /**
  46750. * Gets or sets a boolean indicating that up and down values must be inverted
  46751. */
  46752. reverseUpDown: boolean;
  46753. /**
  46754. * Gets the offset value for the position (ie. the change of the position value)
  46755. */
  46756. deltaPosition: Vector3;
  46757. /**
  46758. * Gets a boolean indicating if the virtual joystick was pressed
  46759. */
  46760. pressed: boolean;
  46761. /**
  46762. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46763. */
  46764. static Canvas: Nullable<HTMLCanvasElement>;
  46765. /**
  46766. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46767. */
  46768. limitToContainer: boolean;
  46769. private static _globalJoystickIndex;
  46770. private static _alwaysVisibleSticks;
  46771. private static vjCanvasContext;
  46772. private static vjCanvasWidth;
  46773. private static vjCanvasHeight;
  46774. private static halfWidth;
  46775. private static _GetDefaultOptions;
  46776. private _action;
  46777. private _axisTargetedByLeftAndRight;
  46778. private _axisTargetedByUpAndDown;
  46779. private _joystickSensibility;
  46780. private _inversedSensibility;
  46781. private _joystickPointerID;
  46782. private _joystickColor;
  46783. private _joystickPointerPos;
  46784. private _joystickPreviousPointerPos;
  46785. private _joystickPointerStartPos;
  46786. private _deltaJoystickVector;
  46787. private _leftJoystick;
  46788. private _touches;
  46789. private _joystickPosition;
  46790. private _alwaysVisible;
  46791. private _puckImage;
  46792. private _containerImage;
  46793. private _joystickPuckSize;
  46794. private _joystickContainerSize;
  46795. private _clearPuckSize;
  46796. private _clearContainerSize;
  46797. private _clearPuckSizeOffset;
  46798. private _clearContainerSizeOffset;
  46799. private _onPointerDownHandlerRef;
  46800. private _onPointerMoveHandlerRef;
  46801. private _onPointerUpHandlerRef;
  46802. private _onResize;
  46803. /**
  46804. * Creates a new virtual joystick
  46805. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46806. * @param customizations Defines the options we want to customize the VirtualJoystick
  46807. */
  46808. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46809. /**
  46810. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46811. * @param newJoystickSensibility defines the new sensibility
  46812. */
  46813. setJoystickSensibility(newJoystickSensibility: number): void;
  46814. private _onPointerDown;
  46815. private _onPointerMove;
  46816. private _onPointerUp;
  46817. /**
  46818. * Change the color of the virtual joystick
  46819. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46820. */
  46821. setJoystickColor(newColor: string): void;
  46822. /**
  46823. * Size of the joystick's container
  46824. */
  46825. set containerSize(newSize: number);
  46826. get containerSize(): number;
  46827. /**
  46828. * Size of the joystick's puck
  46829. */
  46830. set puckSize(newSize: number);
  46831. get puckSize(): number;
  46832. /**
  46833. * Clears the set position of the joystick
  46834. */
  46835. clearPosition(): void;
  46836. /**
  46837. * Defines whether or not the joystick container is always visible
  46838. */
  46839. set alwaysVisible(value: boolean);
  46840. get alwaysVisible(): boolean;
  46841. /**
  46842. * Sets the constant position of the Joystick container
  46843. * @param x X axis coordinate
  46844. * @param y Y axis coordinate
  46845. */
  46846. setPosition(x: number, y: number): void;
  46847. /**
  46848. * Defines a callback to call when the joystick is touched
  46849. * @param action defines the callback
  46850. */
  46851. setActionOnTouch(action: () => any): void;
  46852. /**
  46853. * Defines which axis you'd like to control for left & right
  46854. * @param axis defines the axis to use
  46855. */
  46856. setAxisForLeftRight(axis: JoystickAxis): void;
  46857. /**
  46858. * Defines which axis you'd like to control for up & down
  46859. * @param axis defines the axis to use
  46860. */
  46861. setAxisForUpDown(axis: JoystickAxis): void;
  46862. /**
  46863. * Clears the canvas from the previous puck / container draw
  46864. */
  46865. private _clearPreviousDraw;
  46866. /**
  46867. * Loads `urlPath` to be used for the container's image
  46868. * @param urlPath defines the urlPath of an image to use
  46869. */
  46870. setContainerImage(urlPath: string): void;
  46871. /**
  46872. * Loads `urlPath` to be used for the puck's image
  46873. * @param urlPath defines the urlPath of an image to use
  46874. */
  46875. setPuckImage(urlPath: string): void;
  46876. /**
  46877. * Draws the Virtual Joystick's container
  46878. */
  46879. private _drawContainer;
  46880. /**
  46881. * Draws the Virtual Joystick's puck
  46882. */
  46883. private _drawPuck;
  46884. private _drawVirtualJoystick;
  46885. /**
  46886. * Release internal HTML canvas
  46887. */
  46888. releaseCanvas(): void;
  46889. }
  46890. }
  46891. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46892. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46893. import { Nullable } from "babylonjs/types";
  46894. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46895. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46896. module "babylonjs/Cameras/freeCameraInputsManager" {
  46897. interface FreeCameraInputsManager {
  46898. /**
  46899. * Add virtual joystick input support to the input manager.
  46900. * @returns the current input manager
  46901. */
  46902. addVirtualJoystick(): FreeCameraInputsManager;
  46903. }
  46904. }
  46905. /**
  46906. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46907. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46908. */
  46909. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46910. /**
  46911. * Defines the camera the input is attached to.
  46912. */
  46913. camera: FreeCamera;
  46914. private _leftjoystick;
  46915. private _rightjoystick;
  46916. /**
  46917. * Gets the left stick of the virtual joystick.
  46918. * @returns The virtual Joystick
  46919. */
  46920. getLeftJoystick(): VirtualJoystick;
  46921. /**
  46922. * Gets the right stick of the virtual joystick.
  46923. * @returns The virtual Joystick
  46924. */
  46925. getRightJoystick(): VirtualJoystick;
  46926. /**
  46927. * Update the current camera state depending on the inputs that have been used this frame.
  46928. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46929. */
  46930. checkInputs(): void;
  46931. /**
  46932. * Attach the input controls to a specific dom element to get the input from.
  46933. * @param element Defines the element the controls should be listened from
  46934. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46935. */
  46936. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46937. /**
  46938. * Detach the current controls from the specified dom element.
  46939. * @param element Defines the element to stop listening the inputs from
  46940. */
  46941. detachControl(element: Nullable<HTMLElement>): void;
  46942. /**
  46943. * Gets the class name of the current intput.
  46944. * @returns the class name
  46945. */
  46946. getClassName(): string;
  46947. /**
  46948. * Get the friendly name associated with the input class.
  46949. * @returns the input friendly name
  46950. */
  46951. getSimpleName(): string;
  46952. }
  46953. }
  46954. declare module "babylonjs/Cameras/Inputs/index" {
  46955. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  46956. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  46957. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  46958. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  46959. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46960. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  46961. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  46962. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  46963. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  46964. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  46965. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46966. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  46967. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  46968. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  46969. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  46970. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46971. }
  46972. declare module "babylonjs/Cameras/touchCamera" {
  46973. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46974. import { Scene } from "babylonjs/scene";
  46975. import { Vector3 } from "babylonjs/Maths/math.vector";
  46976. /**
  46977. * This represents a FPS type of camera controlled by touch.
  46978. * This is like a universal camera minus the Gamepad controls.
  46979. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46980. */
  46981. export class TouchCamera extends FreeCamera {
  46982. /**
  46983. * Defines the touch sensibility for rotation.
  46984. * The higher the faster.
  46985. */
  46986. get touchAngularSensibility(): number;
  46987. set touchAngularSensibility(value: number);
  46988. /**
  46989. * Defines the touch sensibility for move.
  46990. * The higher the faster.
  46991. */
  46992. get touchMoveSensibility(): number;
  46993. set touchMoveSensibility(value: number);
  46994. /**
  46995. * Instantiates a new touch camera.
  46996. * This represents a FPS type of camera controlled by touch.
  46997. * This is like a universal camera minus the Gamepad controls.
  46998. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46999. * @param name Define the name of the camera in the scene
  47000. * @param position Define the start position of the camera in the scene
  47001. * @param scene Define the scene the camera belongs to
  47002. */
  47003. constructor(name: string, position: Vector3, scene: Scene);
  47004. /**
  47005. * Gets the current object class name.
  47006. * @return the class name
  47007. */
  47008. getClassName(): string;
  47009. /** @hidden */
  47010. _setupInputs(): void;
  47011. }
  47012. }
  47013. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  47014. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47015. import { Scene } from "babylonjs/scene";
  47016. import { Vector3 } from "babylonjs/Maths/math.vector";
  47017. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47018. import { Axis } from "babylonjs/Maths/math.axis";
  47019. /**
  47020. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  47021. * being tilted forward or back and left or right.
  47022. */
  47023. export class DeviceOrientationCamera extends FreeCamera {
  47024. private _initialQuaternion;
  47025. private _quaternionCache;
  47026. private _tmpDragQuaternion;
  47027. private _disablePointerInputWhenUsingDeviceOrientation;
  47028. /**
  47029. * Creates a new device orientation camera
  47030. * @param name The name of the camera
  47031. * @param position The start position camera
  47032. * @param scene The scene the camera belongs to
  47033. */
  47034. constructor(name: string, position: Vector3, scene: Scene);
  47035. /**
  47036. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  47037. */
  47038. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  47039. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  47040. private _dragFactor;
  47041. /**
  47042. * Enabled turning on the y axis when the orientation sensor is active
  47043. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  47044. */
  47045. enableHorizontalDragging(dragFactor?: number): void;
  47046. /**
  47047. * Gets the current instance class name ("DeviceOrientationCamera").
  47048. * This helps avoiding instanceof at run time.
  47049. * @returns the class name
  47050. */
  47051. getClassName(): string;
  47052. /**
  47053. * @hidden
  47054. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  47055. */
  47056. _checkInputs(): void;
  47057. /**
  47058. * Reset the camera to its default orientation on the specified axis only.
  47059. * @param axis The axis to reset
  47060. */
  47061. resetToCurrentRotation(axis?: Axis): void;
  47062. }
  47063. }
  47064. declare module "babylonjs/Gamepads/xboxGamepad" {
  47065. import { Observable } from "babylonjs/Misc/observable";
  47066. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47067. /**
  47068. * Defines supported buttons for XBox360 compatible gamepads
  47069. */
  47070. export enum Xbox360Button {
  47071. /** A */
  47072. A = 0,
  47073. /** B */
  47074. B = 1,
  47075. /** X */
  47076. X = 2,
  47077. /** Y */
  47078. Y = 3,
  47079. /** Left button */
  47080. LB = 4,
  47081. /** Right button */
  47082. RB = 5,
  47083. /** Back */
  47084. Back = 8,
  47085. /** Start */
  47086. Start = 9,
  47087. /** Left stick */
  47088. LeftStick = 10,
  47089. /** Right stick */
  47090. RightStick = 11
  47091. }
  47092. /** Defines values for XBox360 DPad */
  47093. export enum Xbox360Dpad {
  47094. /** Up */
  47095. Up = 12,
  47096. /** Down */
  47097. Down = 13,
  47098. /** Left */
  47099. Left = 14,
  47100. /** Right */
  47101. Right = 15
  47102. }
  47103. /**
  47104. * Defines a XBox360 gamepad
  47105. */
  47106. export class Xbox360Pad extends Gamepad {
  47107. private _leftTrigger;
  47108. private _rightTrigger;
  47109. private _onlefttriggerchanged;
  47110. private _onrighttriggerchanged;
  47111. private _onbuttondown;
  47112. private _onbuttonup;
  47113. private _ondpaddown;
  47114. private _ondpadup;
  47115. /** Observable raised when a button is pressed */
  47116. onButtonDownObservable: Observable<Xbox360Button>;
  47117. /** Observable raised when a button is released */
  47118. onButtonUpObservable: Observable<Xbox360Button>;
  47119. /** Observable raised when a pad is pressed */
  47120. onPadDownObservable: Observable<Xbox360Dpad>;
  47121. /** Observable raised when a pad is released */
  47122. onPadUpObservable: Observable<Xbox360Dpad>;
  47123. private _buttonA;
  47124. private _buttonB;
  47125. private _buttonX;
  47126. private _buttonY;
  47127. private _buttonBack;
  47128. private _buttonStart;
  47129. private _buttonLB;
  47130. private _buttonRB;
  47131. private _buttonLeftStick;
  47132. private _buttonRightStick;
  47133. private _dPadUp;
  47134. private _dPadDown;
  47135. private _dPadLeft;
  47136. private _dPadRight;
  47137. private _isXboxOnePad;
  47138. /**
  47139. * Creates a new XBox360 gamepad object
  47140. * @param id defines the id of this gamepad
  47141. * @param index defines its index
  47142. * @param gamepad defines the internal HTML gamepad object
  47143. * @param xboxOne defines if it is a XBox One gamepad
  47144. */
  47145. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47146. /**
  47147. * Defines the callback to call when left trigger is pressed
  47148. * @param callback defines the callback to use
  47149. */
  47150. onlefttriggerchanged(callback: (value: number) => void): void;
  47151. /**
  47152. * Defines the callback to call when right trigger is pressed
  47153. * @param callback defines the callback to use
  47154. */
  47155. onrighttriggerchanged(callback: (value: number) => void): void;
  47156. /**
  47157. * Gets the left trigger value
  47158. */
  47159. get leftTrigger(): number;
  47160. /**
  47161. * Sets the left trigger value
  47162. */
  47163. set leftTrigger(newValue: number);
  47164. /**
  47165. * Gets the right trigger value
  47166. */
  47167. get rightTrigger(): number;
  47168. /**
  47169. * Sets the right trigger value
  47170. */
  47171. set rightTrigger(newValue: number);
  47172. /**
  47173. * Defines the callback to call when a button is pressed
  47174. * @param callback defines the callback to use
  47175. */
  47176. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47177. /**
  47178. * Defines the callback to call when a button is released
  47179. * @param callback defines the callback to use
  47180. */
  47181. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47182. /**
  47183. * Defines the callback to call when a pad is pressed
  47184. * @param callback defines the callback to use
  47185. */
  47186. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47187. /**
  47188. * Defines the callback to call when a pad is released
  47189. * @param callback defines the callback to use
  47190. */
  47191. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47192. private _setButtonValue;
  47193. private _setDPadValue;
  47194. /**
  47195. * Gets the value of the `A` button
  47196. */
  47197. get buttonA(): number;
  47198. /**
  47199. * Sets the value of the `A` button
  47200. */
  47201. set buttonA(value: number);
  47202. /**
  47203. * Gets the value of the `B` button
  47204. */
  47205. get buttonB(): number;
  47206. /**
  47207. * Sets the value of the `B` button
  47208. */
  47209. set buttonB(value: number);
  47210. /**
  47211. * Gets the value of the `X` button
  47212. */
  47213. get buttonX(): number;
  47214. /**
  47215. * Sets the value of the `X` button
  47216. */
  47217. set buttonX(value: number);
  47218. /**
  47219. * Gets the value of the `Y` button
  47220. */
  47221. get buttonY(): number;
  47222. /**
  47223. * Sets the value of the `Y` button
  47224. */
  47225. set buttonY(value: number);
  47226. /**
  47227. * Gets the value of the `Start` button
  47228. */
  47229. get buttonStart(): number;
  47230. /**
  47231. * Sets the value of the `Start` button
  47232. */
  47233. set buttonStart(value: number);
  47234. /**
  47235. * Gets the value of the `Back` button
  47236. */
  47237. get buttonBack(): number;
  47238. /**
  47239. * Sets the value of the `Back` button
  47240. */
  47241. set buttonBack(value: number);
  47242. /**
  47243. * Gets the value of the `Left` button
  47244. */
  47245. get buttonLB(): number;
  47246. /**
  47247. * Sets the value of the `Left` button
  47248. */
  47249. set buttonLB(value: number);
  47250. /**
  47251. * Gets the value of the `Right` button
  47252. */
  47253. get buttonRB(): number;
  47254. /**
  47255. * Sets the value of the `Right` button
  47256. */
  47257. set buttonRB(value: number);
  47258. /**
  47259. * Gets the value of the Left joystick
  47260. */
  47261. get buttonLeftStick(): number;
  47262. /**
  47263. * Sets the value of the Left joystick
  47264. */
  47265. set buttonLeftStick(value: number);
  47266. /**
  47267. * Gets the value of the Right joystick
  47268. */
  47269. get buttonRightStick(): number;
  47270. /**
  47271. * Sets the value of the Right joystick
  47272. */
  47273. set buttonRightStick(value: number);
  47274. /**
  47275. * Gets the value of D-pad up
  47276. */
  47277. get dPadUp(): number;
  47278. /**
  47279. * Sets the value of D-pad up
  47280. */
  47281. set dPadUp(value: number);
  47282. /**
  47283. * Gets the value of D-pad down
  47284. */
  47285. get dPadDown(): number;
  47286. /**
  47287. * Sets the value of D-pad down
  47288. */
  47289. set dPadDown(value: number);
  47290. /**
  47291. * Gets the value of D-pad left
  47292. */
  47293. get dPadLeft(): number;
  47294. /**
  47295. * Sets the value of D-pad left
  47296. */
  47297. set dPadLeft(value: number);
  47298. /**
  47299. * Gets the value of D-pad right
  47300. */
  47301. get dPadRight(): number;
  47302. /**
  47303. * Sets the value of D-pad right
  47304. */
  47305. set dPadRight(value: number);
  47306. /**
  47307. * Force the gamepad to synchronize with device values
  47308. */
  47309. update(): void;
  47310. /**
  47311. * Disposes the gamepad
  47312. */
  47313. dispose(): void;
  47314. }
  47315. }
  47316. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47317. import { Observable } from "babylonjs/Misc/observable";
  47318. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47319. /**
  47320. * Defines supported buttons for DualShock compatible gamepads
  47321. */
  47322. export enum DualShockButton {
  47323. /** Cross */
  47324. Cross = 0,
  47325. /** Circle */
  47326. Circle = 1,
  47327. /** Square */
  47328. Square = 2,
  47329. /** Triangle */
  47330. Triangle = 3,
  47331. /** L1 */
  47332. L1 = 4,
  47333. /** R1 */
  47334. R1 = 5,
  47335. /** Share */
  47336. Share = 8,
  47337. /** Options */
  47338. Options = 9,
  47339. /** Left stick */
  47340. LeftStick = 10,
  47341. /** Right stick */
  47342. RightStick = 11
  47343. }
  47344. /** Defines values for DualShock DPad */
  47345. export enum DualShockDpad {
  47346. /** Up */
  47347. Up = 12,
  47348. /** Down */
  47349. Down = 13,
  47350. /** Left */
  47351. Left = 14,
  47352. /** Right */
  47353. Right = 15
  47354. }
  47355. /**
  47356. * Defines a DualShock gamepad
  47357. */
  47358. export class DualShockPad extends Gamepad {
  47359. private _leftTrigger;
  47360. private _rightTrigger;
  47361. private _onlefttriggerchanged;
  47362. private _onrighttriggerchanged;
  47363. private _onbuttondown;
  47364. private _onbuttonup;
  47365. private _ondpaddown;
  47366. private _ondpadup;
  47367. /** Observable raised when a button is pressed */
  47368. onButtonDownObservable: Observable<DualShockButton>;
  47369. /** Observable raised when a button is released */
  47370. onButtonUpObservable: Observable<DualShockButton>;
  47371. /** Observable raised when a pad is pressed */
  47372. onPadDownObservable: Observable<DualShockDpad>;
  47373. /** Observable raised when a pad is released */
  47374. onPadUpObservable: Observable<DualShockDpad>;
  47375. private _buttonCross;
  47376. private _buttonCircle;
  47377. private _buttonSquare;
  47378. private _buttonTriangle;
  47379. private _buttonShare;
  47380. private _buttonOptions;
  47381. private _buttonL1;
  47382. private _buttonR1;
  47383. private _buttonLeftStick;
  47384. private _buttonRightStick;
  47385. private _dPadUp;
  47386. private _dPadDown;
  47387. private _dPadLeft;
  47388. private _dPadRight;
  47389. /**
  47390. * Creates a new DualShock gamepad object
  47391. * @param id defines the id of this gamepad
  47392. * @param index defines its index
  47393. * @param gamepad defines the internal HTML gamepad object
  47394. */
  47395. constructor(id: string, index: number, gamepad: any);
  47396. /**
  47397. * Defines the callback to call when left trigger is pressed
  47398. * @param callback defines the callback to use
  47399. */
  47400. onlefttriggerchanged(callback: (value: number) => void): void;
  47401. /**
  47402. * Defines the callback to call when right trigger is pressed
  47403. * @param callback defines the callback to use
  47404. */
  47405. onrighttriggerchanged(callback: (value: number) => void): void;
  47406. /**
  47407. * Gets the left trigger value
  47408. */
  47409. get leftTrigger(): number;
  47410. /**
  47411. * Sets the left trigger value
  47412. */
  47413. set leftTrigger(newValue: number);
  47414. /**
  47415. * Gets the right trigger value
  47416. */
  47417. get rightTrigger(): number;
  47418. /**
  47419. * Sets the right trigger value
  47420. */
  47421. set rightTrigger(newValue: number);
  47422. /**
  47423. * Defines the callback to call when a button is pressed
  47424. * @param callback defines the callback to use
  47425. */
  47426. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47427. /**
  47428. * Defines the callback to call when a button is released
  47429. * @param callback defines the callback to use
  47430. */
  47431. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47432. /**
  47433. * Defines the callback to call when a pad is pressed
  47434. * @param callback defines the callback to use
  47435. */
  47436. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47437. /**
  47438. * Defines the callback to call when a pad is released
  47439. * @param callback defines the callback to use
  47440. */
  47441. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47442. private _setButtonValue;
  47443. private _setDPadValue;
  47444. /**
  47445. * Gets the value of the `Cross` button
  47446. */
  47447. get buttonCross(): number;
  47448. /**
  47449. * Sets the value of the `Cross` button
  47450. */
  47451. set buttonCross(value: number);
  47452. /**
  47453. * Gets the value of the `Circle` button
  47454. */
  47455. get buttonCircle(): number;
  47456. /**
  47457. * Sets the value of the `Circle` button
  47458. */
  47459. set buttonCircle(value: number);
  47460. /**
  47461. * Gets the value of the `Square` button
  47462. */
  47463. get buttonSquare(): number;
  47464. /**
  47465. * Sets the value of the `Square` button
  47466. */
  47467. set buttonSquare(value: number);
  47468. /**
  47469. * Gets the value of the `Triangle` button
  47470. */
  47471. get buttonTriangle(): number;
  47472. /**
  47473. * Sets the value of the `Triangle` button
  47474. */
  47475. set buttonTriangle(value: number);
  47476. /**
  47477. * Gets the value of the `Options` button
  47478. */
  47479. get buttonOptions(): number;
  47480. /**
  47481. * Sets the value of the `Options` button
  47482. */
  47483. set buttonOptions(value: number);
  47484. /**
  47485. * Gets the value of the `Share` button
  47486. */
  47487. get buttonShare(): number;
  47488. /**
  47489. * Sets the value of the `Share` button
  47490. */
  47491. set buttonShare(value: number);
  47492. /**
  47493. * Gets the value of the `L1` button
  47494. */
  47495. get buttonL1(): number;
  47496. /**
  47497. * Sets the value of the `L1` button
  47498. */
  47499. set buttonL1(value: number);
  47500. /**
  47501. * Gets the value of the `R1` button
  47502. */
  47503. get buttonR1(): number;
  47504. /**
  47505. * Sets the value of the `R1` button
  47506. */
  47507. set buttonR1(value: number);
  47508. /**
  47509. * Gets the value of the Left joystick
  47510. */
  47511. get buttonLeftStick(): number;
  47512. /**
  47513. * Sets the value of the Left joystick
  47514. */
  47515. set buttonLeftStick(value: number);
  47516. /**
  47517. * Gets the value of the Right joystick
  47518. */
  47519. get buttonRightStick(): number;
  47520. /**
  47521. * Sets the value of the Right joystick
  47522. */
  47523. set buttonRightStick(value: number);
  47524. /**
  47525. * Gets the value of D-pad up
  47526. */
  47527. get dPadUp(): number;
  47528. /**
  47529. * Sets the value of D-pad up
  47530. */
  47531. set dPadUp(value: number);
  47532. /**
  47533. * Gets the value of D-pad down
  47534. */
  47535. get dPadDown(): number;
  47536. /**
  47537. * Sets the value of D-pad down
  47538. */
  47539. set dPadDown(value: number);
  47540. /**
  47541. * Gets the value of D-pad left
  47542. */
  47543. get dPadLeft(): number;
  47544. /**
  47545. * Sets the value of D-pad left
  47546. */
  47547. set dPadLeft(value: number);
  47548. /**
  47549. * Gets the value of D-pad right
  47550. */
  47551. get dPadRight(): number;
  47552. /**
  47553. * Sets the value of D-pad right
  47554. */
  47555. set dPadRight(value: number);
  47556. /**
  47557. * Force the gamepad to synchronize with device values
  47558. */
  47559. update(): void;
  47560. /**
  47561. * Disposes the gamepad
  47562. */
  47563. dispose(): void;
  47564. }
  47565. }
  47566. declare module "babylonjs/Gamepads/gamepadManager" {
  47567. import { Observable } from "babylonjs/Misc/observable";
  47568. import { Nullable } from "babylonjs/types";
  47569. import { Scene } from "babylonjs/scene";
  47570. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47571. /**
  47572. * Manager for handling gamepads
  47573. */
  47574. export class GamepadManager {
  47575. private _scene?;
  47576. private _babylonGamepads;
  47577. private _oneGamepadConnected;
  47578. /** @hidden */
  47579. _isMonitoring: boolean;
  47580. private _gamepadEventSupported;
  47581. private _gamepadSupport?;
  47582. /**
  47583. * observable to be triggered when the gamepad controller has been connected
  47584. */
  47585. onGamepadConnectedObservable: Observable<Gamepad>;
  47586. /**
  47587. * observable to be triggered when the gamepad controller has been disconnected
  47588. */
  47589. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47590. private _onGamepadConnectedEvent;
  47591. private _onGamepadDisconnectedEvent;
  47592. /**
  47593. * Initializes the gamepad manager
  47594. * @param _scene BabylonJS scene
  47595. */
  47596. constructor(_scene?: Scene | undefined);
  47597. /**
  47598. * The gamepads in the game pad manager
  47599. */
  47600. get gamepads(): Gamepad[];
  47601. /**
  47602. * Get the gamepad controllers based on type
  47603. * @param type The type of gamepad controller
  47604. * @returns Nullable gamepad
  47605. */
  47606. getGamepadByType(type?: number): Nullable<Gamepad>;
  47607. /**
  47608. * Disposes the gamepad manager
  47609. */
  47610. dispose(): void;
  47611. private _addNewGamepad;
  47612. private _startMonitoringGamepads;
  47613. private _stopMonitoringGamepads;
  47614. /** @hidden */
  47615. _checkGamepadsStatus(): void;
  47616. private _updateGamepadObjects;
  47617. }
  47618. }
  47619. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47620. import { Nullable } from "babylonjs/types";
  47621. import { Scene } from "babylonjs/scene";
  47622. import { ISceneComponent } from "babylonjs/sceneComponent";
  47623. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47624. module "babylonjs/scene" {
  47625. interface Scene {
  47626. /** @hidden */
  47627. _gamepadManager: Nullable<GamepadManager>;
  47628. /**
  47629. * Gets the gamepad manager associated with the scene
  47630. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47631. */
  47632. gamepadManager: GamepadManager;
  47633. }
  47634. }
  47635. module "babylonjs/Cameras/freeCameraInputsManager" {
  47636. /**
  47637. * Interface representing a free camera inputs manager
  47638. */
  47639. interface FreeCameraInputsManager {
  47640. /**
  47641. * Adds gamepad input support to the FreeCameraInputsManager.
  47642. * @returns the FreeCameraInputsManager
  47643. */
  47644. addGamepad(): FreeCameraInputsManager;
  47645. }
  47646. }
  47647. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47648. /**
  47649. * Interface representing an arc rotate camera inputs manager
  47650. */
  47651. interface ArcRotateCameraInputsManager {
  47652. /**
  47653. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47654. * @returns the camera inputs manager
  47655. */
  47656. addGamepad(): ArcRotateCameraInputsManager;
  47657. }
  47658. }
  47659. /**
  47660. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47661. */
  47662. export class GamepadSystemSceneComponent implements ISceneComponent {
  47663. /**
  47664. * The component name helpfull to identify the component in the list of scene components.
  47665. */
  47666. readonly name: string;
  47667. /**
  47668. * The scene the component belongs to.
  47669. */
  47670. scene: Scene;
  47671. /**
  47672. * Creates a new instance of the component for the given scene
  47673. * @param scene Defines the scene to register the component in
  47674. */
  47675. constructor(scene: Scene);
  47676. /**
  47677. * Registers the component in a given scene
  47678. */
  47679. register(): void;
  47680. /**
  47681. * Rebuilds the elements related to this component in case of
  47682. * context lost for instance.
  47683. */
  47684. rebuild(): void;
  47685. /**
  47686. * Disposes the component and the associated ressources
  47687. */
  47688. dispose(): void;
  47689. private _beforeCameraUpdate;
  47690. }
  47691. }
  47692. declare module "babylonjs/Cameras/universalCamera" {
  47693. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47694. import { Scene } from "babylonjs/scene";
  47695. import { Vector3 } from "babylonjs/Maths/math.vector";
  47696. import "babylonjs/Gamepads/gamepadSceneComponent";
  47697. /**
  47698. * 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,
  47699. * which still works and will still be found in many Playgrounds.
  47700. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47701. */
  47702. export class UniversalCamera extends TouchCamera {
  47703. /**
  47704. * Defines the gamepad rotation sensiblity.
  47705. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47706. */
  47707. get gamepadAngularSensibility(): number;
  47708. set gamepadAngularSensibility(value: number);
  47709. /**
  47710. * Defines the gamepad move sensiblity.
  47711. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47712. */
  47713. get gamepadMoveSensibility(): number;
  47714. set gamepadMoveSensibility(value: number);
  47715. /**
  47716. * 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,
  47717. * which still works and will still be found in many Playgrounds.
  47718. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47719. * @param name Define the name of the camera in the scene
  47720. * @param position Define the start position of the camera in the scene
  47721. * @param scene Define the scene the camera belongs to
  47722. */
  47723. constructor(name: string, position: Vector3, scene: Scene);
  47724. /**
  47725. * Gets the current object class name.
  47726. * @return the class name
  47727. */
  47728. getClassName(): string;
  47729. }
  47730. }
  47731. declare module "babylonjs/Cameras/gamepadCamera" {
  47732. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47733. import { Scene } from "babylonjs/scene";
  47734. import { Vector3 } from "babylonjs/Maths/math.vector";
  47735. /**
  47736. * This represents a FPS type of camera. This is only here for back compat purpose.
  47737. * Please use the UniversalCamera instead as both are identical.
  47738. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47739. */
  47740. export class GamepadCamera extends UniversalCamera {
  47741. /**
  47742. * Instantiates a new Gamepad Camera
  47743. * This represents a FPS type of camera. This is only here for back compat purpose.
  47744. * Please use the UniversalCamera instead as both are identical.
  47745. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47746. * @param name Define the name of the camera in the scene
  47747. * @param position Define the start position of the camera in the scene
  47748. * @param scene Define the scene the camera belongs to
  47749. */
  47750. constructor(name: string, position: Vector3, scene: Scene);
  47751. /**
  47752. * Gets the current object class name.
  47753. * @return the class name
  47754. */
  47755. getClassName(): string;
  47756. }
  47757. }
  47758. declare module "babylonjs/Shaders/pass.fragment" {
  47759. /** @hidden */
  47760. export var passPixelShader: {
  47761. name: string;
  47762. shader: string;
  47763. };
  47764. }
  47765. declare module "babylonjs/Shaders/passCube.fragment" {
  47766. /** @hidden */
  47767. export var passCubePixelShader: {
  47768. name: string;
  47769. shader: string;
  47770. };
  47771. }
  47772. declare module "babylonjs/PostProcesses/passPostProcess" {
  47773. import { Nullable } from "babylonjs/types";
  47774. import { Camera } from "babylonjs/Cameras/camera";
  47775. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47776. import { Engine } from "babylonjs/Engines/engine";
  47777. import "babylonjs/Shaders/pass.fragment";
  47778. import "babylonjs/Shaders/passCube.fragment";
  47779. import { Scene } from "babylonjs/scene";
  47780. /**
  47781. * PassPostProcess which produces an output the same as it's input
  47782. */
  47783. export class PassPostProcess extends PostProcess {
  47784. /**
  47785. * Gets a string identifying the name of the class
  47786. * @returns "PassPostProcess" string
  47787. */
  47788. getClassName(): string;
  47789. /**
  47790. * Creates the PassPostProcess
  47791. * @param name The name of the effect.
  47792. * @param options The required width/height ratio to downsize to before computing the render pass.
  47793. * @param camera The camera to apply the render pass to.
  47794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47795. * @param engine The engine which the post process will be applied. (default: current engine)
  47796. * @param reusable If the post process can be reused on the same frame. (default: false)
  47797. * @param textureType The type of texture to be used when performing the post processing.
  47798. * @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)
  47799. */
  47800. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47801. /** @hidden */
  47802. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47803. }
  47804. /**
  47805. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47806. */
  47807. export class PassCubePostProcess extends PostProcess {
  47808. private _face;
  47809. /**
  47810. * Gets or sets the cube face to display.
  47811. * * 0 is +X
  47812. * * 1 is -X
  47813. * * 2 is +Y
  47814. * * 3 is -Y
  47815. * * 4 is +Z
  47816. * * 5 is -Z
  47817. */
  47818. get face(): number;
  47819. set face(value: number);
  47820. /**
  47821. * Gets a string identifying the name of the class
  47822. * @returns "PassCubePostProcess" string
  47823. */
  47824. getClassName(): string;
  47825. /**
  47826. * Creates the PassCubePostProcess
  47827. * @param name The name of the effect.
  47828. * @param options The required width/height ratio to downsize to before computing the render pass.
  47829. * @param camera The camera to apply the render pass to.
  47830. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47831. * @param engine The engine which the post process will be applied. (default: current engine)
  47832. * @param reusable If the post process can be reused on the same frame. (default: false)
  47833. * @param textureType The type of texture to be used when performing the post processing.
  47834. * @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)
  47835. */
  47836. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47837. /** @hidden */
  47838. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  47839. }
  47840. }
  47841. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47842. /** @hidden */
  47843. export var anaglyphPixelShader: {
  47844. name: string;
  47845. shader: string;
  47846. };
  47847. }
  47848. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47849. import { Engine } from "babylonjs/Engines/engine";
  47850. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47851. import { Camera } from "babylonjs/Cameras/camera";
  47852. import "babylonjs/Shaders/anaglyph.fragment";
  47853. /**
  47854. * Postprocess used to generate anaglyphic rendering
  47855. */
  47856. export class AnaglyphPostProcess extends PostProcess {
  47857. private _passedProcess;
  47858. /**
  47859. * Gets a string identifying the name of the class
  47860. * @returns "AnaglyphPostProcess" string
  47861. */
  47862. getClassName(): string;
  47863. /**
  47864. * Creates a new AnaglyphPostProcess
  47865. * @param name defines postprocess name
  47866. * @param options defines creation options or target ratio scale
  47867. * @param rigCameras defines cameras using this postprocess
  47868. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47869. * @param engine defines hosting engine
  47870. * @param reusable defines if the postprocess will be reused multiple times per frame
  47871. */
  47872. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47873. }
  47874. }
  47875. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47876. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47877. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47878. import { Scene } from "babylonjs/scene";
  47879. import { Vector3 } from "babylonjs/Maths/math.vector";
  47880. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47881. /**
  47882. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47883. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47884. */
  47885. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47886. /**
  47887. * Creates a new AnaglyphArcRotateCamera
  47888. * @param name defines camera name
  47889. * @param alpha defines alpha angle (in radians)
  47890. * @param beta defines beta angle (in radians)
  47891. * @param radius defines radius
  47892. * @param target defines camera target
  47893. * @param interaxialDistance defines distance between each color axis
  47894. * @param scene defines the hosting scene
  47895. */
  47896. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47897. /**
  47898. * Gets camera class name
  47899. * @returns AnaglyphArcRotateCamera
  47900. */
  47901. getClassName(): string;
  47902. }
  47903. }
  47904. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47905. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47906. import { Scene } from "babylonjs/scene";
  47907. import { Vector3 } from "babylonjs/Maths/math.vector";
  47908. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47909. /**
  47910. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47911. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47912. */
  47913. export class AnaglyphFreeCamera extends FreeCamera {
  47914. /**
  47915. * Creates a new AnaglyphFreeCamera
  47916. * @param name defines camera name
  47917. * @param position defines initial position
  47918. * @param interaxialDistance defines distance between each color axis
  47919. * @param scene defines the hosting scene
  47920. */
  47921. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47922. /**
  47923. * Gets camera class name
  47924. * @returns AnaglyphFreeCamera
  47925. */
  47926. getClassName(): string;
  47927. }
  47928. }
  47929. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47930. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47931. import { Scene } from "babylonjs/scene";
  47932. import { Vector3 } from "babylonjs/Maths/math.vector";
  47933. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47934. /**
  47935. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47936. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47937. */
  47938. export class AnaglyphGamepadCamera extends GamepadCamera {
  47939. /**
  47940. * Creates a new AnaglyphGamepadCamera
  47941. * @param name defines camera name
  47942. * @param position defines initial position
  47943. * @param interaxialDistance defines distance between each color axis
  47944. * @param scene defines the hosting scene
  47945. */
  47946. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47947. /**
  47948. * Gets camera class name
  47949. * @returns AnaglyphGamepadCamera
  47950. */
  47951. getClassName(): string;
  47952. }
  47953. }
  47954. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  47955. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47956. import { Scene } from "babylonjs/scene";
  47957. import { Vector3 } from "babylonjs/Maths/math.vector";
  47958. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47959. /**
  47960. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  47961. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47962. */
  47963. export class AnaglyphUniversalCamera extends UniversalCamera {
  47964. /**
  47965. * Creates a new AnaglyphUniversalCamera
  47966. * @param name defines camera name
  47967. * @param position defines initial position
  47968. * @param interaxialDistance defines distance between each color axis
  47969. * @param scene defines the hosting scene
  47970. */
  47971. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47972. /**
  47973. * Gets camera class name
  47974. * @returns AnaglyphUniversalCamera
  47975. */
  47976. getClassName(): string;
  47977. }
  47978. }
  47979. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  47980. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  47981. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47982. import { Scene } from "babylonjs/scene";
  47983. import { Vector3 } from "babylonjs/Maths/math.vector";
  47984. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47985. /**
  47986. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  47987. * @see https://doc.babylonjs.com/features/cameras
  47988. */
  47989. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  47990. /**
  47991. * Creates a new StereoscopicArcRotateCamera
  47992. * @param name defines camera name
  47993. * @param alpha defines alpha angle (in radians)
  47994. * @param beta defines beta angle (in radians)
  47995. * @param radius defines radius
  47996. * @param target defines camera target
  47997. * @param interaxialDistance defines distance between each color axis
  47998. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47999. * @param scene defines the hosting scene
  48000. */
  48001. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48002. /**
  48003. * Gets camera class name
  48004. * @returns StereoscopicArcRotateCamera
  48005. */
  48006. getClassName(): string;
  48007. }
  48008. }
  48009. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  48010. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48011. import { Scene } from "babylonjs/scene";
  48012. import { Vector3 } from "babylonjs/Maths/math.vector";
  48013. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48014. /**
  48015. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  48016. * @see https://doc.babylonjs.com/features/cameras
  48017. */
  48018. export class StereoscopicFreeCamera extends FreeCamera {
  48019. /**
  48020. * Creates a new StereoscopicFreeCamera
  48021. * @param name defines camera name
  48022. * @param position defines initial position
  48023. * @param interaxialDistance defines distance between each color axis
  48024. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48025. * @param scene defines the hosting scene
  48026. */
  48027. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48028. /**
  48029. * Gets camera class name
  48030. * @returns StereoscopicFreeCamera
  48031. */
  48032. getClassName(): string;
  48033. }
  48034. }
  48035. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  48036. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  48037. import { Scene } from "babylonjs/scene";
  48038. import { Vector3 } from "babylonjs/Maths/math.vector";
  48039. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48040. /**
  48041. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  48042. * @see https://doc.babylonjs.com/features/cameras
  48043. */
  48044. export class StereoscopicGamepadCamera extends GamepadCamera {
  48045. /**
  48046. * Creates a new StereoscopicGamepadCamera
  48047. * @param name defines camera name
  48048. * @param position defines initial position
  48049. * @param interaxialDistance defines distance between each color axis
  48050. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48051. * @param scene defines the hosting scene
  48052. */
  48053. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48054. /**
  48055. * Gets camera class name
  48056. * @returns StereoscopicGamepadCamera
  48057. */
  48058. getClassName(): string;
  48059. }
  48060. }
  48061. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  48062. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48063. import { Scene } from "babylonjs/scene";
  48064. import { Vector3 } from "babylonjs/Maths/math.vector";
  48065. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48066. /**
  48067. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  48068. * @see https://doc.babylonjs.com/features/cameras
  48069. */
  48070. export class StereoscopicUniversalCamera extends UniversalCamera {
  48071. /**
  48072. * Creates a new StereoscopicUniversalCamera
  48073. * @param name defines camera name
  48074. * @param position defines initial position
  48075. * @param interaxialDistance defines distance between each color axis
  48076. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48077. * @param scene defines the hosting scene
  48078. */
  48079. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48080. /**
  48081. * Gets camera class name
  48082. * @returns StereoscopicUniversalCamera
  48083. */
  48084. getClassName(): string;
  48085. }
  48086. }
  48087. declare module "babylonjs/Cameras/Stereoscopic/index" {
  48088. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  48089. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  48090. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  48091. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  48092. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  48093. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  48094. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  48095. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  48096. }
  48097. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  48098. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48099. import { Scene } from "babylonjs/scene";
  48100. import { Vector3 } from "babylonjs/Maths/math.vector";
  48101. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  48102. /**
  48103. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  48104. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48105. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48106. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48107. */
  48108. export class VirtualJoysticksCamera extends FreeCamera {
  48109. /**
  48110. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  48111. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48112. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48113. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48114. * @param name Define the name of the camera in the scene
  48115. * @param position Define the start position of the camera in the scene
  48116. * @param scene Define the scene the camera belongs to
  48117. */
  48118. constructor(name: string, position: Vector3, scene: Scene);
  48119. /**
  48120. * Gets the current object class name.
  48121. * @return the class name
  48122. */
  48123. getClassName(): string;
  48124. }
  48125. }
  48126. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  48127. import { Matrix } from "babylonjs/Maths/math.vector";
  48128. /**
  48129. * This represents all the required metrics to create a VR camera.
  48130. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  48131. */
  48132. export class VRCameraMetrics {
  48133. /**
  48134. * Define the horizontal resolution off the screen.
  48135. */
  48136. hResolution: number;
  48137. /**
  48138. * Define the vertical resolution off the screen.
  48139. */
  48140. vResolution: number;
  48141. /**
  48142. * Define the horizontal screen size.
  48143. */
  48144. hScreenSize: number;
  48145. /**
  48146. * Define the vertical screen size.
  48147. */
  48148. vScreenSize: number;
  48149. /**
  48150. * Define the vertical screen center position.
  48151. */
  48152. vScreenCenter: number;
  48153. /**
  48154. * Define the distance of the eyes to the screen.
  48155. */
  48156. eyeToScreenDistance: number;
  48157. /**
  48158. * Define the distance between both lenses
  48159. */
  48160. lensSeparationDistance: number;
  48161. /**
  48162. * Define the distance between both viewer's eyes.
  48163. */
  48164. interpupillaryDistance: number;
  48165. /**
  48166. * Define the distortion factor of the VR postprocess.
  48167. * Please, touch with care.
  48168. */
  48169. distortionK: number[];
  48170. /**
  48171. * Define the chromatic aberration correction factors for the VR post process.
  48172. */
  48173. chromaAbCorrection: number[];
  48174. /**
  48175. * Define the scale factor of the post process.
  48176. * The smaller the better but the slower.
  48177. */
  48178. postProcessScaleFactor: number;
  48179. /**
  48180. * Define an offset for the lens center.
  48181. */
  48182. lensCenterOffset: number;
  48183. /**
  48184. * Define if the current vr camera should compensate the distortion of the lense or not.
  48185. */
  48186. compensateDistortion: boolean;
  48187. /**
  48188. * Defines if multiview should be enabled when rendering (Default: false)
  48189. */
  48190. multiviewEnabled: boolean;
  48191. /**
  48192. * Gets the rendering aspect ratio based on the provided resolutions.
  48193. */
  48194. get aspectRatio(): number;
  48195. /**
  48196. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48197. */
  48198. get aspectRatioFov(): number;
  48199. /**
  48200. * @hidden
  48201. */
  48202. get leftHMatrix(): Matrix;
  48203. /**
  48204. * @hidden
  48205. */
  48206. get rightHMatrix(): Matrix;
  48207. /**
  48208. * @hidden
  48209. */
  48210. get leftPreViewMatrix(): Matrix;
  48211. /**
  48212. * @hidden
  48213. */
  48214. get rightPreViewMatrix(): Matrix;
  48215. /**
  48216. * Get the default VRMetrics based on the most generic setup.
  48217. * @returns the default vr metrics
  48218. */
  48219. static GetDefault(): VRCameraMetrics;
  48220. }
  48221. }
  48222. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48223. /** @hidden */
  48224. export var vrDistortionCorrectionPixelShader: {
  48225. name: string;
  48226. shader: string;
  48227. };
  48228. }
  48229. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48230. import { Camera } from "babylonjs/Cameras/camera";
  48231. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48232. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48233. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48234. /**
  48235. * VRDistortionCorrectionPostProcess used for mobile VR
  48236. */
  48237. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48238. private _isRightEye;
  48239. private _distortionFactors;
  48240. private _postProcessScaleFactor;
  48241. private _lensCenterOffset;
  48242. private _scaleIn;
  48243. private _scaleFactor;
  48244. private _lensCenter;
  48245. /**
  48246. * Gets a string identifying the name of the class
  48247. * @returns "VRDistortionCorrectionPostProcess" string
  48248. */
  48249. getClassName(): string;
  48250. /**
  48251. * Initializes the VRDistortionCorrectionPostProcess
  48252. * @param name The name of the effect.
  48253. * @param camera The camera to apply the render pass to.
  48254. * @param isRightEye If this is for the right eye distortion
  48255. * @param vrMetrics All the required metrics for the VR camera
  48256. */
  48257. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48258. }
  48259. }
  48260. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48261. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48262. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48263. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48264. import { Scene } from "babylonjs/scene";
  48265. import { Vector3 } from "babylonjs/Maths/math.vector";
  48266. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48267. import "babylonjs/Cameras/RigModes/vrRigMode";
  48268. /**
  48269. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48270. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48271. */
  48272. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48273. /**
  48274. * Creates a new VRDeviceOrientationArcRotateCamera
  48275. * @param name defines camera name
  48276. * @param alpha defines the camera rotation along the logitudinal axis
  48277. * @param beta defines the camera rotation along the latitudinal axis
  48278. * @param radius defines the camera distance from its target
  48279. * @param target defines the camera target
  48280. * @param scene defines the scene the camera belongs to
  48281. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48282. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48283. */
  48284. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48285. /**
  48286. * Gets camera class name
  48287. * @returns VRDeviceOrientationArcRotateCamera
  48288. */
  48289. getClassName(): string;
  48290. }
  48291. }
  48292. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48293. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48294. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48295. import { Scene } from "babylonjs/scene";
  48296. import { Vector3 } from "babylonjs/Maths/math.vector";
  48297. import "babylonjs/Cameras/RigModes/vrRigMode";
  48298. /**
  48299. * Camera used to simulate VR rendering (based on FreeCamera)
  48300. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48301. */
  48302. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48303. /**
  48304. * Creates a new VRDeviceOrientationFreeCamera
  48305. * @param name defines camera name
  48306. * @param position defines the start position of the camera
  48307. * @param scene defines the scene the camera belongs to
  48308. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48309. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48310. */
  48311. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48312. /**
  48313. * Gets camera class name
  48314. * @returns VRDeviceOrientationFreeCamera
  48315. */
  48316. getClassName(): string;
  48317. }
  48318. }
  48319. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48320. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48321. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48322. import { Scene } from "babylonjs/scene";
  48323. import { Vector3 } from "babylonjs/Maths/math.vector";
  48324. import "babylonjs/Gamepads/gamepadSceneComponent";
  48325. /**
  48326. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48327. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48328. */
  48329. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48330. /**
  48331. * Creates a new VRDeviceOrientationGamepadCamera
  48332. * @param name defines camera name
  48333. * @param position defines the start position of the camera
  48334. * @param scene defines the scene the camera belongs to
  48335. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48336. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48337. */
  48338. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48339. /**
  48340. * Gets camera class name
  48341. * @returns VRDeviceOrientationGamepadCamera
  48342. */
  48343. getClassName(): string;
  48344. }
  48345. }
  48346. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48347. import { Scene } from "babylonjs/scene";
  48348. import { Texture } from "babylonjs/Materials/Textures/texture";
  48349. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48350. /**
  48351. * A class extending Texture allowing drawing on a texture
  48352. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48353. */
  48354. export class DynamicTexture extends Texture {
  48355. private _generateMipMaps;
  48356. private _canvas;
  48357. private _context;
  48358. /**
  48359. * Creates a DynamicTexture
  48360. * @param name defines the name of the texture
  48361. * @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
  48362. * @param scene defines the scene where you want the texture
  48363. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48364. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48365. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48366. */
  48367. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48368. /**
  48369. * Get the current class name of the texture useful for serialization or dynamic coding.
  48370. * @returns "DynamicTexture"
  48371. */
  48372. getClassName(): string;
  48373. /**
  48374. * Gets the current state of canRescale
  48375. */
  48376. get canRescale(): boolean;
  48377. private _recreate;
  48378. /**
  48379. * Scales the texture
  48380. * @param ratio the scale factor to apply to both width and height
  48381. */
  48382. scale(ratio: number): void;
  48383. /**
  48384. * Resizes the texture
  48385. * @param width the new width
  48386. * @param height the new height
  48387. */
  48388. scaleTo(width: number, height: number): void;
  48389. /**
  48390. * Gets the context of the canvas used by the texture
  48391. * @returns the canvas context of the dynamic texture
  48392. */
  48393. getContext(): CanvasRenderingContext2D;
  48394. /**
  48395. * Clears the texture
  48396. */
  48397. clear(): void;
  48398. /**
  48399. * Updates the texture
  48400. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48401. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48402. */
  48403. update(invertY?: boolean, premulAlpha?: boolean): void;
  48404. /**
  48405. * Draws text onto the texture
  48406. * @param text defines the text to be drawn
  48407. * @param x defines the placement of the text from the left
  48408. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48409. * @param font defines the font to be used with font-style, font-size, font-name
  48410. * @param color defines the color used for the text
  48411. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48412. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48413. * @param update defines whether texture is immediately update (default is true)
  48414. */
  48415. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48416. /**
  48417. * Clones the texture
  48418. * @returns the clone of the texture.
  48419. */
  48420. clone(): DynamicTexture;
  48421. /**
  48422. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48423. * @returns a serialized dynamic texture object
  48424. */
  48425. serialize(): any;
  48426. private _IsCanvasElement;
  48427. /** @hidden */
  48428. _rebuild(): void;
  48429. }
  48430. }
  48431. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48432. import { Scene } from "babylonjs/scene";
  48433. import { Color3 } from "babylonjs/Maths/math.color";
  48434. import { Mesh } from "babylonjs/Meshes/mesh";
  48435. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48436. import { Nullable } from "babylonjs/types";
  48437. /**
  48438. * Class containing static functions to help procedurally build meshes
  48439. */
  48440. export class GroundBuilder {
  48441. /**
  48442. * Creates a ground mesh
  48443. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48444. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48446. * @param name defines the name of the mesh
  48447. * @param options defines the options used to create the mesh
  48448. * @param scene defines the hosting scene
  48449. * @returns the ground mesh
  48450. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48451. */
  48452. static CreateGround(name: string, options: {
  48453. width?: number;
  48454. height?: number;
  48455. subdivisions?: number;
  48456. subdivisionsX?: number;
  48457. subdivisionsY?: number;
  48458. updatable?: boolean;
  48459. }, scene: any): Mesh;
  48460. /**
  48461. * Creates a tiled ground mesh
  48462. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48463. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48464. * * 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
  48465. * * 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
  48466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48467. * @param name defines the name of the mesh
  48468. * @param options defines the options used to create the mesh
  48469. * @param scene defines the hosting scene
  48470. * @returns the tiled ground mesh
  48471. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48472. */
  48473. static CreateTiledGround(name: string, options: {
  48474. xmin: number;
  48475. zmin: number;
  48476. xmax: number;
  48477. zmax: number;
  48478. subdivisions?: {
  48479. w: number;
  48480. h: number;
  48481. };
  48482. precision?: {
  48483. w: number;
  48484. h: number;
  48485. };
  48486. updatable?: boolean;
  48487. }, scene?: Nullable<Scene>): Mesh;
  48488. /**
  48489. * Creates a ground mesh from a height map
  48490. * * The parameter `url` sets the URL of the height map image resource.
  48491. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48492. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48493. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48494. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48495. * * 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.
  48496. * * 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).
  48497. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48499. * @param name defines the name of the mesh
  48500. * @param url defines the url to the height map
  48501. * @param options defines the options used to create the mesh
  48502. * @param scene defines the hosting scene
  48503. * @returns the ground mesh
  48504. * @see https://doc.babylonjs.com/babylon101/height_map
  48505. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48506. */
  48507. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48508. width?: number;
  48509. height?: number;
  48510. subdivisions?: number;
  48511. minHeight?: number;
  48512. maxHeight?: number;
  48513. colorFilter?: Color3;
  48514. alphaFilter?: number;
  48515. updatable?: boolean;
  48516. onReady?: (mesh: GroundMesh) => void;
  48517. }, scene?: Nullable<Scene>): GroundMesh;
  48518. }
  48519. }
  48520. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48521. import { Vector4 } from "babylonjs/Maths/math.vector";
  48522. import { Mesh } from "babylonjs/Meshes/mesh";
  48523. /**
  48524. * Class containing static functions to help procedurally build meshes
  48525. */
  48526. export class TorusBuilder {
  48527. /**
  48528. * Creates a torus mesh
  48529. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48530. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48531. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48533. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48535. * @param name defines the name of the mesh
  48536. * @param options defines the options used to create the mesh
  48537. * @param scene defines the hosting scene
  48538. * @returns the torus mesh
  48539. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48540. */
  48541. static CreateTorus(name: string, options: {
  48542. diameter?: number;
  48543. thickness?: number;
  48544. tessellation?: number;
  48545. updatable?: boolean;
  48546. sideOrientation?: number;
  48547. frontUVs?: Vector4;
  48548. backUVs?: Vector4;
  48549. }, scene: any): Mesh;
  48550. }
  48551. }
  48552. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48553. import { Vector4 } from "babylonjs/Maths/math.vector";
  48554. import { Color4 } from "babylonjs/Maths/math.color";
  48555. import { Mesh } from "babylonjs/Meshes/mesh";
  48556. /**
  48557. * Class containing static functions to help procedurally build meshes
  48558. */
  48559. export class CylinderBuilder {
  48560. /**
  48561. * Creates a cylinder or a cone mesh
  48562. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48563. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48564. * * 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.
  48565. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48566. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48567. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48568. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48569. * * 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).
  48570. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48571. * * 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).
  48572. * * 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
  48573. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48574. * * 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
  48575. * * 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.
  48576. * * If `enclose` is false, a ring surface is one element.
  48577. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48578. * * 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
  48579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48580. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48582. * @param name defines the name of the mesh
  48583. * @param options defines the options used to create the mesh
  48584. * @param scene defines the hosting scene
  48585. * @returns the cylinder mesh
  48586. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48587. */
  48588. static CreateCylinder(name: string, options: {
  48589. height?: number;
  48590. diameterTop?: number;
  48591. diameterBottom?: number;
  48592. diameter?: number;
  48593. tessellation?: number;
  48594. subdivisions?: number;
  48595. arc?: number;
  48596. faceColors?: Color4[];
  48597. faceUV?: Vector4[];
  48598. updatable?: boolean;
  48599. hasRings?: boolean;
  48600. enclose?: boolean;
  48601. cap?: number;
  48602. sideOrientation?: number;
  48603. frontUVs?: Vector4;
  48604. backUVs?: Vector4;
  48605. }, scene: any): Mesh;
  48606. }
  48607. }
  48608. declare module "babylonjs/XR/webXRTypes" {
  48609. import { Nullable } from "babylonjs/types";
  48610. import { IDisposable } from "babylonjs/scene";
  48611. /**
  48612. * States of the webXR experience
  48613. */
  48614. export enum WebXRState {
  48615. /**
  48616. * Transitioning to being in XR mode
  48617. */
  48618. ENTERING_XR = 0,
  48619. /**
  48620. * Transitioning to non XR mode
  48621. */
  48622. EXITING_XR = 1,
  48623. /**
  48624. * In XR mode and presenting
  48625. */
  48626. IN_XR = 2,
  48627. /**
  48628. * Not entered XR mode
  48629. */
  48630. NOT_IN_XR = 3
  48631. }
  48632. /**
  48633. * Abstraction of the XR render target
  48634. */
  48635. export interface WebXRRenderTarget extends IDisposable {
  48636. /**
  48637. * xrpresent context of the canvas which can be used to display/mirror xr content
  48638. */
  48639. canvasContext: WebGLRenderingContext;
  48640. /**
  48641. * xr layer for the canvas
  48642. */
  48643. xrLayer: Nullable<XRWebGLLayer>;
  48644. /**
  48645. * Initializes the xr layer for the session
  48646. * @param xrSession xr session
  48647. * @returns a promise that will resolve once the XR Layer has been created
  48648. */
  48649. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48650. }
  48651. }
  48652. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48653. import { Nullable } from "babylonjs/types";
  48654. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  48655. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48656. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48657. import { Observable } from "babylonjs/Misc/observable";
  48658. /**
  48659. * COnfiguration object for WebXR output canvas
  48660. */
  48661. export class WebXRManagedOutputCanvasOptions {
  48662. /**
  48663. * An optional canvas in case you wish to create it yourself and provide it here.
  48664. * If not provided, a new canvas will be created
  48665. */
  48666. canvasElement?: HTMLCanvasElement;
  48667. /**
  48668. * Options for this XR Layer output
  48669. */
  48670. canvasOptions?: XRWebGLLayerOptions;
  48671. /**
  48672. * CSS styling for a newly created canvas (if not provided)
  48673. */
  48674. newCanvasCssStyle?: string;
  48675. /**
  48676. * Get the default values of the configuration object
  48677. * @param engine defines the engine to use (can be null)
  48678. * @returns default values of this configuration object
  48679. */
  48680. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  48681. }
  48682. /**
  48683. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48684. */
  48685. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48686. private _options;
  48687. private _canvas;
  48688. private _engine;
  48689. private _originalCanvasSize;
  48690. /**
  48691. * Rendering context of the canvas which can be used to display/mirror xr content
  48692. */
  48693. canvasContext: WebGLRenderingContext;
  48694. /**
  48695. * xr layer for the canvas
  48696. */
  48697. xrLayer: Nullable<XRWebGLLayer>;
  48698. /**
  48699. * Obseervers registered here will be triggered when the xr layer was initialized
  48700. */
  48701. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48702. /**
  48703. * Initializes the canvas to be added/removed upon entering/exiting xr
  48704. * @param _xrSessionManager The XR Session manager
  48705. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48706. */
  48707. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48708. /**
  48709. * Disposes of the object
  48710. */
  48711. dispose(): void;
  48712. /**
  48713. * Initializes the xr layer for the session
  48714. * @param xrSession xr session
  48715. * @returns a promise that will resolve once the XR Layer has been created
  48716. */
  48717. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48718. private _addCanvas;
  48719. private _removeCanvas;
  48720. private _setCanvasSize;
  48721. private _setManagedOutputCanvas;
  48722. }
  48723. }
  48724. declare module "babylonjs/XR/webXRSessionManager" {
  48725. import { Observable } from "babylonjs/Misc/observable";
  48726. import { Nullable } from "babylonjs/types";
  48727. import { IDisposable, Scene } from "babylonjs/scene";
  48728. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48729. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48730. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48731. /**
  48732. * Manages an XRSession to work with Babylon's engine
  48733. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48734. */
  48735. export class WebXRSessionManager implements IDisposable {
  48736. /** The scene which the session should be created for */
  48737. scene: Scene;
  48738. private _referenceSpace;
  48739. private _rttProvider;
  48740. private _sessionEnded;
  48741. private _xrNavigator;
  48742. private baseLayer;
  48743. /**
  48744. * The base reference space from which the session started. good if you want to reset your
  48745. * reference space
  48746. */
  48747. baseReferenceSpace: XRReferenceSpace;
  48748. /**
  48749. * Current XR frame
  48750. */
  48751. currentFrame: Nullable<XRFrame>;
  48752. /** WebXR timestamp updated every frame */
  48753. currentTimestamp: number;
  48754. /**
  48755. * Used just in case of a failure to initialize an immersive session.
  48756. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48757. */
  48758. defaultHeightCompensation: number;
  48759. /**
  48760. * Fires every time a new xrFrame arrives which can be used to update the camera
  48761. */
  48762. onXRFrameObservable: Observable<XRFrame>;
  48763. /**
  48764. * Fires when the reference space changed
  48765. */
  48766. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48767. /**
  48768. * Fires when the xr session is ended either by the device or manually done
  48769. */
  48770. onXRSessionEnded: Observable<any>;
  48771. /**
  48772. * Fires when the xr session is ended either by the device or manually done
  48773. */
  48774. onXRSessionInit: Observable<XRSession>;
  48775. /**
  48776. * Underlying xr session
  48777. */
  48778. session: XRSession;
  48779. /**
  48780. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48781. * or get the offset the player is currently at.
  48782. */
  48783. viewerReferenceSpace: XRReferenceSpace;
  48784. /**
  48785. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48786. * @param scene The scene which the session should be created for
  48787. */
  48788. constructor(
  48789. /** The scene which the session should be created for */
  48790. scene: Scene);
  48791. /**
  48792. * The current reference space used in this session. This reference space can constantly change!
  48793. * It is mainly used to offset the camera's position.
  48794. */
  48795. get referenceSpace(): XRReferenceSpace;
  48796. /**
  48797. * Set a new reference space and triggers the observable
  48798. */
  48799. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48800. /**
  48801. * Disposes of the session manager
  48802. */
  48803. dispose(): void;
  48804. /**
  48805. * Stops the xrSession and restores the render loop
  48806. * @returns Promise which resolves after it exits XR
  48807. */
  48808. exitXRAsync(): Promise<void>;
  48809. /**
  48810. * Gets the correct render target texture to be rendered this frame for this eye
  48811. * @param eye the eye for which to get the render target
  48812. * @returns the render target for the specified eye
  48813. */
  48814. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48815. /**
  48816. * Creates a WebXRRenderTarget object for the XR session
  48817. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48818. * @param options optional options to provide when creating a new render target
  48819. * @returns a WebXR render target to which the session can render
  48820. */
  48821. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48822. /**
  48823. * Initializes the manager
  48824. * After initialization enterXR can be called to start an XR session
  48825. * @returns Promise which resolves after it is initialized
  48826. */
  48827. initializeAsync(): Promise<void>;
  48828. /**
  48829. * Initializes an xr session
  48830. * @param xrSessionMode mode to initialize
  48831. * @param xrSessionInit defines optional and required values to pass to the session builder
  48832. * @returns a promise which will resolve once the session has been initialized
  48833. */
  48834. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48835. /**
  48836. * Checks if a session would be supported for the creation options specified
  48837. * @param sessionMode session mode to check if supported eg. immersive-vr
  48838. * @returns A Promise that resolves to true if supported and false if not
  48839. */
  48840. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48841. /**
  48842. * Resets the reference space to the one started the session
  48843. */
  48844. resetReferenceSpace(): void;
  48845. /**
  48846. * Starts rendering to the xr layer
  48847. */
  48848. runXRRenderLoop(): void;
  48849. /**
  48850. * Sets the reference space on the xr session
  48851. * @param referenceSpaceType space to set
  48852. * @returns a promise that will resolve once the reference space has been set
  48853. */
  48854. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48855. /**
  48856. * Updates the render state of the session
  48857. * @param state state to set
  48858. * @returns a promise that resolves once the render state has been updated
  48859. */
  48860. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48861. /**
  48862. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48863. * @param sessionMode defines the session to test
  48864. * @returns a promise with boolean as final value
  48865. */
  48866. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48867. private _createRenderTargetTexture;
  48868. }
  48869. }
  48870. declare module "babylonjs/XR/webXRCamera" {
  48871. import { Vector3 } from "babylonjs/Maths/math.vector";
  48872. import { Scene } from "babylonjs/scene";
  48873. import { Camera } from "babylonjs/Cameras/camera";
  48874. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48875. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48876. import { Observable } from "babylonjs/Misc/observable";
  48877. /**
  48878. * WebXR Camera which holds the views for the xrSession
  48879. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48880. */
  48881. export class WebXRCamera extends FreeCamera {
  48882. private _xrSessionManager;
  48883. private _firstFrame;
  48884. private _referenceQuaternion;
  48885. private _referencedPosition;
  48886. private _xrInvPositionCache;
  48887. private _xrInvQuaternionCache;
  48888. /**
  48889. * Observable raised before camera teleportation
  48890. */
  48891. onBeforeCameraTeleport: Observable<Vector3>;
  48892. /**
  48893. * Observable raised after camera teleportation
  48894. */
  48895. onAfterCameraTeleport: Observable<Vector3>;
  48896. /**
  48897. * Should position compensation execute on first frame.
  48898. * This is used when copying the position from a native (non XR) camera
  48899. */
  48900. compensateOnFirstFrame: boolean;
  48901. /**
  48902. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48903. * @param name the name of the camera
  48904. * @param scene the scene to add the camera to
  48905. * @param _xrSessionManager a constructed xr session manager
  48906. */
  48907. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48908. /**
  48909. * Return the user's height, unrelated to the current ground.
  48910. * This will be the y position of this camera, when ground level is 0.
  48911. */
  48912. get realWorldHeight(): number;
  48913. /** @hidden */
  48914. _updateForDualEyeDebugging(): void;
  48915. /**
  48916. * Sets this camera's transformation based on a non-vr camera
  48917. * @param otherCamera the non-vr camera to copy the transformation from
  48918. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48919. */
  48920. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48921. /**
  48922. * Gets the current instance class name ("WebXRCamera").
  48923. * @returns the class name
  48924. */
  48925. getClassName(): string;
  48926. private _rotate180;
  48927. private _updateFromXRSession;
  48928. private _updateNumberOfRigCameras;
  48929. private _updateReferenceSpace;
  48930. private _updateReferenceSpaceOffset;
  48931. }
  48932. }
  48933. declare module "babylonjs/XR/webXRFeaturesManager" {
  48934. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48935. import { IDisposable } from "babylonjs/scene";
  48936. /**
  48937. * Defining the interface required for a (webxr) feature
  48938. */
  48939. export interface IWebXRFeature extends IDisposable {
  48940. /**
  48941. * Is this feature attached
  48942. */
  48943. attached: boolean;
  48944. /**
  48945. * Should auto-attach be disabled?
  48946. */
  48947. disableAutoAttach: boolean;
  48948. /**
  48949. * Attach the feature to the session
  48950. * Will usually be called by the features manager
  48951. *
  48952. * @param force should attachment be forced (even when already attached)
  48953. * @returns true if successful.
  48954. */
  48955. attach(force?: boolean): boolean;
  48956. /**
  48957. * Detach the feature from the session
  48958. * Will usually be called by the features manager
  48959. *
  48960. * @returns true if successful.
  48961. */
  48962. detach(): boolean;
  48963. /**
  48964. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48965. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48966. *
  48967. * @returns whether or not the feature is compatible in this environment
  48968. */
  48969. isCompatible(): boolean;
  48970. /**
  48971. * Was this feature disposed;
  48972. */
  48973. isDisposed: boolean;
  48974. /**
  48975. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  48976. */
  48977. xrNativeFeatureName?: string;
  48978. /**
  48979. * A list of (Babylon WebXR) features this feature depends on
  48980. */
  48981. dependsOn?: string[];
  48982. }
  48983. /**
  48984. * A list of the currently available features without referencing them
  48985. */
  48986. export class WebXRFeatureName {
  48987. /**
  48988. * The name of the anchor system feature
  48989. */
  48990. static readonly ANCHOR_SYSTEM: string;
  48991. /**
  48992. * The name of the background remover feature
  48993. */
  48994. static readonly BACKGROUND_REMOVER: string;
  48995. /**
  48996. * The name of the hit test feature
  48997. */
  48998. static readonly HIT_TEST: string;
  48999. /**
  49000. * physics impostors for xr controllers feature
  49001. */
  49002. static readonly PHYSICS_CONTROLLERS: string;
  49003. /**
  49004. * The name of the plane detection feature
  49005. */
  49006. static readonly PLANE_DETECTION: string;
  49007. /**
  49008. * The name of the pointer selection feature
  49009. */
  49010. static readonly POINTER_SELECTION: string;
  49011. /**
  49012. * The name of the teleportation feature
  49013. */
  49014. static readonly TELEPORTATION: string;
  49015. /**
  49016. * The name of the feature points feature.
  49017. */
  49018. static readonly FEATURE_POINTS: string;
  49019. /**
  49020. * The name of the hand tracking feature.
  49021. */
  49022. static readonly HAND_TRACKING: string;
  49023. }
  49024. /**
  49025. * Defining the constructor of a feature. Used to register the modules.
  49026. */
  49027. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  49028. /**
  49029. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  49030. * It is mainly used in AR sessions.
  49031. *
  49032. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  49033. */
  49034. export class WebXRFeaturesManager implements IDisposable {
  49035. private _xrSessionManager;
  49036. private static readonly _AvailableFeatures;
  49037. private _features;
  49038. /**
  49039. * constructs a new features manages.
  49040. *
  49041. * @param _xrSessionManager an instance of WebXRSessionManager
  49042. */
  49043. constructor(_xrSessionManager: WebXRSessionManager);
  49044. /**
  49045. * Used to register a module. After calling this function a developer can use this feature in the scene.
  49046. * Mainly used internally.
  49047. *
  49048. * @param featureName the name of the feature to register
  49049. * @param constructorFunction the function used to construct the module
  49050. * @param version the (babylon) version of the module
  49051. * @param stable is that a stable version of this module
  49052. */
  49053. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  49054. /**
  49055. * Returns a constructor of a specific feature.
  49056. *
  49057. * @param featureName the name of the feature to construct
  49058. * @param version the version of the feature to load
  49059. * @param xrSessionManager the xrSessionManager. Used to construct the module
  49060. * @param options optional options provided to the module.
  49061. * @returns a function that, when called, will return a new instance of this feature
  49062. */
  49063. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  49064. /**
  49065. * Can be used to return the list of features currently registered
  49066. *
  49067. * @returns an Array of available features
  49068. */
  49069. static GetAvailableFeatures(): string[];
  49070. /**
  49071. * Gets the versions available for a specific feature
  49072. * @param featureName the name of the feature
  49073. * @returns an array with the available versions
  49074. */
  49075. static GetAvailableVersions(featureName: string): string[];
  49076. /**
  49077. * Return the latest unstable version of this feature
  49078. * @param featureName the name of the feature to search
  49079. * @returns the version number. if not found will return -1
  49080. */
  49081. static GetLatestVersionOfFeature(featureName: string): number;
  49082. /**
  49083. * Return the latest stable version of this feature
  49084. * @param featureName the name of the feature to search
  49085. * @returns the version number. if not found will return -1
  49086. */
  49087. static GetStableVersionOfFeature(featureName: string): number;
  49088. /**
  49089. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  49090. * Can be used during a session to start a feature
  49091. * @param featureName the name of feature to attach
  49092. */
  49093. attachFeature(featureName: string): void;
  49094. /**
  49095. * Can be used inside a session or when the session ends to detach a specific feature
  49096. * @param featureName the name of the feature to detach
  49097. */
  49098. detachFeature(featureName: string): void;
  49099. /**
  49100. * Used to disable an already-enabled feature
  49101. * The feature will be disposed and will be recreated once enabled.
  49102. * @param featureName the feature to disable
  49103. * @returns true if disable was successful
  49104. */
  49105. disableFeature(featureName: string | {
  49106. Name: string;
  49107. }): boolean;
  49108. /**
  49109. * dispose this features manager
  49110. */
  49111. dispose(): void;
  49112. /**
  49113. * 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.
  49114. * 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.
  49115. *
  49116. * @param featureName the name of the feature to load or the class of the feature
  49117. * @param version optional version to load. if not provided the latest version will be enabled
  49118. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  49119. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  49120. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  49121. * @returns a new constructed feature or throws an error if feature not found.
  49122. */
  49123. enableFeature(featureName: string | {
  49124. Name: string;
  49125. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  49126. /**
  49127. * get the implementation of an enabled feature.
  49128. * @param featureName the name of the feature to load
  49129. * @returns the feature class, if found
  49130. */
  49131. getEnabledFeature(featureName: string): IWebXRFeature;
  49132. /**
  49133. * Get the list of enabled features
  49134. * @returns an array of enabled features
  49135. */
  49136. getEnabledFeatures(): string[];
  49137. /**
  49138. * This function will exten the session creation configuration object with enabled features.
  49139. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  49140. * according to the defined "required" variable, provided during enableFeature call
  49141. * @param xrSessionInit the xr Session init object to extend
  49142. *
  49143. * @returns an extended XRSessionInit object
  49144. */
  49145. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  49146. }
  49147. }
  49148. declare module "babylonjs/XR/webXRExperienceHelper" {
  49149. import { Observable } from "babylonjs/Misc/observable";
  49150. import { IDisposable, Scene } from "babylonjs/scene";
  49151. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49152. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49153. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49154. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49155. /**
  49156. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49157. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49158. */
  49159. export class WebXRExperienceHelper implements IDisposable {
  49160. private scene;
  49161. private _nonVRCamera;
  49162. private _originalSceneAutoClear;
  49163. private _supported;
  49164. /**
  49165. * Camera used to render xr content
  49166. */
  49167. camera: WebXRCamera;
  49168. /** A features manager for this xr session */
  49169. featuresManager: WebXRFeaturesManager;
  49170. /**
  49171. * Observers registered here will be triggered after the camera's initial transformation is set
  49172. * This can be used to set a different ground level or an extra rotation.
  49173. *
  49174. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49175. * to the position set after this observable is done executing.
  49176. */
  49177. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49178. /**
  49179. * Fires when the state of the experience helper has changed
  49180. */
  49181. onStateChangedObservable: Observable<WebXRState>;
  49182. /** Session manager used to keep track of xr session */
  49183. sessionManager: WebXRSessionManager;
  49184. /**
  49185. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49186. */
  49187. state: WebXRState;
  49188. /**
  49189. * Creates a WebXRExperienceHelper
  49190. * @param scene The scene the helper should be created in
  49191. */
  49192. private constructor();
  49193. /**
  49194. * Creates the experience helper
  49195. * @param scene the scene to attach the experience helper to
  49196. * @returns a promise for the experience helper
  49197. */
  49198. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49199. /**
  49200. * Disposes of the experience helper
  49201. */
  49202. dispose(): void;
  49203. /**
  49204. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49205. * @param sessionMode options for the XR session
  49206. * @param referenceSpaceType frame of reference of the XR session
  49207. * @param renderTarget the output canvas that will be used to enter XR mode
  49208. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49209. * @returns promise that resolves after xr mode has entered
  49210. */
  49211. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49212. /**
  49213. * Exits XR mode and returns the scene to its original state
  49214. * @returns promise that resolves after xr mode has exited
  49215. */
  49216. exitXRAsync(): Promise<void>;
  49217. private _nonXRToXRCamera;
  49218. private _setState;
  49219. }
  49220. }
  49221. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49222. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49223. import { Observable } from "babylonjs/Misc/observable";
  49224. import { IDisposable } from "babylonjs/scene";
  49225. /**
  49226. * X-Y values for axes in WebXR
  49227. */
  49228. export interface IWebXRMotionControllerAxesValue {
  49229. /**
  49230. * The value of the x axis
  49231. */
  49232. x: number;
  49233. /**
  49234. * The value of the y-axis
  49235. */
  49236. y: number;
  49237. }
  49238. /**
  49239. * changed / previous values for the values of this component
  49240. */
  49241. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49242. /**
  49243. * current (this frame) value
  49244. */
  49245. current: T;
  49246. /**
  49247. * previous (last change) value
  49248. */
  49249. previous: T;
  49250. }
  49251. /**
  49252. * Represents changes in the component between current frame and last values recorded
  49253. */
  49254. export interface IWebXRMotionControllerComponentChanges {
  49255. /**
  49256. * will be populated with previous and current values if axes changed
  49257. */
  49258. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49259. /**
  49260. * will be populated with previous and current values if pressed changed
  49261. */
  49262. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49263. /**
  49264. * will be populated with previous and current values if touched changed
  49265. */
  49266. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49267. /**
  49268. * will be populated with previous and current values if value changed
  49269. */
  49270. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49271. }
  49272. /**
  49273. * This class represents a single component (for example button or thumbstick) of a motion controller
  49274. */
  49275. export class WebXRControllerComponent implements IDisposable {
  49276. /**
  49277. * the id of this component
  49278. */
  49279. id: string;
  49280. /**
  49281. * the type of the component
  49282. */
  49283. type: MotionControllerComponentType;
  49284. private _buttonIndex;
  49285. private _axesIndices;
  49286. private _axes;
  49287. private _changes;
  49288. private _currentValue;
  49289. private _hasChanges;
  49290. private _pressed;
  49291. private _touched;
  49292. /**
  49293. * button component type
  49294. */
  49295. static BUTTON_TYPE: MotionControllerComponentType;
  49296. /**
  49297. * squeeze component type
  49298. */
  49299. static SQUEEZE_TYPE: MotionControllerComponentType;
  49300. /**
  49301. * Thumbstick component type
  49302. */
  49303. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49304. /**
  49305. * Touchpad component type
  49306. */
  49307. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49308. /**
  49309. * trigger component type
  49310. */
  49311. static TRIGGER_TYPE: MotionControllerComponentType;
  49312. /**
  49313. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49314. * the axes data changes
  49315. */
  49316. onAxisValueChangedObservable: Observable<{
  49317. x: number;
  49318. y: number;
  49319. }>;
  49320. /**
  49321. * Observers registered here will be triggered when the state of a button changes
  49322. * State change is either pressed / touched / value
  49323. */
  49324. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49325. /**
  49326. * Creates a new component for a motion controller.
  49327. * It is created by the motion controller itself
  49328. *
  49329. * @param id the id of this component
  49330. * @param type the type of the component
  49331. * @param _buttonIndex index in the buttons array of the gamepad
  49332. * @param _axesIndices indices of the values in the axes array of the gamepad
  49333. */
  49334. constructor(
  49335. /**
  49336. * the id of this component
  49337. */
  49338. id: string,
  49339. /**
  49340. * the type of the component
  49341. */
  49342. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49343. /**
  49344. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49345. */
  49346. get axes(): IWebXRMotionControllerAxesValue;
  49347. /**
  49348. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49349. */
  49350. get changes(): IWebXRMotionControllerComponentChanges;
  49351. /**
  49352. * Return whether or not the component changed the last frame
  49353. */
  49354. get hasChanges(): boolean;
  49355. /**
  49356. * is the button currently pressed
  49357. */
  49358. get pressed(): boolean;
  49359. /**
  49360. * is the button currently touched
  49361. */
  49362. get touched(): boolean;
  49363. /**
  49364. * Get the current value of this component
  49365. */
  49366. get value(): number;
  49367. /**
  49368. * Dispose this component
  49369. */
  49370. dispose(): void;
  49371. /**
  49372. * Are there axes correlating to this component
  49373. * @return true is axes data is available
  49374. */
  49375. isAxes(): boolean;
  49376. /**
  49377. * Is this component a button (hence - pressable)
  49378. * @returns true if can be pressed
  49379. */
  49380. isButton(): boolean;
  49381. /**
  49382. * update this component using the gamepad object it is in. Called on every frame
  49383. * @param nativeController the native gamepad controller object
  49384. */
  49385. update(nativeController: IMinimalMotionControllerObject): void;
  49386. }
  49387. }
  49388. declare module "babylonjs/Loading/sceneLoader" {
  49389. import { Observable } from "babylonjs/Misc/observable";
  49390. import { Nullable } from "babylonjs/types";
  49391. import { Scene } from "babylonjs/scene";
  49392. import { Engine } from "babylonjs/Engines/engine";
  49393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49394. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49395. import { AssetContainer } from "babylonjs/assetContainer";
  49396. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49397. import { Skeleton } from "babylonjs/Bones/skeleton";
  49398. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49399. import { WebRequest } from "babylonjs/Misc/webRequest";
  49400. /**
  49401. * Interface used to represent data loading progression
  49402. */
  49403. export interface ISceneLoaderProgressEvent {
  49404. /**
  49405. * Defines if data length to load can be evaluated
  49406. */
  49407. readonly lengthComputable: boolean;
  49408. /**
  49409. * Defines the loaded data length
  49410. */
  49411. readonly loaded: number;
  49412. /**
  49413. * Defines the data length to load
  49414. */
  49415. readonly total: number;
  49416. }
  49417. /**
  49418. * Interface used by SceneLoader plugins to define supported file extensions
  49419. */
  49420. export interface ISceneLoaderPluginExtensions {
  49421. /**
  49422. * Defines the list of supported extensions
  49423. */
  49424. [extension: string]: {
  49425. isBinary: boolean;
  49426. };
  49427. }
  49428. /**
  49429. * Interface used by SceneLoader plugin factory
  49430. */
  49431. export interface ISceneLoaderPluginFactory {
  49432. /**
  49433. * Defines the name of the factory
  49434. */
  49435. name: string;
  49436. /**
  49437. * Function called to create a new plugin
  49438. * @return the new plugin
  49439. */
  49440. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49441. /**
  49442. * The callback that returns true if the data can be directly loaded.
  49443. * @param data string containing the file data
  49444. * @returns if the data can be loaded directly
  49445. */
  49446. canDirectLoad?(data: string): boolean;
  49447. }
  49448. /**
  49449. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49450. */
  49451. export interface ISceneLoaderPluginBase {
  49452. /**
  49453. * The friendly name of this plugin.
  49454. */
  49455. name: string;
  49456. /**
  49457. * The file extensions supported by this plugin.
  49458. */
  49459. extensions: string | ISceneLoaderPluginExtensions;
  49460. /**
  49461. * The callback called when loading from a url.
  49462. * @param scene scene loading this url
  49463. * @param url url to load
  49464. * @param onSuccess callback called when the file successfully loads
  49465. * @param onProgress callback called while file is loading (if the server supports this mode)
  49466. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49467. * @param onError callback called when the file fails to load
  49468. * @returns a file request object
  49469. */
  49470. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49471. /**
  49472. * The callback called when loading from a file object.
  49473. * @param scene scene loading this file
  49474. * @param file defines the file to load
  49475. * @param onSuccess defines the callback to call when data is loaded
  49476. * @param onProgress defines the callback to call during loading process
  49477. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49478. * @param onError defines the callback to call when an error occurs
  49479. * @returns a file request object
  49480. */
  49481. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49482. /**
  49483. * The callback that returns true if the data can be directly loaded.
  49484. * @param data string containing the file data
  49485. * @returns if the data can be loaded directly
  49486. */
  49487. canDirectLoad?(data: string): boolean;
  49488. /**
  49489. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49490. * @param scene scene loading this data
  49491. * @param data string containing the data
  49492. * @returns data to pass to the plugin
  49493. */
  49494. directLoad?(scene: Scene, data: string): any;
  49495. /**
  49496. * The callback that allows custom handling of the root url based on the response url.
  49497. * @param rootUrl the original root url
  49498. * @param responseURL the response url if available
  49499. * @returns the new root url
  49500. */
  49501. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49502. }
  49503. /**
  49504. * Interface used to define a SceneLoader plugin
  49505. */
  49506. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49507. /**
  49508. * Import meshes into a scene.
  49509. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49510. * @param scene The scene to import into
  49511. * @param data The data to import
  49512. * @param rootUrl The root url for scene and resources
  49513. * @param meshes The meshes array to import into
  49514. * @param particleSystems The particle systems array to import into
  49515. * @param skeletons The skeletons array to import into
  49516. * @param onError The callback when import fails
  49517. * @returns True if successful or false otherwise
  49518. */
  49519. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49520. /**
  49521. * Load into a scene.
  49522. * @param scene The scene to load into
  49523. * @param data The data to import
  49524. * @param rootUrl The root url for scene and resources
  49525. * @param onError The callback when import fails
  49526. * @returns True if successful or false otherwise
  49527. */
  49528. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49529. /**
  49530. * Load into an asset container.
  49531. * @param scene The scene to load into
  49532. * @param data The data to import
  49533. * @param rootUrl The root url for scene and resources
  49534. * @param onError The callback when import fails
  49535. * @returns The loaded asset container
  49536. */
  49537. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49538. }
  49539. /**
  49540. * Interface used to define an async SceneLoader plugin
  49541. */
  49542. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49543. /**
  49544. * Import meshes into a scene.
  49545. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49546. * @param scene The scene to import into
  49547. * @param data The data to import
  49548. * @param rootUrl The root url for scene and resources
  49549. * @param onProgress The callback when the load progresses
  49550. * @param fileName Defines the name of the file to load
  49551. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49552. */
  49553. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49554. meshes: AbstractMesh[];
  49555. particleSystems: IParticleSystem[];
  49556. skeletons: Skeleton[];
  49557. animationGroups: AnimationGroup[];
  49558. }>;
  49559. /**
  49560. * Load into a scene.
  49561. * @param scene The scene to load into
  49562. * @param data The data to import
  49563. * @param rootUrl The root url for scene and resources
  49564. * @param onProgress The callback when the load progresses
  49565. * @param fileName Defines the name of the file to load
  49566. * @returns Nothing
  49567. */
  49568. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49569. /**
  49570. * Load into an asset container.
  49571. * @param scene The scene to load into
  49572. * @param data The data to import
  49573. * @param rootUrl The root url for scene and resources
  49574. * @param onProgress The callback when the load progresses
  49575. * @param fileName Defines the name of the file to load
  49576. * @returns The loaded asset container
  49577. */
  49578. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49579. }
  49580. /**
  49581. * Mode that determines how to handle old animation groups before loading new ones.
  49582. */
  49583. export enum SceneLoaderAnimationGroupLoadingMode {
  49584. /**
  49585. * Reset all old animations to initial state then dispose them.
  49586. */
  49587. Clean = 0,
  49588. /**
  49589. * Stop all old animations.
  49590. */
  49591. Stop = 1,
  49592. /**
  49593. * Restart old animations from first frame.
  49594. */
  49595. Sync = 2,
  49596. /**
  49597. * Old animations remains untouched.
  49598. */
  49599. NoSync = 3
  49600. }
  49601. /**
  49602. * Defines a plugin registered by the SceneLoader
  49603. */
  49604. interface IRegisteredPlugin {
  49605. /**
  49606. * Defines the plugin to use
  49607. */
  49608. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49609. /**
  49610. * Defines if the plugin supports binary data
  49611. */
  49612. isBinary: boolean;
  49613. }
  49614. /**
  49615. * Class used to load scene from various file formats using registered plugins
  49616. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49617. */
  49618. export class SceneLoader {
  49619. /**
  49620. * No logging while loading
  49621. */
  49622. static readonly NO_LOGGING: number;
  49623. /**
  49624. * Minimal logging while loading
  49625. */
  49626. static readonly MINIMAL_LOGGING: number;
  49627. /**
  49628. * Summary logging while loading
  49629. */
  49630. static readonly SUMMARY_LOGGING: number;
  49631. /**
  49632. * Detailled logging while loading
  49633. */
  49634. static readonly DETAILED_LOGGING: number;
  49635. /**
  49636. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49637. */
  49638. static get ForceFullSceneLoadingForIncremental(): boolean;
  49639. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49640. /**
  49641. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49642. */
  49643. static get ShowLoadingScreen(): boolean;
  49644. static set ShowLoadingScreen(value: boolean);
  49645. /**
  49646. * Defines the current logging level (while loading the scene)
  49647. * @ignorenaming
  49648. */
  49649. static get loggingLevel(): number;
  49650. static set loggingLevel(value: number);
  49651. /**
  49652. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49653. */
  49654. static get CleanBoneMatrixWeights(): boolean;
  49655. static set CleanBoneMatrixWeights(value: boolean);
  49656. /**
  49657. * Event raised when a plugin is used to load a scene
  49658. */
  49659. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49660. private static _registeredPlugins;
  49661. private static _showingLoadingScreen;
  49662. /**
  49663. * Gets the default plugin (used to load Babylon files)
  49664. * @returns the .babylon plugin
  49665. */
  49666. static GetDefaultPlugin(): IRegisteredPlugin;
  49667. private static _GetPluginForExtension;
  49668. private static _GetPluginForDirectLoad;
  49669. private static _GetPluginForFilename;
  49670. private static _GetDirectLoad;
  49671. private static _LoadData;
  49672. private static _GetFileInfo;
  49673. /**
  49674. * Gets a plugin that can load the given extension
  49675. * @param extension defines the extension to load
  49676. * @returns a plugin or null if none works
  49677. */
  49678. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49679. /**
  49680. * Gets a boolean indicating that the given extension can be loaded
  49681. * @param extension defines the extension to load
  49682. * @returns true if the extension is supported
  49683. */
  49684. static IsPluginForExtensionAvailable(extension: string): boolean;
  49685. /**
  49686. * Adds a new plugin to the list of registered plugins
  49687. * @param plugin defines the plugin to add
  49688. */
  49689. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49690. /**
  49691. * Import meshes into a scene
  49692. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49693. * @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)
  49694. * @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)
  49695. * @param scene the instance of BABYLON.Scene to append to
  49696. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49697. * @param onProgress a callback with a progress event for each file being loaded
  49698. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49699. * @param pluginExtension the extension used to determine the plugin
  49700. * @returns The loaded plugin
  49701. */
  49702. 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>;
  49703. /**
  49704. * Import meshes into a scene
  49705. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49706. * @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)
  49707. * @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)
  49708. * @param scene the instance of BABYLON.Scene to append to
  49709. * @param onProgress a callback with a progress event for each file being loaded
  49710. * @param pluginExtension the extension used to determine the plugin
  49711. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49712. */
  49713. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49714. meshes: AbstractMesh[];
  49715. particleSystems: IParticleSystem[];
  49716. skeletons: Skeleton[];
  49717. animationGroups: AnimationGroup[];
  49718. }>;
  49719. /**
  49720. * Load a scene
  49721. * @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)
  49722. * @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)
  49723. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49724. * @param onSuccess a callback with the scene when import succeeds
  49725. * @param onProgress a callback with a progress event for each file being loaded
  49726. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49727. * @param pluginExtension the extension used to determine the plugin
  49728. * @returns The loaded plugin
  49729. */
  49730. 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>;
  49731. /**
  49732. * Load a scene
  49733. * @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)
  49734. * @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)
  49735. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49736. * @param onProgress a callback with a progress event for each file being loaded
  49737. * @param pluginExtension the extension used to determine the plugin
  49738. * @returns The loaded scene
  49739. */
  49740. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49741. /**
  49742. * Append a scene
  49743. * @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)
  49744. * @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)
  49745. * @param scene is the instance of BABYLON.Scene to append to
  49746. * @param onSuccess a callback with the scene when import succeeds
  49747. * @param onProgress a callback with a progress event for each file being loaded
  49748. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49749. * @param pluginExtension the extension used to determine the plugin
  49750. * @returns The loaded plugin
  49751. */
  49752. 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>;
  49753. /**
  49754. * Append a scene
  49755. * @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)
  49756. * @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)
  49757. * @param scene is the instance of BABYLON.Scene to append to
  49758. * @param onProgress a callback with a progress event for each file being loaded
  49759. * @param pluginExtension the extension used to determine the plugin
  49760. * @returns The given scene
  49761. */
  49762. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49763. /**
  49764. * Load a scene into an asset container
  49765. * @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)
  49766. * @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)
  49767. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49768. * @param onSuccess a callback with the scene when import succeeds
  49769. * @param onProgress a callback with a progress event for each file being loaded
  49770. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49771. * @param pluginExtension the extension used to determine the plugin
  49772. * @returns The loaded plugin
  49773. */
  49774. 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>;
  49775. /**
  49776. * Load a scene into an asset container
  49777. * @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)
  49778. * @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)
  49779. * @param scene is the instance of Scene to append to
  49780. * @param onProgress a callback with a progress event for each file being loaded
  49781. * @param pluginExtension the extension used to determine the plugin
  49782. * @returns The loaded asset container
  49783. */
  49784. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49785. /**
  49786. * Import animations from a file into a scene
  49787. * @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)
  49788. * @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)
  49789. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49790. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49791. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49792. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49793. * @param onSuccess a callback with the scene when import succeeds
  49794. * @param onProgress a callback with a progress event for each file being loaded
  49795. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49796. * @param pluginExtension the extension used to determine the plugin
  49797. */
  49798. 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;
  49799. /**
  49800. * Import animations from a file into a scene
  49801. * @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)
  49802. * @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)
  49803. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49804. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49805. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49806. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49807. * @param onSuccess a callback with the scene when import succeeds
  49808. * @param onProgress a callback with a progress event for each file being loaded
  49809. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49810. * @param pluginExtension the extension used to determine the plugin
  49811. * @returns the updated scene with imported animations
  49812. */
  49813. 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>;
  49814. }
  49815. }
  49816. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49817. import { IDisposable, Scene } from "babylonjs/scene";
  49818. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49819. import { Observable } from "babylonjs/Misc/observable";
  49820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49821. import { Nullable } from "babylonjs/types";
  49822. /**
  49823. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49824. */
  49825. export type MotionControllerHandedness = "none" | "left" | "right";
  49826. /**
  49827. * The type of components available in motion controllers.
  49828. * This is not the name of the component.
  49829. */
  49830. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49831. /**
  49832. * The state of a controller component
  49833. */
  49834. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49835. /**
  49836. * The schema of motion controller layout.
  49837. * No object will be initialized using this interface
  49838. * This is used just to define the profile.
  49839. */
  49840. export interface IMotionControllerLayout {
  49841. /**
  49842. * Path to load the assets. Usually relative to the base path
  49843. */
  49844. assetPath: string;
  49845. /**
  49846. * Available components (unsorted)
  49847. */
  49848. components: {
  49849. /**
  49850. * A map of component Ids
  49851. */
  49852. [componentId: string]: {
  49853. /**
  49854. * The type of input the component outputs
  49855. */
  49856. type: MotionControllerComponentType;
  49857. /**
  49858. * The indices of this component in the gamepad object
  49859. */
  49860. gamepadIndices: {
  49861. /**
  49862. * Index of button
  49863. */
  49864. button?: number;
  49865. /**
  49866. * If available, index of x-axis
  49867. */
  49868. xAxis?: number;
  49869. /**
  49870. * If available, index of y-axis
  49871. */
  49872. yAxis?: number;
  49873. };
  49874. /**
  49875. * The mesh's root node name
  49876. */
  49877. rootNodeName: string;
  49878. /**
  49879. * Animation definitions for this model
  49880. */
  49881. visualResponses: {
  49882. [stateKey: string]: {
  49883. /**
  49884. * What property will be animated
  49885. */
  49886. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49887. /**
  49888. * What states influence this visual response
  49889. */
  49890. states: MotionControllerComponentStateType[];
  49891. /**
  49892. * Type of animation - movement or visibility
  49893. */
  49894. valueNodeProperty: "transform" | "visibility";
  49895. /**
  49896. * Base node name to move. Its position will be calculated according to the min and max nodes
  49897. */
  49898. valueNodeName?: string;
  49899. /**
  49900. * Minimum movement node
  49901. */
  49902. minNodeName?: string;
  49903. /**
  49904. * Max movement node
  49905. */
  49906. maxNodeName?: string;
  49907. };
  49908. };
  49909. /**
  49910. * If touch enabled, what is the name of node to display user feedback
  49911. */
  49912. touchPointNodeName?: string;
  49913. };
  49914. };
  49915. /**
  49916. * Is it xr standard mapping or not
  49917. */
  49918. gamepadMapping: "" | "xr-standard";
  49919. /**
  49920. * Base root node of this entire model
  49921. */
  49922. rootNodeName: string;
  49923. /**
  49924. * Defines the main button component id
  49925. */
  49926. selectComponentId: string;
  49927. }
  49928. /**
  49929. * A definition for the layout map in the input profile
  49930. */
  49931. export interface IMotionControllerLayoutMap {
  49932. /**
  49933. * Layouts with handedness type as a key
  49934. */
  49935. [handedness: string]: IMotionControllerLayout;
  49936. }
  49937. /**
  49938. * The XR Input profile schema
  49939. * Profiles can be found here:
  49940. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49941. */
  49942. export interface IMotionControllerProfile {
  49943. /**
  49944. * fallback profiles for this profileId
  49945. */
  49946. fallbackProfileIds: string[];
  49947. /**
  49948. * The layout map, with handedness as key
  49949. */
  49950. layouts: IMotionControllerLayoutMap;
  49951. /**
  49952. * The id of this profile
  49953. * correlates to the profile(s) in the xrInput.profiles array
  49954. */
  49955. profileId: string;
  49956. }
  49957. /**
  49958. * A helper-interface for the 3 meshes needed for controller button animation
  49959. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  49960. */
  49961. export interface IMotionControllerButtonMeshMap {
  49962. /**
  49963. * the mesh that defines the pressed value mesh position.
  49964. * This is used to find the max-position of this button
  49965. */
  49966. pressedMesh: AbstractMesh;
  49967. /**
  49968. * the mesh that defines the unpressed value mesh position.
  49969. * This is used to find the min (or initial) position of this button
  49970. */
  49971. unpressedMesh: AbstractMesh;
  49972. /**
  49973. * The mesh that will be changed when value changes
  49974. */
  49975. valueMesh: AbstractMesh;
  49976. }
  49977. /**
  49978. * A helper-interface for the 3 meshes needed for controller axis animation.
  49979. * This will be expanded when touchpad animations are fully supported
  49980. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  49981. */
  49982. export interface IMotionControllerMeshMap {
  49983. /**
  49984. * the mesh that defines the maximum value mesh position.
  49985. */
  49986. maxMesh?: AbstractMesh;
  49987. /**
  49988. * the mesh that defines the minimum value mesh position.
  49989. */
  49990. minMesh?: AbstractMesh;
  49991. /**
  49992. * The mesh that will be changed when axis value changes
  49993. */
  49994. valueMesh?: AbstractMesh;
  49995. }
  49996. /**
  49997. * The elements needed for change-detection of the gamepad objects in motion controllers
  49998. */
  49999. export interface IMinimalMotionControllerObject {
  50000. /**
  50001. * Available axes of this controller
  50002. */
  50003. axes: number[];
  50004. /**
  50005. * An array of available buttons
  50006. */
  50007. buttons: Array<{
  50008. /**
  50009. * Value of the button/trigger
  50010. */
  50011. value: number;
  50012. /**
  50013. * If the button/trigger is currently touched
  50014. */
  50015. touched: boolean;
  50016. /**
  50017. * If the button/trigger is currently pressed
  50018. */
  50019. pressed: boolean;
  50020. }>;
  50021. /**
  50022. * EXPERIMENTAL haptic support.
  50023. */
  50024. hapticActuators?: Array<{
  50025. pulse: (value: number, duration: number) => Promise<boolean>;
  50026. }>;
  50027. }
  50028. /**
  50029. * An Abstract Motion controller
  50030. * This class receives an xrInput and a profile layout and uses those to initialize the components
  50031. * Each component has an observable to check for changes in value and state
  50032. */
  50033. export abstract class WebXRAbstractMotionController implements IDisposable {
  50034. protected scene: Scene;
  50035. protected layout: IMotionControllerLayout;
  50036. /**
  50037. * The gamepad object correlating to this controller
  50038. */
  50039. gamepadObject: IMinimalMotionControllerObject;
  50040. /**
  50041. * handedness (left/right/none) of this controller
  50042. */
  50043. handedness: MotionControllerHandedness;
  50044. private _initComponent;
  50045. private _modelReady;
  50046. /**
  50047. * A map of components (WebXRControllerComponent) in this motion controller
  50048. * Components have a ComponentType and can also have both button and axis definitions
  50049. */
  50050. readonly components: {
  50051. [id: string]: WebXRControllerComponent;
  50052. };
  50053. /**
  50054. * Disable the model's animation. Can be set at any time.
  50055. */
  50056. disableAnimation: boolean;
  50057. /**
  50058. * Observers registered here will be triggered when the model of this controller is done loading
  50059. */
  50060. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  50061. /**
  50062. * The profile id of this motion controller
  50063. */
  50064. abstract profileId: string;
  50065. /**
  50066. * The root mesh of the model. It is null if the model was not yet initialized
  50067. */
  50068. rootMesh: Nullable<AbstractMesh>;
  50069. /**
  50070. * constructs a new abstract motion controller
  50071. * @param scene the scene to which the model of the controller will be added
  50072. * @param layout The profile layout to load
  50073. * @param gamepadObject The gamepad object correlating to this controller
  50074. * @param handedness handedness (left/right/none) of this controller
  50075. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  50076. */
  50077. constructor(scene: Scene, layout: IMotionControllerLayout,
  50078. /**
  50079. * The gamepad object correlating to this controller
  50080. */
  50081. gamepadObject: IMinimalMotionControllerObject,
  50082. /**
  50083. * handedness (left/right/none) of this controller
  50084. */
  50085. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  50086. /**
  50087. * Dispose this controller, the model mesh and all its components
  50088. */
  50089. dispose(): void;
  50090. /**
  50091. * Returns all components of specific type
  50092. * @param type the type to search for
  50093. * @return an array of components with this type
  50094. */
  50095. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  50096. /**
  50097. * get a component based an its component id as defined in layout.components
  50098. * @param id the id of the component
  50099. * @returns the component correlates to the id or undefined if not found
  50100. */
  50101. getComponent(id: string): WebXRControllerComponent;
  50102. /**
  50103. * Get the list of components available in this motion controller
  50104. * @returns an array of strings correlating to available components
  50105. */
  50106. getComponentIds(): string[];
  50107. /**
  50108. * Get the first component of specific type
  50109. * @param type type of component to find
  50110. * @return a controller component or null if not found
  50111. */
  50112. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  50113. /**
  50114. * Get the main (Select) component of this controller as defined in the layout
  50115. * @returns the main component of this controller
  50116. */
  50117. getMainComponent(): WebXRControllerComponent;
  50118. /**
  50119. * Loads the model correlating to this controller
  50120. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  50121. * @returns A promise fulfilled with the result of the model loading
  50122. */
  50123. loadModel(): Promise<boolean>;
  50124. /**
  50125. * Update this model using the current XRFrame
  50126. * @param xrFrame the current xr frame to use and update the model
  50127. */
  50128. updateFromXRFrame(xrFrame: XRFrame): void;
  50129. /**
  50130. * Backwards compatibility due to a deeply-integrated typo
  50131. */
  50132. get handness(): XREye;
  50133. /**
  50134. * Pulse (vibrate) this controller
  50135. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  50136. * Consecutive calls to this function will cancel the last pulse call
  50137. *
  50138. * @param value the strength of the pulse in 0.0...1.0 range
  50139. * @param duration Duration of the pulse in milliseconds
  50140. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  50141. * @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
  50142. */
  50143. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  50144. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50145. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50146. /**
  50147. * Moves the axis on the controller mesh based on its current state
  50148. * @param axis the index of the axis
  50149. * @param axisValue the value of the axis which determines the meshes new position
  50150. * @hidden
  50151. */
  50152. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  50153. /**
  50154. * Update the model itself with the current frame data
  50155. * @param xrFrame the frame to use for updating the model mesh
  50156. */
  50157. protected updateModel(xrFrame: XRFrame): void;
  50158. /**
  50159. * Get the filename and path for this controller's model
  50160. * @returns a map of filename and path
  50161. */
  50162. protected abstract _getFilenameAndPath(): {
  50163. filename: string;
  50164. path: string;
  50165. };
  50166. /**
  50167. * This function is called before the mesh is loaded. It checks for loading constraints.
  50168. * For example, this function can check if the GLB loader is available
  50169. * If this function returns false, the generic controller will be loaded instead
  50170. * @returns Is the client ready to load the mesh
  50171. */
  50172. protected abstract _getModelLoadingConstraints(): boolean;
  50173. /**
  50174. * This function will be called after the model was successfully loaded and can be used
  50175. * for mesh transformations before it is available for the user
  50176. * @param meshes the loaded meshes
  50177. */
  50178. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50179. /**
  50180. * Set the root mesh for this controller. Important for the WebXR controller class
  50181. * @param meshes the loaded meshes
  50182. */
  50183. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50184. /**
  50185. * A function executed each frame that updates the mesh (if needed)
  50186. * @param xrFrame the current xrFrame
  50187. */
  50188. protected abstract _updateModel(xrFrame: XRFrame): void;
  50189. private _getGenericFilenameAndPath;
  50190. private _getGenericParentMesh;
  50191. }
  50192. }
  50193. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50194. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50196. import { Scene } from "babylonjs/scene";
  50197. /**
  50198. * A generic trigger-only motion controller for WebXR
  50199. */
  50200. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50201. /**
  50202. * Static version of the profile id of this controller
  50203. */
  50204. static ProfileId: string;
  50205. profileId: string;
  50206. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50207. protected _getFilenameAndPath(): {
  50208. filename: string;
  50209. path: string;
  50210. };
  50211. protected _getModelLoadingConstraints(): boolean;
  50212. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50213. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50214. protected _updateModel(): void;
  50215. }
  50216. }
  50217. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50218. import { Vector4 } from "babylonjs/Maths/math.vector";
  50219. import { Mesh } from "babylonjs/Meshes/mesh";
  50220. import { Scene } from "babylonjs/scene";
  50221. import { Nullable } from "babylonjs/types";
  50222. /**
  50223. * Class containing static functions to help procedurally build meshes
  50224. */
  50225. export class SphereBuilder {
  50226. /**
  50227. * Creates a sphere mesh
  50228. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50229. * * 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`)
  50230. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50231. * * 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
  50232. * * 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)
  50233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50234. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50236. * @param name defines the name of the mesh
  50237. * @param options defines the options used to create the mesh
  50238. * @param scene defines the hosting scene
  50239. * @returns the sphere mesh
  50240. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50241. */
  50242. static CreateSphere(name: string, options: {
  50243. segments?: number;
  50244. diameter?: number;
  50245. diameterX?: number;
  50246. diameterY?: number;
  50247. diameterZ?: number;
  50248. arc?: number;
  50249. slice?: number;
  50250. sideOrientation?: number;
  50251. frontUVs?: Vector4;
  50252. backUVs?: Vector4;
  50253. updatable?: boolean;
  50254. }, scene?: Nullable<Scene>): Mesh;
  50255. }
  50256. }
  50257. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50259. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50260. import { Scene } from "babylonjs/scene";
  50261. /**
  50262. * A profiled motion controller has its profile loaded from an online repository.
  50263. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50264. */
  50265. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50266. private _repositoryUrl;
  50267. private _buttonMeshMapping;
  50268. private _touchDots;
  50269. /**
  50270. * The profile ID of this controller. Will be populated when the controller initializes.
  50271. */
  50272. profileId: string;
  50273. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50274. dispose(): void;
  50275. protected _getFilenameAndPath(): {
  50276. filename: string;
  50277. path: string;
  50278. };
  50279. protected _getModelLoadingConstraints(): boolean;
  50280. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50281. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50282. protected _updateModel(_xrFrame: XRFrame): void;
  50283. }
  50284. }
  50285. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50286. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50287. import { Scene } from "babylonjs/scene";
  50288. /**
  50289. * A construction function type to create a new controller based on an xrInput object
  50290. */
  50291. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50292. /**
  50293. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50294. *
  50295. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50296. * it should be replaced with auto-loaded controllers.
  50297. *
  50298. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50299. */
  50300. export class WebXRMotionControllerManager {
  50301. private static _AvailableControllers;
  50302. private static _Fallbacks;
  50303. private static _ProfileLoadingPromises;
  50304. private static _ProfilesList;
  50305. /**
  50306. * The base URL of the online controller repository. Can be changed at any time.
  50307. */
  50308. static BaseRepositoryUrl: string;
  50309. /**
  50310. * Which repository gets priority - local or online
  50311. */
  50312. static PrioritizeOnlineRepository: boolean;
  50313. /**
  50314. * Use the online repository, or use only locally-defined controllers
  50315. */
  50316. static UseOnlineRepository: boolean;
  50317. /**
  50318. * Clear the cache used for profile loading and reload when requested again
  50319. */
  50320. static ClearProfilesCache(): void;
  50321. /**
  50322. * Register the default fallbacks.
  50323. * This function is called automatically when this file is imported.
  50324. */
  50325. static DefaultFallbacks(): void;
  50326. /**
  50327. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50328. * @param profileId the profile to which a fallback needs to be found
  50329. * @return an array with corresponding fallback profiles
  50330. */
  50331. static FindFallbackWithProfileId(profileId: string): string[];
  50332. /**
  50333. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50334. * The order of search:
  50335. *
  50336. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50337. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50338. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50339. * 4) return the generic trigger controller if none were found
  50340. *
  50341. * @param xrInput the xrInput to which a new controller is initialized
  50342. * @param scene the scene to which the model will be added
  50343. * @param forceProfile force a certain profile for this controller
  50344. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50345. */
  50346. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50347. /**
  50348. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50349. *
  50350. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50351. *
  50352. * @param type the profile type to register
  50353. * @param constructFunction the function to be called when loading this profile
  50354. */
  50355. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50356. /**
  50357. * Register a fallback to a specific profile.
  50358. * @param profileId the profileId that will receive the fallbacks
  50359. * @param fallbacks A list of fallback profiles
  50360. */
  50361. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50362. /**
  50363. * Will update the list of profiles available in the repository
  50364. * @return a promise that resolves to a map of profiles available online
  50365. */
  50366. static UpdateProfilesList(): Promise<{
  50367. [profile: string]: string;
  50368. }>;
  50369. private static _LoadProfileFromRepository;
  50370. private static _LoadProfilesFromAvailableControllers;
  50371. }
  50372. }
  50373. declare module "babylonjs/XR/webXRInputSource" {
  50374. import { Observable } from "babylonjs/Misc/observable";
  50375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50376. import { Ray } from "babylonjs/Culling/ray";
  50377. import { Scene } from "babylonjs/scene";
  50378. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50379. /**
  50380. * Configuration options for the WebXR controller creation
  50381. */
  50382. export interface IWebXRControllerOptions {
  50383. /**
  50384. * Should the controller mesh be animated when a user interacts with it
  50385. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50386. */
  50387. disableMotionControllerAnimation?: boolean;
  50388. /**
  50389. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50390. */
  50391. doNotLoadControllerMesh?: boolean;
  50392. /**
  50393. * Force a specific controller type for this controller.
  50394. * This can be used when creating your own profile or when testing different controllers
  50395. */
  50396. forceControllerProfile?: string;
  50397. /**
  50398. * Defines a rendering group ID for meshes that will be loaded.
  50399. * This is for the default controllers only.
  50400. */
  50401. renderingGroupId?: number;
  50402. }
  50403. /**
  50404. * Represents an XR controller
  50405. */
  50406. export class WebXRInputSource {
  50407. private _scene;
  50408. /** The underlying input source for the controller */
  50409. inputSource: XRInputSource;
  50410. private _options;
  50411. private _tmpVector;
  50412. private _uniqueId;
  50413. private _disposed;
  50414. /**
  50415. * 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
  50416. */
  50417. grip?: AbstractMesh;
  50418. /**
  50419. * If available, this is the gamepad object related to this controller.
  50420. * Using this object it is possible to get click events and trackpad changes of the
  50421. * webxr controller that is currently being used.
  50422. */
  50423. motionController?: WebXRAbstractMotionController;
  50424. /**
  50425. * Event that fires when the controller is removed/disposed.
  50426. * The object provided as event data is this controller, after associated assets were disposed.
  50427. * uniqueId is still available.
  50428. */
  50429. onDisposeObservable: Observable<WebXRInputSource>;
  50430. /**
  50431. * Will be triggered when the mesh associated with the motion controller is done loading.
  50432. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50433. * A shortened version of controller -> motion controller -> on mesh loaded.
  50434. */
  50435. onMeshLoadedObservable: Observable<AbstractMesh>;
  50436. /**
  50437. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50438. */
  50439. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50440. /**
  50441. * Pointer which can be used to select objects or attach a visible laser to
  50442. */
  50443. pointer: AbstractMesh;
  50444. /**
  50445. * Creates the input source object
  50446. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50447. * @param _scene the scene which the controller should be associated to
  50448. * @param inputSource the underlying input source for the controller
  50449. * @param _options options for this controller creation
  50450. */
  50451. constructor(_scene: Scene,
  50452. /** The underlying input source for the controller */
  50453. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50454. /**
  50455. * Get this controllers unique id
  50456. */
  50457. get uniqueId(): string;
  50458. /**
  50459. * Disposes of the object
  50460. */
  50461. dispose(): void;
  50462. /**
  50463. * Gets a world space ray coming from the pointer or grip
  50464. * @param result the resulting ray
  50465. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50466. */
  50467. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50468. /**
  50469. * Updates the controller pose based on the given XRFrame
  50470. * @param xrFrame xr frame to update the pose with
  50471. * @param referenceSpace reference space to use
  50472. */
  50473. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50474. }
  50475. }
  50476. declare module "babylonjs/XR/webXRInput" {
  50477. import { Observable } from "babylonjs/Misc/observable";
  50478. import { IDisposable } from "babylonjs/scene";
  50479. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50480. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50481. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50482. /**
  50483. * The schema for initialization options of the XR Input class
  50484. */
  50485. export interface IWebXRInputOptions {
  50486. /**
  50487. * If set to true no model will be automatically loaded
  50488. */
  50489. doNotLoadControllerMeshes?: boolean;
  50490. /**
  50491. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50492. * If not found, the xr input profile data will be used.
  50493. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50494. */
  50495. forceInputProfile?: string;
  50496. /**
  50497. * Do not send a request to the controller repository to load the profile.
  50498. *
  50499. * Instead, use the controllers available in babylon itself.
  50500. */
  50501. disableOnlineControllerRepository?: boolean;
  50502. /**
  50503. * A custom URL for the controllers repository
  50504. */
  50505. customControllersRepositoryURL?: string;
  50506. /**
  50507. * Should the controller model's components not move according to the user input
  50508. */
  50509. disableControllerAnimation?: boolean;
  50510. /**
  50511. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50512. */
  50513. controllerOptions?: IWebXRControllerOptions;
  50514. }
  50515. /**
  50516. * XR input used to track XR inputs such as controllers/rays
  50517. */
  50518. export class WebXRInput implements IDisposable {
  50519. /**
  50520. * the xr session manager for this session
  50521. */
  50522. xrSessionManager: WebXRSessionManager;
  50523. /**
  50524. * the WebXR camera for this session. Mainly used for teleportation
  50525. */
  50526. xrCamera: WebXRCamera;
  50527. private readonly options;
  50528. /**
  50529. * XR controllers being tracked
  50530. */
  50531. controllers: Array<WebXRInputSource>;
  50532. private _frameObserver;
  50533. private _sessionEndedObserver;
  50534. private _sessionInitObserver;
  50535. /**
  50536. * Event when a controller has been connected/added
  50537. */
  50538. onControllerAddedObservable: Observable<WebXRInputSource>;
  50539. /**
  50540. * Event when a controller has been removed/disconnected
  50541. */
  50542. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50543. /**
  50544. * Initializes the WebXRInput
  50545. * @param xrSessionManager the xr session manager for this session
  50546. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50547. * @param options = initialization options for this xr input
  50548. */
  50549. constructor(
  50550. /**
  50551. * the xr session manager for this session
  50552. */
  50553. xrSessionManager: WebXRSessionManager,
  50554. /**
  50555. * the WebXR camera for this session. Mainly used for teleportation
  50556. */
  50557. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50558. private _onInputSourcesChange;
  50559. private _addAndRemoveControllers;
  50560. /**
  50561. * Disposes of the object
  50562. */
  50563. dispose(): void;
  50564. }
  50565. }
  50566. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50567. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50568. import { Observable, EventState } from "babylonjs/Misc/observable";
  50569. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50570. /**
  50571. * This is the base class for all WebXR features.
  50572. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50573. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50574. */
  50575. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50576. protected _xrSessionManager: WebXRSessionManager;
  50577. private _attached;
  50578. private _removeOnDetach;
  50579. /**
  50580. * Is this feature disposed?
  50581. */
  50582. isDisposed: boolean;
  50583. /**
  50584. * Should auto-attach be disabled?
  50585. */
  50586. disableAutoAttach: boolean;
  50587. /**
  50588. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50589. */
  50590. xrNativeFeatureName: string;
  50591. /**
  50592. * Construct a new (abstract) WebXR feature
  50593. * @param _xrSessionManager the xr session manager for this feature
  50594. */
  50595. constructor(_xrSessionManager: WebXRSessionManager);
  50596. /**
  50597. * Is this feature attached
  50598. */
  50599. get attached(): boolean;
  50600. /**
  50601. * attach this feature
  50602. *
  50603. * @param force should attachment be forced (even when already attached)
  50604. * @returns true if successful, false is failed or already attached
  50605. */
  50606. attach(force?: boolean): boolean;
  50607. /**
  50608. * detach this feature.
  50609. *
  50610. * @returns true if successful, false if failed or already detached
  50611. */
  50612. detach(): boolean;
  50613. /**
  50614. * Dispose this feature and all of the resources attached
  50615. */
  50616. dispose(): void;
  50617. /**
  50618. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50619. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50620. *
  50621. * @returns whether or not the feature is compatible in this environment
  50622. */
  50623. isCompatible(): boolean;
  50624. /**
  50625. * This is used to register callbacks that will automatically be removed when detach is called.
  50626. * @param observable the observable to which the observer will be attached
  50627. * @param callback the callback to register
  50628. */
  50629. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50630. /**
  50631. * Code in this function will be executed on each xrFrame received from the browser.
  50632. * This function will not execute after the feature is detached.
  50633. * @param _xrFrame the current frame
  50634. */
  50635. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50636. }
  50637. }
  50638. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50639. import { IDisposable, Scene } from "babylonjs/scene";
  50640. import { Nullable } from "babylonjs/types";
  50641. import { Observable } from "babylonjs/Misc/observable";
  50642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50643. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50644. import { Camera } from "babylonjs/Cameras/camera";
  50645. /**
  50646. * Renders a layer on top of an existing scene
  50647. */
  50648. export class UtilityLayerRenderer implements IDisposable {
  50649. /** the original scene that will be rendered on top of */
  50650. originalScene: Scene;
  50651. private _pointerCaptures;
  50652. private _lastPointerEvents;
  50653. private static _DefaultUtilityLayer;
  50654. private static _DefaultKeepDepthUtilityLayer;
  50655. private _sharedGizmoLight;
  50656. private _renderCamera;
  50657. /**
  50658. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50659. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50660. * @returns the camera that is used when rendering the utility layer
  50661. */
  50662. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50663. /**
  50664. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50665. * @param cam the camera that should be used when rendering the utility layer
  50666. */
  50667. setRenderCamera(cam: Nullable<Camera>): void;
  50668. /**
  50669. * @hidden
  50670. * Light which used by gizmos to get light shading
  50671. */
  50672. _getSharedGizmoLight(): HemisphericLight;
  50673. /**
  50674. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50675. */
  50676. pickUtilitySceneFirst: boolean;
  50677. /**
  50678. * 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)
  50679. */
  50680. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50681. /**
  50682. * 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)
  50683. */
  50684. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50685. /**
  50686. * The scene that is rendered on top of the original scene
  50687. */
  50688. utilityLayerScene: Scene;
  50689. /**
  50690. * If the utility layer should automatically be rendered on top of existing scene
  50691. */
  50692. shouldRender: boolean;
  50693. /**
  50694. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50695. */
  50696. onlyCheckPointerDownEvents: boolean;
  50697. /**
  50698. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50699. */
  50700. processAllEvents: boolean;
  50701. /**
  50702. * Observable raised when the pointer move from the utility layer scene to the main scene
  50703. */
  50704. onPointerOutObservable: Observable<number>;
  50705. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50706. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50707. private _afterRenderObserver;
  50708. private _sceneDisposeObserver;
  50709. private _originalPointerObserver;
  50710. /**
  50711. * Instantiates a UtilityLayerRenderer
  50712. * @param originalScene the original scene that will be rendered on top of
  50713. * @param handleEvents boolean indicating if the utility layer should handle events
  50714. */
  50715. constructor(
  50716. /** the original scene that will be rendered on top of */
  50717. originalScene: Scene, handleEvents?: boolean);
  50718. private _notifyObservers;
  50719. /**
  50720. * Renders the utility layers scene on top of the original scene
  50721. */
  50722. render(): void;
  50723. /**
  50724. * Disposes of the renderer
  50725. */
  50726. dispose(): void;
  50727. private _updateCamera;
  50728. }
  50729. }
  50730. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50731. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50733. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50734. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50735. import { Scene } from "babylonjs/scene";
  50736. import { Nullable } from "babylonjs/types";
  50737. import { Color3 } from "babylonjs/Maths/math.color";
  50738. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50739. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50740. /**
  50741. * Options interface for the pointer selection module
  50742. */
  50743. export interface IWebXRControllerPointerSelectionOptions {
  50744. /**
  50745. * if provided, this scene will be used to render meshes.
  50746. */
  50747. customUtilityLayerScene?: Scene;
  50748. /**
  50749. * 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)
  50750. * If not disabled, the last picked point will be used to execute a pointer up event
  50751. * If disabled, pointer up event will be triggered right after the pointer down event.
  50752. * Used in screen and gaze target ray mode only
  50753. */
  50754. disablePointerUpOnTouchOut: boolean;
  50755. /**
  50756. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50757. */
  50758. forceGazeMode: boolean;
  50759. /**
  50760. * 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
  50761. * to start a new countdown to the pointer down event.
  50762. * Defaults to 1.
  50763. */
  50764. gazeModePointerMovedFactor?: number;
  50765. /**
  50766. * Different button type to use instead of the main component
  50767. */
  50768. overrideButtonId?: string;
  50769. /**
  50770. * use this rendering group id for the meshes (optional)
  50771. */
  50772. renderingGroupId?: number;
  50773. /**
  50774. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50775. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50776. * 3000 means 3 seconds between pointing at something and selecting it
  50777. */
  50778. timeToSelect?: number;
  50779. /**
  50780. * Should meshes created here be added to a utility layer or the main scene
  50781. */
  50782. useUtilityLayer?: boolean;
  50783. /**
  50784. * Optional WebXR camera to be used for gaze selection
  50785. */
  50786. gazeCamera?: WebXRCamera;
  50787. /**
  50788. * the xr input to use with this pointer selection
  50789. */
  50790. xrInput: WebXRInput;
  50791. }
  50792. /**
  50793. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50794. */
  50795. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50796. private readonly _options;
  50797. private static _idCounter;
  50798. private _attachController;
  50799. private _controllers;
  50800. private _scene;
  50801. private _tmpVectorForPickCompare;
  50802. /**
  50803. * The module's name
  50804. */
  50805. static readonly Name: string;
  50806. /**
  50807. * The (Babylon) version of this module.
  50808. * This is an integer representing the implementation version.
  50809. * This number does not correspond to the WebXR specs version
  50810. */
  50811. static readonly Version: number;
  50812. /**
  50813. * Disable lighting on the laser pointer (so it will always be visible)
  50814. */
  50815. disablePointerLighting: boolean;
  50816. /**
  50817. * Disable lighting on the selection mesh (so it will always be visible)
  50818. */
  50819. disableSelectionMeshLighting: boolean;
  50820. /**
  50821. * Should the laser pointer be displayed
  50822. */
  50823. displayLaserPointer: boolean;
  50824. /**
  50825. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50826. */
  50827. displaySelectionMesh: boolean;
  50828. /**
  50829. * This color will be set to the laser pointer when selection is triggered
  50830. */
  50831. laserPointerPickedColor: Color3;
  50832. /**
  50833. * Default color of the laser pointer
  50834. */
  50835. laserPointerDefaultColor: Color3;
  50836. /**
  50837. * default color of the selection ring
  50838. */
  50839. selectionMeshDefaultColor: Color3;
  50840. /**
  50841. * This color will be applied to the selection ring when selection is triggered
  50842. */
  50843. selectionMeshPickedColor: Color3;
  50844. /**
  50845. * Optional filter to be used for ray selection. This predicate shares behavior with
  50846. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50847. */
  50848. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50849. /**
  50850. * constructs a new background remover module
  50851. * @param _xrSessionManager the session manager for this module
  50852. * @param _options read-only options to be used in this module
  50853. */
  50854. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50855. /**
  50856. * attach this feature
  50857. * Will usually be called by the features manager
  50858. *
  50859. * @returns true if successful.
  50860. */
  50861. attach(): boolean;
  50862. /**
  50863. * detach this feature.
  50864. * Will usually be called by the features manager
  50865. *
  50866. * @returns true if successful.
  50867. */
  50868. detach(): boolean;
  50869. /**
  50870. * Will get the mesh under a specific pointer.
  50871. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50872. * @param controllerId the controllerId to check
  50873. * @returns The mesh under pointer or null if no mesh is under the pointer
  50874. */
  50875. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50876. /**
  50877. * Get the xr controller that correlates to the pointer id in the pointer event
  50878. *
  50879. * @param id the pointer id to search for
  50880. * @returns the controller that correlates to this id or null if not found
  50881. */
  50882. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50883. protected _onXRFrame(_xrFrame: XRFrame): void;
  50884. private _attachGazeMode;
  50885. private _attachScreenRayMode;
  50886. private _attachTrackedPointerRayMode;
  50887. private _convertNormalToDirectionOfRay;
  50888. private _detachController;
  50889. private _generateNewMeshPair;
  50890. private _pickingMoved;
  50891. private _updatePointerDistance;
  50892. /** @hidden */
  50893. get lasterPointerDefaultColor(): Color3;
  50894. }
  50895. }
  50896. declare module "babylonjs/XR/webXREnterExitUI" {
  50897. import { Nullable } from "babylonjs/types";
  50898. import { Observable } from "babylonjs/Misc/observable";
  50899. import { IDisposable, Scene } from "babylonjs/scene";
  50900. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50901. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50902. /**
  50903. * Button which can be used to enter a different mode of XR
  50904. */
  50905. export class WebXREnterExitUIButton {
  50906. /** button element */
  50907. element: HTMLElement;
  50908. /** XR initialization options for the button */
  50909. sessionMode: XRSessionMode;
  50910. /** Reference space type */
  50911. referenceSpaceType: XRReferenceSpaceType;
  50912. /**
  50913. * Creates a WebXREnterExitUIButton
  50914. * @param element button element
  50915. * @param sessionMode XR initialization session mode
  50916. * @param referenceSpaceType the type of reference space to be used
  50917. */
  50918. constructor(
  50919. /** button element */
  50920. element: HTMLElement,
  50921. /** XR initialization options for the button */
  50922. sessionMode: XRSessionMode,
  50923. /** Reference space type */
  50924. referenceSpaceType: XRReferenceSpaceType);
  50925. /**
  50926. * Extendable function which can be used to update the button's visuals when the state changes
  50927. * @param activeButton the current active button in the UI
  50928. */
  50929. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50930. }
  50931. /**
  50932. * Options to create the webXR UI
  50933. */
  50934. export class WebXREnterExitUIOptions {
  50935. /**
  50936. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50937. */
  50938. customButtons?: Array<WebXREnterExitUIButton>;
  50939. /**
  50940. * A reference space type to use when creating the default button.
  50941. * Default is local-floor
  50942. */
  50943. referenceSpaceType?: XRReferenceSpaceType;
  50944. /**
  50945. * Context to enter xr with
  50946. */
  50947. renderTarget?: Nullable<WebXRRenderTarget>;
  50948. /**
  50949. * A session mode to use when creating the default button.
  50950. * Default is immersive-vr
  50951. */
  50952. sessionMode?: XRSessionMode;
  50953. /**
  50954. * A list of optional features to init the session with
  50955. */
  50956. optionalFeatures?: string[];
  50957. /**
  50958. * A list of optional features to init the session with
  50959. */
  50960. requiredFeatures?: string[];
  50961. }
  50962. /**
  50963. * UI to allow the user to enter/exit XR mode
  50964. */
  50965. export class WebXREnterExitUI implements IDisposable {
  50966. private scene;
  50967. /** version of the options passed to this UI */
  50968. options: WebXREnterExitUIOptions;
  50969. private _activeButton;
  50970. private _buttons;
  50971. /**
  50972. * The HTML Div Element to which buttons are added.
  50973. */
  50974. readonly overlay: HTMLDivElement;
  50975. /**
  50976. * Fired every time the active button is changed.
  50977. *
  50978. * When xr is entered via a button that launches xr that button will be the callback parameter
  50979. *
  50980. * When exiting xr the callback parameter will be null)
  50981. */
  50982. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  50983. /**
  50984. *
  50985. * @param scene babylon scene object to use
  50986. * @param options (read-only) version of the options passed to this UI
  50987. */
  50988. private constructor();
  50989. /**
  50990. * Creates UI to allow the user to enter/exit XR mode
  50991. * @param scene the scene to add the ui to
  50992. * @param helper the xr experience helper to enter/exit xr with
  50993. * @param options options to configure the UI
  50994. * @returns the created ui
  50995. */
  50996. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  50997. /**
  50998. * Disposes of the XR UI component
  50999. */
  51000. dispose(): void;
  51001. private _updateButtons;
  51002. }
  51003. }
  51004. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  51005. import { Vector3 } from "babylonjs/Maths/math.vector";
  51006. import { Color4 } from "babylonjs/Maths/math.color";
  51007. import { Nullable } from "babylonjs/types";
  51008. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51009. import { Scene } from "babylonjs/scene";
  51010. /**
  51011. * Class containing static functions to help procedurally build meshes
  51012. */
  51013. export class LinesBuilder {
  51014. /**
  51015. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51016. * * 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
  51017. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51018. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51019. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51020. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51021. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51022. * * 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
  51023. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51025. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51026. * @param name defines the name of the new line system
  51027. * @param options defines the options used to create the line system
  51028. * @param scene defines the hosting scene
  51029. * @returns a new line system mesh
  51030. */
  51031. static CreateLineSystem(name: string, options: {
  51032. lines: Vector3[][];
  51033. updatable?: boolean;
  51034. instance?: Nullable<LinesMesh>;
  51035. colors?: Nullable<Color4[][]>;
  51036. useVertexAlpha?: boolean;
  51037. }, scene: Nullable<Scene>): LinesMesh;
  51038. /**
  51039. * Creates a line mesh
  51040. * 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
  51041. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51042. * * The parameter `points` is an array successive Vector3
  51043. * * 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
  51044. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51045. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51046. * * When updating an instance, remember that only point positions can change, not the number of points
  51047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51048. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51049. * @param name defines the name of the new line system
  51050. * @param options defines the options used to create the line system
  51051. * @param scene defines the hosting scene
  51052. * @returns a new line mesh
  51053. */
  51054. static CreateLines(name: string, options: {
  51055. points: Vector3[];
  51056. updatable?: boolean;
  51057. instance?: Nullable<LinesMesh>;
  51058. colors?: Color4[];
  51059. useVertexAlpha?: boolean;
  51060. }, scene?: Nullable<Scene>): LinesMesh;
  51061. /**
  51062. * Creates a dashed line mesh
  51063. * * 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
  51064. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51065. * * The parameter `points` is an array successive Vector3
  51066. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51067. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51068. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51069. * * 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
  51070. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51071. * * When updating an instance, remember that only point positions can change, not the number of points
  51072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51073. * @param name defines the name of the mesh
  51074. * @param options defines the options used to create the mesh
  51075. * @param scene defines the hosting scene
  51076. * @returns the dashed line mesh
  51077. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51078. */
  51079. static CreateDashedLines(name: string, options: {
  51080. points: Vector3[];
  51081. dashSize?: number;
  51082. gapSize?: number;
  51083. dashNb?: number;
  51084. updatable?: boolean;
  51085. instance?: LinesMesh;
  51086. useVertexAlpha?: boolean;
  51087. }, scene?: Nullable<Scene>): LinesMesh;
  51088. }
  51089. }
  51090. declare module "babylonjs/Misc/timer" {
  51091. import { Observable, Observer } from "babylonjs/Misc/observable";
  51092. import { Nullable } from "babylonjs/types";
  51093. import { IDisposable } from "babylonjs/scene";
  51094. /**
  51095. * Construction options for a timer
  51096. */
  51097. export interface ITimerOptions<T> {
  51098. /**
  51099. * Time-to-end
  51100. */
  51101. timeout: number;
  51102. /**
  51103. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  51104. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  51105. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  51106. */
  51107. contextObservable: Observable<T>;
  51108. /**
  51109. * Optional parameters when adding an observer to the observable
  51110. */
  51111. observableParameters?: {
  51112. mask?: number;
  51113. insertFirst?: boolean;
  51114. scope?: any;
  51115. };
  51116. /**
  51117. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  51118. */
  51119. breakCondition?: (data?: ITimerData<T>) => boolean;
  51120. /**
  51121. * Will be triggered when the time condition has met
  51122. */
  51123. onEnded?: (data: ITimerData<any>) => void;
  51124. /**
  51125. * Will be triggered when the break condition has met (prematurely ended)
  51126. */
  51127. onAborted?: (data: ITimerData<any>) => void;
  51128. /**
  51129. * Optional function to execute on each tick (or count)
  51130. */
  51131. onTick?: (data: ITimerData<any>) => void;
  51132. }
  51133. /**
  51134. * An interface defining the data sent by the timer
  51135. */
  51136. export interface ITimerData<T> {
  51137. /**
  51138. * When did it start
  51139. */
  51140. startTime: number;
  51141. /**
  51142. * Time now
  51143. */
  51144. currentTime: number;
  51145. /**
  51146. * Time passed since started
  51147. */
  51148. deltaTime: number;
  51149. /**
  51150. * How much is completed, in [0.0...1.0].
  51151. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  51152. */
  51153. completeRate: number;
  51154. /**
  51155. * What the registered observable sent in the last count
  51156. */
  51157. payload: T;
  51158. }
  51159. /**
  51160. * The current state of the timer
  51161. */
  51162. export enum TimerState {
  51163. /**
  51164. * Timer initialized, not yet started
  51165. */
  51166. INIT = 0,
  51167. /**
  51168. * Timer started and counting
  51169. */
  51170. STARTED = 1,
  51171. /**
  51172. * Timer ended (whether aborted or time reached)
  51173. */
  51174. ENDED = 2
  51175. }
  51176. /**
  51177. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51178. *
  51179. * @param options options with which to initialize this timer
  51180. */
  51181. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51182. /**
  51183. * An advanced implementation of a timer class
  51184. */
  51185. export class AdvancedTimer<T = any> implements IDisposable {
  51186. /**
  51187. * Will notify each time the timer calculates the remaining time
  51188. */
  51189. onEachCountObservable: Observable<ITimerData<T>>;
  51190. /**
  51191. * Will trigger when the timer was aborted due to the break condition
  51192. */
  51193. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51194. /**
  51195. * Will trigger when the timer ended successfully
  51196. */
  51197. onTimerEndedObservable: Observable<ITimerData<T>>;
  51198. /**
  51199. * Will trigger when the timer state has changed
  51200. */
  51201. onStateChangedObservable: Observable<TimerState>;
  51202. private _observer;
  51203. private _contextObservable;
  51204. private _observableParameters;
  51205. private _startTime;
  51206. private _timer;
  51207. private _state;
  51208. private _breakCondition;
  51209. private _timeToEnd;
  51210. private _breakOnNextTick;
  51211. /**
  51212. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51213. * @param options construction options for this advanced timer
  51214. */
  51215. constructor(options: ITimerOptions<T>);
  51216. /**
  51217. * set a breaking condition for this timer. Default is to never break during count
  51218. * @param predicate the new break condition. Returns true to break, false otherwise
  51219. */
  51220. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51221. /**
  51222. * Reset ALL associated observables in this advanced timer
  51223. */
  51224. clearObservables(): void;
  51225. /**
  51226. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51227. *
  51228. * @param timeToEnd how much time to measure until timer ended
  51229. */
  51230. start(timeToEnd?: number): void;
  51231. /**
  51232. * Will force a stop on the next tick.
  51233. */
  51234. stop(): void;
  51235. /**
  51236. * Dispose this timer, clearing all resources
  51237. */
  51238. dispose(): void;
  51239. private _setState;
  51240. private _tick;
  51241. private _stop;
  51242. }
  51243. }
  51244. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51245. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51246. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51247. import { Nullable } from "babylonjs/types";
  51248. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51250. import { Vector3 } from "babylonjs/Maths/math.vector";
  51251. import { Material } from "babylonjs/Materials/material";
  51252. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51253. import { Scene } from "babylonjs/scene";
  51254. /**
  51255. * The options container for the teleportation module
  51256. */
  51257. export interface IWebXRTeleportationOptions {
  51258. /**
  51259. * if provided, this scene will be used to render meshes.
  51260. */
  51261. customUtilityLayerScene?: Scene;
  51262. /**
  51263. * Values to configure the default target mesh
  51264. */
  51265. defaultTargetMeshOptions?: {
  51266. /**
  51267. * Fill color of the teleportation area
  51268. */
  51269. teleportationFillColor?: string;
  51270. /**
  51271. * Border color for the teleportation area
  51272. */
  51273. teleportationBorderColor?: string;
  51274. /**
  51275. * Disable the mesh's animation sequence
  51276. */
  51277. disableAnimation?: boolean;
  51278. /**
  51279. * Disable lighting on the material or the ring and arrow
  51280. */
  51281. disableLighting?: boolean;
  51282. /**
  51283. * Override the default material of the torus and arrow
  51284. */
  51285. torusArrowMaterial?: Material;
  51286. };
  51287. /**
  51288. * A list of meshes to use as floor meshes.
  51289. * Meshes can be added and removed after initializing the feature using the
  51290. * addFloorMesh and removeFloorMesh functions
  51291. * If empty, rotation will still work
  51292. */
  51293. floorMeshes?: AbstractMesh[];
  51294. /**
  51295. * use this rendering group id for the meshes (optional)
  51296. */
  51297. renderingGroupId?: number;
  51298. /**
  51299. * Should teleportation move only to snap points
  51300. */
  51301. snapPointsOnly?: boolean;
  51302. /**
  51303. * An array of points to which the teleportation will snap to.
  51304. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51305. */
  51306. snapPositions?: Vector3[];
  51307. /**
  51308. * How close should the teleportation ray be in order to snap to position.
  51309. * Default to 0.8 units (meters)
  51310. */
  51311. snapToPositionRadius?: number;
  51312. /**
  51313. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51314. * If you want to support rotation, make sure your mesh has a direction indicator.
  51315. *
  51316. * When left untouched, the default mesh will be initialized.
  51317. */
  51318. teleportationTargetMesh?: AbstractMesh;
  51319. /**
  51320. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51321. */
  51322. timeToTeleport?: number;
  51323. /**
  51324. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51325. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51326. */
  51327. useMainComponentOnly?: boolean;
  51328. /**
  51329. * Should meshes created here be added to a utility layer or the main scene
  51330. */
  51331. useUtilityLayer?: boolean;
  51332. /**
  51333. * Babylon XR Input class for controller
  51334. */
  51335. xrInput: WebXRInput;
  51336. /**
  51337. * Meshes that the teleportation ray cannot go through
  51338. */
  51339. pickBlockerMeshes?: AbstractMesh[];
  51340. }
  51341. /**
  51342. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51343. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51344. * the input of the attached controllers.
  51345. */
  51346. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51347. private _options;
  51348. private _controllers;
  51349. private _currentTeleportationControllerId;
  51350. private _floorMeshes;
  51351. private _quadraticBezierCurve;
  51352. private _selectionFeature;
  51353. private _snapToPositions;
  51354. private _snappedToPoint;
  51355. private _teleportationRingMaterial?;
  51356. private _tmpRay;
  51357. private _tmpVector;
  51358. private _tmpQuaternion;
  51359. /**
  51360. * The module's name
  51361. */
  51362. static readonly Name: string;
  51363. /**
  51364. * The (Babylon) version of this module.
  51365. * This is an integer representing the implementation version.
  51366. * This number does not correspond to the webxr specs version
  51367. */
  51368. static readonly Version: number;
  51369. /**
  51370. * Is movement backwards enabled
  51371. */
  51372. backwardsMovementEnabled: boolean;
  51373. /**
  51374. * Distance to travel when moving backwards
  51375. */
  51376. backwardsTeleportationDistance: number;
  51377. /**
  51378. * The distance from the user to the inspection point in the direction of the controller
  51379. * A higher number will allow the user to move further
  51380. * defaults to 5 (meters, in xr units)
  51381. */
  51382. parabolicCheckRadius: number;
  51383. /**
  51384. * Should the module support parabolic ray on top of direct ray
  51385. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51386. * Very helpful when moving between floors / different heights
  51387. */
  51388. parabolicRayEnabled: boolean;
  51389. /**
  51390. * How much rotation should be applied when rotating right and left
  51391. */
  51392. rotationAngle: number;
  51393. /**
  51394. * Is rotation enabled when moving forward?
  51395. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51396. */
  51397. rotationEnabled: boolean;
  51398. /**
  51399. * constructs a new anchor system
  51400. * @param _xrSessionManager an instance of WebXRSessionManager
  51401. * @param _options configuration object for this feature
  51402. */
  51403. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51404. /**
  51405. * Get the snapPointsOnly flag
  51406. */
  51407. get snapPointsOnly(): boolean;
  51408. /**
  51409. * Sets the snapPointsOnly flag
  51410. * @param snapToPoints should teleportation be exclusively to snap points
  51411. */
  51412. set snapPointsOnly(snapToPoints: boolean);
  51413. /**
  51414. * Add a new mesh to the floor meshes array
  51415. * @param mesh the mesh to use as floor mesh
  51416. */
  51417. addFloorMesh(mesh: AbstractMesh): void;
  51418. /**
  51419. * Add a new snap-to point to fix teleportation to this position
  51420. * @param newSnapPoint The new Snap-To point
  51421. */
  51422. addSnapPoint(newSnapPoint: Vector3): void;
  51423. attach(): boolean;
  51424. detach(): boolean;
  51425. dispose(): void;
  51426. /**
  51427. * Remove a mesh from the floor meshes array
  51428. * @param mesh the mesh to remove
  51429. */
  51430. removeFloorMesh(mesh: AbstractMesh): void;
  51431. /**
  51432. * Remove a mesh from the floor meshes array using its name
  51433. * @param name the mesh name to remove
  51434. */
  51435. removeFloorMeshByName(name: string): void;
  51436. /**
  51437. * 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
  51438. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51439. * @returns was the point found and removed or not
  51440. */
  51441. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51442. /**
  51443. * This function sets a selection feature that will be disabled when
  51444. * the forward ray is shown and will be reattached when hidden.
  51445. * This is used to remove the selection rays when moving.
  51446. * @param selectionFeature the feature to disable when forward movement is enabled
  51447. */
  51448. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  51449. protected _onXRFrame(_xrFrame: XRFrame): void;
  51450. private _attachController;
  51451. private _createDefaultTargetMesh;
  51452. private _detachController;
  51453. private _findClosestSnapPointWithRadius;
  51454. private _setTargetMeshPosition;
  51455. private _setTargetMeshVisibility;
  51456. private _showParabolicPath;
  51457. private _teleportForward;
  51458. }
  51459. }
  51460. declare module "babylonjs/XR/webXRDefaultExperience" {
  51461. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51462. import { Scene } from "babylonjs/scene";
  51463. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51464. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51465. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51466. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51468. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51469. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51470. /**
  51471. * Options for the default xr helper
  51472. */
  51473. export class WebXRDefaultExperienceOptions {
  51474. /**
  51475. * Enable or disable default UI to enter XR
  51476. */
  51477. disableDefaultUI?: boolean;
  51478. /**
  51479. * Should teleportation not initialize. defaults to false.
  51480. */
  51481. disableTeleportation?: boolean;
  51482. /**
  51483. * Floor meshes that will be used for teleport
  51484. */
  51485. floorMeshes?: Array<AbstractMesh>;
  51486. /**
  51487. * If set to true, the first frame will not be used to reset position
  51488. * The first frame is mainly used when copying transformation from the old camera
  51489. * Mainly used in AR
  51490. */
  51491. ignoreNativeCameraTransformation?: boolean;
  51492. /**
  51493. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51494. */
  51495. inputOptions?: IWebXRInputOptions;
  51496. /**
  51497. * optional configuration for the output canvas
  51498. */
  51499. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51500. /**
  51501. * optional UI options. This can be used among other to change session mode and reference space type
  51502. */
  51503. uiOptions?: WebXREnterExitUIOptions;
  51504. /**
  51505. * When loading teleportation and pointer select, use stable versions instead of latest.
  51506. */
  51507. useStablePlugins?: boolean;
  51508. /**
  51509. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51510. */
  51511. renderingGroupId?: number;
  51512. /**
  51513. * A list of optional features to init the session with
  51514. * If set to true, all features we support will be added
  51515. */
  51516. optionalFeatures?: boolean | string[];
  51517. }
  51518. /**
  51519. * Default experience which provides a similar setup to the previous webVRExperience
  51520. */
  51521. export class WebXRDefaultExperience {
  51522. /**
  51523. * Base experience
  51524. */
  51525. baseExperience: WebXRExperienceHelper;
  51526. /**
  51527. * Enables ui for entering/exiting xr
  51528. */
  51529. enterExitUI: WebXREnterExitUI;
  51530. /**
  51531. * Input experience extension
  51532. */
  51533. input: WebXRInput;
  51534. /**
  51535. * Enables laser pointer and selection
  51536. */
  51537. pointerSelection: WebXRControllerPointerSelection;
  51538. /**
  51539. * Default target xr should render to
  51540. */
  51541. renderTarget: WebXRRenderTarget;
  51542. /**
  51543. * Enables teleportation
  51544. */
  51545. teleportation: WebXRMotionControllerTeleportation;
  51546. private constructor();
  51547. /**
  51548. * Creates the default xr experience
  51549. * @param scene scene
  51550. * @param options options for basic configuration
  51551. * @returns resulting WebXRDefaultExperience
  51552. */
  51553. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51554. /**
  51555. * DIsposes of the experience helper
  51556. */
  51557. dispose(): void;
  51558. }
  51559. }
  51560. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51561. import { Observable } from "babylonjs/Misc/observable";
  51562. import { Nullable } from "babylonjs/types";
  51563. import { Camera } from "babylonjs/Cameras/camera";
  51564. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51565. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51566. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51567. import { Scene } from "babylonjs/scene";
  51568. import { Vector3 } from "babylonjs/Maths/math.vector";
  51569. import { Color3 } from "babylonjs/Maths/math.color";
  51570. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51572. import { Mesh } from "babylonjs/Meshes/mesh";
  51573. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51574. import { EasingFunction } from "babylonjs/Animations/easing";
  51575. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51576. import "babylonjs/Meshes/Builders/groundBuilder";
  51577. import "babylonjs/Meshes/Builders/torusBuilder";
  51578. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51579. import "babylonjs/Gamepads/gamepadSceneComponent";
  51580. import "babylonjs/Animations/animatable";
  51581. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51582. /**
  51583. * Options to modify the vr teleportation behavior.
  51584. */
  51585. export interface VRTeleportationOptions {
  51586. /**
  51587. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51588. */
  51589. floorMeshName?: string;
  51590. /**
  51591. * A list of meshes to be used as the teleportation floor. (default: empty)
  51592. */
  51593. floorMeshes?: Mesh[];
  51594. /**
  51595. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51596. */
  51597. teleportationMode?: number;
  51598. /**
  51599. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51600. */
  51601. teleportationTime?: number;
  51602. /**
  51603. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51604. */
  51605. teleportationSpeed?: number;
  51606. /**
  51607. * The easing function used in the animation or null for Linear. (default CircleEase)
  51608. */
  51609. easingFunction?: EasingFunction;
  51610. }
  51611. /**
  51612. * Options to modify the vr experience helper's behavior.
  51613. */
  51614. export interface VRExperienceHelperOptions extends WebVROptions {
  51615. /**
  51616. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51617. */
  51618. createDeviceOrientationCamera?: boolean;
  51619. /**
  51620. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51621. */
  51622. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51623. /**
  51624. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51625. */
  51626. laserToggle?: boolean;
  51627. /**
  51628. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51629. */
  51630. floorMeshes?: Mesh[];
  51631. /**
  51632. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51633. */
  51634. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51635. /**
  51636. * Defines if WebXR should be used instead of WebVR (if available)
  51637. */
  51638. useXR?: boolean;
  51639. }
  51640. /**
  51641. * Event containing information after VR has been entered
  51642. */
  51643. export class OnAfterEnteringVRObservableEvent {
  51644. /**
  51645. * If entering vr was successful
  51646. */
  51647. success: boolean;
  51648. }
  51649. /**
  51650. * Helps to quickly add VR support to an existing scene.
  51651. * See https://doc.babylonjs.com/how_to/webvr_helper
  51652. */
  51653. export class VRExperienceHelper {
  51654. /** Options to modify the vr experience helper's behavior. */
  51655. webVROptions: VRExperienceHelperOptions;
  51656. private _scene;
  51657. private _position;
  51658. private _btnVR;
  51659. private _btnVRDisplayed;
  51660. private _webVRsupported;
  51661. private _webVRready;
  51662. private _webVRrequesting;
  51663. private _webVRpresenting;
  51664. private _hasEnteredVR;
  51665. private _fullscreenVRpresenting;
  51666. private _inputElement;
  51667. private _webVRCamera;
  51668. private _vrDeviceOrientationCamera;
  51669. private _deviceOrientationCamera;
  51670. private _existingCamera;
  51671. private _onKeyDown;
  51672. private _onVrDisplayPresentChange;
  51673. private _onVRDisplayChanged;
  51674. private _onVRRequestPresentStart;
  51675. private _onVRRequestPresentComplete;
  51676. /**
  51677. * 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)
  51678. */
  51679. enableGazeEvenWhenNoPointerLock: boolean;
  51680. /**
  51681. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51682. */
  51683. exitVROnDoubleTap: boolean;
  51684. /**
  51685. * Observable raised right before entering VR.
  51686. */
  51687. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51688. /**
  51689. * Observable raised when entering VR has completed.
  51690. */
  51691. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51692. /**
  51693. * Observable raised when exiting VR.
  51694. */
  51695. onExitingVRObservable: Observable<VRExperienceHelper>;
  51696. /**
  51697. * Observable raised when controller mesh is loaded.
  51698. */
  51699. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51700. /** Return this.onEnteringVRObservable
  51701. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51702. */
  51703. get onEnteringVR(): Observable<VRExperienceHelper>;
  51704. /** Return this.onExitingVRObservable
  51705. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51706. */
  51707. get onExitingVR(): Observable<VRExperienceHelper>;
  51708. /** Return this.onControllerMeshLoadedObservable
  51709. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51710. */
  51711. get onControllerMeshLoaded(): Observable<WebVRController>;
  51712. private _rayLength;
  51713. private _useCustomVRButton;
  51714. private _teleportationRequested;
  51715. private _teleportActive;
  51716. private _floorMeshName;
  51717. private _floorMeshesCollection;
  51718. private _teleportationMode;
  51719. private _teleportationTime;
  51720. private _teleportationSpeed;
  51721. private _teleportationEasing;
  51722. private _rotationAllowed;
  51723. private _teleportBackwardsVector;
  51724. private _teleportationTarget;
  51725. private _isDefaultTeleportationTarget;
  51726. private _postProcessMove;
  51727. private _teleportationFillColor;
  51728. private _teleportationBorderColor;
  51729. private _rotationAngle;
  51730. private _haloCenter;
  51731. private _cameraGazer;
  51732. private _padSensibilityUp;
  51733. private _padSensibilityDown;
  51734. private _leftController;
  51735. private _rightController;
  51736. private _gazeColor;
  51737. private _laserColor;
  51738. private _pickedLaserColor;
  51739. private _pickedGazeColor;
  51740. /**
  51741. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51742. */
  51743. onNewMeshSelected: Observable<AbstractMesh>;
  51744. /**
  51745. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51746. * This observable will provide the mesh and the controller used to select the mesh
  51747. */
  51748. onMeshSelectedWithController: Observable<{
  51749. mesh: AbstractMesh;
  51750. controller: WebVRController;
  51751. }>;
  51752. /**
  51753. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51754. */
  51755. onNewMeshPicked: Observable<PickingInfo>;
  51756. private _circleEase;
  51757. /**
  51758. * Observable raised before camera teleportation
  51759. */
  51760. onBeforeCameraTeleport: Observable<Vector3>;
  51761. /**
  51762. * Observable raised after camera teleportation
  51763. */
  51764. onAfterCameraTeleport: Observable<Vector3>;
  51765. /**
  51766. * Observable raised when current selected mesh gets unselected
  51767. */
  51768. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51769. private _raySelectionPredicate;
  51770. /**
  51771. * To be optionaly changed by user to define custom ray selection
  51772. */
  51773. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51774. /**
  51775. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51776. */
  51777. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51778. /**
  51779. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51780. */
  51781. teleportationEnabled: boolean;
  51782. private _defaultHeight;
  51783. private _teleportationInitialized;
  51784. private _interactionsEnabled;
  51785. private _interactionsRequested;
  51786. private _displayGaze;
  51787. private _displayLaserPointer;
  51788. /**
  51789. * The mesh used to display where the user is going to teleport.
  51790. */
  51791. get teleportationTarget(): Mesh;
  51792. /**
  51793. * Sets the mesh to be used to display where the user is going to teleport.
  51794. */
  51795. set teleportationTarget(value: Mesh);
  51796. /**
  51797. * 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
  51798. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51799. * See https://doc.babylonjs.com/resources/baking_transformations
  51800. */
  51801. get gazeTrackerMesh(): Mesh;
  51802. set gazeTrackerMesh(value: Mesh);
  51803. /**
  51804. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51805. */
  51806. updateGazeTrackerScale: boolean;
  51807. /**
  51808. * If the gaze trackers color should be updated when selecting meshes
  51809. */
  51810. updateGazeTrackerColor: boolean;
  51811. /**
  51812. * If the controller laser color should be updated when selecting meshes
  51813. */
  51814. updateControllerLaserColor: boolean;
  51815. /**
  51816. * The gaze tracking mesh corresponding to the left controller
  51817. */
  51818. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51819. /**
  51820. * The gaze tracking mesh corresponding to the right controller
  51821. */
  51822. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51823. /**
  51824. * If the ray of the gaze should be displayed.
  51825. */
  51826. get displayGaze(): boolean;
  51827. /**
  51828. * Sets if the ray of the gaze should be displayed.
  51829. */
  51830. set displayGaze(value: boolean);
  51831. /**
  51832. * If the ray of the LaserPointer should be displayed.
  51833. */
  51834. get displayLaserPointer(): boolean;
  51835. /**
  51836. * Sets if the ray of the LaserPointer should be displayed.
  51837. */
  51838. set displayLaserPointer(value: boolean);
  51839. /**
  51840. * The deviceOrientationCamera used as the camera when not in VR.
  51841. */
  51842. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51843. /**
  51844. * Based on the current WebVR support, returns the current VR camera used.
  51845. */
  51846. get currentVRCamera(): Nullable<Camera>;
  51847. /**
  51848. * The webVRCamera which is used when in VR.
  51849. */
  51850. get webVRCamera(): WebVRFreeCamera;
  51851. /**
  51852. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51853. */
  51854. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51855. /**
  51856. * The html button that is used to trigger entering into VR.
  51857. */
  51858. get vrButton(): Nullable<HTMLButtonElement>;
  51859. private get _teleportationRequestInitiated();
  51860. /**
  51861. * Defines whether or not Pointer lock should be requested when switching to
  51862. * full screen.
  51863. */
  51864. requestPointerLockOnFullScreen: boolean;
  51865. /**
  51866. * If asking to force XR, this will be populated with the default xr experience
  51867. */
  51868. xr: WebXRDefaultExperience;
  51869. /**
  51870. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51871. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51872. */
  51873. xrTestDone: boolean;
  51874. /**
  51875. * Instantiates a VRExperienceHelper.
  51876. * Helps to quickly add VR support to an existing scene.
  51877. * @param scene The scene the VRExperienceHelper belongs to.
  51878. * @param webVROptions Options to modify the vr experience helper's behavior.
  51879. */
  51880. constructor(scene: Scene,
  51881. /** Options to modify the vr experience helper's behavior. */
  51882. webVROptions?: VRExperienceHelperOptions);
  51883. private completeVRInit;
  51884. private _onDefaultMeshLoaded;
  51885. private _onResize;
  51886. private _onFullscreenChange;
  51887. /**
  51888. * Gets a value indicating if we are currently in VR mode.
  51889. */
  51890. get isInVRMode(): boolean;
  51891. private onVrDisplayPresentChange;
  51892. private onVRDisplayChanged;
  51893. private moveButtonToBottomRight;
  51894. private displayVRButton;
  51895. private updateButtonVisibility;
  51896. private _cachedAngularSensibility;
  51897. /**
  51898. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51899. * Otherwise, will use the fullscreen API.
  51900. */
  51901. enterVR(): void;
  51902. /**
  51903. * Attempt to exit VR, or fullscreen.
  51904. */
  51905. exitVR(): void;
  51906. /**
  51907. * The position of the vr experience helper.
  51908. */
  51909. get position(): Vector3;
  51910. /**
  51911. * Sets the position of the vr experience helper.
  51912. */
  51913. set position(value: Vector3);
  51914. /**
  51915. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51916. */
  51917. enableInteractions(): void;
  51918. private get _noControllerIsActive();
  51919. private beforeRender;
  51920. private _isTeleportationFloor;
  51921. /**
  51922. * Adds a floor mesh to be used for teleportation.
  51923. * @param floorMesh the mesh to be used for teleportation.
  51924. */
  51925. addFloorMesh(floorMesh: Mesh): void;
  51926. /**
  51927. * Removes a floor mesh from being used for teleportation.
  51928. * @param floorMesh the mesh to be removed.
  51929. */
  51930. removeFloorMesh(floorMesh: Mesh): void;
  51931. /**
  51932. * Enables interactions and teleportation using the VR controllers and gaze.
  51933. * @param vrTeleportationOptions options to modify teleportation behavior.
  51934. */
  51935. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51936. private _onNewGamepadConnected;
  51937. private _tryEnableInteractionOnController;
  51938. private _onNewGamepadDisconnected;
  51939. private _enableInteractionOnController;
  51940. private _checkTeleportWithRay;
  51941. private _checkRotate;
  51942. private _checkTeleportBackwards;
  51943. private _enableTeleportationOnController;
  51944. private _createTeleportationCircles;
  51945. private _displayTeleportationTarget;
  51946. private _hideTeleportationTarget;
  51947. private _rotateCamera;
  51948. private _moveTeleportationSelectorTo;
  51949. private _workingVector;
  51950. private _workingQuaternion;
  51951. private _workingMatrix;
  51952. /**
  51953. * Time Constant Teleportation Mode
  51954. */
  51955. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  51956. /**
  51957. * Speed Constant Teleportation Mode
  51958. */
  51959. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  51960. /**
  51961. * Teleports the users feet to the desired location
  51962. * @param location The location where the user's feet should be placed
  51963. */
  51964. teleportCamera(location: Vector3): void;
  51965. private _convertNormalToDirectionOfRay;
  51966. private _castRayAndSelectObject;
  51967. private _notifySelectedMeshUnselected;
  51968. /**
  51969. * Permanently set new colors for the laser pointer
  51970. * @param color the new laser color
  51971. * @param pickedColor the new laser color when picked mesh detected
  51972. */
  51973. setLaserColor(color: Color3, pickedColor?: Color3): void;
  51974. /**
  51975. * Set lighting enabled / disabled on the laser pointer of both controllers
  51976. * @param enabled should the lighting be enabled on the laser pointer
  51977. */
  51978. setLaserLightingState(enabled?: boolean): void;
  51979. /**
  51980. * Permanently set new colors for the gaze pointer
  51981. * @param color the new gaze color
  51982. * @param pickedColor the new gaze color when picked mesh detected
  51983. */
  51984. setGazeColor(color: Color3, pickedColor?: Color3): void;
  51985. /**
  51986. * Sets the color of the laser ray from the vr controllers.
  51987. * @param color new color for the ray.
  51988. */
  51989. changeLaserColor(color: Color3): void;
  51990. /**
  51991. * Sets the color of the ray from the vr headsets gaze.
  51992. * @param color new color for the ray.
  51993. */
  51994. changeGazeColor(color: Color3): void;
  51995. /**
  51996. * Exits VR and disposes of the vr experience helper
  51997. */
  51998. dispose(): void;
  51999. /**
  52000. * Gets the name of the VRExperienceHelper class
  52001. * @returns "VRExperienceHelper"
  52002. */
  52003. getClassName(): string;
  52004. }
  52005. }
  52006. declare module "babylonjs/Cameras/VR/index" {
  52007. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  52008. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  52009. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52010. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  52011. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  52012. export * from "babylonjs/Cameras/VR/webVRCamera";
  52013. }
  52014. declare module "babylonjs/Cameras/RigModes/index" {
  52015. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  52016. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  52017. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  52018. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  52019. }
  52020. declare module "babylonjs/Cameras/index" {
  52021. export * from "babylonjs/Cameras/Inputs/index";
  52022. export * from "babylonjs/Cameras/cameraInputsManager";
  52023. export * from "babylonjs/Cameras/camera";
  52024. export * from "babylonjs/Cameras/targetCamera";
  52025. export * from "babylonjs/Cameras/freeCamera";
  52026. export * from "babylonjs/Cameras/freeCameraInputsManager";
  52027. export * from "babylonjs/Cameras/touchCamera";
  52028. export * from "babylonjs/Cameras/arcRotateCamera";
  52029. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  52030. export * from "babylonjs/Cameras/deviceOrientationCamera";
  52031. export * from "babylonjs/Cameras/flyCamera";
  52032. export * from "babylonjs/Cameras/flyCameraInputsManager";
  52033. export * from "babylonjs/Cameras/followCamera";
  52034. export * from "babylonjs/Cameras/followCameraInputsManager";
  52035. export * from "babylonjs/Cameras/gamepadCamera";
  52036. export * from "babylonjs/Cameras/Stereoscopic/index";
  52037. export * from "babylonjs/Cameras/universalCamera";
  52038. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  52039. export * from "babylonjs/Cameras/VR/index";
  52040. export * from "babylonjs/Cameras/RigModes/index";
  52041. }
  52042. declare module "babylonjs/Collisions/index" {
  52043. export * from "babylonjs/Collisions/collider";
  52044. export * from "babylonjs/Collisions/collisionCoordinator";
  52045. export * from "babylonjs/Collisions/pickingInfo";
  52046. export * from "babylonjs/Collisions/intersectionInfo";
  52047. export * from "babylonjs/Collisions/meshCollisionData";
  52048. }
  52049. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  52050. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  52051. import { Vector3 } from "babylonjs/Maths/math.vector";
  52052. import { Ray } from "babylonjs/Culling/ray";
  52053. import { Plane } from "babylonjs/Maths/math.plane";
  52054. /**
  52055. * Contains an array of blocks representing the octree
  52056. */
  52057. export interface IOctreeContainer<T> {
  52058. /**
  52059. * Blocks within the octree
  52060. */
  52061. blocks: Array<OctreeBlock<T>>;
  52062. }
  52063. /**
  52064. * Class used to store a cell in an octree
  52065. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52066. */
  52067. export class OctreeBlock<T> {
  52068. /**
  52069. * Gets the content of the current block
  52070. */
  52071. entries: T[];
  52072. /**
  52073. * Gets the list of block children
  52074. */
  52075. blocks: Array<OctreeBlock<T>>;
  52076. private _depth;
  52077. private _maxDepth;
  52078. private _capacity;
  52079. private _minPoint;
  52080. private _maxPoint;
  52081. private _boundingVectors;
  52082. private _creationFunc;
  52083. /**
  52084. * Creates a new block
  52085. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  52086. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  52087. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52088. * @param depth defines the current depth of this block in the octree
  52089. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  52090. * @param creationFunc defines a callback to call when an element is added to the block
  52091. */
  52092. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  52093. /**
  52094. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52095. */
  52096. get capacity(): number;
  52097. /**
  52098. * Gets the minimum vector (in world space) of the block's bounding box
  52099. */
  52100. get minPoint(): Vector3;
  52101. /**
  52102. * Gets the maximum vector (in world space) of the block's bounding box
  52103. */
  52104. get maxPoint(): Vector3;
  52105. /**
  52106. * Add a new element to this block
  52107. * @param entry defines the element to add
  52108. */
  52109. addEntry(entry: T): void;
  52110. /**
  52111. * Remove an element from this block
  52112. * @param entry defines the element to remove
  52113. */
  52114. removeEntry(entry: T): void;
  52115. /**
  52116. * Add an array of elements to this block
  52117. * @param entries defines the array of elements to add
  52118. */
  52119. addEntries(entries: T[]): void;
  52120. /**
  52121. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  52122. * @param frustumPlanes defines the frustum planes to test
  52123. * @param selection defines the array to store current content if selection is positive
  52124. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52125. */
  52126. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52127. /**
  52128. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  52129. * @param sphereCenter defines the bounding sphere center
  52130. * @param sphereRadius defines the bounding sphere radius
  52131. * @param selection defines the array to store current content if selection is positive
  52132. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52133. */
  52134. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52135. /**
  52136. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  52137. * @param ray defines the ray to test with
  52138. * @param selection defines the array to store current content if selection is positive
  52139. */
  52140. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  52141. /**
  52142. * Subdivide the content into child blocks (this block will then be empty)
  52143. */
  52144. createInnerBlocks(): void;
  52145. /**
  52146. * @hidden
  52147. */
  52148. 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;
  52149. }
  52150. }
  52151. declare module "babylonjs/Culling/Octrees/octree" {
  52152. import { SmartArray } from "babylonjs/Misc/smartArray";
  52153. import { Vector3 } from "babylonjs/Maths/math.vector";
  52154. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52156. import { Ray } from "babylonjs/Culling/ray";
  52157. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  52158. import { Plane } from "babylonjs/Maths/math.plane";
  52159. /**
  52160. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  52161. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52162. */
  52163. export class Octree<T> {
  52164. /** 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.) */
  52165. maxDepth: number;
  52166. /**
  52167. * Blocks within the octree containing objects
  52168. */
  52169. blocks: Array<OctreeBlock<T>>;
  52170. /**
  52171. * Content stored in the octree
  52172. */
  52173. dynamicContent: T[];
  52174. private _maxBlockCapacity;
  52175. private _selectionContent;
  52176. private _creationFunc;
  52177. /**
  52178. * Creates a octree
  52179. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52180. * @param creationFunc function to be used to instatiate the octree
  52181. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52182. * @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.)
  52183. */
  52184. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52185. /** 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.) */
  52186. maxDepth?: number);
  52187. /**
  52188. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52189. * @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);
  52190. * @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);
  52191. * @param entries meshes to be added to the octree blocks
  52192. */
  52193. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52194. /**
  52195. * Adds a mesh to the octree
  52196. * @param entry Mesh to add to the octree
  52197. */
  52198. addMesh(entry: T): void;
  52199. /**
  52200. * Remove an element from the octree
  52201. * @param entry defines the element to remove
  52202. */
  52203. removeMesh(entry: T): void;
  52204. /**
  52205. * Selects an array of meshes within the frustum
  52206. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52207. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52208. * @returns array of meshes within the frustum
  52209. */
  52210. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52211. /**
  52212. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52213. * @param sphereCenter defines the bounding sphere center
  52214. * @param sphereRadius defines the bounding sphere radius
  52215. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52216. * @returns an array of objects that intersect the sphere
  52217. */
  52218. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52219. /**
  52220. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52221. * @param ray defines the ray to test with
  52222. * @returns array of intersected objects
  52223. */
  52224. intersectsRay(ray: Ray): SmartArray<T>;
  52225. /**
  52226. * Adds a mesh into the octree block if it intersects the block
  52227. */
  52228. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52229. /**
  52230. * Adds a submesh into the octree block if it intersects the block
  52231. */
  52232. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52233. }
  52234. }
  52235. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52236. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52237. import { Scene } from "babylonjs/scene";
  52238. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52240. import { Ray } from "babylonjs/Culling/ray";
  52241. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52242. import { Collider } from "babylonjs/Collisions/collider";
  52243. module "babylonjs/scene" {
  52244. interface Scene {
  52245. /**
  52246. * @hidden
  52247. * Backing Filed
  52248. */
  52249. _selectionOctree: Octree<AbstractMesh>;
  52250. /**
  52251. * Gets the octree used to boost mesh selection (picking)
  52252. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52253. */
  52254. selectionOctree: Octree<AbstractMesh>;
  52255. /**
  52256. * Creates or updates the octree used to boost selection (picking)
  52257. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52258. * @param maxCapacity defines the maximum capacity per leaf
  52259. * @param maxDepth defines the maximum depth of the octree
  52260. * @returns an octree of AbstractMesh
  52261. */
  52262. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52263. }
  52264. }
  52265. module "babylonjs/Meshes/abstractMesh" {
  52266. interface AbstractMesh {
  52267. /**
  52268. * @hidden
  52269. * Backing Field
  52270. */
  52271. _submeshesOctree: Octree<SubMesh>;
  52272. /**
  52273. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52274. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52275. * @param maxCapacity defines the maximum size of each block (64 by default)
  52276. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52277. * @returns the new octree
  52278. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52279. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52280. */
  52281. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52282. }
  52283. }
  52284. /**
  52285. * Defines the octree scene component responsible to manage any octrees
  52286. * in a given scene.
  52287. */
  52288. export class OctreeSceneComponent {
  52289. /**
  52290. * The component name help to identify the component in the list of scene components.
  52291. */
  52292. readonly name: string;
  52293. /**
  52294. * The scene the component belongs to.
  52295. */
  52296. scene: Scene;
  52297. /**
  52298. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52299. */
  52300. readonly checksIsEnabled: boolean;
  52301. /**
  52302. * Creates a new instance of the component for the given scene
  52303. * @param scene Defines the scene to register the component in
  52304. */
  52305. constructor(scene: Scene);
  52306. /**
  52307. * Registers the component in a given scene
  52308. */
  52309. register(): void;
  52310. /**
  52311. * Return the list of active meshes
  52312. * @returns the list of active meshes
  52313. */
  52314. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52315. /**
  52316. * Return the list of active sub meshes
  52317. * @param mesh The mesh to get the candidates sub meshes from
  52318. * @returns the list of active sub meshes
  52319. */
  52320. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52321. private _tempRay;
  52322. /**
  52323. * Return the list of sub meshes intersecting with a given local ray
  52324. * @param mesh defines the mesh to find the submesh for
  52325. * @param localRay defines the ray in local space
  52326. * @returns the list of intersecting sub meshes
  52327. */
  52328. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52329. /**
  52330. * Return the list of sub meshes colliding with a collider
  52331. * @param mesh defines the mesh to find the submesh for
  52332. * @param collider defines the collider to evaluate the collision against
  52333. * @returns the list of colliding sub meshes
  52334. */
  52335. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52336. /**
  52337. * Rebuilds the elements related to this component in case of
  52338. * context lost for instance.
  52339. */
  52340. rebuild(): void;
  52341. /**
  52342. * Disposes the component and the associated ressources.
  52343. */
  52344. dispose(): void;
  52345. }
  52346. }
  52347. declare module "babylonjs/Culling/Octrees/index" {
  52348. export * from "babylonjs/Culling/Octrees/octree";
  52349. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52350. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52351. }
  52352. declare module "babylonjs/Culling/index" {
  52353. export * from "babylonjs/Culling/boundingBox";
  52354. export * from "babylonjs/Culling/boundingInfo";
  52355. export * from "babylonjs/Culling/boundingSphere";
  52356. export * from "babylonjs/Culling/Octrees/index";
  52357. export * from "babylonjs/Culling/ray";
  52358. }
  52359. declare module "babylonjs/Gizmos/gizmo" {
  52360. import { Nullable } from "babylonjs/types";
  52361. import { IDisposable } from "babylonjs/scene";
  52362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52363. import { Mesh } from "babylonjs/Meshes/mesh";
  52364. import { Node } from "babylonjs/node";
  52365. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52366. /**
  52367. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52368. */
  52369. export class Gizmo implements IDisposable {
  52370. /** The utility layer the gizmo will be added to */
  52371. gizmoLayer: UtilityLayerRenderer;
  52372. /**
  52373. * The root mesh of the gizmo
  52374. */
  52375. _rootMesh: Mesh;
  52376. private _attachedMesh;
  52377. private _attachedNode;
  52378. /**
  52379. * Ratio for the scale of the gizmo (Default: 1)
  52380. */
  52381. protected _scaleRatio: number;
  52382. /**
  52383. * Ratio for the scale of the gizmo (Default: 1)
  52384. */
  52385. set scaleRatio(value: number);
  52386. get scaleRatio(): number;
  52387. /**
  52388. * If a custom mesh has been set (Default: false)
  52389. */
  52390. protected _customMeshSet: boolean;
  52391. /**
  52392. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52393. * * When set, interactions will be enabled
  52394. */
  52395. get attachedMesh(): Nullable<AbstractMesh>;
  52396. set attachedMesh(value: Nullable<AbstractMesh>);
  52397. /**
  52398. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52399. * * When set, interactions will be enabled
  52400. */
  52401. get attachedNode(): Nullable<Node>;
  52402. set attachedNode(value: Nullable<Node>);
  52403. /**
  52404. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52405. * @param mesh The mesh to replace the default mesh of the gizmo
  52406. */
  52407. setCustomMesh(mesh: Mesh): void;
  52408. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  52409. /**
  52410. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52411. */
  52412. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52413. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52414. /**
  52415. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52416. */
  52417. updateGizmoPositionToMatchAttachedMesh: boolean;
  52418. /**
  52419. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52420. */
  52421. updateScale: boolean;
  52422. protected _interactionsEnabled: boolean;
  52423. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52424. private _beforeRenderObserver;
  52425. private _tempQuaternion;
  52426. private _tempVector;
  52427. private _tempVector2;
  52428. private _tempMatrix1;
  52429. private _tempMatrix2;
  52430. private _rightHandtoLeftHandMatrix;
  52431. /**
  52432. * Creates a gizmo
  52433. * @param gizmoLayer The utility layer the gizmo will be added to
  52434. */
  52435. constructor(
  52436. /** The utility layer the gizmo will be added to */
  52437. gizmoLayer?: UtilityLayerRenderer);
  52438. /**
  52439. * Updates the gizmo to match the attached mesh's position/rotation
  52440. */
  52441. protected _update(): void;
  52442. /**
  52443. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52444. * @param value Node, TransformNode or mesh
  52445. */
  52446. protected _matrixChanged(): void;
  52447. /**
  52448. * Disposes of the gizmo
  52449. */
  52450. dispose(): void;
  52451. }
  52452. }
  52453. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52454. import { Observable } from "babylonjs/Misc/observable";
  52455. import { Nullable } from "babylonjs/types";
  52456. import { Vector3 } from "babylonjs/Maths/math.vector";
  52457. import { Color3 } from "babylonjs/Maths/math.color";
  52458. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52459. import { Node } from "babylonjs/node";
  52460. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52461. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52462. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52463. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52464. import { Scene } from "babylonjs/scene";
  52465. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52466. /**
  52467. * Single plane drag gizmo
  52468. */
  52469. export class PlaneDragGizmo extends Gizmo {
  52470. /**
  52471. * Drag behavior responsible for the gizmos dragging interactions
  52472. */
  52473. dragBehavior: PointerDragBehavior;
  52474. private _pointerObserver;
  52475. /**
  52476. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52477. */
  52478. snapDistance: number;
  52479. /**
  52480. * Event that fires each time the gizmo snaps to a new location.
  52481. * * snapDistance is the the change in distance
  52482. */
  52483. onSnapObservable: Observable<{
  52484. snapDistance: number;
  52485. }>;
  52486. private _plane;
  52487. private _coloredMaterial;
  52488. private _hoverMaterial;
  52489. private _isEnabled;
  52490. private _parent;
  52491. /** @hidden */
  52492. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52493. /** @hidden */
  52494. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52495. /**
  52496. * Creates a PlaneDragGizmo
  52497. * @param gizmoLayer The utility layer the gizmo will be added to
  52498. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52499. * @param color The color of the gizmo
  52500. */
  52501. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52502. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52503. /**
  52504. * If the gizmo is enabled
  52505. */
  52506. set isEnabled(value: boolean);
  52507. get isEnabled(): boolean;
  52508. /**
  52509. * Disposes of the gizmo
  52510. */
  52511. dispose(): void;
  52512. }
  52513. }
  52514. declare module "babylonjs/Gizmos/positionGizmo" {
  52515. import { Observable } from "babylonjs/Misc/observable";
  52516. import { Nullable } from "babylonjs/types";
  52517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52518. import { Node } from "babylonjs/node";
  52519. import { Mesh } from "babylonjs/Meshes/mesh";
  52520. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52521. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52522. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52523. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52524. /**
  52525. * Gizmo that enables dragging a mesh along 3 axis
  52526. */
  52527. export class PositionGizmo extends Gizmo {
  52528. /**
  52529. * Internal gizmo used for interactions on the x axis
  52530. */
  52531. xGizmo: AxisDragGizmo;
  52532. /**
  52533. * Internal gizmo used for interactions on the y axis
  52534. */
  52535. yGizmo: AxisDragGizmo;
  52536. /**
  52537. * Internal gizmo used for interactions on the z axis
  52538. */
  52539. zGizmo: AxisDragGizmo;
  52540. /**
  52541. * Internal gizmo used for interactions on the yz plane
  52542. */
  52543. xPlaneGizmo: PlaneDragGizmo;
  52544. /**
  52545. * Internal gizmo used for interactions on the xz plane
  52546. */
  52547. yPlaneGizmo: PlaneDragGizmo;
  52548. /**
  52549. * Internal gizmo used for interactions on the xy plane
  52550. */
  52551. zPlaneGizmo: PlaneDragGizmo;
  52552. /**
  52553. * private variables
  52554. */
  52555. private _meshAttached;
  52556. private _nodeAttached;
  52557. private _snapDistance;
  52558. /** Fires an event when any of it's sub gizmos are dragged */
  52559. onDragStartObservable: Observable<unknown>;
  52560. /** Fires an event when any of it's sub gizmos are released from dragging */
  52561. onDragEndObservable: Observable<unknown>;
  52562. /**
  52563. * If set to true, planar drag is enabled
  52564. */
  52565. private _planarGizmoEnabled;
  52566. get attachedMesh(): Nullable<AbstractMesh>;
  52567. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52568. get attachedNode(): Nullable<Node>;
  52569. set attachedNode(node: Nullable<Node>);
  52570. /**
  52571. * Creates a PositionGizmo
  52572. * @param gizmoLayer The utility layer the gizmo will be added to
  52573. @param thickness display gizmo axis thickness
  52574. */
  52575. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52576. /**
  52577. * If the planar drag gizmo is enabled
  52578. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52579. */
  52580. set planarGizmoEnabled(value: boolean);
  52581. get planarGizmoEnabled(): boolean;
  52582. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52583. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52584. /**
  52585. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52586. */
  52587. set snapDistance(value: number);
  52588. get snapDistance(): number;
  52589. /**
  52590. * Ratio for the scale of the gizmo (Default: 1)
  52591. */
  52592. set scaleRatio(value: number);
  52593. get scaleRatio(): number;
  52594. /**
  52595. * Disposes of the gizmo
  52596. */
  52597. dispose(): void;
  52598. /**
  52599. * CustomMeshes are not supported by this gizmo
  52600. * @param mesh The mesh to replace the default mesh of the gizmo
  52601. */
  52602. setCustomMesh(mesh: Mesh): void;
  52603. }
  52604. }
  52605. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52606. import { Observable } from "babylonjs/Misc/observable";
  52607. import { Nullable } from "babylonjs/types";
  52608. import { Vector3 } from "babylonjs/Maths/math.vector";
  52609. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52610. import { Node } from "babylonjs/node";
  52611. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52612. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52613. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52614. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52615. import { Scene } from "babylonjs/scene";
  52616. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52617. import { Color3 } from "babylonjs/Maths/math.color";
  52618. /**
  52619. * Single axis drag gizmo
  52620. */
  52621. export class AxisDragGizmo extends Gizmo {
  52622. /**
  52623. * Drag behavior responsible for the gizmos dragging interactions
  52624. */
  52625. dragBehavior: PointerDragBehavior;
  52626. private _pointerObserver;
  52627. /**
  52628. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52629. */
  52630. snapDistance: number;
  52631. /**
  52632. * Event that fires each time the gizmo snaps to a new location.
  52633. * * snapDistance is the the change in distance
  52634. */
  52635. onSnapObservable: Observable<{
  52636. snapDistance: number;
  52637. }>;
  52638. private _isEnabled;
  52639. private _parent;
  52640. private _arrow;
  52641. private _coloredMaterial;
  52642. private _hoverMaterial;
  52643. /** @hidden */
  52644. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52645. /** @hidden */
  52646. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52647. /**
  52648. * Creates an AxisDragGizmo
  52649. * @param gizmoLayer The utility layer the gizmo will be added to
  52650. * @param dragAxis The axis which the gizmo will be able to drag on
  52651. * @param color The color of the gizmo
  52652. * @param thickness display gizmo axis thickness
  52653. */
  52654. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52655. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52656. /**
  52657. * If the gizmo is enabled
  52658. */
  52659. set isEnabled(value: boolean);
  52660. get isEnabled(): boolean;
  52661. /**
  52662. * Disposes of the gizmo
  52663. */
  52664. dispose(): void;
  52665. }
  52666. }
  52667. declare module "babylonjs/Debug/axesViewer" {
  52668. import { Vector3 } from "babylonjs/Maths/math.vector";
  52669. import { Nullable } from "babylonjs/types";
  52670. import { Scene } from "babylonjs/scene";
  52671. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52672. /**
  52673. * The Axes viewer will show 3 axes in a specific point in space
  52674. */
  52675. export class AxesViewer {
  52676. private _xAxis;
  52677. private _yAxis;
  52678. private _zAxis;
  52679. private _scaleLinesFactor;
  52680. private _instanced;
  52681. /**
  52682. * Gets the hosting scene
  52683. */
  52684. scene: Nullable<Scene>;
  52685. /**
  52686. * Gets or sets a number used to scale line length
  52687. */
  52688. scaleLines: number;
  52689. /** Gets the node hierarchy used to render x-axis */
  52690. get xAxis(): TransformNode;
  52691. /** Gets the node hierarchy used to render y-axis */
  52692. get yAxis(): TransformNode;
  52693. /** Gets the node hierarchy used to render z-axis */
  52694. get zAxis(): TransformNode;
  52695. /**
  52696. * Creates a new AxesViewer
  52697. * @param scene defines the hosting scene
  52698. * @param scaleLines defines a number used to scale line length (1 by default)
  52699. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52700. * @param xAxis defines the node hierarchy used to render the x-axis
  52701. * @param yAxis defines the node hierarchy used to render the y-axis
  52702. * @param zAxis defines the node hierarchy used to render the z-axis
  52703. */
  52704. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52705. /**
  52706. * Force the viewer to update
  52707. * @param position defines the position of the viewer
  52708. * @param xaxis defines the x axis of the viewer
  52709. * @param yaxis defines the y axis of the viewer
  52710. * @param zaxis defines the z axis of the viewer
  52711. */
  52712. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52713. /**
  52714. * Creates an instance of this axes viewer.
  52715. * @returns a new axes viewer with instanced meshes
  52716. */
  52717. createInstance(): AxesViewer;
  52718. /** Releases resources */
  52719. dispose(): void;
  52720. private static _SetRenderingGroupId;
  52721. }
  52722. }
  52723. declare module "babylonjs/Debug/boneAxesViewer" {
  52724. import { Nullable } from "babylonjs/types";
  52725. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52726. import { Vector3 } from "babylonjs/Maths/math.vector";
  52727. import { Mesh } from "babylonjs/Meshes/mesh";
  52728. import { Bone } from "babylonjs/Bones/bone";
  52729. import { Scene } from "babylonjs/scene";
  52730. /**
  52731. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52732. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52733. */
  52734. export class BoneAxesViewer extends AxesViewer {
  52735. /**
  52736. * Gets or sets the target mesh where to display the axes viewer
  52737. */
  52738. mesh: Nullable<Mesh>;
  52739. /**
  52740. * Gets or sets the target bone where to display the axes viewer
  52741. */
  52742. bone: Nullable<Bone>;
  52743. /** Gets current position */
  52744. pos: Vector3;
  52745. /** Gets direction of X axis */
  52746. xaxis: Vector3;
  52747. /** Gets direction of Y axis */
  52748. yaxis: Vector3;
  52749. /** Gets direction of Z axis */
  52750. zaxis: Vector3;
  52751. /**
  52752. * Creates a new BoneAxesViewer
  52753. * @param scene defines the hosting scene
  52754. * @param bone defines the target bone
  52755. * @param mesh defines the target mesh
  52756. * @param scaleLines defines a scaling factor for line length (1 by default)
  52757. */
  52758. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52759. /**
  52760. * Force the viewer to update
  52761. */
  52762. update(): void;
  52763. /** Releases resources */
  52764. dispose(): void;
  52765. }
  52766. }
  52767. declare module "babylonjs/Debug/debugLayer" {
  52768. import { Scene } from "babylonjs/scene";
  52769. /**
  52770. * Interface used to define scene explorer extensibility option
  52771. */
  52772. export interface IExplorerExtensibilityOption {
  52773. /**
  52774. * Define the option label
  52775. */
  52776. label: string;
  52777. /**
  52778. * Defines the action to execute on click
  52779. */
  52780. action: (entity: any) => void;
  52781. }
  52782. /**
  52783. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52784. */
  52785. export interface IExplorerExtensibilityGroup {
  52786. /**
  52787. * Defines a predicate to test if a given type mut be extended
  52788. */
  52789. predicate: (entity: any) => boolean;
  52790. /**
  52791. * Gets the list of options added to a type
  52792. */
  52793. entries: IExplorerExtensibilityOption[];
  52794. }
  52795. /**
  52796. * Interface used to define the options to use to create the Inspector
  52797. */
  52798. export interface IInspectorOptions {
  52799. /**
  52800. * Display in overlay mode (default: false)
  52801. */
  52802. overlay?: boolean;
  52803. /**
  52804. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52805. */
  52806. globalRoot?: HTMLElement;
  52807. /**
  52808. * Display the Scene explorer
  52809. */
  52810. showExplorer?: boolean;
  52811. /**
  52812. * Display the property inspector
  52813. */
  52814. showInspector?: boolean;
  52815. /**
  52816. * Display in embed mode (both panes on the right)
  52817. */
  52818. embedMode?: boolean;
  52819. /**
  52820. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52821. */
  52822. handleResize?: boolean;
  52823. /**
  52824. * Allow the panes to popup (default: true)
  52825. */
  52826. enablePopup?: boolean;
  52827. /**
  52828. * Allow the panes to be closed by users (default: true)
  52829. */
  52830. enableClose?: boolean;
  52831. /**
  52832. * Optional list of extensibility entries
  52833. */
  52834. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52835. /**
  52836. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52837. */
  52838. inspectorURL?: string;
  52839. /**
  52840. * Optional initial tab (default to DebugLayerTab.Properties)
  52841. */
  52842. initialTab?: DebugLayerTab;
  52843. }
  52844. module "babylonjs/scene" {
  52845. interface Scene {
  52846. /**
  52847. * @hidden
  52848. * Backing field
  52849. */
  52850. _debugLayer: DebugLayer;
  52851. /**
  52852. * Gets the debug layer (aka Inspector) associated with the scene
  52853. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52854. */
  52855. debugLayer: DebugLayer;
  52856. }
  52857. }
  52858. /**
  52859. * Enum of inspector action tab
  52860. */
  52861. export enum DebugLayerTab {
  52862. /**
  52863. * Properties tag (default)
  52864. */
  52865. Properties = 0,
  52866. /**
  52867. * Debug tab
  52868. */
  52869. Debug = 1,
  52870. /**
  52871. * Statistics tab
  52872. */
  52873. Statistics = 2,
  52874. /**
  52875. * Tools tab
  52876. */
  52877. Tools = 3,
  52878. /**
  52879. * Settings tab
  52880. */
  52881. Settings = 4
  52882. }
  52883. /**
  52884. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52885. * what is happening in your scene
  52886. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52887. */
  52888. export class DebugLayer {
  52889. /**
  52890. * Define the url to get the inspector script from.
  52891. * By default it uses the babylonjs CDN.
  52892. * @ignoreNaming
  52893. */
  52894. static InspectorURL: string;
  52895. private _scene;
  52896. private BJSINSPECTOR;
  52897. private _onPropertyChangedObservable?;
  52898. /**
  52899. * Observable triggered when a property is changed through the inspector.
  52900. */
  52901. get onPropertyChangedObservable(): any;
  52902. /**
  52903. * Instantiates a new debug layer.
  52904. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52905. * what is happening in your scene
  52906. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52907. * @param scene Defines the scene to inspect
  52908. */
  52909. constructor(scene: Scene);
  52910. /** Creates the inspector window. */
  52911. private _createInspector;
  52912. /**
  52913. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52914. * @param entity defines the entity to select
  52915. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52916. */
  52917. select(entity: any, lineContainerTitles?: string | string[]): void;
  52918. /** Get the inspector from bundle or global */
  52919. private _getGlobalInspector;
  52920. /**
  52921. * Get if the inspector is visible or not.
  52922. * @returns true if visible otherwise, false
  52923. */
  52924. isVisible(): boolean;
  52925. /**
  52926. * Hide the inspector and close its window.
  52927. */
  52928. hide(): void;
  52929. /**
  52930. * Update the scene in the inspector
  52931. */
  52932. setAsActiveScene(): void;
  52933. /**
  52934. * Launch the debugLayer.
  52935. * @param config Define the configuration of the inspector
  52936. * @return a promise fulfilled when the debug layer is visible
  52937. */
  52938. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52939. }
  52940. }
  52941. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52942. import { Nullable } from "babylonjs/types";
  52943. import { Scene } from "babylonjs/scene";
  52944. import { Vector4 } from "babylonjs/Maths/math.vector";
  52945. import { Color4 } from "babylonjs/Maths/math.color";
  52946. import { Mesh } from "babylonjs/Meshes/mesh";
  52947. /**
  52948. * Class containing static functions to help procedurally build meshes
  52949. */
  52950. export class BoxBuilder {
  52951. /**
  52952. * Creates a box mesh
  52953. * * The parameter `size` sets the size (float) of each box side (default 1)
  52954. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52955. * * 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)
  52956. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52960. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52961. * @param name defines the name of the mesh
  52962. * @param options defines the options used to create the mesh
  52963. * @param scene defines the hosting scene
  52964. * @returns the box mesh
  52965. */
  52966. static CreateBox(name: string, options: {
  52967. size?: number;
  52968. width?: number;
  52969. height?: number;
  52970. depth?: number;
  52971. faceUV?: Vector4[];
  52972. faceColors?: Color4[];
  52973. sideOrientation?: number;
  52974. frontUVs?: Vector4;
  52975. backUVs?: Vector4;
  52976. wrap?: boolean;
  52977. topBaseAt?: number;
  52978. bottomBaseAt?: number;
  52979. updatable?: boolean;
  52980. }, scene?: Nullable<Scene>): Mesh;
  52981. }
  52982. }
  52983. declare module "babylonjs/Debug/physicsViewer" {
  52984. import { Nullable } from "babylonjs/types";
  52985. import { Scene } from "babylonjs/scene";
  52986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52987. import { Mesh } from "babylonjs/Meshes/mesh";
  52988. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52989. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52990. /**
  52991. * Used to show the physics impostor around the specific mesh
  52992. */
  52993. export class PhysicsViewer {
  52994. /** @hidden */
  52995. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  52996. /** @hidden */
  52997. protected _meshes: Array<Nullable<AbstractMesh>>;
  52998. /** @hidden */
  52999. protected _scene: Nullable<Scene>;
  53000. /** @hidden */
  53001. protected _numMeshes: number;
  53002. /** @hidden */
  53003. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  53004. private _renderFunction;
  53005. private _utilityLayer;
  53006. private _debugBoxMesh;
  53007. private _debugSphereMesh;
  53008. private _debugCylinderMesh;
  53009. private _debugMaterial;
  53010. private _debugMeshMeshes;
  53011. /**
  53012. * Creates a new PhysicsViewer
  53013. * @param scene defines the hosting scene
  53014. */
  53015. constructor(scene: Scene);
  53016. /** @hidden */
  53017. protected _updateDebugMeshes(): void;
  53018. /**
  53019. * Renders a specified physic impostor
  53020. * @param impostor defines the impostor to render
  53021. * @param targetMesh defines the mesh represented by the impostor
  53022. * @returns the new debug mesh used to render the impostor
  53023. */
  53024. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  53025. /**
  53026. * Hides a specified physic impostor
  53027. * @param impostor defines the impostor to hide
  53028. */
  53029. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  53030. private _getDebugMaterial;
  53031. private _getDebugBoxMesh;
  53032. private _getDebugSphereMesh;
  53033. private _getDebugCylinderMesh;
  53034. private _getDebugMeshMesh;
  53035. private _getDebugMesh;
  53036. /** Releases all resources */
  53037. dispose(): void;
  53038. }
  53039. }
  53040. declare module "babylonjs/Debug/rayHelper" {
  53041. import { Nullable } from "babylonjs/types";
  53042. import { Ray } from "babylonjs/Culling/ray";
  53043. import { Vector3 } from "babylonjs/Maths/math.vector";
  53044. import { Color3 } from "babylonjs/Maths/math.color";
  53045. import { Scene } from "babylonjs/scene";
  53046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53047. import "babylonjs/Meshes/Builders/linesBuilder";
  53048. /**
  53049. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53050. * in order to better appreciate the issue one might have.
  53051. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53052. */
  53053. export class RayHelper {
  53054. /**
  53055. * Defines the ray we are currently tryin to visualize.
  53056. */
  53057. ray: Nullable<Ray>;
  53058. private _renderPoints;
  53059. private _renderLine;
  53060. private _renderFunction;
  53061. private _scene;
  53062. private _onAfterRenderObserver;
  53063. private _onAfterStepObserver;
  53064. private _attachedToMesh;
  53065. private _meshSpaceDirection;
  53066. private _meshSpaceOrigin;
  53067. /**
  53068. * Helper function to create a colored helper in a scene in one line.
  53069. * @param ray Defines the ray we are currently tryin to visualize
  53070. * @param scene Defines the scene the ray is used in
  53071. * @param color Defines the color we want to see the ray in
  53072. * @returns The newly created ray helper.
  53073. */
  53074. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  53075. /**
  53076. * Instantiate a new ray helper.
  53077. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53078. * in order to better appreciate the issue one might have.
  53079. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53080. * @param ray Defines the ray we are currently tryin to visualize
  53081. */
  53082. constructor(ray: Ray);
  53083. /**
  53084. * Shows the ray we are willing to debug.
  53085. * @param scene Defines the scene the ray needs to be rendered in
  53086. * @param color Defines the color the ray needs to be rendered in
  53087. */
  53088. show(scene: Scene, color?: Color3): void;
  53089. /**
  53090. * Hides the ray we are debugging.
  53091. */
  53092. hide(): void;
  53093. private _render;
  53094. /**
  53095. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  53096. * @param mesh Defines the mesh we want the helper attached to
  53097. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  53098. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  53099. * @param length Defines the length of the ray
  53100. */
  53101. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  53102. /**
  53103. * Detach the ray helper from the mesh it has previously been attached to.
  53104. */
  53105. detachFromMesh(): void;
  53106. private _updateToMesh;
  53107. /**
  53108. * Dispose the helper and release its associated resources.
  53109. */
  53110. dispose(): void;
  53111. }
  53112. }
  53113. declare module "babylonjs/Debug/ISkeletonViewer" {
  53114. import { Skeleton } from "babylonjs/Bones/skeleton";
  53115. import { Color3 } from "babylonjs/Maths/math.color";
  53116. /**
  53117. * Defines the options associated with the creation of a SkeletonViewer.
  53118. */
  53119. export interface ISkeletonViewerOptions {
  53120. /** Should the system pause animations before building the Viewer? */
  53121. pauseAnimations: boolean;
  53122. /** Should the system return the skeleton to rest before building? */
  53123. returnToRest: boolean;
  53124. /** public Display Mode of the Viewer */
  53125. displayMode: number;
  53126. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53127. displayOptions: ISkeletonViewerDisplayOptions;
  53128. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53129. computeBonesUsingShaders: boolean;
  53130. /** Flag ignore non weighted bones */
  53131. useAllBones: boolean;
  53132. }
  53133. /**
  53134. * Defines how to display the various bone meshes for the viewer.
  53135. */
  53136. export interface ISkeletonViewerDisplayOptions {
  53137. /** How far down to start tapering the bone spurs */
  53138. midStep?: number;
  53139. /** How big is the midStep? */
  53140. midStepFactor?: number;
  53141. /** Base for the Sphere Size */
  53142. sphereBaseSize?: number;
  53143. /** The ratio of the sphere to the longest bone in units */
  53144. sphereScaleUnit?: number;
  53145. /** Ratio for the Sphere Size */
  53146. sphereFactor?: number;
  53147. }
  53148. /**
  53149. * Defines the constructor options for the BoneWeight Shader.
  53150. */
  53151. export interface IBoneWeightShaderOptions {
  53152. /** Skeleton to Map */
  53153. skeleton: Skeleton;
  53154. /** Colors for Uninfluenced bones */
  53155. colorBase?: Color3;
  53156. /** Colors for 0.0-0.25 Weight bones */
  53157. colorZero?: Color3;
  53158. /** Color for 0.25-0.5 Weight Influence */
  53159. colorQuarter?: Color3;
  53160. /** Color for 0.5-0.75 Weight Influence */
  53161. colorHalf?: Color3;
  53162. /** Color for 0.75-1 Weight Influence */
  53163. colorFull?: Color3;
  53164. /** Color for Zero Weight Influence */
  53165. targetBoneIndex?: number;
  53166. }
  53167. /**
  53168. * Simple structure of the gradient steps for the Color Map.
  53169. */
  53170. export interface ISkeletonMapShaderColorMapKnot {
  53171. /** Color of the Knot */
  53172. color: Color3;
  53173. /** Location of the Knot */
  53174. location: number;
  53175. }
  53176. /**
  53177. * Defines the constructor options for the SkeletonMap Shader.
  53178. */
  53179. export interface ISkeletonMapShaderOptions {
  53180. /** Skeleton to Map */
  53181. skeleton: Skeleton;
  53182. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  53183. colorMap?: ISkeletonMapShaderColorMapKnot[];
  53184. }
  53185. }
  53186. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53187. import { Nullable } from "babylonjs/types";
  53188. import { Scene } from "babylonjs/scene";
  53189. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53190. import { Color4 } from "babylonjs/Maths/math.color";
  53191. import { Mesh } from "babylonjs/Meshes/mesh";
  53192. /**
  53193. * Class containing static functions to help procedurally build meshes
  53194. */
  53195. export class RibbonBuilder {
  53196. /**
  53197. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53198. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53199. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53200. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53201. * * 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
  53202. * * 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
  53203. * * 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
  53204. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53205. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53206. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53207. * * 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
  53208. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53209. * * 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
  53210. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53212. * @param name defines the name of the mesh
  53213. * @param options defines the options used to create the mesh
  53214. * @param scene defines the hosting scene
  53215. * @returns the ribbon mesh
  53216. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53217. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53218. */
  53219. static CreateRibbon(name: string, options: {
  53220. pathArray: Vector3[][];
  53221. closeArray?: boolean;
  53222. closePath?: boolean;
  53223. offset?: number;
  53224. updatable?: boolean;
  53225. sideOrientation?: number;
  53226. frontUVs?: Vector4;
  53227. backUVs?: Vector4;
  53228. instance?: Mesh;
  53229. invertUV?: boolean;
  53230. uvs?: Vector2[];
  53231. colors?: Color4[];
  53232. }, scene?: Nullable<Scene>): Mesh;
  53233. }
  53234. }
  53235. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53236. import { Nullable } from "babylonjs/types";
  53237. import { Scene } from "babylonjs/scene";
  53238. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53239. import { Mesh } from "babylonjs/Meshes/mesh";
  53240. /**
  53241. * Class containing static functions to help procedurally build meshes
  53242. */
  53243. export class ShapeBuilder {
  53244. /**
  53245. * 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.
  53246. * * 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.
  53247. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53248. * * 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.
  53249. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53250. * * 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
  53251. * * 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
  53252. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53255. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53257. * @param name defines the name of the mesh
  53258. * @param options defines the options used to create the mesh
  53259. * @param scene defines the hosting scene
  53260. * @returns the extruded shape mesh
  53261. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53263. */
  53264. static ExtrudeShape(name: string, options: {
  53265. shape: Vector3[];
  53266. path: Vector3[];
  53267. scale?: number;
  53268. rotation?: number;
  53269. cap?: number;
  53270. updatable?: boolean;
  53271. sideOrientation?: number;
  53272. frontUVs?: Vector4;
  53273. backUVs?: Vector4;
  53274. instance?: Mesh;
  53275. invertUV?: boolean;
  53276. }, scene?: Nullable<Scene>): Mesh;
  53277. /**
  53278. * Creates an custom extruded shape mesh.
  53279. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53280. * * 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.
  53281. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53282. * * 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
  53283. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53284. * * 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
  53285. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53286. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53287. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53288. * * 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
  53289. * * 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
  53290. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53292. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53293. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53295. * @param name defines the name of the mesh
  53296. * @param options defines the options used to create the mesh
  53297. * @param scene defines the hosting scene
  53298. * @returns the custom extruded shape mesh
  53299. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53300. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53302. */
  53303. static ExtrudeShapeCustom(name: string, options: {
  53304. shape: Vector3[];
  53305. path: Vector3[];
  53306. scaleFunction?: any;
  53307. rotationFunction?: any;
  53308. ribbonCloseArray?: boolean;
  53309. ribbonClosePath?: boolean;
  53310. cap?: number;
  53311. updatable?: boolean;
  53312. sideOrientation?: number;
  53313. frontUVs?: Vector4;
  53314. backUVs?: Vector4;
  53315. instance?: Mesh;
  53316. invertUV?: boolean;
  53317. }, scene?: Nullable<Scene>): Mesh;
  53318. private static _ExtrudeShapeGeneric;
  53319. }
  53320. }
  53321. declare module "babylonjs/Debug/skeletonViewer" {
  53322. import { Color3 } from "babylonjs/Maths/math.color";
  53323. import { Scene } from "babylonjs/scene";
  53324. import { Nullable } from "babylonjs/types";
  53325. import { Skeleton } from "babylonjs/Bones/skeleton";
  53326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53327. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53328. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53329. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  53330. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  53331. /**
  53332. * Class used to render a debug view of a given skeleton
  53333. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53334. */
  53335. export class SkeletonViewer {
  53336. /** defines the skeleton to render */
  53337. skeleton: Skeleton;
  53338. /** defines the mesh attached to the skeleton */
  53339. mesh: AbstractMesh;
  53340. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53341. autoUpdateBonesMatrices: boolean;
  53342. /** defines the rendering group id to use with the viewer */
  53343. renderingGroupId: number;
  53344. /** is the options for the viewer */
  53345. options: Partial<ISkeletonViewerOptions>;
  53346. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53347. static readonly DISPLAY_LINES: number;
  53348. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53349. static readonly DISPLAY_SPHERES: number;
  53350. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53351. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53352. /** public static method to create a BoneWeight Shader
  53353. * @param options The constructor options
  53354. * @param scene The scene that the shader is scoped to
  53355. * @returns The created ShaderMaterial
  53356. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  53357. */
  53358. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  53359. /** public static method to create a BoneWeight Shader
  53360. * @param options The constructor options
  53361. * @param scene The scene that the shader is scoped to
  53362. * @returns The created ShaderMaterial
  53363. */
  53364. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  53365. /** private static method to create a BoneWeight Shader
  53366. * @param size The size of the buffer to create (usually the bone count)
  53367. * @param colorMap The gradient data to generate
  53368. * @param scene The scene that the shader is scoped to
  53369. * @returns an Array of floats from the color gradient values
  53370. */
  53371. private static _CreateBoneMapColorBuffer;
  53372. /** If SkeletonViewer scene scope. */
  53373. private _scene;
  53374. /** Gets or sets the color used to render the skeleton */
  53375. color: Color3;
  53376. /** Array of the points of the skeleton fo the line view. */
  53377. private _debugLines;
  53378. /** The SkeletonViewers Mesh. */
  53379. private _debugMesh;
  53380. /** If SkeletonViewer is enabled. */
  53381. private _isEnabled;
  53382. /** If SkeletonViewer is ready. */
  53383. private _ready;
  53384. /** SkeletonViewer render observable. */
  53385. private _obs;
  53386. /** The Utility Layer to render the gizmos in. */
  53387. private _utilityLayer;
  53388. private _boneIndices;
  53389. /** Gets the Scene. */
  53390. get scene(): Scene;
  53391. /** Gets the utilityLayer. */
  53392. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53393. /** Checks Ready Status. */
  53394. get isReady(): Boolean;
  53395. /** Sets Ready Status. */
  53396. set ready(value: boolean);
  53397. /** Gets the debugMesh */
  53398. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53399. /** Sets the debugMesh */
  53400. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53401. /** Gets the displayMode */
  53402. get displayMode(): number;
  53403. /** Sets the displayMode */
  53404. set displayMode(value: number);
  53405. /**
  53406. * Creates a new SkeletonViewer
  53407. * @param skeleton defines the skeleton to render
  53408. * @param mesh defines the mesh attached to the skeleton
  53409. * @param scene defines the hosting scene
  53410. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53411. * @param renderingGroupId defines the rendering group id to use with the viewer
  53412. * @param options All of the extra constructor options for the SkeletonViewer
  53413. */
  53414. constructor(
  53415. /** defines the skeleton to render */
  53416. skeleton: Skeleton,
  53417. /** defines the mesh attached to the skeleton */
  53418. mesh: AbstractMesh,
  53419. /** The Scene scope*/
  53420. scene: Scene,
  53421. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53422. autoUpdateBonesMatrices?: boolean,
  53423. /** defines the rendering group id to use with the viewer */
  53424. renderingGroupId?: number,
  53425. /** is the options for the viewer */
  53426. options?: Partial<ISkeletonViewerOptions>);
  53427. /** The Dynamic bindings for the update functions */
  53428. private _bindObs;
  53429. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53430. update(): void;
  53431. /** Gets or sets a boolean indicating if the viewer is enabled */
  53432. set isEnabled(value: boolean);
  53433. get isEnabled(): boolean;
  53434. private _getBonePosition;
  53435. private _getLinesForBonesWithLength;
  53436. private _getLinesForBonesNoLength;
  53437. /** function to revert the mesh and scene back to the initial state. */
  53438. private _revert;
  53439. /** function to build and bind sphere joint points and spur bone representations. */
  53440. private _buildSpheresAndSpurs;
  53441. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53442. private _displayLinesUpdate;
  53443. /** Changes the displayMode of the skeleton viewer
  53444. * @param mode The displayMode numerical value
  53445. */
  53446. changeDisplayMode(mode: number): void;
  53447. /** Changes the displayMode of the skeleton viewer
  53448. * @param option String of the option name
  53449. * @param value The numerical option value
  53450. */
  53451. changeDisplayOptions(option: string, value: number): void;
  53452. /** Release associated resources */
  53453. dispose(): void;
  53454. }
  53455. }
  53456. declare module "babylonjs/Debug/index" {
  53457. export * from "babylonjs/Debug/axesViewer";
  53458. export * from "babylonjs/Debug/boneAxesViewer";
  53459. export * from "babylonjs/Debug/debugLayer";
  53460. export * from "babylonjs/Debug/physicsViewer";
  53461. export * from "babylonjs/Debug/rayHelper";
  53462. export * from "babylonjs/Debug/skeletonViewer";
  53463. export * from "babylonjs/Debug/ISkeletonViewer";
  53464. }
  53465. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53466. /**
  53467. * Enum for Device Types
  53468. */
  53469. export enum DeviceType {
  53470. /** Generic */
  53471. Generic = 0,
  53472. /** Keyboard */
  53473. Keyboard = 1,
  53474. /** Mouse */
  53475. Mouse = 2,
  53476. /** Touch Pointers */
  53477. Touch = 3,
  53478. /** PS4 Dual Shock */
  53479. DualShock = 4,
  53480. /** Xbox */
  53481. Xbox = 5,
  53482. /** Switch Controller */
  53483. Switch = 6
  53484. }
  53485. /**
  53486. * Enum for All Pointers (Touch/Mouse)
  53487. */
  53488. export enum PointerInput {
  53489. /** Horizontal Axis */
  53490. Horizontal = 0,
  53491. /** Vertical Axis */
  53492. Vertical = 1,
  53493. /** Left Click or Touch */
  53494. LeftClick = 2,
  53495. /** Middle Click */
  53496. MiddleClick = 3,
  53497. /** Right Click */
  53498. RightClick = 4,
  53499. /** Browser Back */
  53500. BrowserBack = 5,
  53501. /** Browser Forward */
  53502. BrowserForward = 6
  53503. }
  53504. /**
  53505. * Enum for Dual Shock Gamepad
  53506. */
  53507. export enum DualShockInput {
  53508. /** Cross */
  53509. Cross = 0,
  53510. /** Circle */
  53511. Circle = 1,
  53512. /** Square */
  53513. Square = 2,
  53514. /** Triangle */
  53515. Triangle = 3,
  53516. /** L1 */
  53517. L1 = 4,
  53518. /** R1 */
  53519. R1 = 5,
  53520. /** L2 */
  53521. L2 = 6,
  53522. /** R2 */
  53523. R2 = 7,
  53524. /** Share */
  53525. Share = 8,
  53526. /** Options */
  53527. Options = 9,
  53528. /** L3 */
  53529. L3 = 10,
  53530. /** R3 */
  53531. R3 = 11,
  53532. /** DPadUp */
  53533. DPadUp = 12,
  53534. /** DPadDown */
  53535. DPadDown = 13,
  53536. /** DPadLeft */
  53537. DPadLeft = 14,
  53538. /** DRight */
  53539. DPadRight = 15,
  53540. /** Home */
  53541. Home = 16,
  53542. /** TouchPad */
  53543. TouchPad = 17,
  53544. /** LStickXAxis */
  53545. LStickXAxis = 18,
  53546. /** LStickYAxis */
  53547. LStickYAxis = 19,
  53548. /** RStickXAxis */
  53549. RStickXAxis = 20,
  53550. /** RStickYAxis */
  53551. RStickYAxis = 21
  53552. }
  53553. /**
  53554. * Enum for Xbox Gamepad
  53555. */
  53556. export enum XboxInput {
  53557. /** A */
  53558. A = 0,
  53559. /** B */
  53560. B = 1,
  53561. /** X */
  53562. X = 2,
  53563. /** Y */
  53564. Y = 3,
  53565. /** LB */
  53566. LB = 4,
  53567. /** RB */
  53568. RB = 5,
  53569. /** LT */
  53570. LT = 6,
  53571. /** RT */
  53572. RT = 7,
  53573. /** Back */
  53574. Back = 8,
  53575. /** Start */
  53576. Start = 9,
  53577. /** LS */
  53578. LS = 10,
  53579. /** RS */
  53580. RS = 11,
  53581. /** DPadUp */
  53582. DPadUp = 12,
  53583. /** DPadDown */
  53584. DPadDown = 13,
  53585. /** DPadLeft */
  53586. DPadLeft = 14,
  53587. /** DRight */
  53588. DPadRight = 15,
  53589. /** Home */
  53590. Home = 16,
  53591. /** LStickXAxis */
  53592. LStickXAxis = 17,
  53593. /** LStickYAxis */
  53594. LStickYAxis = 18,
  53595. /** RStickXAxis */
  53596. RStickXAxis = 19,
  53597. /** RStickYAxis */
  53598. RStickYAxis = 20
  53599. }
  53600. /**
  53601. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53602. */
  53603. export enum SwitchInput {
  53604. /** B */
  53605. B = 0,
  53606. /** A */
  53607. A = 1,
  53608. /** Y */
  53609. Y = 2,
  53610. /** X */
  53611. X = 3,
  53612. /** L */
  53613. L = 4,
  53614. /** R */
  53615. R = 5,
  53616. /** ZL */
  53617. ZL = 6,
  53618. /** ZR */
  53619. ZR = 7,
  53620. /** Minus */
  53621. Minus = 8,
  53622. /** Plus */
  53623. Plus = 9,
  53624. /** LS */
  53625. LS = 10,
  53626. /** RS */
  53627. RS = 11,
  53628. /** DPadUp */
  53629. DPadUp = 12,
  53630. /** DPadDown */
  53631. DPadDown = 13,
  53632. /** DPadLeft */
  53633. DPadLeft = 14,
  53634. /** DRight */
  53635. DPadRight = 15,
  53636. /** Home */
  53637. Home = 16,
  53638. /** Capture */
  53639. Capture = 17,
  53640. /** LStickXAxis */
  53641. LStickXAxis = 18,
  53642. /** LStickYAxis */
  53643. LStickYAxis = 19,
  53644. /** RStickXAxis */
  53645. RStickXAxis = 20,
  53646. /** RStickYAxis */
  53647. RStickYAxis = 21
  53648. }
  53649. }
  53650. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53651. import { Engine } from "babylonjs/Engines/engine";
  53652. import { IDisposable } from "babylonjs/scene";
  53653. import { Nullable } from "babylonjs/types";
  53654. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53655. /**
  53656. * This class will take all inputs from Keyboard, Pointer, and
  53657. * any Gamepads and provide a polling system that all devices
  53658. * will use. This class assumes that there will only be one
  53659. * pointer device and one keyboard.
  53660. */
  53661. export class DeviceInputSystem implements IDisposable {
  53662. /**
  53663. * Callback to be triggered when a device is connected
  53664. */
  53665. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53666. /**
  53667. * Callback to be triggered when a device is disconnected
  53668. */
  53669. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53670. /**
  53671. * Callback to be triggered when event driven input is updated
  53672. */
  53673. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53674. private _inputs;
  53675. private _gamepads;
  53676. private _keyboardActive;
  53677. private _pointerActive;
  53678. private _elementToAttachTo;
  53679. private _keyboardDownEvent;
  53680. private _keyboardUpEvent;
  53681. private _pointerMoveEvent;
  53682. private _pointerDownEvent;
  53683. private _pointerUpEvent;
  53684. private _gamepadConnectedEvent;
  53685. private _gamepadDisconnectedEvent;
  53686. private static _MAX_KEYCODES;
  53687. private static _MAX_POINTER_INPUTS;
  53688. private constructor();
  53689. /**
  53690. * Creates a new DeviceInputSystem instance
  53691. * @param engine Engine to pull input element from
  53692. * @returns The new instance
  53693. */
  53694. static Create(engine: Engine): DeviceInputSystem;
  53695. /**
  53696. * Checks for current device input value, given an id and input index
  53697. * @param deviceName Id of connected device
  53698. * @param inputIndex Index of device input
  53699. * @returns Current value of input
  53700. */
  53701. /**
  53702. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  53703. * @param deviceType Enum specifiying device type
  53704. * @param deviceSlot "Slot" or index that device is referenced in
  53705. * @param inputIndex Id of input to be checked
  53706. * @returns Current value of input
  53707. */
  53708. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  53709. /**
  53710. * Dispose of all the eventlisteners
  53711. */
  53712. dispose(): void;
  53713. /**
  53714. * Add device and inputs to device array
  53715. * @param deviceType Enum specifiying device type
  53716. * @param deviceSlot "Slot" or index that device is referenced in
  53717. * @param numberOfInputs Number of input entries to create for given device
  53718. */
  53719. private _registerDevice;
  53720. /**
  53721. * Given a specific device name, remove that device from the device map
  53722. * @param deviceType Enum specifiying device type
  53723. * @param deviceSlot "Slot" or index that device is referenced in
  53724. */
  53725. private _unregisterDevice;
  53726. /**
  53727. * Handle all actions that come from keyboard interaction
  53728. */
  53729. private _handleKeyActions;
  53730. /**
  53731. * Handle all actions that come from pointer interaction
  53732. */
  53733. private _handlePointerActions;
  53734. /**
  53735. * Handle all actions that come from gamepad interaction
  53736. */
  53737. private _handleGamepadActions;
  53738. /**
  53739. * Update all non-event based devices with each frame
  53740. * @param deviceType Enum specifiying device type
  53741. * @param deviceSlot "Slot" or index that device is referenced in
  53742. * @param inputIndex Id of input to be checked
  53743. */
  53744. private _updateDevice;
  53745. /**
  53746. * Gets DeviceType from the device name
  53747. * @param deviceName Name of Device from DeviceInputSystem
  53748. * @returns DeviceType enum value
  53749. */
  53750. private _getGamepadDeviceType;
  53751. }
  53752. }
  53753. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53754. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53755. /**
  53756. * Type to handle enforcement of inputs
  53757. */
  53758. 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;
  53759. }
  53760. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53761. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53762. import { Engine } from "babylonjs/Engines/engine";
  53763. import { IDisposable } from "babylonjs/scene";
  53764. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53765. import { Nullable } from "babylonjs/types";
  53766. import { Observable } from "babylonjs/Misc/observable";
  53767. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53768. /**
  53769. * Class that handles all input for a specific device
  53770. */
  53771. export class DeviceSource<T extends DeviceType> {
  53772. /** Type of device */
  53773. readonly deviceType: DeviceType;
  53774. /** "Slot" or index that device is referenced in */
  53775. readonly deviceSlot: number;
  53776. /**
  53777. * Observable to handle device input changes per device
  53778. */
  53779. readonly onInputChangedObservable: Observable<{
  53780. inputIndex: DeviceInput<T>;
  53781. previousState: Nullable<number>;
  53782. currentState: Nullable<number>;
  53783. }>;
  53784. private readonly _deviceInputSystem;
  53785. /**
  53786. * Default Constructor
  53787. * @param deviceInputSystem Reference to DeviceInputSystem
  53788. * @param deviceType Type of device
  53789. * @param deviceSlot "Slot" or index that device is referenced in
  53790. */
  53791. constructor(deviceInputSystem: DeviceInputSystem,
  53792. /** Type of device */
  53793. deviceType: DeviceType,
  53794. /** "Slot" or index that device is referenced in */
  53795. deviceSlot?: number);
  53796. /**
  53797. * Get input for specific input
  53798. * @param inputIndex index of specific input on device
  53799. * @returns Input value from DeviceInputSystem
  53800. */
  53801. getInput(inputIndex: DeviceInput<T>): number;
  53802. }
  53803. /**
  53804. * Class to keep track of devices
  53805. */
  53806. export class DeviceSourceManager implements IDisposable {
  53807. /**
  53808. * Observable to be triggered when before a device is connected
  53809. */
  53810. readonly onBeforeDeviceConnectedObservable: Observable<{
  53811. deviceType: DeviceType;
  53812. deviceSlot: number;
  53813. }>;
  53814. /**
  53815. * Observable to be triggered when before a device is disconnected
  53816. */
  53817. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53818. deviceType: DeviceType;
  53819. deviceSlot: number;
  53820. }>;
  53821. /**
  53822. * Observable to be triggered when after a device is connected
  53823. */
  53824. readonly onAfterDeviceConnectedObservable: Observable<{
  53825. deviceType: DeviceType;
  53826. deviceSlot: number;
  53827. }>;
  53828. /**
  53829. * Observable to be triggered when after a device is disconnected
  53830. */
  53831. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53832. deviceType: DeviceType;
  53833. deviceSlot: number;
  53834. }>;
  53835. private readonly _devices;
  53836. private readonly _firstDevice;
  53837. private readonly _deviceInputSystem;
  53838. /**
  53839. * Default Constructor
  53840. * @param engine engine to pull input element from
  53841. */
  53842. constructor(engine: Engine);
  53843. /**
  53844. * Gets a DeviceSource, given a type and slot
  53845. * @param deviceType Enum specifying device type
  53846. * @param deviceSlot "Slot" or index that device is referenced in
  53847. * @returns DeviceSource object
  53848. */
  53849. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53850. /**
  53851. * Gets an array of DeviceSource objects for a given device type
  53852. * @param deviceType Enum specifying device type
  53853. * @returns Array of DeviceSource objects
  53854. */
  53855. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53856. /**
  53857. * Dispose of DeviceInputSystem and other parts
  53858. */
  53859. dispose(): void;
  53860. /**
  53861. * Function to add device name to device list
  53862. * @param deviceType Enum specifying device type
  53863. * @param deviceSlot "Slot" or index that device is referenced in
  53864. */
  53865. private _addDevice;
  53866. /**
  53867. * Function to remove device name to device list
  53868. * @param deviceType Enum specifying device type
  53869. * @param deviceSlot "Slot" or index that device is referenced in
  53870. */
  53871. private _removeDevice;
  53872. /**
  53873. * Updates array storing first connected device of each type
  53874. * @param type Type of Device
  53875. */
  53876. private _updateFirstDevices;
  53877. }
  53878. }
  53879. declare module "babylonjs/DeviceInput/index" {
  53880. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53881. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53882. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53883. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53884. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53885. }
  53886. declare module "babylonjs/Engines/nullEngine" {
  53887. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53888. import { Engine } from "babylonjs/Engines/engine";
  53889. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53890. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53891. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53892. import { Effect } from "babylonjs/Materials/effect";
  53893. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53894. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53895. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53896. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53897. /**
  53898. * Options to create the null engine
  53899. */
  53900. export class NullEngineOptions {
  53901. /**
  53902. * Render width (Default: 512)
  53903. */
  53904. renderWidth: number;
  53905. /**
  53906. * Render height (Default: 256)
  53907. */
  53908. renderHeight: number;
  53909. /**
  53910. * Texture size (Default: 512)
  53911. */
  53912. textureSize: number;
  53913. /**
  53914. * If delta time between frames should be constant
  53915. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53916. */
  53917. deterministicLockstep: boolean;
  53918. /**
  53919. * Maximum about of steps between frames (Default: 4)
  53920. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53921. */
  53922. lockstepMaxSteps: number;
  53923. /**
  53924. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  53925. */
  53926. useHighPrecisionMatrix?: boolean;
  53927. }
  53928. /**
  53929. * The null engine class provides support for headless version of babylon.js.
  53930. * This can be used in server side scenario or for testing purposes
  53931. */
  53932. export class NullEngine extends Engine {
  53933. private _options;
  53934. /**
  53935. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  53936. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53937. * @returns true if engine is in deterministic lock step mode
  53938. */
  53939. isDeterministicLockStep(): boolean;
  53940. /**
  53941. * Gets the max steps when engine is running in deterministic lock step
  53942. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53943. * @returns the max steps
  53944. */
  53945. getLockstepMaxSteps(): number;
  53946. /**
  53947. * Gets the current hardware scaling level.
  53948. * By default the hardware scaling level is computed from the window device ratio.
  53949. * 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.
  53950. * @returns a number indicating the current hardware scaling level
  53951. */
  53952. getHardwareScalingLevel(): number;
  53953. constructor(options?: NullEngineOptions);
  53954. /**
  53955. * Creates a vertex buffer
  53956. * @param vertices the data for the vertex buffer
  53957. * @returns the new WebGL static buffer
  53958. */
  53959. createVertexBuffer(vertices: FloatArray): DataBuffer;
  53960. /**
  53961. * Creates a new index buffer
  53962. * @param indices defines the content of the index buffer
  53963. * @param updatable defines if the index buffer must be updatable
  53964. * @returns a new webGL buffer
  53965. */
  53966. createIndexBuffer(indices: IndicesArray): DataBuffer;
  53967. /**
  53968. * Clear the current render buffer or the current render target (if any is set up)
  53969. * @param color defines the color to use
  53970. * @param backBuffer defines if the back buffer must be cleared
  53971. * @param depth defines if the depth buffer must be cleared
  53972. * @param stencil defines if the stencil buffer must be cleared
  53973. */
  53974. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53975. /**
  53976. * Gets the current render width
  53977. * @param useScreen defines if screen size must be used (or the current render target if any)
  53978. * @returns a number defining the current render width
  53979. */
  53980. getRenderWidth(useScreen?: boolean): number;
  53981. /**
  53982. * Gets the current render height
  53983. * @param useScreen defines if screen size must be used (or the current render target if any)
  53984. * @returns a number defining the current render height
  53985. */
  53986. getRenderHeight(useScreen?: boolean): number;
  53987. /**
  53988. * Set the WebGL's viewport
  53989. * @param viewport defines the viewport element to be used
  53990. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  53991. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  53992. */
  53993. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  53994. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  53995. /**
  53996. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  53997. * @param pipelineContext defines the pipeline context to use
  53998. * @param uniformsNames defines the list of uniform names
  53999. * @returns an array of webGL uniform locations
  54000. */
  54001. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  54002. /**
  54003. * Gets the lsit of active attributes for a given webGL program
  54004. * @param pipelineContext defines the pipeline context to use
  54005. * @param attributesNames defines the list of attribute names to get
  54006. * @returns an array of indices indicating the offset of each attribute
  54007. */
  54008. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54009. /**
  54010. * Binds an effect to the webGL context
  54011. * @param effect defines the effect to bind
  54012. */
  54013. bindSamplers(effect: Effect): void;
  54014. /**
  54015. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  54016. * @param effect defines the effect to activate
  54017. */
  54018. enableEffect(effect: Effect): void;
  54019. /**
  54020. * Set various states to the webGL context
  54021. * @param culling defines backface culling state
  54022. * @param zOffset defines the value to apply to zOffset (0 by default)
  54023. * @param force defines if states must be applied even if cache is up to date
  54024. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  54025. */
  54026. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54027. /**
  54028. * Set the value of an uniform to an array of int32
  54029. * @param uniform defines the webGL uniform location where to store the value
  54030. * @param array defines the array of int32 to store
  54031. */
  54032. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  54033. /**
  54034. * Set the value of an uniform to an array of int32 (stored as vec2)
  54035. * @param uniform defines the webGL uniform location where to store the value
  54036. * @param array defines the array of int32 to store
  54037. */
  54038. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  54039. /**
  54040. * Set the value of an uniform to an array of int32 (stored as vec3)
  54041. * @param uniform defines the webGL uniform location where to store the value
  54042. * @param array defines the array of int32 to store
  54043. */
  54044. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  54045. /**
  54046. * Set the value of an uniform to an array of int32 (stored as vec4)
  54047. * @param uniform defines the webGL uniform location where to store the value
  54048. * @param array defines the array of int32 to store
  54049. */
  54050. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  54051. /**
  54052. * Set the value of an uniform to an array of float32
  54053. * @param uniform defines the webGL uniform location where to store the value
  54054. * @param array defines the array of float32 to store
  54055. */
  54056. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  54057. /**
  54058. * Set the value of an uniform to an array of float32 (stored as vec2)
  54059. * @param uniform defines the webGL uniform location where to store the value
  54060. * @param array defines the array of float32 to store
  54061. */
  54062. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  54063. /**
  54064. * Set the value of an uniform to an array of float32 (stored as vec3)
  54065. * @param uniform defines the webGL uniform location where to store the value
  54066. * @param array defines the array of float32 to store
  54067. */
  54068. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  54069. /**
  54070. * Set the value of an uniform to an array of float32 (stored as vec4)
  54071. * @param uniform defines the webGL uniform location where to store the value
  54072. * @param array defines the array of float32 to store
  54073. */
  54074. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  54075. /**
  54076. * Set the value of an uniform to an array of number
  54077. * @param uniform defines the webGL uniform location where to store the value
  54078. * @param array defines the array of number to store
  54079. */
  54080. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  54081. /**
  54082. * Set the value of an uniform to an array of number (stored as vec2)
  54083. * @param uniform defines the webGL uniform location where to store the value
  54084. * @param array defines the array of number to store
  54085. */
  54086. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  54087. /**
  54088. * Set the value of an uniform to an array of number (stored as vec3)
  54089. * @param uniform defines the webGL uniform location where to store the value
  54090. * @param array defines the array of number to store
  54091. */
  54092. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  54093. /**
  54094. * Set the value of an uniform to an array of number (stored as vec4)
  54095. * @param uniform defines the webGL uniform location where to store the value
  54096. * @param array defines the array of number to store
  54097. */
  54098. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  54099. /**
  54100. * Set the value of an uniform to an array of float32 (stored as matrices)
  54101. * @param uniform defines the webGL uniform location where to store the value
  54102. * @param matrices defines the array of float32 to store
  54103. */
  54104. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  54105. /**
  54106. * Set the value of an uniform to a matrix (3x3)
  54107. * @param uniform defines the webGL uniform location where to store the value
  54108. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  54109. */
  54110. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54111. /**
  54112. * Set the value of an uniform to a matrix (2x2)
  54113. * @param uniform defines the webGL uniform location where to store the value
  54114. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  54115. */
  54116. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54117. /**
  54118. * Set the value of an uniform to a number (float)
  54119. * @param uniform defines the webGL uniform location where to store the value
  54120. * @param value defines the float number to store
  54121. */
  54122. setFloat(uniform: WebGLUniformLocation, value: number): void;
  54123. /**
  54124. * Set the value of an uniform to a vec2
  54125. * @param uniform defines the webGL uniform location where to store the value
  54126. * @param x defines the 1st component of the value
  54127. * @param y defines the 2nd component of the value
  54128. */
  54129. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  54130. /**
  54131. * Set the value of an uniform to a vec3
  54132. * @param uniform defines the webGL uniform location where to store the value
  54133. * @param x defines the 1st component of the value
  54134. * @param y defines the 2nd component of the value
  54135. * @param z defines the 3rd component of the value
  54136. */
  54137. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  54138. /**
  54139. * Set the value of an uniform to a boolean
  54140. * @param uniform defines the webGL uniform location where to store the value
  54141. * @param bool defines the boolean to store
  54142. */
  54143. setBool(uniform: WebGLUniformLocation, bool: number): void;
  54144. /**
  54145. * Set the value of an uniform to a vec4
  54146. * @param uniform defines the webGL uniform location where to store the value
  54147. * @param x defines the 1st component of the value
  54148. * @param y defines the 2nd component of the value
  54149. * @param z defines the 3rd component of the value
  54150. * @param w defines the 4th component of the value
  54151. */
  54152. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54153. /**
  54154. * Sets the current alpha mode
  54155. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  54156. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54157. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54158. */
  54159. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54160. /**
  54161. * Bind webGl buffers directly to the webGL context
  54162. * @param vertexBuffers defines the vertex buffer to bind
  54163. * @param indexBuffer defines the index buffer to bind
  54164. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  54165. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  54166. * @param effect defines the effect associated with the vertex buffer
  54167. */
  54168. bindBuffers(vertexBuffers: {
  54169. [key: string]: VertexBuffer;
  54170. }, indexBuffer: DataBuffer, effect: Effect): void;
  54171. /**
  54172. * Force the entire cache to be cleared
  54173. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  54174. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  54175. */
  54176. wipeCaches(bruteForce?: boolean): void;
  54177. /**
  54178. * Send a draw order
  54179. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  54180. * @param indexStart defines the starting index
  54181. * @param indexCount defines the number of index to draw
  54182. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54183. */
  54184. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  54185. /**
  54186. * Draw a list of indexed primitives
  54187. * @param fillMode defines the primitive to use
  54188. * @param indexStart defines the starting index
  54189. * @param indexCount defines the number of index to draw
  54190. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54191. */
  54192. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54193. /**
  54194. * Draw a list of unindexed primitives
  54195. * @param fillMode defines the primitive to use
  54196. * @param verticesStart defines the index of first vertex to draw
  54197. * @param verticesCount defines the count of vertices to draw
  54198. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54199. */
  54200. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54201. /** @hidden */
  54202. _createTexture(): WebGLTexture;
  54203. /** @hidden */
  54204. _releaseTexture(texture: InternalTexture): void;
  54205. /**
  54206. * Usually called from Texture.ts.
  54207. * Passed information to create a WebGLTexture
  54208. * @param urlArg defines a value which contains one of the following:
  54209. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54210. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54211. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54212. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54213. * @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)
  54214. * @param scene needed for loading to the correct scene
  54215. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54216. * @param onLoad optional callback to be called upon successful completion
  54217. * @param onError optional callback to be called upon failure
  54218. * @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
  54219. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54220. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54221. * @param forcedExtension defines the extension to use to pick the right loader
  54222. * @param mimeType defines an optional mime type
  54223. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54224. */
  54225. 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;
  54226. /**
  54227. * Creates a new render target texture
  54228. * @param size defines the size of the texture
  54229. * @param options defines the options used to create the texture
  54230. * @returns a new render target texture stored in an InternalTexture
  54231. */
  54232. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  54233. /**
  54234. * Update the sampling mode of a given texture
  54235. * @param samplingMode defines the required sampling mode
  54236. * @param texture defines the texture to update
  54237. */
  54238. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54239. /**
  54240. * Binds the frame buffer to the specified texture.
  54241. * @param texture The texture to render to or null for the default canvas
  54242. * @param faceIndex The face of the texture to render to in case of cube texture
  54243. * @param requiredWidth The width of the target to render to
  54244. * @param requiredHeight The height of the target to render to
  54245. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54246. * @param lodLevel defines le lod level to bind to the frame buffer
  54247. */
  54248. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54249. /**
  54250. * Unbind the current render target texture from the webGL context
  54251. * @param texture defines the render target texture to unbind
  54252. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54253. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54254. */
  54255. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54256. /**
  54257. * Creates a dynamic vertex buffer
  54258. * @param vertices the data for the dynamic vertex buffer
  54259. * @returns the new WebGL dynamic buffer
  54260. */
  54261. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54262. /**
  54263. * Update the content of a dynamic texture
  54264. * @param texture defines the texture to update
  54265. * @param canvas defines the canvas containing the source
  54266. * @param invertY defines if data must be stored with Y axis inverted
  54267. * @param premulAlpha defines if alpha is stored as premultiplied
  54268. * @param format defines the format of the data
  54269. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54270. */
  54271. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54272. /**
  54273. * Gets a boolean indicating if all created effects are ready
  54274. * @returns true if all effects are ready
  54275. */
  54276. areAllEffectsReady(): boolean;
  54277. /**
  54278. * @hidden
  54279. * Get the current error code of the webGL context
  54280. * @returns the error code
  54281. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54282. */
  54283. getError(): number;
  54284. /** @hidden */
  54285. _getUnpackAlignement(): number;
  54286. /** @hidden */
  54287. _unpackFlipY(value: boolean): void;
  54288. /**
  54289. * Update a dynamic index buffer
  54290. * @param indexBuffer defines the target index buffer
  54291. * @param indices defines the data to update
  54292. * @param offset defines the offset in the target index buffer where update should start
  54293. */
  54294. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54295. /**
  54296. * Updates a dynamic vertex buffer.
  54297. * @param vertexBuffer the vertex buffer to update
  54298. * @param vertices the data used to update the vertex buffer
  54299. * @param byteOffset the byte offset of the data (optional)
  54300. * @param byteLength the byte length of the data (optional)
  54301. */
  54302. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54303. /** @hidden */
  54304. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54305. /** @hidden */
  54306. _bindTexture(channel: number, texture: InternalTexture): void;
  54307. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54308. /**
  54309. * 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
  54310. */
  54311. releaseEffects(): void;
  54312. displayLoadingUI(): void;
  54313. hideLoadingUI(): void;
  54314. /** @hidden */
  54315. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54316. /** @hidden */
  54317. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54318. /** @hidden */
  54319. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54320. /** @hidden */
  54321. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54322. }
  54323. }
  54324. declare module "babylonjs/Instrumentation/timeToken" {
  54325. import { Nullable } from "babylonjs/types";
  54326. /**
  54327. * @hidden
  54328. **/
  54329. export class _TimeToken {
  54330. _startTimeQuery: Nullable<WebGLQuery>;
  54331. _endTimeQuery: Nullable<WebGLQuery>;
  54332. _timeElapsedQuery: Nullable<WebGLQuery>;
  54333. _timeElapsedQueryEnded: boolean;
  54334. }
  54335. }
  54336. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54337. import { Nullable, int } from "babylonjs/types";
  54338. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54339. /** @hidden */
  54340. export class _OcclusionDataStorage {
  54341. /** @hidden */
  54342. occlusionInternalRetryCounter: number;
  54343. /** @hidden */
  54344. isOcclusionQueryInProgress: boolean;
  54345. /** @hidden */
  54346. isOccluded: boolean;
  54347. /** @hidden */
  54348. occlusionRetryCount: number;
  54349. /** @hidden */
  54350. occlusionType: number;
  54351. /** @hidden */
  54352. occlusionQueryAlgorithmType: number;
  54353. }
  54354. module "babylonjs/Engines/engine" {
  54355. interface Engine {
  54356. /**
  54357. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54358. * @return the new query
  54359. */
  54360. createQuery(): WebGLQuery;
  54361. /**
  54362. * Delete and release a webGL query
  54363. * @param query defines the query to delete
  54364. * @return the current engine
  54365. */
  54366. deleteQuery(query: WebGLQuery): Engine;
  54367. /**
  54368. * Check if a given query has resolved and got its value
  54369. * @param query defines the query to check
  54370. * @returns true if the query got its value
  54371. */
  54372. isQueryResultAvailable(query: WebGLQuery): boolean;
  54373. /**
  54374. * Gets the value of a given query
  54375. * @param query defines the query to check
  54376. * @returns the value of the query
  54377. */
  54378. getQueryResult(query: WebGLQuery): number;
  54379. /**
  54380. * Initiates an occlusion query
  54381. * @param algorithmType defines the algorithm to use
  54382. * @param query defines the query to use
  54383. * @returns the current engine
  54384. * @see https://doc.babylonjs.com/features/occlusionquery
  54385. */
  54386. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54387. /**
  54388. * Ends an occlusion query
  54389. * @see https://doc.babylonjs.com/features/occlusionquery
  54390. * @param algorithmType defines the algorithm to use
  54391. * @returns the current engine
  54392. */
  54393. endOcclusionQuery(algorithmType: number): Engine;
  54394. /**
  54395. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54396. * Please note that only one query can be issued at a time
  54397. * @returns a time token used to track the time span
  54398. */
  54399. startTimeQuery(): Nullable<_TimeToken>;
  54400. /**
  54401. * Ends a time query
  54402. * @param token defines the token used to measure the time span
  54403. * @returns the time spent (in ns)
  54404. */
  54405. endTimeQuery(token: _TimeToken): int;
  54406. /** @hidden */
  54407. _currentNonTimestampToken: Nullable<_TimeToken>;
  54408. /** @hidden */
  54409. _createTimeQuery(): WebGLQuery;
  54410. /** @hidden */
  54411. _deleteTimeQuery(query: WebGLQuery): void;
  54412. /** @hidden */
  54413. _getGlAlgorithmType(algorithmType: number): number;
  54414. /** @hidden */
  54415. _getTimeQueryResult(query: WebGLQuery): any;
  54416. /** @hidden */
  54417. _getTimeQueryAvailability(query: WebGLQuery): any;
  54418. }
  54419. }
  54420. module "babylonjs/Meshes/abstractMesh" {
  54421. interface AbstractMesh {
  54422. /**
  54423. * Backing filed
  54424. * @hidden
  54425. */
  54426. __occlusionDataStorage: _OcclusionDataStorage;
  54427. /**
  54428. * Access property
  54429. * @hidden
  54430. */
  54431. _occlusionDataStorage: _OcclusionDataStorage;
  54432. /**
  54433. * 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.
  54434. * The default value is -1 which means don't break the query and wait till the result
  54435. * @see https://doc.babylonjs.com/features/occlusionquery
  54436. */
  54437. occlusionRetryCount: number;
  54438. /**
  54439. * 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:
  54440. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54441. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54442. * * 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.
  54443. * @see https://doc.babylonjs.com/features/occlusionquery
  54444. */
  54445. occlusionType: number;
  54446. /**
  54447. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54448. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54449. * * 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.
  54450. * @see https://doc.babylonjs.com/features/occlusionquery
  54451. */
  54452. occlusionQueryAlgorithmType: number;
  54453. /**
  54454. * 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
  54455. * @see https://doc.babylonjs.com/features/occlusionquery
  54456. */
  54457. isOccluded: boolean;
  54458. /**
  54459. * Flag to check the progress status of the query
  54460. * @see https://doc.babylonjs.com/features/occlusionquery
  54461. */
  54462. isOcclusionQueryInProgress: boolean;
  54463. }
  54464. }
  54465. }
  54466. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54467. import { Nullable } from "babylonjs/types";
  54468. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54469. /** @hidden */
  54470. export var _forceTransformFeedbackToBundle: boolean;
  54471. module "babylonjs/Engines/engine" {
  54472. interface Engine {
  54473. /**
  54474. * Creates a webGL transform feedback object
  54475. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54476. * @returns the webGL transform feedback object
  54477. */
  54478. createTransformFeedback(): WebGLTransformFeedback;
  54479. /**
  54480. * Delete a webGL transform feedback object
  54481. * @param value defines the webGL transform feedback object to delete
  54482. */
  54483. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54484. /**
  54485. * Bind a webGL transform feedback object to the webgl context
  54486. * @param value defines the webGL transform feedback object to bind
  54487. */
  54488. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54489. /**
  54490. * Begins a transform feedback operation
  54491. * @param usePoints defines if points or triangles must be used
  54492. */
  54493. beginTransformFeedback(usePoints: boolean): void;
  54494. /**
  54495. * Ends a transform feedback operation
  54496. */
  54497. endTransformFeedback(): void;
  54498. /**
  54499. * Specify the varyings to use with transform feedback
  54500. * @param program defines the associated webGL program
  54501. * @param value defines the list of strings representing the varying names
  54502. */
  54503. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54504. /**
  54505. * Bind a webGL buffer for a transform feedback operation
  54506. * @param value defines the webGL buffer to bind
  54507. */
  54508. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54509. }
  54510. }
  54511. }
  54512. declare module "babylonjs/Engines/Extensions/engine.views" {
  54513. import { Camera } from "babylonjs/Cameras/camera";
  54514. import { Nullable } from "babylonjs/types";
  54515. /**
  54516. * Class used to define an additional view for the engine
  54517. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54518. */
  54519. export class EngineView {
  54520. /** Defines the canvas where to render the view */
  54521. target: HTMLCanvasElement;
  54522. /** Defines an optional camera used to render the view (will use active camera else) */
  54523. camera?: Camera;
  54524. }
  54525. module "babylonjs/Engines/engine" {
  54526. interface Engine {
  54527. /**
  54528. * Gets or sets the HTML element to use for attaching events
  54529. */
  54530. inputElement: Nullable<HTMLElement>;
  54531. /**
  54532. * Gets the current engine view
  54533. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54534. */
  54535. activeView: Nullable<EngineView>;
  54536. /** Gets or sets the list of views */
  54537. views: EngineView[];
  54538. /**
  54539. * Register a new child canvas
  54540. * @param canvas defines the canvas to register
  54541. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54542. * @returns the associated view
  54543. */
  54544. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54545. /**
  54546. * Remove a registered child canvas
  54547. * @param canvas defines the canvas to remove
  54548. * @returns the current engine
  54549. */
  54550. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54551. }
  54552. }
  54553. }
  54554. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54555. import { Nullable } from "babylonjs/types";
  54556. module "babylonjs/Engines/engine" {
  54557. interface Engine {
  54558. /** @hidden */
  54559. _excludedCompressedTextures: string[];
  54560. /** @hidden */
  54561. _textureFormatInUse: string;
  54562. /**
  54563. * Gets the list of texture formats supported
  54564. */
  54565. readonly texturesSupported: Array<string>;
  54566. /**
  54567. * Gets the texture format in use
  54568. */
  54569. readonly textureFormatInUse: Nullable<string>;
  54570. /**
  54571. * Set the compressed texture extensions or file names to skip.
  54572. *
  54573. * @param skippedFiles defines the list of those texture files you want to skip
  54574. * Example: [".dds", ".env", "myfile.png"]
  54575. */
  54576. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54577. /**
  54578. * Set the compressed texture format to use, based on the formats you have, and the formats
  54579. * supported by the hardware / browser.
  54580. *
  54581. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54582. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54583. * to API arguments needed to compressed textures. This puts the burden on the container
  54584. * generator to house the arcane code for determining these for current & future formats.
  54585. *
  54586. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54587. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54588. *
  54589. * Note: The result of this call is not taken into account when a texture is base64.
  54590. *
  54591. * @param formatsAvailable defines the list of those format families you have created
  54592. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54593. *
  54594. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54595. * @returns The extension selected.
  54596. */
  54597. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54598. }
  54599. }
  54600. }
  54601. declare module "babylonjs/Engines/Extensions/index" {
  54602. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54603. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54604. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54605. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54606. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54607. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54608. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54609. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54610. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54611. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54612. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54613. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54614. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54615. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54616. export * from "babylonjs/Engines/Extensions/engine.views";
  54617. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54618. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54619. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54620. }
  54621. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54622. import { Nullable } from "babylonjs/types";
  54623. /**
  54624. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54625. */
  54626. export interface CubeMapInfo {
  54627. /**
  54628. * The pixel array for the front face.
  54629. * This is stored in format, left to right, up to down format.
  54630. */
  54631. front: Nullable<ArrayBufferView>;
  54632. /**
  54633. * The pixel array for the back face.
  54634. * This is stored in format, left to right, up to down format.
  54635. */
  54636. back: Nullable<ArrayBufferView>;
  54637. /**
  54638. * The pixel array for the left face.
  54639. * This is stored in format, left to right, up to down format.
  54640. */
  54641. left: Nullable<ArrayBufferView>;
  54642. /**
  54643. * The pixel array for the right face.
  54644. * This is stored in format, left to right, up to down format.
  54645. */
  54646. right: Nullable<ArrayBufferView>;
  54647. /**
  54648. * The pixel array for the up face.
  54649. * This is stored in format, left to right, up to down format.
  54650. */
  54651. up: Nullable<ArrayBufferView>;
  54652. /**
  54653. * The pixel array for the down face.
  54654. * This is stored in format, left to right, up to down format.
  54655. */
  54656. down: Nullable<ArrayBufferView>;
  54657. /**
  54658. * The size of the cubemap stored.
  54659. *
  54660. * Each faces will be size * size pixels.
  54661. */
  54662. size: number;
  54663. /**
  54664. * The format of the texture.
  54665. *
  54666. * RGBA, RGB.
  54667. */
  54668. format: number;
  54669. /**
  54670. * The type of the texture data.
  54671. *
  54672. * UNSIGNED_INT, FLOAT.
  54673. */
  54674. type: number;
  54675. /**
  54676. * Specifies whether the texture is in gamma space.
  54677. */
  54678. gammaSpace: boolean;
  54679. }
  54680. /**
  54681. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54682. */
  54683. export class PanoramaToCubeMapTools {
  54684. private static FACE_LEFT;
  54685. private static FACE_RIGHT;
  54686. private static FACE_FRONT;
  54687. private static FACE_BACK;
  54688. private static FACE_DOWN;
  54689. private static FACE_UP;
  54690. /**
  54691. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54692. *
  54693. * @param float32Array The source data.
  54694. * @param inputWidth The width of the input panorama.
  54695. * @param inputHeight The height of the input panorama.
  54696. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54697. * @return The cubemap data
  54698. */
  54699. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54700. private static CreateCubemapTexture;
  54701. private static CalcProjectionSpherical;
  54702. }
  54703. }
  54704. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54705. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54706. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54707. import { Nullable } from "babylonjs/types";
  54708. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54709. /**
  54710. * Helper class dealing with the extraction of spherical polynomial dataArray
  54711. * from a cube map.
  54712. */
  54713. export class CubeMapToSphericalPolynomialTools {
  54714. private static FileFaces;
  54715. /**
  54716. * Converts a texture to the according Spherical Polynomial data.
  54717. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54718. *
  54719. * @param texture The texture to extract the information from.
  54720. * @return The Spherical Polynomial data.
  54721. */
  54722. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54723. /**
  54724. * Converts a cubemap to the according Spherical Polynomial data.
  54725. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54726. *
  54727. * @param cubeInfo The Cube map to extract the information from.
  54728. * @return The Spherical Polynomial data.
  54729. */
  54730. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54731. }
  54732. }
  54733. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54734. import { Nullable } from "babylonjs/types";
  54735. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54736. module "babylonjs/Materials/Textures/baseTexture" {
  54737. interface BaseTexture {
  54738. /**
  54739. * Get the polynomial representation of the texture data.
  54740. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54741. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54742. */
  54743. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54744. }
  54745. }
  54746. }
  54747. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54748. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54749. /** @hidden */
  54750. export var rgbdEncodePixelShader: {
  54751. name: string;
  54752. shader: string;
  54753. };
  54754. }
  54755. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54756. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54757. /** @hidden */
  54758. export var rgbdDecodePixelShader: {
  54759. name: string;
  54760. shader: string;
  54761. };
  54762. }
  54763. declare module "babylonjs/Misc/environmentTextureTools" {
  54764. import { Nullable } from "babylonjs/types";
  54765. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54766. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54767. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54768. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54769. import "babylonjs/Engines/Extensions/engine.readTexture";
  54770. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54771. import "babylonjs/Shaders/rgbdEncode.fragment";
  54772. import "babylonjs/Shaders/rgbdDecode.fragment";
  54773. /**
  54774. * Raw texture data and descriptor sufficient for WebGL texture upload
  54775. */
  54776. export interface EnvironmentTextureInfo {
  54777. /**
  54778. * Version of the environment map
  54779. */
  54780. version: number;
  54781. /**
  54782. * Width of image
  54783. */
  54784. width: number;
  54785. /**
  54786. * Irradiance information stored in the file.
  54787. */
  54788. irradiance: any;
  54789. /**
  54790. * Specular information stored in the file.
  54791. */
  54792. specular: any;
  54793. }
  54794. /**
  54795. * Defines One Image in the file. It requires only the position in the file
  54796. * as well as the length.
  54797. */
  54798. interface BufferImageData {
  54799. /**
  54800. * Length of the image data.
  54801. */
  54802. length: number;
  54803. /**
  54804. * Position of the data from the null terminator delimiting the end of the JSON.
  54805. */
  54806. position: number;
  54807. }
  54808. /**
  54809. * Defines the specular data enclosed in the file.
  54810. * This corresponds to the version 1 of the data.
  54811. */
  54812. export interface EnvironmentTextureSpecularInfoV1 {
  54813. /**
  54814. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54815. */
  54816. specularDataPosition?: number;
  54817. /**
  54818. * This contains all the images data needed to reconstruct the cubemap.
  54819. */
  54820. mipmaps: Array<BufferImageData>;
  54821. /**
  54822. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54823. */
  54824. lodGenerationScale: number;
  54825. }
  54826. /**
  54827. * Sets of helpers addressing the serialization and deserialization of environment texture
  54828. * stored in a BabylonJS env file.
  54829. * Those files are usually stored as .env files.
  54830. */
  54831. export class EnvironmentTextureTools {
  54832. /**
  54833. * Magic number identifying the env file.
  54834. */
  54835. private static _MagicBytes;
  54836. /**
  54837. * Gets the environment info from an env file.
  54838. * @param data The array buffer containing the .env bytes.
  54839. * @returns the environment file info (the json header) if successfully parsed.
  54840. */
  54841. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54842. /**
  54843. * Creates an environment texture from a loaded cube texture.
  54844. * @param texture defines the cube texture to convert in env file
  54845. * @return a promise containing the environment data if succesfull.
  54846. */
  54847. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54848. /**
  54849. * Creates a JSON representation of the spherical data.
  54850. * @param texture defines the texture containing the polynomials
  54851. * @return the JSON representation of the spherical info
  54852. */
  54853. private static _CreateEnvTextureIrradiance;
  54854. /**
  54855. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54856. * @param data the image data
  54857. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54858. * @return the views described by info providing access to the underlying buffer
  54859. */
  54860. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54861. /**
  54862. * Uploads the texture info contained in the env file to the GPU.
  54863. * @param texture defines the internal texture to upload to
  54864. * @param data defines the data to load
  54865. * @param info defines the texture info retrieved through the GetEnvInfo method
  54866. * @returns a promise
  54867. */
  54868. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54869. private static _OnImageReadyAsync;
  54870. /**
  54871. * Uploads the levels of image data to the GPU.
  54872. * @param texture defines the internal texture to upload to
  54873. * @param imageData defines the array buffer views of image data [mipmap][face]
  54874. * @returns a promise
  54875. */
  54876. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54877. /**
  54878. * Uploads spherical polynomials information to the texture.
  54879. * @param texture defines the texture we are trying to upload the information to
  54880. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54881. */
  54882. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54883. /** @hidden */
  54884. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54885. }
  54886. }
  54887. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54888. /**
  54889. * Class used to inline functions in shader code
  54890. */
  54891. export class ShaderCodeInliner {
  54892. private static readonly _RegexpFindFunctionNameAndType;
  54893. private _sourceCode;
  54894. private _functionDescr;
  54895. private _numMaxIterations;
  54896. /** Gets or sets the token used to mark the functions to inline */
  54897. inlineToken: string;
  54898. /** Gets or sets the debug mode */
  54899. debug: boolean;
  54900. /** Gets the code after the inlining process */
  54901. get code(): string;
  54902. /**
  54903. * Initializes the inliner
  54904. * @param sourceCode shader code source to inline
  54905. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  54906. */
  54907. constructor(sourceCode: string, numMaxIterations?: number);
  54908. /**
  54909. * Start the processing of the shader code
  54910. */
  54911. processCode(): void;
  54912. private _collectFunctions;
  54913. private _processInlining;
  54914. private _extractBetweenMarkers;
  54915. private _skipWhitespaces;
  54916. private _removeComments;
  54917. private _replaceFunctionCallsByCode;
  54918. private _findBackward;
  54919. private _escapeRegExp;
  54920. private _replaceNames;
  54921. }
  54922. }
  54923. declare module "babylonjs/Engines/nativeEngine" {
  54924. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  54925. import { Engine } from "babylonjs/Engines/engine";
  54926. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54927. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54928. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54929. import { Effect } from "babylonjs/Materials/effect";
  54930. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54931. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  54932. import { IColor4Like } from "babylonjs/Maths/math.like";
  54933. import { Scene } from "babylonjs/scene";
  54934. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54935. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54936. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54937. /**
  54938. * Container for accessors for natively-stored mesh data buffers.
  54939. */
  54940. class NativeDataBuffer extends DataBuffer {
  54941. /**
  54942. * Accessor value used to identify/retrieve a natively-stored index buffer.
  54943. */
  54944. nativeIndexBuffer?: any;
  54945. /**
  54946. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  54947. */
  54948. nativeVertexBuffer?: any;
  54949. }
  54950. /** @hidden */
  54951. class NativeTexture extends InternalTexture {
  54952. getInternalTexture(): InternalTexture;
  54953. getViewCount(): number;
  54954. }
  54955. /** @hidden */
  54956. export class NativeEngine extends Engine {
  54957. private readonly _native;
  54958. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  54959. private readonly INVALID_HANDLE;
  54960. private _boundBuffersVertexArray;
  54961. getHardwareScalingLevel(): number;
  54962. constructor();
  54963. dispose(): void;
  54964. /**
  54965. * Can be used to override the current requestAnimationFrame requester.
  54966. * @hidden
  54967. */
  54968. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  54969. /**
  54970. * Override default engine behavior.
  54971. * @param color
  54972. * @param backBuffer
  54973. * @param depth
  54974. * @param stencil
  54975. */
  54976. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  54977. /**
  54978. * Gets host document
  54979. * @returns the host document object
  54980. */
  54981. getHostDocument(): Nullable<Document>;
  54982. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54983. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  54984. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  54985. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  54986. [key: string]: VertexBuffer;
  54987. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54988. bindBuffers(vertexBuffers: {
  54989. [key: string]: VertexBuffer;
  54990. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54991. recordVertexArrayObject(vertexBuffers: {
  54992. [key: string]: VertexBuffer;
  54993. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  54994. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54995. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54996. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54997. /**
  54998. * Draw a list of indexed primitives
  54999. * @param fillMode defines the primitive to use
  55000. * @param indexStart defines the starting index
  55001. * @param indexCount defines the number of index to draw
  55002. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55003. */
  55004. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55005. /**
  55006. * Draw a list of unindexed primitives
  55007. * @param fillMode defines the primitive to use
  55008. * @param verticesStart defines the index of first vertex to draw
  55009. * @param verticesCount defines the count of vertices to draw
  55010. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55011. */
  55012. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55013. createPipelineContext(): IPipelineContext;
  55014. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55015. /** @hidden */
  55016. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55017. /** @hidden */
  55018. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55019. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55020. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55021. protected _setProgram(program: WebGLProgram): void;
  55022. _releaseEffect(effect: Effect): void;
  55023. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55024. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55025. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55026. bindSamplers(effect: Effect): void;
  55027. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55028. getRenderWidth(useScreen?: boolean): number;
  55029. getRenderHeight(useScreen?: boolean): number;
  55030. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55031. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55032. /**
  55033. * Set the z offset to apply to current rendering
  55034. * @param value defines the offset to apply
  55035. */
  55036. setZOffset(value: number): void;
  55037. /**
  55038. * Gets the current value of the zOffset
  55039. * @returns the current zOffset state
  55040. */
  55041. getZOffset(): number;
  55042. /**
  55043. * Enable or disable depth buffering
  55044. * @param enable defines the state to set
  55045. */
  55046. setDepthBuffer(enable: boolean): void;
  55047. /**
  55048. * Gets a boolean indicating if depth writing is enabled
  55049. * @returns the current depth writing state
  55050. */
  55051. getDepthWrite(): boolean;
  55052. /**
  55053. * Enable or disable depth writing
  55054. * @param enable defines the state to set
  55055. */
  55056. setDepthWrite(enable: boolean): void;
  55057. /**
  55058. * Enable or disable color writing
  55059. * @param enable defines the state to set
  55060. */
  55061. setColorWrite(enable: boolean): void;
  55062. /**
  55063. * Gets a boolean indicating if color writing is enabled
  55064. * @returns the current color writing state
  55065. */
  55066. getColorWrite(): boolean;
  55067. /**
  55068. * Sets alpha constants used by some alpha blending modes
  55069. * @param r defines the red component
  55070. * @param g defines the green component
  55071. * @param b defines the blue component
  55072. * @param a defines the alpha component
  55073. */
  55074. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55075. /**
  55076. * Sets the current alpha mode
  55077. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55078. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55079. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55080. */
  55081. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55082. /**
  55083. * Gets the current alpha mode
  55084. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55085. * @returns the current alpha mode
  55086. */
  55087. getAlphaMode(): number;
  55088. setInt(uniform: WebGLUniformLocation, int: number): void;
  55089. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  55090. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  55091. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  55092. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  55093. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  55094. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  55095. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  55096. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  55097. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  55098. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  55099. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  55100. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  55101. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  55102. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  55103. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  55104. setFloat(uniform: WebGLUniformLocation, value: number): void;
  55105. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  55106. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  55107. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  55108. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  55109. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  55110. wipeCaches(bruteForce?: boolean): void;
  55111. _createTexture(): WebGLTexture;
  55112. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55113. /**
  55114. * Usually called from Texture.ts.
  55115. * Passed information to create a WebGLTexture
  55116. * @param url defines a value which contains one of the following:
  55117. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55118. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55119. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55120. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55121. * @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)
  55122. * @param scene needed for loading to the correct scene
  55123. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55124. * @param onLoad optional callback to be called upon successful completion
  55125. * @param onError optional callback to be called upon failure
  55126. * @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
  55127. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55128. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55129. * @param forcedExtension defines the extension to use to pick the right loader
  55130. * @param mimeType defines an optional mime type
  55131. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55132. */
  55133. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  55134. /**
  55135. * Creates a cube texture
  55136. * @param rootUrl defines the url where the files to load is located
  55137. * @param scene defines the current scene
  55138. * @param files defines the list of files to load (1 per face)
  55139. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55140. * @param onLoad defines an optional callback raised when the texture is loaded
  55141. * @param onError defines an optional callback raised if there is an issue to load the texture
  55142. * @param format defines the format of the data
  55143. * @param forcedExtension defines the extension to use to pick the right loader
  55144. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55145. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55146. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55147. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55148. * @returns the cube texture as an InternalTexture
  55149. */
  55150. 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;
  55151. private _getSamplingFilter;
  55152. private static _GetNativeTextureFormat;
  55153. createRenderTargetTexture(size: number | {
  55154. width: number;
  55155. height: number;
  55156. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55157. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55158. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55159. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55160. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55161. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55162. /**
  55163. * Updates a dynamic vertex buffer.
  55164. * @param vertexBuffer the vertex buffer to update
  55165. * @param data the data used to update the vertex buffer
  55166. * @param byteOffset the byte offset of the data (optional)
  55167. * @param byteLength the byte length of the data (optional)
  55168. */
  55169. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55170. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55171. private _updateAnisotropicLevel;
  55172. private _getAddressMode;
  55173. /** @hidden */
  55174. _bindTexture(channel: number, texture: InternalTexture): void;
  55175. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55176. releaseEffects(): void;
  55177. /** @hidden */
  55178. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55179. /** @hidden */
  55180. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55181. /** @hidden */
  55182. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55183. /** @hidden */
  55184. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55185. }
  55186. }
  55187. declare module "babylonjs/Engines/index" {
  55188. export * from "babylonjs/Engines/constants";
  55189. export * from "babylonjs/Engines/engineCapabilities";
  55190. export * from "babylonjs/Engines/instancingAttributeInfo";
  55191. export * from "babylonjs/Engines/thinEngine";
  55192. export * from "babylonjs/Engines/engine";
  55193. export * from "babylonjs/Engines/engineStore";
  55194. export * from "babylonjs/Engines/nullEngine";
  55195. export * from "babylonjs/Engines/Extensions/index";
  55196. export * from "babylonjs/Engines/IPipelineContext";
  55197. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  55198. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  55199. export * from "babylonjs/Engines/nativeEngine";
  55200. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  55201. export * from "babylonjs/Engines/performanceConfigurator";
  55202. }
  55203. declare module "babylonjs/Events/clipboardEvents" {
  55204. /**
  55205. * Gather the list of clipboard event types as constants.
  55206. */
  55207. export class ClipboardEventTypes {
  55208. /**
  55209. * The clipboard event is fired when a copy command is active (pressed).
  55210. */
  55211. static readonly COPY: number;
  55212. /**
  55213. * The clipboard event is fired when a cut command is active (pressed).
  55214. */
  55215. static readonly CUT: number;
  55216. /**
  55217. * The clipboard event is fired when a paste command is active (pressed).
  55218. */
  55219. static readonly PASTE: number;
  55220. }
  55221. /**
  55222. * This class is used to store clipboard related info for the onClipboardObservable event.
  55223. */
  55224. export class ClipboardInfo {
  55225. /**
  55226. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55227. */
  55228. type: number;
  55229. /**
  55230. * Defines the related dom event
  55231. */
  55232. event: ClipboardEvent;
  55233. /**
  55234. *Creates an instance of ClipboardInfo.
  55235. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55236. * @param event Defines the related dom event
  55237. */
  55238. constructor(
  55239. /**
  55240. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55241. */
  55242. type: number,
  55243. /**
  55244. * Defines the related dom event
  55245. */
  55246. event: ClipboardEvent);
  55247. /**
  55248. * Get the clipboard event's type from the keycode.
  55249. * @param keyCode Defines the keyCode for the current keyboard event.
  55250. * @return {number}
  55251. */
  55252. static GetTypeFromCharacter(keyCode: number): number;
  55253. }
  55254. }
  55255. declare module "babylonjs/Events/index" {
  55256. export * from "babylonjs/Events/keyboardEvents";
  55257. export * from "babylonjs/Events/pointerEvents";
  55258. export * from "babylonjs/Events/clipboardEvents";
  55259. }
  55260. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55261. import { Scene } from "babylonjs/scene";
  55262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55263. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55264. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55265. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55266. /**
  55267. * Google Daydream controller
  55268. */
  55269. export class DaydreamController extends WebVRController {
  55270. /**
  55271. * Base Url for the controller model.
  55272. */
  55273. static MODEL_BASE_URL: string;
  55274. /**
  55275. * File name for the controller model.
  55276. */
  55277. static MODEL_FILENAME: string;
  55278. /**
  55279. * Gamepad Id prefix used to identify Daydream Controller.
  55280. */
  55281. static readonly GAMEPAD_ID_PREFIX: string;
  55282. /**
  55283. * Creates a new DaydreamController from a gamepad
  55284. * @param vrGamepad the gamepad that the controller should be created from
  55285. */
  55286. constructor(vrGamepad: any);
  55287. /**
  55288. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55289. * @param scene scene in which to add meshes
  55290. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55291. */
  55292. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55293. /**
  55294. * Called once for each button that changed state since the last frame
  55295. * @param buttonIdx Which button index changed
  55296. * @param state New state of the button
  55297. * @param changes Which properties on the state changed since last frame
  55298. */
  55299. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55300. }
  55301. }
  55302. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55303. import { Scene } from "babylonjs/scene";
  55304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55305. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55306. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55307. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55308. /**
  55309. * Gear VR Controller
  55310. */
  55311. export class GearVRController extends WebVRController {
  55312. /**
  55313. * Base Url for the controller model.
  55314. */
  55315. static MODEL_BASE_URL: string;
  55316. /**
  55317. * File name for the controller model.
  55318. */
  55319. static MODEL_FILENAME: string;
  55320. /**
  55321. * Gamepad Id prefix used to identify this controller.
  55322. */
  55323. static readonly GAMEPAD_ID_PREFIX: string;
  55324. private readonly _buttonIndexToObservableNameMap;
  55325. /**
  55326. * Creates a new GearVRController from a gamepad
  55327. * @param vrGamepad the gamepad that the controller should be created from
  55328. */
  55329. constructor(vrGamepad: any);
  55330. /**
  55331. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55332. * @param scene scene in which to add meshes
  55333. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55334. */
  55335. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55336. /**
  55337. * Called once for each button that changed state since the last frame
  55338. * @param buttonIdx Which button index changed
  55339. * @param state New state of the button
  55340. * @param changes Which properties on the state changed since last frame
  55341. */
  55342. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55343. }
  55344. }
  55345. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55346. import { Scene } from "babylonjs/scene";
  55347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55348. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55349. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55350. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55351. /**
  55352. * Generic Controller
  55353. */
  55354. export class GenericController extends WebVRController {
  55355. /**
  55356. * Base Url for the controller model.
  55357. */
  55358. static readonly MODEL_BASE_URL: string;
  55359. /**
  55360. * File name for the controller model.
  55361. */
  55362. static readonly MODEL_FILENAME: string;
  55363. /**
  55364. * Creates a new GenericController from a gamepad
  55365. * @param vrGamepad the gamepad that the controller should be created from
  55366. */
  55367. constructor(vrGamepad: any);
  55368. /**
  55369. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55370. * @param scene scene in which to add meshes
  55371. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55372. */
  55373. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55374. /**
  55375. * Called once for each button that changed state since the last frame
  55376. * @param buttonIdx Which button index changed
  55377. * @param state New state of the button
  55378. * @param changes Which properties on the state changed since last frame
  55379. */
  55380. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55381. }
  55382. }
  55383. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55384. import { Observable } from "babylonjs/Misc/observable";
  55385. import { Scene } from "babylonjs/scene";
  55386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55387. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55388. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55389. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55390. /**
  55391. * Oculus Touch Controller
  55392. */
  55393. export class OculusTouchController extends WebVRController {
  55394. /**
  55395. * Base Url for the controller model.
  55396. */
  55397. static MODEL_BASE_URL: string;
  55398. /**
  55399. * File name for the left controller model.
  55400. */
  55401. static MODEL_LEFT_FILENAME: string;
  55402. /**
  55403. * File name for the right controller model.
  55404. */
  55405. static MODEL_RIGHT_FILENAME: string;
  55406. /**
  55407. * Base Url for the Quest controller model.
  55408. */
  55409. static QUEST_MODEL_BASE_URL: string;
  55410. /**
  55411. * @hidden
  55412. * If the controllers are running on a device that needs the updated Quest controller models
  55413. */
  55414. static _IsQuest: boolean;
  55415. /**
  55416. * Fired when the secondary trigger on this controller is modified
  55417. */
  55418. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55419. /**
  55420. * Fired when the thumb rest on this controller is modified
  55421. */
  55422. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55423. /**
  55424. * Creates a new OculusTouchController from a gamepad
  55425. * @param vrGamepad the gamepad that the controller should be created from
  55426. */
  55427. constructor(vrGamepad: any);
  55428. /**
  55429. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55430. * @param scene scene in which to add meshes
  55431. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55432. */
  55433. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55434. /**
  55435. * Fired when the A button on this controller is modified
  55436. */
  55437. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55438. /**
  55439. * Fired when the B button on this controller is modified
  55440. */
  55441. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55442. /**
  55443. * Fired when the X button on this controller is modified
  55444. */
  55445. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55446. /**
  55447. * Fired when the Y button on this controller is modified
  55448. */
  55449. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55450. /**
  55451. * Called once for each button that changed state since the last frame
  55452. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55453. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55454. * 2) secondary trigger (same)
  55455. * 3) A (right) X (left), touch, pressed = value
  55456. * 4) B / Y
  55457. * 5) thumb rest
  55458. * @param buttonIdx Which button index changed
  55459. * @param state New state of the button
  55460. * @param changes Which properties on the state changed since last frame
  55461. */
  55462. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55463. }
  55464. }
  55465. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55466. import { Scene } from "babylonjs/scene";
  55467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55468. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55469. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55470. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55471. import { Observable } from "babylonjs/Misc/observable";
  55472. /**
  55473. * Vive Controller
  55474. */
  55475. export class ViveController extends WebVRController {
  55476. /**
  55477. * Base Url for the controller model.
  55478. */
  55479. static MODEL_BASE_URL: string;
  55480. /**
  55481. * File name for the controller model.
  55482. */
  55483. static MODEL_FILENAME: string;
  55484. /**
  55485. * Creates a new ViveController from a gamepad
  55486. * @param vrGamepad the gamepad that the controller should be created from
  55487. */
  55488. constructor(vrGamepad: any);
  55489. /**
  55490. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55491. * @param scene scene in which to add meshes
  55492. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55493. */
  55494. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55495. /**
  55496. * Fired when the left button on this controller is modified
  55497. */
  55498. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55499. /**
  55500. * Fired when the right button on this controller is modified
  55501. */
  55502. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55503. /**
  55504. * Fired when the menu button on this controller is modified
  55505. */
  55506. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55507. /**
  55508. * Called once for each button that changed state since the last frame
  55509. * Vive mapping:
  55510. * 0: touchpad
  55511. * 1: trigger
  55512. * 2: left AND right buttons
  55513. * 3: menu button
  55514. * @param buttonIdx Which button index changed
  55515. * @param state New state of the button
  55516. * @param changes Which properties on the state changed since last frame
  55517. */
  55518. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55519. }
  55520. }
  55521. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55522. import { Observable } from "babylonjs/Misc/observable";
  55523. import { Scene } from "babylonjs/scene";
  55524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55525. import { Ray } from "babylonjs/Culling/ray";
  55526. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55527. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55528. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55529. /**
  55530. * Defines the WindowsMotionController object that the state of the windows motion controller
  55531. */
  55532. export class WindowsMotionController extends WebVRController {
  55533. /**
  55534. * The base url used to load the left and right controller models
  55535. */
  55536. static MODEL_BASE_URL: string;
  55537. /**
  55538. * The name of the left controller model file
  55539. */
  55540. static MODEL_LEFT_FILENAME: string;
  55541. /**
  55542. * The name of the right controller model file
  55543. */
  55544. static MODEL_RIGHT_FILENAME: string;
  55545. /**
  55546. * The controller name prefix for this controller type
  55547. */
  55548. static readonly GAMEPAD_ID_PREFIX: string;
  55549. /**
  55550. * The controller id pattern for this controller type
  55551. */
  55552. private static readonly GAMEPAD_ID_PATTERN;
  55553. private _loadedMeshInfo;
  55554. protected readonly _mapping: {
  55555. buttons: string[];
  55556. buttonMeshNames: {
  55557. trigger: string;
  55558. menu: string;
  55559. grip: string;
  55560. thumbstick: string;
  55561. trackpad: string;
  55562. };
  55563. buttonObservableNames: {
  55564. trigger: string;
  55565. menu: string;
  55566. grip: string;
  55567. thumbstick: string;
  55568. trackpad: string;
  55569. };
  55570. axisMeshNames: string[];
  55571. pointingPoseMeshName: string;
  55572. };
  55573. /**
  55574. * Fired when the trackpad on this controller is clicked
  55575. */
  55576. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55577. /**
  55578. * Fired when the trackpad on this controller is modified
  55579. */
  55580. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55581. /**
  55582. * The current x and y values of this controller's trackpad
  55583. */
  55584. trackpad: StickValues;
  55585. /**
  55586. * Creates a new WindowsMotionController from a gamepad
  55587. * @param vrGamepad the gamepad that the controller should be created from
  55588. */
  55589. constructor(vrGamepad: any);
  55590. /**
  55591. * Fired when the trigger on this controller is modified
  55592. */
  55593. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55594. /**
  55595. * Fired when the menu button on this controller is modified
  55596. */
  55597. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55598. /**
  55599. * Fired when the grip button on this controller is modified
  55600. */
  55601. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55602. /**
  55603. * Fired when the thumbstick button on this controller is modified
  55604. */
  55605. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55606. /**
  55607. * Fired when the touchpad button on this controller is modified
  55608. */
  55609. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55610. /**
  55611. * Fired when the touchpad values on this controller are modified
  55612. */
  55613. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55614. protected _updateTrackpad(): void;
  55615. /**
  55616. * Called once per frame by the engine.
  55617. */
  55618. update(): void;
  55619. /**
  55620. * Called once for each button that changed state since the last frame
  55621. * @param buttonIdx Which button index changed
  55622. * @param state New state of the button
  55623. * @param changes Which properties on the state changed since last frame
  55624. */
  55625. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55626. /**
  55627. * Moves the buttons on the controller mesh based on their current state
  55628. * @param buttonName the name of the button to move
  55629. * @param buttonValue the value of the button which determines the buttons new position
  55630. */
  55631. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55632. /**
  55633. * Moves the axis on the controller mesh based on its current state
  55634. * @param axis the index of the axis
  55635. * @param axisValue the value of the axis which determines the meshes new position
  55636. * @hidden
  55637. */
  55638. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55639. /**
  55640. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55641. * @param scene scene in which to add meshes
  55642. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55643. */
  55644. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55645. /**
  55646. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55647. * can be transformed by button presses and axes values, based on this._mapping.
  55648. *
  55649. * @param scene scene in which the meshes exist
  55650. * @param meshes list of meshes that make up the controller model to process
  55651. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55652. */
  55653. private processModel;
  55654. private createMeshInfo;
  55655. /**
  55656. * Gets the ray of the controller in the direction the controller is pointing
  55657. * @param length the length the resulting ray should be
  55658. * @returns a ray in the direction the controller is pointing
  55659. */
  55660. getForwardRay(length?: number): Ray;
  55661. /**
  55662. * Disposes of the controller
  55663. */
  55664. dispose(): void;
  55665. }
  55666. /**
  55667. * This class represents a new windows motion controller in XR.
  55668. */
  55669. export class XRWindowsMotionController extends WindowsMotionController {
  55670. /**
  55671. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55672. */
  55673. protected readonly _mapping: {
  55674. buttons: string[];
  55675. buttonMeshNames: {
  55676. trigger: string;
  55677. menu: string;
  55678. grip: string;
  55679. thumbstick: string;
  55680. trackpad: string;
  55681. };
  55682. buttonObservableNames: {
  55683. trigger: string;
  55684. menu: string;
  55685. grip: string;
  55686. thumbstick: string;
  55687. trackpad: string;
  55688. };
  55689. axisMeshNames: string[];
  55690. pointingPoseMeshName: string;
  55691. };
  55692. /**
  55693. * Construct a new XR-Based windows motion controller
  55694. *
  55695. * @param gamepadInfo the gamepad object from the browser
  55696. */
  55697. constructor(gamepadInfo: any);
  55698. /**
  55699. * holds the thumbstick values (X,Y)
  55700. */
  55701. thumbstickValues: StickValues;
  55702. /**
  55703. * Fired when the thumbstick on this controller is clicked
  55704. */
  55705. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55706. /**
  55707. * Fired when the thumbstick on this controller is modified
  55708. */
  55709. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55710. /**
  55711. * Fired when the touchpad button on this controller is modified
  55712. */
  55713. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55714. /**
  55715. * Fired when the touchpad values on this controller are modified
  55716. */
  55717. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55718. /**
  55719. * Fired when the thumbstick button on this controller is modified
  55720. * here to prevent breaking changes
  55721. */
  55722. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55723. /**
  55724. * updating the thumbstick(!) and not the trackpad.
  55725. * This is named this way due to the difference between WebVR and XR and to avoid
  55726. * changing the parent class.
  55727. */
  55728. protected _updateTrackpad(): void;
  55729. /**
  55730. * Disposes the class with joy
  55731. */
  55732. dispose(): void;
  55733. }
  55734. }
  55735. declare module "babylonjs/Gamepads/Controllers/index" {
  55736. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55737. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55738. export * from "babylonjs/Gamepads/Controllers/genericController";
  55739. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55740. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55741. export * from "babylonjs/Gamepads/Controllers/viveController";
  55742. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55743. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55744. }
  55745. declare module "babylonjs/Gamepads/index" {
  55746. export * from "babylonjs/Gamepads/Controllers/index";
  55747. export * from "babylonjs/Gamepads/gamepad";
  55748. export * from "babylonjs/Gamepads/gamepadManager";
  55749. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55750. export * from "babylonjs/Gamepads/xboxGamepad";
  55751. export * from "babylonjs/Gamepads/dualShockGamepad";
  55752. }
  55753. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55754. import { Scene } from "babylonjs/scene";
  55755. import { Vector4 } from "babylonjs/Maths/math.vector";
  55756. import { Color4 } from "babylonjs/Maths/math.color";
  55757. import { Mesh } from "babylonjs/Meshes/mesh";
  55758. import { Nullable } from "babylonjs/types";
  55759. /**
  55760. * Class containing static functions to help procedurally build meshes
  55761. */
  55762. export class PolyhedronBuilder {
  55763. /**
  55764. * Creates a polyhedron mesh
  55765. * * 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
  55766. * * The parameter `size` (positive float, default 1) sets the polygon size
  55767. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55768. * * 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`
  55769. * * 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
  55770. * * 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)`)
  55771. * * 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
  55772. * * 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
  55773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55776. * @param name defines the name of the mesh
  55777. * @param options defines the options used to create the mesh
  55778. * @param scene defines the hosting scene
  55779. * @returns the polyhedron mesh
  55780. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55781. */
  55782. static CreatePolyhedron(name: string, options: {
  55783. type?: number;
  55784. size?: number;
  55785. sizeX?: number;
  55786. sizeY?: number;
  55787. sizeZ?: number;
  55788. custom?: any;
  55789. faceUV?: Vector4[];
  55790. faceColors?: Color4[];
  55791. flat?: boolean;
  55792. updatable?: boolean;
  55793. sideOrientation?: number;
  55794. frontUVs?: Vector4;
  55795. backUVs?: Vector4;
  55796. }, scene?: Nullable<Scene>): Mesh;
  55797. }
  55798. }
  55799. declare module "babylonjs/Gizmos/scaleGizmo" {
  55800. import { Observable } from "babylonjs/Misc/observable";
  55801. import { Nullable } from "babylonjs/types";
  55802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55803. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55804. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55805. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55806. import { Node } from "babylonjs/node";
  55807. /**
  55808. * Gizmo that enables scaling a mesh along 3 axis
  55809. */
  55810. export class ScaleGizmo extends Gizmo {
  55811. /**
  55812. * Internal gizmo used for interactions on the x axis
  55813. */
  55814. xGizmo: AxisScaleGizmo;
  55815. /**
  55816. * Internal gizmo used for interactions on the y axis
  55817. */
  55818. yGizmo: AxisScaleGizmo;
  55819. /**
  55820. * Internal gizmo used for interactions on the z axis
  55821. */
  55822. zGizmo: AxisScaleGizmo;
  55823. /**
  55824. * Internal gizmo used to scale all axis equally
  55825. */
  55826. uniformScaleGizmo: AxisScaleGizmo;
  55827. private _meshAttached;
  55828. private _nodeAttached;
  55829. private _snapDistance;
  55830. private _uniformScalingMesh;
  55831. private _octahedron;
  55832. private _sensitivity;
  55833. /** Fires an event when any of it's sub gizmos are dragged */
  55834. onDragStartObservable: Observable<unknown>;
  55835. /** Fires an event when any of it's sub gizmos are released from dragging */
  55836. onDragEndObservable: Observable<unknown>;
  55837. get attachedMesh(): Nullable<AbstractMesh>;
  55838. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55839. get attachedNode(): Nullable<Node>;
  55840. set attachedNode(node: Nullable<Node>);
  55841. /**
  55842. * Creates a ScaleGizmo
  55843. * @param gizmoLayer The utility layer the gizmo will be added to
  55844. * @param thickness display gizmo axis thickness
  55845. */
  55846. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55847. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55848. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55849. /**
  55850. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55851. */
  55852. set snapDistance(value: number);
  55853. get snapDistance(): number;
  55854. /**
  55855. * Ratio for the scale of the gizmo (Default: 1)
  55856. */
  55857. set scaleRatio(value: number);
  55858. get scaleRatio(): number;
  55859. /**
  55860. * Sensitivity factor for dragging (Default: 1)
  55861. */
  55862. set sensitivity(value: number);
  55863. get sensitivity(): number;
  55864. /**
  55865. * Disposes of the gizmo
  55866. */
  55867. dispose(): void;
  55868. }
  55869. }
  55870. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55871. import { Observable } from "babylonjs/Misc/observable";
  55872. import { Nullable } from "babylonjs/types";
  55873. import { Vector3 } from "babylonjs/Maths/math.vector";
  55874. import { Node } from "babylonjs/node";
  55875. import { Mesh } from "babylonjs/Meshes/mesh";
  55876. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55877. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55878. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55879. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55880. import { Color3 } from "babylonjs/Maths/math.color";
  55881. /**
  55882. * Single axis scale gizmo
  55883. */
  55884. export class AxisScaleGizmo extends Gizmo {
  55885. /**
  55886. * Drag behavior responsible for the gizmos dragging interactions
  55887. */
  55888. dragBehavior: PointerDragBehavior;
  55889. private _pointerObserver;
  55890. /**
  55891. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55892. */
  55893. snapDistance: number;
  55894. /**
  55895. * Event that fires each time the gizmo snaps to a new location.
  55896. * * snapDistance is the the change in distance
  55897. */
  55898. onSnapObservable: Observable<{
  55899. snapDistance: number;
  55900. }>;
  55901. /**
  55902. * If the scaling operation should be done on all axis (default: false)
  55903. */
  55904. uniformScaling: boolean;
  55905. /**
  55906. * Custom sensitivity value for the drag strength
  55907. */
  55908. sensitivity: number;
  55909. private _isEnabled;
  55910. private _parent;
  55911. private _arrow;
  55912. private _coloredMaterial;
  55913. private _hoverMaterial;
  55914. /**
  55915. * Creates an AxisScaleGizmo
  55916. * @param gizmoLayer The utility layer the gizmo will be added to
  55917. * @param dragAxis The axis which the gizmo will be able to scale on
  55918. * @param color The color of the gizmo
  55919. * @param thickness display gizmo axis thickness
  55920. */
  55921. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  55922. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55923. /**
  55924. * If the gizmo is enabled
  55925. */
  55926. set isEnabled(value: boolean);
  55927. get isEnabled(): boolean;
  55928. /**
  55929. * Disposes of the gizmo
  55930. */
  55931. dispose(): void;
  55932. /**
  55933. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55934. * @param mesh The mesh to replace the default mesh of the gizmo
  55935. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  55936. */
  55937. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  55938. }
  55939. }
  55940. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  55941. import { Observable } from "babylonjs/Misc/observable";
  55942. import { Nullable } from "babylonjs/types";
  55943. import { Vector3 } from "babylonjs/Maths/math.vector";
  55944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55945. import { Mesh } from "babylonjs/Meshes/mesh";
  55946. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55947. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55948. import { Color3 } from "babylonjs/Maths/math.color";
  55949. import "babylonjs/Meshes/Builders/boxBuilder";
  55950. /**
  55951. * Bounding box gizmo
  55952. */
  55953. export class BoundingBoxGizmo extends Gizmo {
  55954. private _lineBoundingBox;
  55955. private _rotateSpheresParent;
  55956. private _scaleBoxesParent;
  55957. private _boundingDimensions;
  55958. private _renderObserver;
  55959. private _pointerObserver;
  55960. private _scaleDragSpeed;
  55961. private _tmpQuaternion;
  55962. private _tmpVector;
  55963. private _tmpRotationMatrix;
  55964. /**
  55965. * 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)
  55966. */
  55967. ignoreChildren: boolean;
  55968. /**
  55969. * 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)
  55970. */
  55971. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  55972. /**
  55973. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  55974. */
  55975. rotationSphereSize: number;
  55976. /**
  55977. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  55978. */
  55979. scaleBoxSize: number;
  55980. /**
  55981. * 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)
  55982. */
  55983. fixedDragMeshScreenSize: boolean;
  55984. /**
  55985. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  55986. */
  55987. fixedDragMeshScreenSizeDistanceFactor: number;
  55988. /**
  55989. * Fired when a rotation sphere or scale box is dragged
  55990. */
  55991. onDragStartObservable: Observable<{}>;
  55992. /**
  55993. * Fired when a scale box is dragged
  55994. */
  55995. onScaleBoxDragObservable: Observable<{}>;
  55996. /**
  55997. * Fired when a scale box drag is ended
  55998. */
  55999. onScaleBoxDragEndObservable: Observable<{}>;
  56000. /**
  56001. * Fired when a rotation sphere is dragged
  56002. */
  56003. onRotationSphereDragObservable: Observable<{}>;
  56004. /**
  56005. * Fired when a rotation sphere drag is ended
  56006. */
  56007. onRotationSphereDragEndObservable: Observable<{}>;
  56008. /**
  56009. * 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)
  56010. */
  56011. scalePivot: Nullable<Vector3>;
  56012. /**
  56013. * Mesh used as a pivot to rotate the attached node
  56014. */
  56015. private _anchorMesh;
  56016. private _existingMeshScale;
  56017. private _dragMesh;
  56018. private pointerDragBehavior;
  56019. private coloredMaterial;
  56020. private hoverColoredMaterial;
  56021. /**
  56022. * Sets the color of the bounding box gizmo
  56023. * @param color the color to set
  56024. */
  56025. setColor(color: Color3): void;
  56026. /**
  56027. * Creates an BoundingBoxGizmo
  56028. * @param gizmoLayer The utility layer the gizmo will be added to
  56029. * @param color The color of the gizmo
  56030. */
  56031. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56032. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56033. private _selectNode;
  56034. /**
  56035. * Updates the bounding box information for the Gizmo
  56036. */
  56037. updateBoundingBox(): void;
  56038. private _updateRotationSpheres;
  56039. private _updateScaleBoxes;
  56040. /**
  56041. * Enables rotation on the specified axis and disables rotation on the others
  56042. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56043. */
  56044. setEnabledRotationAxis(axis: string): void;
  56045. /**
  56046. * Enables/disables scaling
  56047. * @param enable if scaling should be enabled
  56048. * @param homogeneousScaling defines if scaling should only be homogeneous
  56049. */
  56050. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56051. private _updateDummy;
  56052. /**
  56053. * Enables a pointer drag behavior on the bounding box of the gizmo
  56054. */
  56055. enableDragBehavior(): void;
  56056. /**
  56057. * Disposes of the gizmo
  56058. */
  56059. dispose(): void;
  56060. /**
  56061. * 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)
  56062. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56063. * @returns the bounding box mesh with the passed in mesh as a child
  56064. */
  56065. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56066. /**
  56067. * CustomMeshes are not supported by this gizmo
  56068. * @param mesh The mesh to replace the default mesh of the gizmo
  56069. */
  56070. setCustomMesh(mesh: Mesh): void;
  56071. }
  56072. }
  56073. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56074. import { Observable } from "babylonjs/Misc/observable";
  56075. import { Nullable } from "babylonjs/types";
  56076. import { Vector3 } from "babylonjs/Maths/math.vector";
  56077. import { Color3 } from "babylonjs/Maths/math.color";
  56078. import { Node } from "babylonjs/node";
  56079. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56080. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56081. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56082. import "babylonjs/Meshes/Builders/linesBuilder";
  56083. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56084. /**
  56085. * Single plane rotation gizmo
  56086. */
  56087. export class PlaneRotationGizmo extends Gizmo {
  56088. /**
  56089. * Drag behavior responsible for the gizmos dragging interactions
  56090. */
  56091. dragBehavior: PointerDragBehavior;
  56092. private _pointerObserver;
  56093. /**
  56094. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56095. */
  56096. snapDistance: number;
  56097. /**
  56098. * Event that fires each time the gizmo snaps to a new location.
  56099. * * snapDistance is the the change in distance
  56100. */
  56101. onSnapObservable: Observable<{
  56102. snapDistance: number;
  56103. }>;
  56104. private _isEnabled;
  56105. private _parent;
  56106. /**
  56107. * Creates a PlaneRotationGizmo
  56108. * @param gizmoLayer The utility layer the gizmo will be added to
  56109. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56110. * @param color The color of the gizmo
  56111. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56112. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56113. * @param thickness display gizmo axis thickness
  56114. */
  56115. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56116. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56117. /**
  56118. * If the gizmo is enabled
  56119. */
  56120. set isEnabled(value: boolean);
  56121. get isEnabled(): boolean;
  56122. /**
  56123. * Disposes of the gizmo
  56124. */
  56125. dispose(): void;
  56126. }
  56127. }
  56128. declare module "babylonjs/Gizmos/rotationGizmo" {
  56129. import { Observable } from "babylonjs/Misc/observable";
  56130. import { Nullable } from "babylonjs/types";
  56131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56132. import { Mesh } from "babylonjs/Meshes/mesh";
  56133. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56134. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56135. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56136. import { Node } from "babylonjs/node";
  56137. /**
  56138. * Gizmo that enables rotating a mesh along 3 axis
  56139. */
  56140. export class RotationGizmo extends Gizmo {
  56141. /**
  56142. * Internal gizmo used for interactions on the x axis
  56143. */
  56144. xGizmo: PlaneRotationGizmo;
  56145. /**
  56146. * Internal gizmo used for interactions on the y axis
  56147. */
  56148. yGizmo: PlaneRotationGizmo;
  56149. /**
  56150. * Internal gizmo used for interactions on the z axis
  56151. */
  56152. zGizmo: PlaneRotationGizmo;
  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. private _meshAttached;
  56158. private _nodeAttached;
  56159. get attachedMesh(): Nullable<AbstractMesh>;
  56160. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56161. get attachedNode(): Nullable<Node>;
  56162. set attachedNode(node: Nullable<Node>);
  56163. /**
  56164. * Creates a RotationGizmo
  56165. * @param gizmoLayer The utility layer the gizmo will be added to
  56166. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56167. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56168. * @param thickness display gizmo axis thickness
  56169. */
  56170. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56171. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56172. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56173. /**
  56174. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56175. */
  56176. set snapDistance(value: number);
  56177. get snapDistance(): number;
  56178. /**
  56179. * Ratio for the scale of the gizmo (Default: 1)
  56180. */
  56181. set scaleRatio(value: number);
  56182. get scaleRatio(): number;
  56183. /**
  56184. * Disposes of the gizmo
  56185. */
  56186. dispose(): void;
  56187. /**
  56188. * CustomMeshes are not supported by this gizmo
  56189. * @param mesh The mesh to replace the default mesh of the gizmo
  56190. */
  56191. setCustomMesh(mesh: Mesh): void;
  56192. }
  56193. }
  56194. declare module "babylonjs/Gizmos/gizmoManager" {
  56195. import { Observable } from "babylonjs/Misc/observable";
  56196. import { Nullable } from "babylonjs/types";
  56197. import { Scene, IDisposable } from "babylonjs/scene";
  56198. import { Node } from "babylonjs/node";
  56199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56200. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56201. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56202. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56203. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56204. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56205. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56206. /**
  56207. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56208. */
  56209. export class GizmoManager implements IDisposable {
  56210. private scene;
  56211. /**
  56212. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56213. */
  56214. gizmos: {
  56215. positionGizmo: Nullable<PositionGizmo>;
  56216. rotationGizmo: Nullable<RotationGizmo>;
  56217. scaleGizmo: Nullable<ScaleGizmo>;
  56218. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56219. };
  56220. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56221. clearGizmoOnEmptyPointerEvent: boolean;
  56222. /** Fires an event when the manager is attached to a mesh */
  56223. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56224. /** Fires an event when the manager is attached to a node */
  56225. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56226. private _gizmosEnabled;
  56227. private _pointerObserver;
  56228. private _attachedMesh;
  56229. private _attachedNode;
  56230. private _boundingBoxColor;
  56231. private _defaultUtilityLayer;
  56232. private _defaultKeepDepthUtilityLayer;
  56233. private _thickness;
  56234. /**
  56235. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56236. */
  56237. boundingBoxDragBehavior: SixDofDragBehavior;
  56238. /**
  56239. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56240. */
  56241. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56242. /**
  56243. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56244. */
  56245. attachableNodes: Nullable<Array<Node>>;
  56246. /**
  56247. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56248. */
  56249. usePointerToAttachGizmos: boolean;
  56250. /**
  56251. * Utility layer that the bounding box gizmo belongs to
  56252. */
  56253. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56254. /**
  56255. * Utility layer that all gizmos besides bounding box belong to
  56256. */
  56257. get utilityLayer(): UtilityLayerRenderer;
  56258. /**
  56259. * Instatiates a gizmo manager
  56260. * @param scene the scene to overlay the gizmos on top of
  56261. * @param thickness display gizmo axis thickness
  56262. */
  56263. constructor(scene: Scene, thickness?: number);
  56264. /**
  56265. * Attaches a set of gizmos to the specified mesh
  56266. * @param mesh The mesh the gizmo's should be attached to
  56267. */
  56268. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56269. /**
  56270. * Attaches a set of gizmos to the specified node
  56271. * @param node The node the gizmo's should be attached to
  56272. */
  56273. attachToNode(node: Nullable<Node>): void;
  56274. /**
  56275. * If the position gizmo is enabled
  56276. */
  56277. set positionGizmoEnabled(value: boolean);
  56278. get positionGizmoEnabled(): boolean;
  56279. /**
  56280. * If the rotation gizmo is enabled
  56281. */
  56282. set rotationGizmoEnabled(value: boolean);
  56283. get rotationGizmoEnabled(): boolean;
  56284. /**
  56285. * If the scale gizmo is enabled
  56286. */
  56287. set scaleGizmoEnabled(value: boolean);
  56288. get scaleGizmoEnabled(): boolean;
  56289. /**
  56290. * If the boundingBox gizmo is enabled
  56291. */
  56292. set boundingBoxGizmoEnabled(value: boolean);
  56293. get boundingBoxGizmoEnabled(): boolean;
  56294. /**
  56295. * Disposes of the gizmo manager
  56296. */
  56297. dispose(): void;
  56298. }
  56299. }
  56300. declare module "babylonjs/Lights/directionalLight" {
  56301. import { Camera } from "babylonjs/Cameras/camera";
  56302. import { Scene } from "babylonjs/scene";
  56303. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56305. import { Light } from "babylonjs/Lights/light";
  56306. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56307. import { Effect } from "babylonjs/Materials/effect";
  56308. /**
  56309. * A directional light is defined by a direction (what a surprise!).
  56310. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56311. * 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.
  56312. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56313. */
  56314. export class DirectionalLight extends ShadowLight {
  56315. private _shadowFrustumSize;
  56316. /**
  56317. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56318. */
  56319. get shadowFrustumSize(): number;
  56320. /**
  56321. * Specifies a fix frustum size for the shadow generation.
  56322. */
  56323. set shadowFrustumSize(value: number);
  56324. private _shadowOrthoScale;
  56325. /**
  56326. * Gets the shadow projection scale against the optimal computed one.
  56327. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56328. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56329. */
  56330. get shadowOrthoScale(): number;
  56331. /**
  56332. * Sets the shadow projection scale against the optimal computed one.
  56333. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56334. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56335. */
  56336. set shadowOrthoScale(value: number);
  56337. /**
  56338. * Automatically compute the projection matrix to best fit (including all the casters)
  56339. * on each frame.
  56340. */
  56341. autoUpdateExtends: boolean;
  56342. /**
  56343. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56344. * on each frame. autoUpdateExtends must be set to true for this to work
  56345. */
  56346. autoCalcShadowZBounds: boolean;
  56347. private _orthoLeft;
  56348. private _orthoRight;
  56349. private _orthoTop;
  56350. private _orthoBottom;
  56351. /**
  56352. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56353. * The directional light is emitted from everywhere in the given direction.
  56354. * It can cast shadows.
  56355. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56356. * @param name The friendly name of the light
  56357. * @param direction The direction of the light
  56358. * @param scene The scene the light belongs to
  56359. */
  56360. constructor(name: string, direction: Vector3, scene: Scene);
  56361. /**
  56362. * Returns the string "DirectionalLight".
  56363. * @return The class name
  56364. */
  56365. getClassName(): string;
  56366. /**
  56367. * Returns the integer 1.
  56368. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56369. */
  56370. getTypeID(): number;
  56371. /**
  56372. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56373. * Returns the DirectionalLight Shadow projection matrix.
  56374. */
  56375. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56376. /**
  56377. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56378. * Returns the DirectionalLight Shadow projection matrix.
  56379. */
  56380. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56381. /**
  56382. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56383. * Returns the DirectionalLight Shadow projection matrix.
  56384. */
  56385. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56386. protected _buildUniformLayout(): void;
  56387. /**
  56388. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56389. * @param effect The effect to update
  56390. * @param lightIndex The index of the light in the effect to update
  56391. * @returns The directional light
  56392. */
  56393. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56394. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56395. /**
  56396. * Gets the minZ used for shadow according to both the scene and the light.
  56397. *
  56398. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56399. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56400. * @param activeCamera The camera we are returning the min for
  56401. * @returns the depth min z
  56402. */
  56403. getDepthMinZ(activeCamera: Camera): number;
  56404. /**
  56405. * Gets the maxZ used for shadow according to both the scene and the light.
  56406. *
  56407. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56408. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56409. * @param activeCamera The camera we are returning the max for
  56410. * @returns the depth max z
  56411. */
  56412. getDepthMaxZ(activeCamera: Camera): number;
  56413. /**
  56414. * Prepares the list of defines specific to the light type.
  56415. * @param defines the list of defines
  56416. * @param lightIndex defines the index of the light for the effect
  56417. */
  56418. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56419. }
  56420. }
  56421. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56422. import { Mesh } from "babylonjs/Meshes/mesh";
  56423. /**
  56424. * Class containing static functions to help procedurally build meshes
  56425. */
  56426. export class HemisphereBuilder {
  56427. /**
  56428. * Creates a hemisphere mesh
  56429. * @param name defines the name of the mesh
  56430. * @param options defines the options used to create the mesh
  56431. * @param scene defines the hosting scene
  56432. * @returns the hemisphere mesh
  56433. */
  56434. static CreateHemisphere(name: string, options: {
  56435. segments?: number;
  56436. diameter?: number;
  56437. sideOrientation?: number;
  56438. }, scene: any): Mesh;
  56439. }
  56440. }
  56441. declare module "babylonjs/Lights/spotLight" {
  56442. import { Nullable } from "babylonjs/types";
  56443. import { Scene } from "babylonjs/scene";
  56444. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56446. import { Effect } from "babylonjs/Materials/effect";
  56447. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56448. import { Light } from "babylonjs/Lights/light";
  56449. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56450. /**
  56451. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56452. * These values define a cone of light starting from the position, emitting toward the direction.
  56453. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56454. * and the exponent defines the speed of the decay of the light with distance (reach).
  56455. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56456. */
  56457. export class SpotLight extends ShadowLight {
  56458. private _angle;
  56459. private _innerAngle;
  56460. private _cosHalfAngle;
  56461. private _lightAngleScale;
  56462. private _lightAngleOffset;
  56463. /**
  56464. * Gets the cone angle of the spot light in Radians.
  56465. */
  56466. get angle(): number;
  56467. /**
  56468. * Sets the cone angle of the spot light in Radians.
  56469. */
  56470. set angle(value: number);
  56471. /**
  56472. * Only used in gltf falloff mode, this defines the angle where
  56473. * the directional falloff will start before cutting at angle which could be seen
  56474. * as outer angle.
  56475. */
  56476. get innerAngle(): number;
  56477. /**
  56478. * Only used in gltf falloff mode, this defines the angle where
  56479. * the directional falloff will start before cutting at angle which could be seen
  56480. * as outer angle.
  56481. */
  56482. set innerAngle(value: number);
  56483. private _shadowAngleScale;
  56484. /**
  56485. * Allows scaling the angle of the light for shadow generation only.
  56486. */
  56487. get shadowAngleScale(): number;
  56488. /**
  56489. * Allows scaling the angle of the light for shadow generation only.
  56490. */
  56491. set shadowAngleScale(value: number);
  56492. /**
  56493. * The light decay speed with the distance from the emission spot.
  56494. */
  56495. exponent: number;
  56496. private _projectionTextureMatrix;
  56497. /**
  56498. * Allows reading the projecton texture
  56499. */
  56500. get projectionTextureMatrix(): Matrix;
  56501. protected _projectionTextureLightNear: number;
  56502. /**
  56503. * Gets the near clip of the Spotlight for texture projection.
  56504. */
  56505. get projectionTextureLightNear(): number;
  56506. /**
  56507. * Sets the near clip of the Spotlight for texture projection.
  56508. */
  56509. set projectionTextureLightNear(value: number);
  56510. protected _projectionTextureLightFar: number;
  56511. /**
  56512. * Gets the far clip of the Spotlight for texture projection.
  56513. */
  56514. get projectionTextureLightFar(): number;
  56515. /**
  56516. * Sets the far clip of the Spotlight for texture projection.
  56517. */
  56518. set projectionTextureLightFar(value: number);
  56519. protected _projectionTextureUpDirection: Vector3;
  56520. /**
  56521. * Gets the Up vector of the Spotlight for texture projection.
  56522. */
  56523. get projectionTextureUpDirection(): Vector3;
  56524. /**
  56525. * Sets the Up vector of the Spotlight for texture projection.
  56526. */
  56527. set projectionTextureUpDirection(value: Vector3);
  56528. private _projectionTexture;
  56529. /**
  56530. * Gets the projection texture of the light.
  56531. */
  56532. get projectionTexture(): Nullable<BaseTexture>;
  56533. /**
  56534. * Sets the projection texture of the light.
  56535. */
  56536. set projectionTexture(value: Nullable<BaseTexture>);
  56537. private _projectionTextureViewLightDirty;
  56538. private _projectionTextureProjectionLightDirty;
  56539. private _projectionTextureDirty;
  56540. private _projectionTextureViewTargetVector;
  56541. private _projectionTextureViewLightMatrix;
  56542. private _projectionTextureProjectionLightMatrix;
  56543. private _projectionTextureScalingMatrix;
  56544. /**
  56545. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56546. * It can cast shadows.
  56547. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56548. * @param name The light friendly name
  56549. * @param position The position of the spot light in the scene
  56550. * @param direction The direction of the light in the scene
  56551. * @param angle The cone angle of the light in Radians
  56552. * @param exponent The light decay speed with the distance from the emission spot
  56553. * @param scene The scene the lights belongs to
  56554. */
  56555. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56556. /**
  56557. * Returns the string "SpotLight".
  56558. * @returns the class name
  56559. */
  56560. getClassName(): string;
  56561. /**
  56562. * Returns the integer 2.
  56563. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56564. */
  56565. getTypeID(): number;
  56566. /**
  56567. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56568. */
  56569. protected _setDirection(value: Vector3): void;
  56570. /**
  56571. * Overrides the position setter to recompute the projection texture view light Matrix.
  56572. */
  56573. protected _setPosition(value: Vector3): void;
  56574. /**
  56575. * 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.
  56576. * Returns the SpotLight.
  56577. */
  56578. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56579. protected _computeProjectionTextureViewLightMatrix(): void;
  56580. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56581. /**
  56582. * Main function for light texture projection matrix computing.
  56583. */
  56584. protected _computeProjectionTextureMatrix(): void;
  56585. protected _buildUniformLayout(): void;
  56586. private _computeAngleValues;
  56587. /**
  56588. * Sets the passed Effect "effect" with the Light textures.
  56589. * @param effect The effect to update
  56590. * @param lightIndex The index of the light in the effect to update
  56591. * @returns The light
  56592. */
  56593. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56594. /**
  56595. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56596. * @param effect The effect to update
  56597. * @param lightIndex The index of the light in the effect to update
  56598. * @returns The spot light
  56599. */
  56600. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56601. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56602. /**
  56603. * Disposes the light and the associated resources.
  56604. */
  56605. dispose(): void;
  56606. /**
  56607. * Prepares the list of defines specific to the light type.
  56608. * @param defines the list of defines
  56609. * @param lightIndex defines the index of the light for the effect
  56610. */
  56611. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56612. }
  56613. }
  56614. declare module "babylonjs/Gizmos/lightGizmo" {
  56615. import { Nullable } from "babylonjs/types";
  56616. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56617. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56618. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56619. import { Light } from "babylonjs/Lights/light";
  56620. import { Observable } from "babylonjs/Misc/observable";
  56621. /**
  56622. * Gizmo that enables viewing a light
  56623. */
  56624. export class LightGizmo extends Gizmo {
  56625. private _lightMesh;
  56626. private _material;
  56627. private _cachedPosition;
  56628. private _cachedForward;
  56629. private _attachedMeshParent;
  56630. private _pointerObserver;
  56631. /**
  56632. * Event that fires each time the gizmo is clicked
  56633. */
  56634. onClickedObservable: Observable<Light>;
  56635. /**
  56636. * Creates a LightGizmo
  56637. * @param gizmoLayer The utility layer the gizmo will be added to
  56638. */
  56639. constructor(gizmoLayer?: UtilityLayerRenderer);
  56640. private _light;
  56641. /**
  56642. * The light that the gizmo is attached to
  56643. */
  56644. set light(light: Nullable<Light>);
  56645. get light(): Nullable<Light>;
  56646. /**
  56647. * Gets the material used to render the light gizmo
  56648. */
  56649. get material(): StandardMaterial;
  56650. /**
  56651. * @hidden
  56652. * Updates the gizmo to match the attached mesh's position/rotation
  56653. */
  56654. protected _update(): void;
  56655. private static _Scale;
  56656. /**
  56657. * Creates the lines for a light mesh
  56658. */
  56659. private static _CreateLightLines;
  56660. /**
  56661. * Disposes of the light gizmo
  56662. */
  56663. dispose(): void;
  56664. private static _CreateHemisphericLightMesh;
  56665. private static _CreatePointLightMesh;
  56666. private static _CreateSpotLightMesh;
  56667. private static _CreateDirectionalLightMesh;
  56668. }
  56669. }
  56670. declare module "babylonjs/Gizmos/cameraGizmo" {
  56671. import { Nullable } from "babylonjs/types";
  56672. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56673. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56674. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56675. import { Camera } from "babylonjs/Cameras/camera";
  56676. import { Observable } from "babylonjs/Misc/observable";
  56677. /**
  56678. * Gizmo that enables viewing a camera
  56679. */
  56680. export class CameraGizmo extends Gizmo {
  56681. private _cameraMesh;
  56682. private _cameraLinesMesh;
  56683. private _material;
  56684. private _pointerObserver;
  56685. /**
  56686. * Event that fires each time the gizmo is clicked
  56687. */
  56688. onClickedObservable: Observable<Camera>;
  56689. /**
  56690. * Creates a CameraGizmo
  56691. * @param gizmoLayer The utility layer the gizmo will be added to
  56692. */
  56693. constructor(gizmoLayer?: UtilityLayerRenderer);
  56694. private _camera;
  56695. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56696. get displayFrustum(): boolean;
  56697. set displayFrustum(value: boolean);
  56698. /**
  56699. * The camera that the gizmo is attached to
  56700. */
  56701. set camera(camera: Nullable<Camera>);
  56702. get camera(): Nullable<Camera>;
  56703. /**
  56704. * Gets the material used to render the camera gizmo
  56705. */
  56706. get material(): StandardMaterial;
  56707. /**
  56708. * @hidden
  56709. * Updates the gizmo to match the attached mesh's position/rotation
  56710. */
  56711. protected _update(): void;
  56712. private static _Scale;
  56713. private _invProjection;
  56714. /**
  56715. * Disposes of the camera gizmo
  56716. */
  56717. dispose(): void;
  56718. private static _CreateCameraMesh;
  56719. private static _CreateCameraFrustum;
  56720. }
  56721. }
  56722. declare module "babylonjs/Gizmos/index" {
  56723. export * from "babylonjs/Gizmos/axisDragGizmo";
  56724. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56725. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56726. export * from "babylonjs/Gizmos/gizmo";
  56727. export * from "babylonjs/Gizmos/gizmoManager";
  56728. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56729. export * from "babylonjs/Gizmos/positionGizmo";
  56730. export * from "babylonjs/Gizmos/rotationGizmo";
  56731. export * from "babylonjs/Gizmos/scaleGizmo";
  56732. export * from "babylonjs/Gizmos/lightGizmo";
  56733. export * from "babylonjs/Gizmos/cameraGizmo";
  56734. export * from "babylonjs/Gizmos/planeDragGizmo";
  56735. }
  56736. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56737. /** @hidden */
  56738. export var backgroundFragmentDeclaration: {
  56739. name: string;
  56740. shader: string;
  56741. };
  56742. }
  56743. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56744. /** @hidden */
  56745. export var backgroundUboDeclaration: {
  56746. name: string;
  56747. shader: string;
  56748. };
  56749. }
  56750. declare module "babylonjs/Shaders/background.fragment" {
  56751. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56752. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56753. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56754. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56755. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56756. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56757. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56758. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56759. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56760. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56761. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56762. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56763. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56764. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56765. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56766. /** @hidden */
  56767. export var backgroundPixelShader: {
  56768. name: string;
  56769. shader: string;
  56770. };
  56771. }
  56772. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56773. /** @hidden */
  56774. export var backgroundVertexDeclaration: {
  56775. name: string;
  56776. shader: string;
  56777. };
  56778. }
  56779. declare module "babylonjs/Shaders/background.vertex" {
  56780. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56781. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56782. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56783. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56784. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56785. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56786. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56787. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56788. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56789. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56790. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56791. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56792. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56793. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56794. /** @hidden */
  56795. export var backgroundVertexShader: {
  56796. name: string;
  56797. shader: string;
  56798. };
  56799. }
  56800. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56801. import { Nullable, int, float } from "babylonjs/types";
  56802. import { Scene } from "babylonjs/scene";
  56803. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56804. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56806. import { Mesh } from "babylonjs/Meshes/mesh";
  56807. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56808. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56809. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56810. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56811. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56812. import { Color3 } from "babylonjs/Maths/math.color";
  56813. import "babylonjs/Shaders/background.fragment";
  56814. import "babylonjs/Shaders/background.vertex";
  56815. /**
  56816. * Background material used to create an efficient environement around your scene.
  56817. */
  56818. export class BackgroundMaterial extends PushMaterial {
  56819. /**
  56820. * Standard reflectance value at parallel view angle.
  56821. */
  56822. static StandardReflectance0: number;
  56823. /**
  56824. * Standard reflectance value at grazing angle.
  56825. */
  56826. static StandardReflectance90: number;
  56827. protected _primaryColor: Color3;
  56828. /**
  56829. * Key light Color (multiply against the environement texture)
  56830. */
  56831. primaryColor: Color3;
  56832. protected __perceptualColor: Nullable<Color3>;
  56833. /**
  56834. * Experimental Internal Use Only.
  56835. *
  56836. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56837. * This acts as a helper to set the primary color to a more "human friendly" value.
  56838. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56839. * output color as close as possible from the chosen value.
  56840. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56841. * part of lighting setup.)
  56842. */
  56843. get _perceptualColor(): Nullable<Color3>;
  56844. set _perceptualColor(value: Nullable<Color3>);
  56845. protected _primaryColorShadowLevel: float;
  56846. /**
  56847. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56848. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56849. */
  56850. get primaryColorShadowLevel(): float;
  56851. set primaryColorShadowLevel(value: float);
  56852. protected _primaryColorHighlightLevel: float;
  56853. /**
  56854. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56855. * The primary color is used at the level chosen to define what the white area would look.
  56856. */
  56857. get primaryColorHighlightLevel(): float;
  56858. set primaryColorHighlightLevel(value: float);
  56859. protected _reflectionTexture: Nullable<BaseTexture>;
  56860. /**
  56861. * Reflection Texture used in the material.
  56862. * Should be author in a specific way for the best result (refer to the documentation).
  56863. */
  56864. reflectionTexture: Nullable<BaseTexture>;
  56865. protected _reflectionBlur: float;
  56866. /**
  56867. * Reflection Texture level of blur.
  56868. *
  56869. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56870. * texture twice.
  56871. */
  56872. reflectionBlur: float;
  56873. protected _diffuseTexture: Nullable<BaseTexture>;
  56874. /**
  56875. * Diffuse Texture used in the material.
  56876. * Should be author in a specific way for the best result (refer to the documentation).
  56877. */
  56878. diffuseTexture: Nullable<BaseTexture>;
  56879. protected _shadowLights: Nullable<IShadowLight[]>;
  56880. /**
  56881. * Specify the list of lights casting shadow on the material.
  56882. * All scene shadow lights will be included if null.
  56883. */
  56884. shadowLights: Nullable<IShadowLight[]>;
  56885. protected _shadowLevel: float;
  56886. /**
  56887. * Helps adjusting the shadow to a softer level if required.
  56888. * 0 means black shadows and 1 means no shadows.
  56889. */
  56890. shadowLevel: float;
  56891. protected _sceneCenter: Vector3;
  56892. /**
  56893. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  56894. * It is usually zero but might be interesting to modify according to your setup.
  56895. */
  56896. sceneCenter: Vector3;
  56897. protected _opacityFresnel: boolean;
  56898. /**
  56899. * This helps specifying that the material is falling off to the sky box at grazing angle.
  56900. * This helps ensuring a nice transition when the camera goes under the ground.
  56901. */
  56902. opacityFresnel: boolean;
  56903. protected _reflectionFresnel: boolean;
  56904. /**
  56905. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  56906. * This helps adding a mirror texture on the ground.
  56907. */
  56908. reflectionFresnel: boolean;
  56909. protected _reflectionFalloffDistance: number;
  56910. /**
  56911. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  56912. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  56913. */
  56914. reflectionFalloffDistance: number;
  56915. protected _reflectionAmount: number;
  56916. /**
  56917. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  56918. */
  56919. reflectionAmount: number;
  56920. protected _reflectionReflectance0: number;
  56921. /**
  56922. * This specifies the weight of the reflection at grazing angle.
  56923. */
  56924. reflectionReflectance0: number;
  56925. protected _reflectionReflectance90: number;
  56926. /**
  56927. * This specifies the weight of the reflection at a perpendicular point of view.
  56928. */
  56929. reflectionReflectance90: number;
  56930. /**
  56931. * Sets the reflection reflectance fresnel values according to the default standard
  56932. * empirically know to work well :-)
  56933. */
  56934. set reflectionStandardFresnelWeight(value: number);
  56935. protected _useRGBColor: boolean;
  56936. /**
  56937. * Helps to directly use the maps channels instead of their level.
  56938. */
  56939. useRGBColor: boolean;
  56940. protected _enableNoise: boolean;
  56941. /**
  56942. * This helps reducing the banding effect that could occur on the background.
  56943. */
  56944. enableNoise: boolean;
  56945. /**
  56946. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56947. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  56948. * Recommended to be keep at 1.0 except for special cases.
  56949. */
  56950. get fovMultiplier(): number;
  56951. set fovMultiplier(value: number);
  56952. private _fovMultiplier;
  56953. /**
  56954. * Enable the FOV adjustment feature controlled by fovMultiplier.
  56955. */
  56956. useEquirectangularFOV: boolean;
  56957. private _maxSimultaneousLights;
  56958. /**
  56959. * Number of Simultaneous lights allowed on the material.
  56960. */
  56961. maxSimultaneousLights: int;
  56962. private _shadowOnly;
  56963. /**
  56964. * Make the material only render shadows
  56965. */
  56966. shadowOnly: boolean;
  56967. /**
  56968. * Default configuration related to image processing available in the Background Material.
  56969. */
  56970. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56971. /**
  56972. * Keep track of the image processing observer to allow dispose and replace.
  56973. */
  56974. private _imageProcessingObserver;
  56975. /**
  56976. * Attaches a new image processing configuration to the PBR Material.
  56977. * @param configuration (if null the scene configuration will be use)
  56978. */
  56979. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56980. /**
  56981. * Gets the image processing configuration used either in this material.
  56982. */
  56983. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  56984. /**
  56985. * Sets the Default image processing configuration used either in the this material.
  56986. *
  56987. * If sets to null, the scene one is in use.
  56988. */
  56989. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  56990. /**
  56991. * Gets wether the color curves effect is enabled.
  56992. */
  56993. get cameraColorCurvesEnabled(): boolean;
  56994. /**
  56995. * Sets wether the color curves effect is enabled.
  56996. */
  56997. set cameraColorCurvesEnabled(value: boolean);
  56998. /**
  56999. * Gets wether the color grading effect is enabled.
  57000. */
  57001. get cameraColorGradingEnabled(): boolean;
  57002. /**
  57003. * Gets wether the color grading effect is enabled.
  57004. */
  57005. set cameraColorGradingEnabled(value: boolean);
  57006. /**
  57007. * Gets wether tonemapping is enabled or not.
  57008. */
  57009. get cameraToneMappingEnabled(): boolean;
  57010. /**
  57011. * Sets wether tonemapping is enabled or not
  57012. */
  57013. set cameraToneMappingEnabled(value: boolean);
  57014. /**
  57015. * The camera exposure used on this material.
  57016. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57017. * This corresponds to a photographic exposure.
  57018. */
  57019. get cameraExposure(): float;
  57020. /**
  57021. * The camera exposure used on this material.
  57022. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57023. * This corresponds to a photographic exposure.
  57024. */
  57025. set cameraExposure(value: float);
  57026. /**
  57027. * Gets The camera contrast used on this material.
  57028. */
  57029. get cameraContrast(): float;
  57030. /**
  57031. * Sets The camera contrast used on this material.
  57032. */
  57033. set cameraContrast(value: float);
  57034. /**
  57035. * Gets the Color Grading 2D Lookup Texture.
  57036. */
  57037. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57038. /**
  57039. * Sets the Color Grading 2D Lookup Texture.
  57040. */
  57041. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57042. /**
  57043. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57044. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57045. * 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;
  57046. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57047. */
  57048. get cameraColorCurves(): Nullable<ColorCurves>;
  57049. /**
  57050. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57051. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57052. * 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;
  57053. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57054. */
  57055. set cameraColorCurves(value: Nullable<ColorCurves>);
  57056. /**
  57057. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57058. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57059. */
  57060. switchToBGR: boolean;
  57061. private _renderTargets;
  57062. private _reflectionControls;
  57063. private _white;
  57064. private _primaryShadowColor;
  57065. private _primaryHighlightColor;
  57066. /**
  57067. * Instantiates a Background Material in the given scene
  57068. * @param name The friendly name of the material
  57069. * @param scene The scene to add the material to
  57070. */
  57071. constructor(name: string, scene: Scene);
  57072. /**
  57073. * Gets a boolean indicating that current material needs to register RTT
  57074. */
  57075. get hasRenderTargetTextures(): boolean;
  57076. /**
  57077. * The entire material has been created in order to prevent overdraw.
  57078. * @returns false
  57079. */
  57080. needAlphaTesting(): boolean;
  57081. /**
  57082. * The entire material has been created in order to prevent overdraw.
  57083. * @returns true if blending is enable
  57084. */
  57085. needAlphaBlending(): boolean;
  57086. /**
  57087. * Checks wether the material is ready to be rendered for a given mesh.
  57088. * @param mesh The mesh to render
  57089. * @param subMesh The submesh to check against
  57090. * @param useInstances Specify wether or not the material is used with instances
  57091. * @returns true if all the dependencies are ready (Textures, Effects...)
  57092. */
  57093. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57094. /**
  57095. * Compute the primary color according to the chosen perceptual color.
  57096. */
  57097. private _computePrimaryColorFromPerceptualColor;
  57098. /**
  57099. * Compute the highlights and shadow colors according to their chosen levels.
  57100. */
  57101. private _computePrimaryColors;
  57102. /**
  57103. * Build the uniform buffer used in the material.
  57104. */
  57105. buildUniformLayout(): void;
  57106. /**
  57107. * Unbind the material.
  57108. */
  57109. unbind(): void;
  57110. /**
  57111. * Bind only the world matrix to the material.
  57112. * @param world The world matrix to bind.
  57113. */
  57114. bindOnlyWorldMatrix(world: Matrix): void;
  57115. /**
  57116. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57117. * @param world The world matrix to bind.
  57118. * @param subMesh The submesh to bind for.
  57119. */
  57120. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57121. /**
  57122. * Checks to see if a texture is used in the material.
  57123. * @param texture - Base texture to use.
  57124. * @returns - Boolean specifying if a texture is used in the material.
  57125. */
  57126. hasTexture(texture: BaseTexture): boolean;
  57127. /**
  57128. * Dispose the material.
  57129. * @param forceDisposeEffect Force disposal of the associated effect.
  57130. * @param forceDisposeTextures Force disposal of the associated textures.
  57131. */
  57132. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57133. /**
  57134. * Clones the material.
  57135. * @param name The cloned name.
  57136. * @returns The cloned material.
  57137. */
  57138. clone(name: string): BackgroundMaterial;
  57139. /**
  57140. * Serializes the current material to its JSON representation.
  57141. * @returns The JSON representation.
  57142. */
  57143. serialize(): any;
  57144. /**
  57145. * Gets the class name of the material
  57146. * @returns "BackgroundMaterial"
  57147. */
  57148. getClassName(): string;
  57149. /**
  57150. * Parse a JSON input to create back a background material.
  57151. * @param source The JSON data to parse
  57152. * @param scene The scene to create the parsed material in
  57153. * @param rootUrl The root url of the assets the material depends upon
  57154. * @returns the instantiated BackgroundMaterial.
  57155. */
  57156. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57157. }
  57158. }
  57159. declare module "babylonjs/Helpers/environmentHelper" {
  57160. import { Observable } from "babylonjs/Misc/observable";
  57161. import { Nullable } from "babylonjs/types";
  57162. import { Scene } from "babylonjs/scene";
  57163. import { Vector3 } from "babylonjs/Maths/math.vector";
  57164. import { Color3 } from "babylonjs/Maths/math.color";
  57165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57166. import { Mesh } from "babylonjs/Meshes/mesh";
  57167. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57168. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  57169. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57170. import "babylonjs/Meshes/Builders/planeBuilder";
  57171. import "babylonjs/Meshes/Builders/boxBuilder";
  57172. /**
  57173. * Represents the different options available during the creation of
  57174. * a Environment helper.
  57175. *
  57176. * This can control the default ground, skybox and image processing setup of your scene.
  57177. */
  57178. export interface IEnvironmentHelperOptions {
  57179. /**
  57180. * Specifies whether or not to create a ground.
  57181. * True by default.
  57182. */
  57183. createGround: boolean;
  57184. /**
  57185. * Specifies the ground size.
  57186. * 15 by default.
  57187. */
  57188. groundSize: number;
  57189. /**
  57190. * The texture used on the ground for the main color.
  57191. * Comes from the BabylonJS CDN by default.
  57192. *
  57193. * Remarks: Can be either a texture or a url.
  57194. */
  57195. groundTexture: string | BaseTexture;
  57196. /**
  57197. * The color mixed in the ground texture by default.
  57198. * BabylonJS clearColor by default.
  57199. */
  57200. groundColor: Color3;
  57201. /**
  57202. * Specifies the ground opacity.
  57203. * 1 by default.
  57204. */
  57205. groundOpacity: number;
  57206. /**
  57207. * Enables the ground to receive shadows.
  57208. * True by default.
  57209. */
  57210. enableGroundShadow: boolean;
  57211. /**
  57212. * Helps preventing the shadow to be fully black on the ground.
  57213. * 0.5 by default.
  57214. */
  57215. groundShadowLevel: number;
  57216. /**
  57217. * Creates a mirror texture attach to the ground.
  57218. * false by default.
  57219. */
  57220. enableGroundMirror: boolean;
  57221. /**
  57222. * Specifies the ground mirror size ratio.
  57223. * 0.3 by default as the default kernel is 64.
  57224. */
  57225. groundMirrorSizeRatio: number;
  57226. /**
  57227. * Specifies the ground mirror blur kernel size.
  57228. * 64 by default.
  57229. */
  57230. groundMirrorBlurKernel: number;
  57231. /**
  57232. * Specifies the ground mirror visibility amount.
  57233. * 1 by default
  57234. */
  57235. groundMirrorAmount: number;
  57236. /**
  57237. * Specifies the ground mirror reflectance weight.
  57238. * This uses the standard weight of the background material to setup the fresnel effect
  57239. * of the mirror.
  57240. * 1 by default.
  57241. */
  57242. groundMirrorFresnelWeight: number;
  57243. /**
  57244. * Specifies the ground mirror Falloff distance.
  57245. * This can helps reducing the size of the reflection.
  57246. * 0 by Default.
  57247. */
  57248. groundMirrorFallOffDistance: number;
  57249. /**
  57250. * Specifies the ground mirror texture type.
  57251. * Unsigned Int by Default.
  57252. */
  57253. groundMirrorTextureType: number;
  57254. /**
  57255. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57256. * the shown objects.
  57257. */
  57258. groundYBias: number;
  57259. /**
  57260. * Specifies whether or not to create a skybox.
  57261. * True by default.
  57262. */
  57263. createSkybox: boolean;
  57264. /**
  57265. * Specifies the skybox size.
  57266. * 20 by default.
  57267. */
  57268. skyboxSize: number;
  57269. /**
  57270. * The texture used on the skybox for the main color.
  57271. * Comes from the BabylonJS CDN by default.
  57272. *
  57273. * Remarks: Can be either a texture or a url.
  57274. */
  57275. skyboxTexture: string | BaseTexture;
  57276. /**
  57277. * The color mixed in the skybox texture by default.
  57278. * BabylonJS clearColor by default.
  57279. */
  57280. skyboxColor: Color3;
  57281. /**
  57282. * The background rotation around the Y axis of the scene.
  57283. * This helps aligning the key lights of your scene with the background.
  57284. * 0 by default.
  57285. */
  57286. backgroundYRotation: number;
  57287. /**
  57288. * Compute automatically the size of the elements to best fit with the scene.
  57289. */
  57290. sizeAuto: boolean;
  57291. /**
  57292. * Default position of the rootMesh if autoSize is not true.
  57293. */
  57294. rootPosition: Vector3;
  57295. /**
  57296. * Sets up the image processing in the scene.
  57297. * true by default.
  57298. */
  57299. setupImageProcessing: boolean;
  57300. /**
  57301. * The texture used as your environment texture in the scene.
  57302. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57303. *
  57304. * Remarks: Can be either a texture or a url.
  57305. */
  57306. environmentTexture: string | BaseTexture;
  57307. /**
  57308. * The value of the exposure to apply to the scene.
  57309. * 0.6 by default if setupImageProcessing is true.
  57310. */
  57311. cameraExposure: number;
  57312. /**
  57313. * The value of the contrast to apply to the scene.
  57314. * 1.6 by default if setupImageProcessing is true.
  57315. */
  57316. cameraContrast: number;
  57317. /**
  57318. * Specifies whether or not tonemapping should be enabled in the scene.
  57319. * true by default if setupImageProcessing is true.
  57320. */
  57321. toneMappingEnabled: boolean;
  57322. }
  57323. /**
  57324. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57325. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57326. * It also helps with the default setup of your imageProcessing configuration.
  57327. */
  57328. export class EnvironmentHelper {
  57329. /**
  57330. * Default ground texture URL.
  57331. */
  57332. private static _groundTextureCDNUrl;
  57333. /**
  57334. * Default skybox texture URL.
  57335. */
  57336. private static _skyboxTextureCDNUrl;
  57337. /**
  57338. * Default environment texture URL.
  57339. */
  57340. private static _environmentTextureCDNUrl;
  57341. /**
  57342. * Creates the default options for the helper.
  57343. */
  57344. private static _getDefaultOptions;
  57345. private _rootMesh;
  57346. /**
  57347. * Gets the root mesh created by the helper.
  57348. */
  57349. get rootMesh(): Mesh;
  57350. private _skybox;
  57351. /**
  57352. * Gets the skybox created by the helper.
  57353. */
  57354. get skybox(): Nullable<Mesh>;
  57355. private _skyboxTexture;
  57356. /**
  57357. * Gets the skybox texture created by the helper.
  57358. */
  57359. get skyboxTexture(): Nullable<BaseTexture>;
  57360. private _skyboxMaterial;
  57361. /**
  57362. * Gets the skybox material created by the helper.
  57363. */
  57364. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57365. private _ground;
  57366. /**
  57367. * Gets the ground mesh created by the helper.
  57368. */
  57369. get ground(): Nullable<Mesh>;
  57370. private _groundTexture;
  57371. /**
  57372. * Gets the ground texture created by the helper.
  57373. */
  57374. get groundTexture(): Nullable<BaseTexture>;
  57375. private _groundMirror;
  57376. /**
  57377. * Gets the ground mirror created by the helper.
  57378. */
  57379. get groundMirror(): Nullable<MirrorTexture>;
  57380. /**
  57381. * Gets the ground mirror render list to helps pushing the meshes
  57382. * you wish in the ground reflection.
  57383. */
  57384. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57385. private _groundMaterial;
  57386. /**
  57387. * Gets the ground material created by the helper.
  57388. */
  57389. get groundMaterial(): Nullable<BackgroundMaterial>;
  57390. /**
  57391. * Stores the creation options.
  57392. */
  57393. private readonly _scene;
  57394. private _options;
  57395. /**
  57396. * This observable will be notified with any error during the creation of the environment,
  57397. * mainly texture creation errors.
  57398. */
  57399. onErrorObservable: Observable<{
  57400. message?: string;
  57401. exception?: any;
  57402. }>;
  57403. /**
  57404. * constructor
  57405. * @param options Defines the options we want to customize the helper
  57406. * @param scene The scene to add the material to
  57407. */
  57408. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57409. /**
  57410. * Updates the background according to the new options
  57411. * @param options
  57412. */
  57413. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57414. /**
  57415. * Sets the primary color of all the available elements.
  57416. * @param color the main color to affect to the ground and the background
  57417. */
  57418. setMainColor(color: Color3): void;
  57419. /**
  57420. * Setup the image processing according to the specified options.
  57421. */
  57422. private _setupImageProcessing;
  57423. /**
  57424. * Setup the environment texture according to the specified options.
  57425. */
  57426. private _setupEnvironmentTexture;
  57427. /**
  57428. * Setup the background according to the specified options.
  57429. */
  57430. private _setupBackground;
  57431. /**
  57432. * Get the scene sizes according to the setup.
  57433. */
  57434. private _getSceneSize;
  57435. /**
  57436. * Setup the ground according to the specified options.
  57437. */
  57438. private _setupGround;
  57439. /**
  57440. * Setup the ground material according to the specified options.
  57441. */
  57442. private _setupGroundMaterial;
  57443. /**
  57444. * Setup the ground diffuse texture according to the specified options.
  57445. */
  57446. private _setupGroundDiffuseTexture;
  57447. /**
  57448. * Setup the ground mirror texture according to the specified options.
  57449. */
  57450. private _setupGroundMirrorTexture;
  57451. /**
  57452. * Setup the ground to receive the mirror texture.
  57453. */
  57454. private _setupMirrorInGroundMaterial;
  57455. /**
  57456. * Setup the skybox according to the specified options.
  57457. */
  57458. private _setupSkybox;
  57459. /**
  57460. * Setup the skybox material according to the specified options.
  57461. */
  57462. private _setupSkyboxMaterial;
  57463. /**
  57464. * Setup the skybox reflection texture according to the specified options.
  57465. */
  57466. private _setupSkyboxReflectionTexture;
  57467. private _errorHandler;
  57468. /**
  57469. * Dispose all the elements created by the Helper.
  57470. */
  57471. dispose(): void;
  57472. }
  57473. }
  57474. declare module "babylonjs/Helpers/textureDome" {
  57475. import { Scene } from "babylonjs/scene";
  57476. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57477. import { Mesh } from "babylonjs/Meshes/mesh";
  57478. import { Texture } from "babylonjs/Materials/Textures/texture";
  57479. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57480. import "babylonjs/Meshes/Builders/sphereBuilder";
  57481. import { Nullable } from "babylonjs/types";
  57482. import { Observable } from "babylonjs/Misc/observable";
  57483. /**
  57484. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  57485. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  57486. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57487. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57488. */
  57489. export abstract class TextureDome<T extends Texture> extends TransformNode {
  57490. protected onError: Nullable<(message?: string, exception?: any) => void>;
  57491. /**
  57492. * Define the source as a Monoscopic panoramic 360/180.
  57493. */
  57494. static readonly MODE_MONOSCOPIC: number;
  57495. /**
  57496. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  57497. */
  57498. static readonly MODE_TOPBOTTOM: number;
  57499. /**
  57500. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  57501. */
  57502. static readonly MODE_SIDEBYSIDE: number;
  57503. private _halfDome;
  57504. protected _useDirectMapping: boolean;
  57505. /**
  57506. * The texture being displayed on the sphere
  57507. */
  57508. protected _texture: T;
  57509. /**
  57510. * Gets the texture being displayed on the sphere
  57511. */
  57512. get texture(): T;
  57513. /**
  57514. * Sets the texture being displayed on the sphere
  57515. */
  57516. set texture(newTexture: T);
  57517. /**
  57518. * The skybox material
  57519. */
  57520. protected _material: BackgroundMaterial;
  57521. /**
  57522. * The surface used for the dome
  57523. */
  57524. protected _mesh: Mesh;
  57525. /**
  57526. * Gets the mesh used for the dome.
  57527. */
  57528. get mesh(): Mesh;
  57529. /**
  57530. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  57531. */
  57532. private _halfDomeMask;
  57533. /**
  57534. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57535. * Also see the options.resolution property.
  57536. */
  57537. get fovMultiplier(): number;
  57538. set fovMultiplier(value: number);
  57539. protected _textureMode: number;
  57540. /**
  57541. * Gets or set the current texture mode for the texture. It can be:
  57542. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57543. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57544. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57545. */
  57546. get textureMode(): number;
  57547. /**
  57548. * Sets the current texture mode for the texture. It can be:
  57549. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57550. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57551. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57552. */
  57553. set textureMode(value: number);
  57554. /**
  57555. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  57556. */
  57557. get halfDome(): boolean;
  57558. /**
  57559. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57560. */
  57561. set halfDome(enabled: boolean);
  57562. /**
  57563. * Oberserver used in Stereoscopic VR Mode.
  57564. */
  57565. private _onBeforeCameraRenderObserver;
  57566. /**
  57567. * Observable raised when an error occured while loading the 360 image
  57568. */
  57569. onLoadErrorObservable: Observable<string>;
  57570. /**
  57571. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  57572. * @param name Element's name, child elements will append suffixes for their own names.
  57573. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  57574. * @param options An object containing optional or exposed sub element properties
  57575. */
  57576. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  57577. resolution?: number;
  57578. clickToPlay?: boolean;
  57579. autoPlay?: boolean;
  57580. loop?: boolean;
  57581. size?: number;
  57582. poster?: string;
  57583. faceForward?: boolean;
  57584. useDirectMapping?: boolean;
  57585. halfDomeMode?: boolean;
  57586. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57587. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  57588. protected _changeTextureMode(value: number): void;
  57589. /**
  57590. * Releases resources associated with this node.
  57591. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57592. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57593. */
  57594. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57595. }
  57596. }
  57597. declare module "babylonjs/Helpers/photoDome" {
  57598. import { Scene } from "babylonjs/scene";
  57599. import { Texture } from "babylonjs/Materials/Textures/texture";
  57600. import { TextureDome } from "babylonjs/Helpers/textureDome";
  57601. /**
  57602. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57603. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57604. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57605. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57606. */
  57607. export class PhotoDome extends TextureDome<Texture> {
  57608. /**
  57609. * Define the image as a Monoscopic panoramic 360 image.
  57610. */
  57611. static readonly MODE_MONOSCOPIC: number;
  57612. /**
  57613. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57614. */
  57615. static readonly MODE_TOPBOTTOM: number;
  57616. /**
  57617. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57618. */
  57619. static readonly MODE_SIDEBYSIDE: number;
  57620. /**
  57621. * Gets or sets the texture being displayed on the sphere
  57622. */
  57623. get photoTexture(): Texture;
  57624. /**
  57625. * sets the texture being displayed on the sphere
  57626. */
  57627. set photoTexture(value: Texture);
  57628. /**
  57629. * Gets the current video mode for the video. It can be:
  57630. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57631. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57632. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57633. */
  57634. get imageMode(): number;
  57635. /**
  57636. * Sets the current video mode for the video. It can be:
  57637. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57638. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57639. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57640. */
  57641. set imageMode(value: number);
  57642. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  57643. }
  57644. }
  57645. declare module "babylonjs/Misc/rgbdTextureTools" {
  57646. import "babylonjs/Shaders/rgbdDecode.fragment";
  57647. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57648. import { Texture } from "babylonjs/Materials/Textures/texture";
  57649. /**
  57650. * Class used to host RGBD texture specific utilities
  57651. */
  57652. export class RGBDTextureTools {
  57653. /**
  57654. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57655. * @param texture the texture to expand.
  57656. */
  57657. static ExpandRGBDTexture(texture: Texture): void;
  57658. }
  57659. }
  57660. declare module "babylonjs/Misc/brdfTextureTools" {
  57661. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57662. import { Scene } from "babylonjs/scene";
  57663. /**
  57664. * Class used to host texture specific utilities
  57665. */
  57666. export class BRDFTextureTools {
  57667. /**
  57668. * Prevents texture cache collision
  57669. */
  57670. private static _instanceNumber;
  57671. /**
  57672. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57673. * @param scene defines the hosting scene
  57674. * @returns the environment BRDF texture
  57675. */
  57676. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57677. private static _environmentBRDFBase64Texture;
  57678. }
  57679. }
  57680. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57681. import { Nullable } from "babylonjs/types";
  57682. import { Color3 } from "babylonjs/Maths/math.color";
  57683. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57684. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57685. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57686. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57687. import { Engine } from "babylonjs/Engines/engine";
  57688. import { Scene } from "babylonjs/scene";
  57689. /**
  57690. * @hidden
  57691. */
  57692. export interface IMaterialClearCoatDefines {
  57693. CLEARCOAT: boolean;
  57694. CLEARCOAT_DEFAULTIOR: boolean;
  57695. CLEARCOAT_TEXTURE: boolean;
  57696. CLEARCOAT_TEXTUREDIRECTUV: number;
  57697. CLEARCOAT_BUMP: boolean;
  57698. CLEARCOAT_BUMPDIRECTUV: number;
  57699. CLEARCOAT_TINT: boolean;
  57700. CLEARCOAT_TINT_TEXTURE: boolean;
  57701. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57702. /** @hidden */
  57703. _areTexturesDirty: boolean;
  57704. }
  57705. /**
  57706. * Define the code related to the clear coat parameters of the pbr material.
  57707. */
  57708. export class PBRClearCoatConfiguration {
  57709. /**
  57710. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57711. * The default fits with a polyurethane material.
  57712. */
  57713. private static readonly _DefaultIndexOfRefraction;
  57714. private _isEnabled;
  57715. /**
  57716. * Defines if the clear coat is enabled in the material.
  57717. */
  57718. isEnabled: boolean;
  57719. /**
  57720. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57721. */
  57722. intensity: number;
  57723. /**
  57724. * Defines the clear coat layer roughness.
  57725. */
  57726. roughness: number;
  57727. private _indexOfRefraction;
  57728. /**
  57729. * Defines the index of refraction of the clear coat.
  57730. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57731. * The default fits with a polyurethane material.
  57732. * Changing the default value is more performance intensive.
  57733. */
  57734. indexOfRefraction: number;
  57735. private _texture;
  57736. /**
  57737. * Stores the clear coat values in a texture.
  57738. */
  57739. texture: Nullable<BaseTexture>;
  57740. private _bumpTexture;
  57741. /**
  57742. * Define the clear coat specific bump texture.
  57743. */
  57744. bumpTexture: Nullable<BaseTexture>;
  57745. private _isTintEnabled;
  57746. /**
  57747. * Defines if the clear coat tint is enabled in the material.
  57748. */
  57749. isTintEnabled: boolean;
  57750. /**
  57751. * Defines the clear coat tint of the material.
  57752. * This is only use if tint is enabled
  57753. */
  57754. tintColor: Color3;
  57755. /**
  57756. * Defines the distance at which the tint color should be found in the
  57757. * clear coat media.
  57758. * This is only use if tint is enabled
  57759. */
  57760. tintColorAtDistance: number;
  57761. /**
  57762. * Defines the clear coat layer thickness.
  57763. * This is only use if tint is enabled
  57764. */
  57765. tintThickness: number;
  57766. private _tintTexture;
  57767. /**
  57768. * Stores the clear tint values in a texture.
  57769. * rgb is tint
  57770. * a is a thickness factor
  57771. */
  57772. tintTexture: Nullable<BaseTexture>;
  57773. /** @hidden */
  57774. private _internalMarkAllSubMeshesAsTexturesDirty;
  57775. /** @hidden */
  57776. _markAllSubMeshesAsTexturesDirty(): void;
  57777. /**
  57778. * Instantiate a new istance of clear coat configuration.
  57779. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57780. */
  57781. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57782. /**
  57783. * Gets wehter the submesh is ready to be used or not.
  57784. * @param defines the list of "defines" to update.
  57785. * @param scene defines the scene the material belongs to.
  57786. * @param engine defines the engine the material belongs to.
  57787. * @param disableBumpMap defines wether the material disables bump or not.
  57788. * @returns - boolean indicating that the submesh is ready or not.
  57789. */
  57790. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57791. /**
  57792. * Checks to see if a texture is used in the material.
  57793. * @param defines the list of "defines" to update.
  57794. * @param scene defines the scene to the material belongs to.
  57795. */
  57796. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57797. /**
  57798. * Binds the material data.
  57799. * @param uniformBuffer defines the Uniform buffer to fill in.
  57800. * @param scene defines the scene the material belongs to.
  57801. * @param engine defines the engine the material belongs to.
  57802. * @param disableBumpMap defines wether the material disables bump or not.
  57803. * @param isFrozen defines wether the material is frozen or not.
  57804. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57805. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57806. */
  57807. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57808. /**
  57809. * Checks to see if a texture is used in the material.
  57810. * @param texture - Base texture to use.
  57811. * @returns - Boolean specifying if a texture is used in the material.
  57812. */
  57813. hasTexture(texture: BaseTexture): boolean;
  57814. /**
  57815. * Returns an array of the actively used textures.
  57816. * @param activeTextures Array of BaseTextures
  57817. */
  57818. getActiveTextures(activeTextures: BaseTexture[]): void;
  57819. /**
  57820. * Returns the animatable textures.
  57821. * @param animatables Array of animatable textures.
  57822. */
  57823. getAnimatables(animatables: IAnimatable[]): void;
  57824. /**
  57825. * Disposes the resources of the material.
  57826. * @param forceDisposeTextures - Forces the disposal of all textures.
  57827. */
  57828. dispose(forceDisposeTextures?: boolean): void;
  57829. /**
  57830. * Get the current class name of the texture useful for serialization or dynamic coding.
  57831. * @returns "PBRClearCoatConfiguration"
  57832. */
  57833. getClassName(): string;
  57834. /**
  57835. * Add fallbacks to the effect fallbacks list.
  57836. * @param defines defines the Base texture to use.
  57837. * @param fallbacks defines the current fallback list.
  57838. * @param currentRank defines the current fallback rank.
  57839. * @returns the new fallback rank.
  57840. */
  57841. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57842. /**
  57843. * Add the required uniforms to the current list.
  57844. * @param uniforms defines the current uniform list.
  57845. */
  57846. static AddUniforms(uniforms: string[]): void;
  57847. /**
  57848. * Add the required samplers to the current list.
  57849. * @param samplers defines the current sampler list.
  57850. */
  57851. static AddSamplers(samplers: string[]): void;
  57852. /**
  57853. * Add the required uniforms to the current buffer.
  57854. * @param uniformBuffer defines the current uniform buffer.
  57855. */
  57856. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57857. /**
  57858. * Makes a duplicate of the current configuration into another one.
  57859. * @param clearCoatConfiguration define the config where to copy the info
  57860. */
  57861. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57862. /**
  57863. * Serializes this clear coat configuration.
  57864. * @returns - An object with the serialized config.
  57865. */
  57866. serialize(): any;
  57867. /**
  57868. * Parses a anisotropy Configuration from a serialized object.
  57869. * @param source - Serialized object.
  57870. * @param scene Defines the scene we are parsing for
  57871. * @param rootUrl Defines the rootUrl to load from
  57872. */
  57873. parse(source: any, scene: Scene, rootUrl: string): void;
  57874. }
  57875. }
  57876. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57877. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57878. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57879. import { Vector2 } from "babylonjs/Maths/math.vector";
  57880. import { Scene } from "babylonjs/scene";
  57881. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57882. import { Nullable } from "babylonjs/types";
  57883. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57884. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57885. /**
  57886. * @hidden
  57887. */
  57888. export interface IMaterialAnisotropicDefines {
  57889. ANISOTROPIC: boolean;
  57890. ANISOTROPIC_TEXTURE: boolean;
  57891. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57892. MAINUV1: boolean;
  57893. _areTexturesDirty: boolean;
  57894. _needUVs: boolean;
  57895. }
  57896. /**
  57897. * Define the code related to the anisotropic parameters of the pbr material.
  57898. */
  57899. export class PBRAnisotropicConfiguration {
  57900. private _isEnabled;
  57901. /**
  57902. * Defines if the anisotropy is enabled in the material.
  57903. */
  57904. isEnabled: boolean;
  57905. /**
  57906. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  57907. */
  57908. intensity: number;
  57909. /**
  57910. * Defines if the effect is along the tangents, bitangents or in between.
  57911. * By default, the effect is "strectching" the highlights along the tangents.
  57912. */
  57913. direction: Vector2;
  57914. private _texture;
  57915. /**
  57916. * Stores the anisotropy values in a texture.
  57917. * rg is direction (like normal from -1 to 1)
  57918. * b is a intensity
  57919. */
  57920. texture: Nullable<BaseTexture>;
  57921. /** @hidden */
  57922. private _internalMarkAllSubMeshesAsTexturesDirty;
  57923. /** @hidden */
  57924. _markAllSubMeshesAsTexturesDirty(): void;
  57925. /**
  57926. * Instantiate a new istance of anisotropy configuration.
  57927. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57928. */
  57929. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57930. /**
  57931. * Specifies that the submesh is ready to be used.
  57932. * @param defines the list of "defines" to update.
  57933. * @param scene defines the scene the material belongs to.
  57934. * @returns - boolean indicating that the submesh is ready or not.
  57935. */
  57936. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  57937. /**
  57938. * Checks to see if a texture is used in the material.
  57939. * @param defines the list of "defines" to update.
  57940. * @param mesh the mesh we are preparing the defines for.
  57941. * @param scene defines the scene the material belongs to.
  57942. */
  57943. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  57944. /**
  57945. * Binds the material data.
  57946. * @param uniformBuffer defines the Uniform buffer to fill in.
  57947. * @param scene defines the scene the material belongs to.
  57948. * @param isFrozen defines wether the material is frozen or not.
  57949. */
  57950. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57951. /**
  57952. * Checks to see if a texture is used in the material.
  57953. * @param texture - Base texture to use.
  57954. * @returns - Boolean specifying if a texture is used in the material.
  57955. */
  57956. hasTexture(texture: BaseTexture): boolean;
  57957. /**
  57958. * Returns an array of the actively used textures.
  57959. * @param activeTextures Array of BaseTextures
  57960. */
  57961. getActiveTextures(activeTextures: BaseTexture[]): void;
  57962. /**
  57963. * Returns the animatable textures.
  57964. * @param animatables Array of animatable textures.
  57965. */
  57966. getAnimatables(animatables: IAnimatable[]): void;
  57967. /**
  57968. * Disposes the resources of the material.
  57969. * @param forceDisposeTextures - Forces the disposal of all textures.
  57970. */
  57971. dispose(forceDisposeTextures?: boolean): void;
  57972. /**
  57973. * Get the current class name of the texture useful for serialization or dynamic coding.
  57974. * @returns "PBRAnisotropicConfiguration"
  57975. */
  57976. getClassName(): string;
  57977. /**
  57978. * Add fallbacks to the effect fallbacks list.
  57979. * @param defines defines the Base texture to use.
  57980. * @param fallbacks defines the current fallback list.
  57981. * @param currentRank defines the current fallback rank.
  57982. * @returns the new fallback rank.
  57983. */
  57984. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57985. /**
  57986. * Add the required uniforms to the current list.
  57987. * @param uniforms defines the current uniform list.
  57988. */
  57989. static AddUniforms(uniforms: string[]): void;
  57990. /**
  57991. * Add the required uniforms to the current buffer.
  57992. * @param uniformBuffer defines the current uniform buffer.
  57993. */
  57994. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57995. /**
  57996. * Add the required samplers to the current list.
  57997. * @param samplers defines the current sampler list.
  57998. */
  57999. static AddSamplers(samplers: string[]): void;
  58000. /**
  58001. * Makes a duplicate of the current configuration into another one.
  58002. * @param anisotropicConfiguration define the config where to copy the info
  58003. */
  58004. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  58005. /**
  58006. * Serializes this anisotropy configuration.
  58007. * @returns - An object with the serialized config.
  58008. */
  58009. serialize(): any;
  58010. /**
  58011. * Parses a anisotropy Configuration from a serialized object.
  58012. * @param source - Serialized object.
  58013. * @param scene Defines the scene we are parsing for
  58014. * @param rootUrl Defines the rootUrl to load from
  58015. */
  58016. parse(source: any, scene: Scene, rootUrl: string): void;
  58017. }
  58018. }
  58019. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  58020. import { Scene } from "babylonjs/scene";
  58021. /**
  58022. * @hidden
  58023. */
  58024. export interface IMaterialBRDFDefines {
  58025. BRDF_V_HEIGHT_CORRELATED: boolean;
  58026. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58027. SPHERICAL_HARMONICS: boolean;
  58028. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58029. /** @hidden */
  58030. _areMiscDirty: boolean;
  58031. }
  58032. /**
  58033. * Define the code related to the BRDF parameters of the pbr material.
  58034. */
  58035. export class PBRBRDFConfiguration {
  58036. /**
  58037. * Default value used for the energy conservation.
  58038. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58039. */
  58040. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  58041. /**
  58042. * Default value used for the Smith Visibility Height Correlated mode.
  58043. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58044. */
  58045. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  58046. /**
  58047. * Default value used for the IBL diffuse part.
  58048. * This can help switching back to the polynomials mode globally which is a tiny bit
  58049. * less GPU intensive at the drawback of a lower quality.
  58050. */
  58051. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  58052. /**
  58053. * Default value used for activating energy conservation for the specular workflow.
  58054. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58055. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58056. */
  58057. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  58058. private _useEnergyConservation;
  58059. /**
  58060. * Defines if the material uses energy conservation.
  58061. */
  58062. useEnergyConservation: boolean;
  58063. private _useSmithVisibilityHeightCorrelated;
  58064. /**
  58065. * LEGACY Mode set to false
  58066. * Defines if the material uses height smith correlated visibility term.
  58067. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  58068. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  58069. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  58070. * Not relying on height correlated will also disable energy conservation.
  58071. */
  58072. useSmithVisibilityHeightCorrelated: boolean;
  58073. private _useSphericalHarmonics;
  58074. /**
  58075. * LEGACY Mode set to false
  58076. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  58077. * diffuse part of the IBL.
  58078. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  58079. * to the ground truth.
  58080. */
  58081. useSphericalHarmonics: boolean;
  58082. private _useSpecularGlossinessInputEnergyConservation;
  58083. /**
  58084. * Defines if the material uses energy conservation, when the specular workflow is active.
  58085. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58086. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58087. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  58088. */
  58089. useSpecularGlossinessInputEnergyConservation: boolean;
  58090. /** @hidden */
  58091. private _internalMarkAllSubMeshesAsMiscDirty;
  58092. /** @hidden */
  58093. _markAllSubMeshesAsMiscDirty(): void;
  58094. /**
  58095. * Instantiate a new istance of clear coat configuration.
  58096. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  58097. */
  58098. constructor(markAllSubMeshesAsMiscDirty: () => void);
  58099. /**
  58100. * Checks to see if a texture is used in the material.
  58101. * @param defines the list of "defines" to update.
  58102. */
  58103. prepareDefines(defines: IMaterialBRDFDefines): void;
  58104. /**
  58105. * Get the current class name of the texture useful for serialization or dynamic coding.
  58106. * @returns "PBRClearCoatConfiguration"
  58107. */
  58108. getClassName(): string;
  58109. /**
  58110. * Makes a duplicate of the current configuration into another one.
  58111. * @param brdfConfiguration define the config where to copy the info
  58112. */
  58113. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  58114. /**
  58115. * Serializes this BRDF configuration.
  58116. * @returns - An object with the serialized config.
  58117. */
  58118. serialize(): any;
  58119. /**
  58120. * Parses a anisotropy Configuration from a serialized object.
  58121. * @param source - Serialized object.
  58122. * @param scene Defines the scene we are parsing for
  58123. * @param rootUrl Defines the rootUrl to load from
  58124. */
  58125. parse(source: any, scene: Scene, rootUrl: string): void;
  58126. }
  58127. }
  58128. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  58129. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58130. import { Color3 } from "babylonjs/Maths/math.color";
  58131. import { Scene } from "babylonjs/scene";
  58132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58133. import { Nullable } from "babylonjs/types";
  58134. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58135. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58136. /**
  58137. * @hidden
  58138. */
  58139. export interface IMaterialSheenDefines {
  58140. SHEEN: boolean;
  58141. SHEEN_TEXTURE: boolean;
  58142. SHEEN_TEXTUREDIRECTUV: number;
  58143. SHEEN_LINKWITHALBEDO: boolean;
  58144. SHEEN_ROUGHNESS: boolean;
  58145. SHEEN_ALBEDOSCALING: boolean;
  58146. /** @hidden */
  58147. _areTexturesDirty: boolean;
  58148. }
  58149. /**
  58150. * Define the code related to the Sheen parameters of the pbr material.
  58151. */
  58152. export class PBRSheenConfiguration {
  58153. private _isEnabled;
  58154. /**
  58155. * Defines if the material uses sheen.
  58156. */
  58157. isEnabled: boolean;
  58158. private _linkSheenWithAlbedo;
  58159. /**
  58160. * Defines if the sheen is linked to the sheen color.
  58161. */
  58162. linkSheenWithAlbedo: boolean;
  58163. /**
  58164. * Defines the sheen intensity.
  58165. */
  58166. intensity: number;
  58167. /**
  58168. * Defines the sheen color.
  58169. */
  58170. color: Color3;
  58171. private _texture;
  58172. /**
  58173. * Stores the sheen tint values in a texture.
  58174. * rgb is tint
  58175. * a is a intensity or roughness if roughness has been defined
  58176. */
  58177. texture: Nullable<BaseTexture>;
  58178. private _roughness;
  58179. /**
  58180. * Defines the sheen roughness.
  58181. * It is not taken into account if linkSheenWithAlbedo is true.
  58182. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  58183. */
  58184. roughness: Nullable<number>;
  58185. private _albedoScaling;
  58186. /**
  58187. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  58188. * It allows the strength of the sheen effect to not depend on the base color of the material,
  58189. * making it easier to setup and tweak the effect
  58190. */
  58191. albedoScaling: boolean;
  58192. /** @hidden */
  58193. private _internalMarkAllSubMeshesAsTexturesDirty;
  58194. /** @hidden */
  58195. _markAllSubMeshesAsTexturesDirty(): void;
  58196. /**
  58197. * Instantiate a new istance of clear coat configuration.
  58198. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58199. */
  58200. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58201. /**
  58202. * Specifies that the submesh is ready to be used.
  58203. * @param defines the list of "defines" to update.
  58204. * @param scene defines the scene the material belongs to.
  58205. * @returns - boolean indicating that the submesh is ready or not.
  58206. */
  58207. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  58208. /**
  58209. * Checks to see if a texture is used in the material.
  58210. * @param defines the list of "defines" to update.
  58211. * @param scene defines the scene the material belongs to.
  58212. */
  58213. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  58214. /**
  58215. * Binds the material data.
  58216. * @param uniformBuffer defines the Uniform buffer to fill in.
  58217. * @param scene defines the scene the material belongs to.
  58218. * @param isFrozen defines wether the material is frozen or not.
  58219. */
  58220. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58221. /**
  58222. * Checks to see if a texture is used in the material.
  58223. * @param texture - Base texture to use.
  58224. * @returns - Boolean specifying if a texture is used in the material.
  58225. */
  58226. hasTexture(texture: BaseTexture): boolean;
  58227. /**
  58228. * Returns an array of the actively used textures.
  58229. * @param activeTextures Array of BaseTextures
  58230. */
  58231. getActiveTextures(activeTextures: BaseTexture[]): void;
  58232. /**
  58233. * Returns the animatable textures.
  58234. * @param animatables Array of animatable textures.
  58235. */
  58236. getAnimatables(animatables: IAnimatable[]): void;
  58237. /**
  58238. * Disposes the resources of the material.
  58239. * @param forceDisposeTextures - Forces the disposal of all textures.
  58240. */
  58241. dispose(forceDisposeTextures?: boolean): void;
  58242. /**
  58243. * Get the current class name of the texture useful for serialization or dynamic coding.
  58244. * @returns "PBRSheenConfiguration"
  58245. */
  58246. getClassName(): string;
  58247. /**
  58248. * Add fallbacks to the effect fallbacks list.
  58249. * @param defines defines the Base texture to use.
  58250. * @param fallbacks defines the current fallback list.
  58251. * @param currentRank defines the current fallback rank.
  58252. * @returns the new fallback rank.
  58253. */
  58254. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58255. /**
  58256. * Add the required uniforms to the current list.
  58257. * @param uniforms defines the current uniform list.
  58258. */
  58259. static AddUniforms(uniforms: string[]): void;
  58260. /**
  58261. * Add the required uniforms to the current buffer.
  58262. * @param uniformBuffer defines the current uniform buffer.
  58263. */
  58264. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58265. /**
  58266. * Add the required samplers to the current list.
  58267. * @param samplers defines the current sampler list.
  58268. */
  58269. static AddSamplers(samplers: string[]): void;
  58270. /**
  58271. * Makes a duplicate of the current configuration into another one.
  58272. * @param sheenConfiguration define the config where to copy the info
  58273. */
  58274. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  58275. /**
  58276. * Serializes this BRDF configuration.
  58277. * @returns - An object with the serialized config.
  58278. */
  58279. serialize(): any;
  58280. /**
  58281. * Parses a anisotropy Configuration from a serialized object.
  58282. * @param source - Serialized object.
  58283. * @param scene Defines the scene we are parsing for
  58284. * @param rootUrl Defines the rootUrl to load from
  58285. */
  58286. parse(source: any, scene: Scene, rootUrl: string): void;
  58287. }
  58288. }
  58289. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  58290. import { Nullable } from "babylonjs/types";
  58291. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58292. import { Color3 } from "babylonjs/Maths/math.color";
  58293. import { SmartArray } from "babylonjs/Misc/smartArray";
  58294. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58295. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58296. import { Effect } from "babylonjs/Materials/effect";
  58297. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58298. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58299. import { Engine } from "babylonjs/Engines/engine";
  58300. import { Scene } from "babylonjs/scene";
  58301. /**
  58302. * @hidden
  58303. */
  58304. export interface IMaterialSubSurfaceDefines {
  58305. SUBSURFACE: boolean;
  58306. SS_REFRACTION: boolean;
  58307. SS_TRANSLUCENCY: boolean;
  58308. SS_SCATTERING: boolean;
  58309. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58310. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58311. SS_REFRACTIONMAP_3D: boolean;
  58312. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58313. SS_LODINREFRACTIONALPHA: boolean;
  58314. SS_GAMMAREFRACTION: boolean;
  58315. SS_RGBDREFRACTION: boolean;
  58316. SS_LINEARSPECULARREFRACTION: boolean;
  58317. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58318. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58319. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58320. /** @hidden */
  58321. _areTexturesDirty: boolean;
  58322. }
  58323. /**
  58324. * Define the code related to the sub surface parameters of the pbr material.
  58325. */
  58326. export class PBRSubSurfaceConfiguration {
  58327. private _isRefractionEnabled;
  58328. /**
  58329. * Defines if the refraction is enabled in the material.
  58330. */
  58331. isRefractionEnabled: boolean;
  58332. private _isTranslucencyEnabled;
  58333. /**
  58334. * Defines if the translucency is enabled in the material.
  58335. */
  58336. isTranslucencyEnabled: boolean;
  58337. private _isScatteringEnabled;
  58338. /**
  58339. * Defines if the sub surface scattering is enabled in the material.
  58340. */
  58341. isScatteringEnabled: boolean;
  58342. private _scatteringDiffusionProfileIndex;
  58343. /**
  58344. * Diffusion profile for subsurface scattering.
  58345. * Useful for better scattering in the skins or foliages.
  58346. */
  58347. get scatteringDiffusionProfile(): Nullable<Color3>;
  58348. set scatteringDiffusionProfile(c: Nullable<Color3>);
  58349. /**
  58350. * Defines the refraction intensity of the material.
  58351. * The refraction when enabled replaces the Diffuse part of the material.
  58352. * The intensity helps transitionning between diffuse and refraction.
  58353. */
  58354. refractionIntensity: number;
  58355. /**
  58356. * Defines the translucency intensity of the material.
  58357. * When translucency has been enabled, this defines how much of the "translucency"
  58358. * is addded to the diffuse part of the material.
  58359. */
  58360. translucencyIntensity: number;
  58361. /**
  58362. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  58363. */
  58364. useAlbedoToTintRefraction: boolean;
  58365. private _thicknessTexture;
  58366. /**
  58367. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  58368. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  58369. * 0 would mean minimumThickness
  58370. * 1 would mean maximumThickness
  58371. * The other channels might be use as a mask to vary the different effects intensity.
  58372. */
  58373. thicknessTexture: Nullable<BaseTexture>;
  58374. private _refractionTexture;
  58375. /**
  58376. * Defines the texture to use for refraction.
  58377. */
  58378. refractionTexture: Nullable<BaseTexture>;
  58379. private _indexOfRefraction;
  58380. /**
  58381. * Index of refraction of the material base layer.
  58382. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58383. *
  58384. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58385. *
  58386. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58387. */
  58388. indexOfRefraction: number;
  58389. private _volumeIndexOfRefraction;
  58390. /**
  58391. * Index of refraction of the material's volume.
  58392. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58393. *
  58394. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58395. * the volume will use the same IOR as the surface.
  58396. */
  58397. get volumeIndexOfRefraction(): number;
  58398. set volumeIndexOfRefraction(value: number);
  58399. private _invertRefractionY;
  58400. /**
  58401. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58402. */
  58403. invertRefractionY: boolean;
  58404. private _linkRefractionWithTransparency;
  58405. /**
  58406. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58407. * Materials half opaque for instance using refraction could benefit from this control.
  58408. */
  58409. linkRefractionWithTransparency: boolean;
  58410. /**
  58411. * Defines the minimum thickness stored in the thickness map.
  58412. * If no thickness map is defined, this value will be used to simulate thickness.
  58413. */
  58414. minimumThickness: number;
  58415. /**
  58416. * Defines the maximum thickness stored in the thickness map.
  58417. */
  58418. maximumThickness: number;
  58419. /**
  58420. * Defines the volume tint of the material.
  58421. * This is used for both translucency and scattering.
  58422. */
  58423. tintColor: Color3;
  58424. /**
  58425. * Defines the distance at which the tint color should be found in the media.
  58426. * This is used for refraction only.
  58427. */
  58428. tintColorAtDistance: number;
  58429. /**
  58430. * Defines how far each channel transmit through the media.
  58431. * It is defined as a color to simplify it selection.
  58432. */
  58433. diffusionDistance: Color3;
  58434. private _useMaskFromThicknessTexture;
  58435. /**
  58436. * Stores the intensity of the different subsurface effects in the thickness texture.
  58437. * * the green channel is the translucency intensity.
  58438. * * the blue channel is the scattering intensity.
  58439. * * the alpha channel is the refraction intensity.
  58440. */
  58441. useMaskFromThicknessTexture: boolean;
  58442. private _scene;
  58443. /** @hidden */
  58444. private _internalMarkAllSubMeshesAsTexturesDirty;
  58445. private _internalMarkScenePrePassDirty;
  58446. /** @hidden */
  58447. _markAllSubMeshesAsTexturesDirty(): void;
  58448. /** @hidden */
  58449. _markScenePrePassDirty(): void;
  58450. /**
  58451. * Instantiate a new istance of sub surface configuration.
  58452. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58453. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58454. * @param scene The scene
  58455. */
  58456. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58457. /**
  58458. * Gets wehter the submesh is ready to be used or not.
  58459. * @param defines the list of "defines" to update.
  58460. * @param scene defines the scene the material belongs to.
  58461. * @returns - boolean indicating that the submesh is ready or not.
  58462. */
  58463. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58464. /**
  58465. * Checks to see if a texture is used in the material.
  58466. * @param defines the list of "defines" to update.
  58467. * @param scene defines the scene to the material belongs to.
  58468. */
  58469. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58470. /**
  58471. * Binds the material data.
  58472. * @param uniformBuffer defines the Uniform buffer to fill in.
  58473. * @param scene defines the scene the material belongs to.
  58474. * @param engine defines the engine the material belongs to.
  58475. * @param isFrozen defines whether the material is frozen or not.
  58476. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58477. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58478. */
  58479. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58480. /**
  58481. * Unbinds the material from the mesh.
  58482. * @param activeEffect defines the effect that should be unbound from.
  58483. * @returns true if unbound, otherwise false
  58484. */
  58485. unbind(activeEffect: Effect): boolean;
  58486. /**
  58487. * Returns the texture used for refraction or null if none is used.
  58488. * @param scene defines the scene the material belongs to.
  58489. * @returns - Refraction texture if present. If no refraction texture and refraction
  58490. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58491. */
  58492. private _getRefractionTexture;
  58493. /**
  58494. * Returns true if alpha blending should be disabled.
  58495. */
  58496. get disableAlphaBlending(): boolean;
  58497. /**
  58498. * Fills the list of render target textures.
  58499. * @param renderTargets the list of render targets to update
  58500. */
  58501. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58502. /**
  58503. * Checks to see if a texture is used in the material.
  58504. * @param texture - Base texture to use.
  58505. * @returns - Boolean specifying if a texture is used in the material.
  58506. */
  58507. hasTexture(texture: BaseTexture): boolean;
  58508. /**
  58509. * Gets a boolean indicating that current material needs to register RTT
  58510. * @returns true if this uses a render target otherwise false.
  58511. */
  58512. hasRenderTargetTextures(): boolean;
  58513. /**
  58514. * Returns an array of the actively used textures.
  58515. * @param activeTextures Array of BaseTextures
  58516. */
  58517. getActiveTextures(activeTextures: BaseTexture[]): void;
  58518. /**
  58519. * Returns the animatable textures.
  58520. * @param animatables Array of animatable textures.
  58521. */
  58522. getAnimatables(animatables: IAnimatable[]): void;
  58523. /**
  58524. * Disposes the resources of the material.
  58525. * @param forceDisposeTextures - Forces the disposal of all textures.
  58526. */
  58527. dispose(forceDisposeTextures?: boolean): void;
  58528. /**
  58529. * Get the current class name of the texture useful for serialization or dynamic coding.
  58530. * @returns "PBRSubSurfaceConfiguration"
  58531. */
  58532. getClassName(): string;
  58533. /**
  58534. * Add fallbacks to the effect fallbacks list.
  58535. * @param defines defines the Base texture to use.
  58536. * @param fallbacks defines the current fallback list.
  58537. * @param currentRank defines the current fallback rank.
  58538. * @returns the new fallback rank.
  58539. */
  58540. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58541. /**
  58542. * Add the required uniforms to the current list.
  58543. * @param uniforms defines the current uniform list.
  58544. */
  58545. static AddUniforms(uniforms: string[]): void;
  58546. /**
  58547. * Add the required samplers to the current list.
  58548. * @param samplers defines the current sampler list.
  58549. */
  58550. static AddSamplers(samplers: string[]): void;
  58551. /**
  58552. * Add the required uniforms to the current buffer.
  58553. * @param uniformBuffer defines the current uniform buffer.
  58554. */
  58555. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58556. /**
  58557. * Makes a duplicate of the current configuration into another one.
  58558. * @param configuration define the config where to copy the info
  58559. */
  58560. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58561. /**
  58562. * Serializes this Sub Surface configuration.
  58563. * @returns - An object with the serialized config.
  58564. */
  58565. serialize(): any;
  58566. /**
  58567. * Parses a anisotropy Configuration from a serialized object.
  58568. * @param source - Serialized object.
  58569. * @param scene Defines the scene we are parsing for
  58570. * @param rootUrl Defines the rootUrl to load from
  58571. */
  58572. parse(source: any, scene: Scene, rootUrl: string): void;
  58573. }
  58574. }
  58575. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58576. /** @hidden */
  58577. export var pbrFragmentDeclaration: {
  58578. name: string;
  58579. shader: string;
  58580. };
  58581. }
  58582. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58583. /** @hidden */
  58584. export var pbrUboDeclaration: {
  58585. name: string;
  58586. shader: string;
  58587. };
  58588. }
  58589. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58590. /** @hidden */
  58591. export var pbrFragmentExtraDeclaration: {
  58592. name: string;
  58593. shader: string;
  58594. };
  58595. }
  58596. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58597. /** @hidden */
  58598. export var pbrFragmentSamplersDeclaration: {
  58599. name: string;
  58600. shader: string;
  58601. };
  58602. }
  58603. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58604. /** @hidden */
  58605. export var importanceSampling: {
  58606. name: string;
  58607. shader: string;
  58608. };
  58609. }
  58610. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58611. /** @hidden */
  58612. export var pbrHelperFunctions: {
  58613. name: string;
  58614. shader: string;
  58615. };
  58616. }
  58617. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58618. /** @hidden */
  58619. export var harmonicsFunctions: {
  58620. name: string;
  58621. shader: string;
  58622. };
  58623. }
  58624. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58625. /** @hidden */
  58626. export var pbrDirectLightingSetupFunctions: {
  58627. name: string;
  58628. shader: string;
  58629. };
  58630. }
  58631. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58632. /** @hidden */
  58633. export var pbrDirectLightingFalloffFunctions: {
  58634. name: string;
  58635. shader: string;
  58636. };
  58637. }
  58638. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58639. /** @hidden */
  58640. export var pbrBRDFFunctions: {
  58641. name: string;
  58642. shader: string;
  58643. };
  58644. }
  58645. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58646. /** @hidden */
  58647. export var hdrFilteringFunctions: {
  58648. name: string;
  58649. shader: string;
  58650. };
  58651. }
  58652. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58653. /** @hidden */
  58654. export var pbrDirectLightingFunctions: {
  58655. name: string;
  58656. shader: string;
  58657. };
  58658. }
  58659. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58660. /** @hidden */
  58661. export var pbrIBLFunctions: {
  58662. name: string;
  58663. shader: string;
  58664. };
  58665. }
  58666. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58667. /** @hidden */
  58668. export var pbrBlockAlbedoOpacity: {
  58669. name: string;
  58670. shader: string;
  58671. };
  58672. }
  58673. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58674. /** @hidden */
  58675. export var pbrBlockReflectivity: {
  58676. name: string;
  58677. shader: string;
  58678. };
  58679. }
  58680. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58681. /** @hidden */
  58682. export var pbrBlockAmbientOcclusion: {
  58683. name: string;
  58684. shader: string;
  58685. };
  58686. }
  58687. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58688. /** @hidden */
  58689. export var pbrBlockAlphaFresnel: {
  58690. name: string;
  58691. shader: string;
  58692. };
  58693. }
  58694. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58695. /** @hidden */
  58696. export var pbrBlockAnisotropic: {
  58697. name: string;
  58698. shader: string;
  58699. };
  58700. }
  58701. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58702. /** @hidden */
  58703. export var pbrBlockReflection: {
  58704. name: string;
  58705. shader: string;
  58706. };
  58707. }
  58708. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58709. /** @hidden */
  58710. export var pbrBlockSheen: {
  58711. name: string;
  58712. shader: string;
  58713. };
  58714. }
  58715. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58716. /** @hidden */
  58717. export var pbrBlockClearcoat: {
  58718. name: string;
  58719. shader: string;
  58720. };
  58721. }
  58722. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58723. /** @hidden */
  58724. export var pbrBlockSubSurface: {
  58725. name: string;
  58726. shader: string;
  58727. };
  58728. }
  58729. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58730. /** @hidden */
  58731. export var pbrBlockNormalGeometric: {
  58732. name: string;
  58733. shader: string;
  58734. };
  58735. }
  58736. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58737. /** @hidden */
  58738. export var pbrBlockNormalFinal: {
  58739. name: string;
  58740. shader: string;
  58741. };
  58742. }
  58743. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58744. /** @hidden */
  58745. export var pbrBlockLightmapInit: {
  58746. name: string;
  58747. shader: string;
  58748. };
  58749. }
  58750. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58751. /** @hidden */
  58752. export var pbrBlockGeometryInfo: {
  58753. name: string;
  58754. shader: string;
  58755. };
  58756. }
  58757. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58758. /** @hidden */
  58759. export var pbrBlockReflectance0: {
  58760. name: string;
  58761. shader: string;
  58762. };
  58763. }
  58764. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58765. /** @hidden */
  58766. export var pbrBlockReflectance: {
  58767. name: string;
  58768. shader: string;
  58769. };
  58770. }
  58771. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58772. /** @hidden */
  58773. export var pbrBlockDirectLighting: {
  58774. name: string;
  58775. shader: string;
  58776. };
  58777. }
  58778. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58779. /** @hidden */
  58780. export var pbrBlockFinalLitComponents: {
  58781. name: string;
  58782. shader: string;
  58783. };
  58784. }
  58785. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58786. /** @hidden */
  58787. export var pbrBlockFinalUnlitComponents: {
  58788. name: string;
  58789. shader: string;
  58790. };
  58791. }
  58792. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58793. /** @hidden */
  58794. export var pbrBlockFinalColorComposition: {
  58795. name: string;
  58796. shader: string;
  58797. };
  58798. }
  58799. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58800. /** @hidden */
  58801. export var pbrBlockImageProcessing: {
  58802. name: string;
  58803. shader: string;
  58804. };
  58805. }
  58806. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58807. /** @hidden */
  58808. export var pbrDebug: {
  58809. name: string;
  58810. shader: string;
  58811. };
  58812. }
  58813. declare module "babylonjs/Shaders/pbr.fragment" {
  58814. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58815. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58816. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58817. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58818. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58819. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58820. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58821. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58822. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58823. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58824. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58825. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58826. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58827. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58828. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58829. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58830. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58831. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58832. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58833. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58834. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58835. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58836. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58837. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58838. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58839. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58840. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58841. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58842. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58843. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58844. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58845. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58846. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58847. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58848. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58849. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58850. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58851. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58852. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58853. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58854. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58855. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58856. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58857. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58858. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58859. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58860. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58861. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58862. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58863. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58864. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58865. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58866. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58867. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58868. /** @hidden */
  58869. export var pbrPixelShader: {
  58870. name: string;
  58871. shader: string;
  58872. };
  58873. }
  58874. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58875. /** @hidden */
  58876. export var pbrVertexDeclaration: {
  58877. name: string;
  58878. shader: string;
  58879. };
  58880. }
  58881. declare module "babylonjs/Shaders/pbr.vertex" {
  58882. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58883. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58884. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58885. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58886. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58887. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58888. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  58889. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  58890. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  58891. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58892. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58893. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58894. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58895. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58896. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58897. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58898. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58899. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  58900. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58901. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  58902. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58903. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  58904. /** @hidden */
  58905. export var pbrVertexShader: {
  58906. name: string;
  58907. shader: string;
  58908. };
  58909. }
  58910. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  58911. import { Nullable } from "babylonjs/types";
  58912. import { Scene } from "babylonjs/scene";
  58913. import { Matrix } from "babylonjs/Maths/math.vector";
  58914. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58916. import { Mesh } from "babylonjs/Meshes/mesh";
  58917. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  58918. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  58919. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  58920. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  58921. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  58922. import { Color3 } from "babylonjs/Maths/math.color";
  58923. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58924. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  58925. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58926. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  58927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58928. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58929. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58930. import "babylonjs/Shaders/pbr.fragment";
  58931. import "babylonjs/Shaders/pbr.vertex";
  58932. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  58933. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  58934. /**
  58935. * Manages the defines for the PBR Material.
  58936. * @hidden
  58937. */
  58938. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  58939. PBR: boolean;
  58940. NUM_SAMPLES: string;
  58941. REALTIME_FILTERING: boolean;
  58942. MAINUV1: boolean;
  58943. MAINUV2: boolean;
  58944. UV1: boolean;
  58945. UV2: boolean;
  58946. ALBEDO: boolean;
  58947. GAMMAALBEDO: boolean;
  58948. ALBEDODIRECTUV: number;
  58949. VERTEXCOLOR: boolean;
  58950. DETAIL: boolean;
  58951. DETAILDIRECTUV: number;
  58952. DETAIL_NORMALBLENDMETHOD: number;
  58953. AMBIENT: boolean;
  58954. AMBIENTDIRECTUV: number;
  58955. AMBIENTINGRAYSCALE: boolean;
  58956. OPACITY: boolean;
  58957. VERTEXALPHA: boolean;
  58958. OPACITYDIRECTUV: number;
  58959. OPACITYRGB: boolean;
  58960. ALPHATEST: boolean;
  58961. DEPTHPREPASS: boolean;
  58962. ALPHABLEND: boolean;
  58963. ALPHAFROMALBEDO: boolean;
  58964. ALPHATESTVALUE: string;
  58965. SPECULAROVERALPHA: boolean;
  58966. RADIANCEOVERALPHA: boolean;
  58967. ALPHAFRESNEL: boolean;
  58968. LINEARALPHAFRESNEL: boolean;
  58969. PREMULTIPLYALPHA: boolean;
  58970. EMISSIVE: boolean;
  58971. EMISSIVEDIRECTUV: number;
  58972. REFLECTIVITY: boolean;
  58973. REFLECTIVITYDIRECTUV: number;
  58974. SPECULARTERM: boolean;
  58975. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  58976. MICROSURFACEAUTOMATIC: boolean;
  58977. LODBASEDMICROSFURACE: boolean;
  58978. MICROSURFACEMAP: boolean;
  58979. MICROSURFACEMAPDIRECTUV: number;
  58980. METALLICWORKFLOW: boolean;
  58981. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  58982. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  58983. METALLNESSSTOREINMETALMAPBLUE: boolean;
  58984. AOSTOREINMETALMAPRED: boolean;
  58985. METALLIC_REFLECTANCE: boolean;
  58986. METALLIC_REFLECTANCEDIRECTUV: number;
  58987. ENVIRONMENTBRDF: boolean;
  58988. ENVIRONMENTBRDF_RGBD: boolean;
  58989. NORMAL: boolean;
  58990. TANGENT: boolean;
  58991. BUMP: boolean;
  58992. BUMPDIRECTUV: number;
  58993. OBJECTSPACE_NORMALMAP: boolean;
  58994. PARALLAX: boolean;
  58995. PARALLAXOCCLUSION: boolean;
  58996. NORMALXYSCALE: boolean;
  58997. LIGHTMAP: boolean;
  58998. LIGHTMAPDIRECTUV: number;
  58999. USELIGHTMAPASSHADOWMAP: boolean;
  59000. GAMMALIGHTMAP: boolean;
  59001. RGBDLIGHTMAP: boolean;
  59002. REFLECTION: boolean;
  59003. REFLECTIONMAP_3D: boolean;
  59004. REFLECTIONMAP_SPHERICAL: boolean;
  59005. REFLECTIONMAP_PLANAR: boolean;
  59006. REFLECTIONMAP_CUBIC: boolean;
  59007. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  59008. REFLECTIONMAP_PROJECTION: boolean;
  59009. REFLECTIONMAP_SKYBOX: boolean;
  59010. REFLECTIONMAP_EXPLICIT: boolean;
  59011. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  59012. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  59013. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  59014. INVERTCUBICMAP: boolean;
  59015. USESPHERICALFROMREFLECTIONMAP: boolean;
  59016. USEIRRADIANCEMAP: boolean;
  59017. SPHERICAL_HARMONICS: boolean;
  59018. USESPHERICALINVERTEX: boolean;
  59019. REFLECTIONMAP_OPPOSITEZ: boolean;
  59020. LODINREFLECTIONALPHA: boolean;
  59021. GAMMAREFLECTION: boolean;
  59022. RGBDREFLECTION: boolean;
  59023. LINEARSPECULARREFLECTION: boolean;
  59024. RADIANCEOCCLUSION: boolean;
  59025. HORIZONOCCLUSION: boolean;
  59026. INSTANCES: boolean;
  59027. THIN_INSTANCES: boolean;
  59028. PREPASS: boolean;
  59029. SCENE_MRT_COUNT: number;
  59030. NUM_BONE_INFLUENCERS: number;
  59031. BonesPerMesh: number;
  59032. BONETEXTURE: boolean;
  59033. NONUNIFORMSCALING: boolean;
  59034. MORPHTARGETS: boolean;
  59035. MORPHTARGETS_NORMAL: boolean;
  59036. MORPHTARGETS_TANGENT: boolean;
  59037. MORPHTARGETS_UV: boolean;
  59038. NUM_MORPH_INFLUENCERS: number;
  59039. IMAGEPROCESSING: boolean;
  59040. VIGNETTE: boolean;
  59041. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59042. VIGNETTEBLENDMODEOPAQUE: boolean;
  59043. TONEMAPPING: boolean;
  59044. TONEMAPPING_ACES: boolean;
  59045. CONTRAST: boolean;
  59046. COLORCURVES: boolean;
  59047. COLORGRADING: boolean;
  59048. COLORGRADING3D: boolean;
  59049. SAMPLER3DGREENDEPTH: boolean;
  59050. SAMPLER3DBGRMAP: boolean;
  59051. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59052. EXPOSURE: boolean;
  59053. MULTIVIEW: boolean;
  59054. USEPHYSICALLIGHTFALLOFF: boolean;
  59055. USEGLTFLIGHTFALLOFF: boolean;
  59056. TWOSIDEDLIGHTING: boolean;
  59057. SHADOWFLOAT: boolean;
  59058. CLIPPLANE: boolean;
  59059. CLIPPLANE2: boolean;
  59060. CLIPPLANE3: boolean;
  59061. CLIPPLANE4: boolean;
  59062. CLIPPLANE5: boolean;
  59063. CLIPPLANE6: boolean;
  59064. POINTSIZE: boolean;
  59065. FOG: boolean;
  59066. LOGARITHMICDEPTH: boolean;
  59067. FORCENORMALFORWARD: boolean;
  59068. SPECULARAA: boolean;
  59069. CLEARCOAT: boolean;
  59070. CLEARCOAT_DEFAULTIOR: boolean;
  59071. CLEARCOAT_TEXTURE: boolean;
  59072. CLEARCOAT_TEXTUREDIRECTUV: number;
  59073. CLEARCOAT_BUMP: boolean;
  59074. CLEARCOAT_BUMPDIRECTUV: number;
  59075. CLEARCOAT_TINT: boolean;
  59076. CLEARCOAT_TINT_TEXTURE: boolean;
  59077. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  59078. ANISOTROPIC: boolean;
  59079. ANISOTROPIC_TEXTURE: boolean;
  59080. ANISOTROPIC_TEXTUREDIRECTUV: number;
  59081. BRDF_V_HEIGHT_CORRELATED: boolean;
  59082. MS_BRDF_ENERGY_CONSERVATION: boolean;
  59083. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  59084. SHEEN: boolean;
  59085. SHEEN_TEXTURE: boolean;
  59086. SHEEN_TEXTUREDIRECTUV: number;
  59087. SHEEN_LINKWITHALBEDO: boolean;
  59088. SHEEN_ROUGHNESS: boolean;
  59089. SHEEN_ALBEDOSCALING: boolean;
  59090. SUBSURFACE: boolean;
  59091. SS_REFRACTION: boolean;
  59092. SS_TRANSLUCENCY: boolean;
  59093. SS_SCATTERING: boolean;
  59094. SS_THICKNESSANDMASK_TEXTURE: boolean;
  59095. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  59096. SS_REFRACTIONMAP_3D: boolean;
  59097. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  59098. SS_LODINREFRACTIONALPHA: boolean;
  59099. SS_GAMMAREFRACTION: boolean;
  59100. SS_RGBDREFRACTION: boolean;
  59101. SS_LINEARSPECULARREFRACTION: boolean;
  59102. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  59103. SS_ALBEDOFORREFRACTIONTINT: boolean;
  59104. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  59105. UNLIT: boolean;
  59106. DEBUGMODE: number;
  59107. /**
  59108. * Initializes the PBR Material defines.
  59109. */
  59110. constructor();
  59111. /**
  59112. * Resets the PBR Material defines.
  59113. */
  59114. reset(): void;
  59115. }
  59116. /**
  59117. * The Physically based material base class of BJS.
  59118. *
  59119. * This offers the main features of a standard PBR material.
  59120. * For more information, please refer to the documentation :
  59121. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59122. */
  59123. export abstract class PBRBaseMaterial extends PushMaterial {
  59124. /**
  59125. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59126. */
  59127. static readonly PBRMATERIAL_OPAQUE: number;
  59128. /**
  59129. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59130. */
  59131. static readonly PBRMATERIAL_ALPHATEST: number;
  59132. /**
  59133. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59134. */
  59135. static readonly PBRMATERIAL_ALPHABLEND: number;
  59136. /**
  59137. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59138. * They are also discarded below the alpha cutoff threshold to improve performances.
  59139. */
  59140. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59141. /**
  59142. * Defines the default value of how much AO map is occluding the analytical lights
  59143. * (point spot...).
  59144. */
  59145. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59146. /**
  59147. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  59148. */
  59149. static readonly LIGHTFALLOFF_PHYSICAL: number;
  59150. /**
  59151. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  59152. * to enhance interoperability with other engines.
  59153. */
  59154. static readonly LIGHTFALLOFF_GLTF: number;
  59155. /**
  59156. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  59157. * to enhance interoperability with other materials.
  59158. */
  59159. static readonly LIGHTFALLOFF_STANDARD: number;
  59160. /**
  59161. * Intensity of the direct lights e.g. the four lights available in your scene.
  59162. * This impacts both the direct diffuse and specular highlights.
  59163. */
  59164. protected _directIntensity: number;
  59165. /**
  59166. * Intensity of the emissive part of the material.
  59167. * This helps controlling the emissive effect without modifying the emissive color.
  59168. */
  59169. protected _emissiveIntensity: number;
  59170. /**
  59171. * Intensity of the environment e.g. how much the environment will light the object
  59172. * either through harmonics for rough material or through the refelction for shiny ones.
  59173. */
  59174. protected _environmentIntensity: number;
  59175. /**
  59176. * This is a special control allowing the reduction of the specular highlights coming from the
  59177. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59178. */
  59179. protected _specularIntensity: number;
  59180. /**
  59181. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  59182. */
  59183. private _lightingInfos;
  59184. /**
  59185. * Debug Control allowing disabling the bump map on this material.
  59186. */
  59187. protected _disableBumpMap: boolean;
  59188. /**
  59189. * AKA Diffuse Texture in standard nomenclature.
  59190. */
  59191. protected _albedoTexture: Nullable<BaseTexture>;
  59192. /**
  59193. * AKA Occlusion Texture in other nomenclature.
  59194. */
  59195. protected _ambientTexture: Nullable<BaseTexture>;
  59196. /**
  59197. * AKA Occlusion Texture Intensity in other nomenclature.
  59198. */
  59199. protected _ambientTextureStrength: number;
  59200. /**
  59201. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59202. * 1 means it completely occludes it
  59203. * 0 mean it has no impact
  59204. */
  59205. protected _ambientTextureImpactOnAnalyticalLights: number;
  59206. /**
  59207. * Stores the alpha values in a texture.
  59208. */
  59209. protected _opacityTexture: Nullable<BaseTexture>;
  59210. /**
  59211. * Stores the reflection values in a texture.
  59212. */
  59213. protected _reflectionTexture: Nullable<BaseTexture>;
  59214. /**
  59215. * Stores the emissive values in a texture.
  59216. */
  59217. protected _emissiveTexture: Nullable<BaseTexture>;
  59218. /**
  59219. * AKA Specular texture in other nomenclature.
  59220. */
  59221. protected _reflectivityTexture: Nullable<BaseTexture>;
  59222. /**
  59223. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59224. */
  59225. protected _metallicTexture: Nullable<BaseTexture>;
  59226. /**
  59227. * Specifies the metallic scalar of the metallic/roughness workflow.
  59228. * Can also be used to scale the metalness values of the metallic texture.
  59229. */
  59230. protected _metallic: Nullable<number>;
  59231. /**
  59232. * Specifies the roughness scalar of the metallic/roughness workflow.
  59233. * Can also be used to scale the roughness values of the metallic texture.
  59234. */
  59235. protected _roughness: Nullable<number>;
  59236. /**
  59237. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59238. * By default the indexOfrefraction is used to compute F0;
  59239. *
  59240. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59241. *
  59242. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59243. * F90 = metallicReflectanceColor;
  59244. */
  59245. protected _metallicF0Factor: number;
  59246. /**
  59247. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59248. * By default the F90 is always 1;
  59249. *
  59250. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59251. *
  59252. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59253. * F90 = metallicReflectanceColor;
  59254. */
  59255. protected _metallicReflectanceColor: Color3;
  59256. /**
  59257. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59258. * This is multiply against the scalar values defined in the material.
  59259. */
  59260. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  59261. /**
  59262. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59263. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59264. */
  59265. protected _microSurfaceTexture: Nullable<BaseTexture>;
  59266. /**
  59267. * Stores surface normal data used to displace a mesh in a texture.
  59268. */
  59269. protected _bumpTexture: Nullable<BaseTexture>;
  59270. /**
  59271. * Stores the pre-calculated light information of a mesh in a texture.
  59272. */
  59273. protected _lightmapTexture: Nullable<BaseTexture>;
  59274. /**
  59275. * The color of a material in ambient lighting.
  59276. */
  59277. protected _ambientColor: Color3;
  59278. /**
  59279. * AKA Diffuse Color in other nomenclature.
  59280. */
  59281. protected _albedoColor: Color3;
  59282. /**
  59283. * AKA Specular Color in other nomenclature.
  59284. */
  59285. protected _reflectivityColor: Color3;
  59286. /**
  59287. * The color applied when light is reflected from a material.
  59288. */
  59289. protected _reflectionColor: Color3;
  59290. /**
  59291. * The color applied when light is emitted from a material.
  59292. */
  59293. protected _emissiveColor: Color3;
  59294. /**
  59295. * AKA Glossiness in other nomenclature.
  59296. */
  59297. protected _microSurface: number;
  59298. /**
  59299. * Specifies that the material will use the light map as a show map.
  59300. */
  59301. protected _useLightmapAsShadowmap: boolean;
  59302. /**
  59303. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59304. * makes the reflect vector face the model (under horizon).
  59305. */
  59306. protected _useHorizonOcclusion: boolean;
  59307. /**
  59308. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59309. * too much the area relying on ambient texture to define their ambient occlusion.
  59310. */
  59311. protected _useRadianceOcclusion: boolean;
  59312. /**
  59313. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59314. */
  59315. protected _useAlphaFromAlbedoTexture: boolean;
  59316. /**
  59317. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  59318. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59319. */
  59320. protected _useSpecularOverAlpha: boolean;
  59321. /**
  59322. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59323. */
  59324. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59325. /**
  59326. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59327. */
  59328. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59329. /**
  59330. * Specifies if the metallic texture contains the roughness information in its green channel.
  59331. */
  59332. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59333. /**
  59334. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59335. */
  59336. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59337. /**
  59338. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59339. */
  59340. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59341. /**
  59342. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59343. */
  59344. protected _useAmbientInGrayScale: boolean;
  59345. /**
  59346. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59347. * The material will try to infer what glossiness each pixel should be.
  59348. */
  59349. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59350. /**
  59351. * Defines the falloff type used in this material.
  59352. * It by default is Physical.
  59353. */
  59354. protected _lightFalloff: number;
  59355. /**
  59356. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59357. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59358. */
  59359. protected _useRadianceOverAlpha: boolean;
  59360. /**
  59361. * Allows using an object space normal map (instead of tangent space).
  59362. */
  59363. protected _useObjectSpaceNormalMap: boolean;
  59364. /**
  59365. * Allows using the bump map in parallax mode.
  59366. */
  59367. protected _useParallax: boolean;
  59368. /**
  59369. * Allows using the bump map in parallax occlusion mode.
  59370. */
  59371. protected _useParallaxOcclusion: boolean;
  59372. /**
  59373. * Controls the scale bias of the parallax mode.
  59374. */
  59375. protected _parallaxScaleBias: number;
  59376. /**
  59377. * If sets to true, disables all the lights affecting the material.
  59378. */
  59379. protected _disableLighting: boolean;
  59380. /**
  59381. * Number of Simultaneous lights allowed on the material.
  59382. */
  59383. protected _maxSimultaneousLights: number;
  59384. /**
  59385. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59386. */
  59387. protected _invertNormalMapX: boolean;
  59388. /**
  59389. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59390. */
  59391. protected _invertNormalMapY: boolean;
  59392. /**
  59393. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59394. */
  59395. protected _twoSidedLighting: boolean;
  59396. /**
  59397. * Defines the alpha limits in alpha test mode.
  59398. */
  59399. protected _alphaCutOff: number;
  59400. /**
  59401. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59402. */
  59403. protected _forceAlphaTest: boolean;
  59404. /**
  59405. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59406. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59407. */
  59408. protected _useAlphaFresnel: boolean;
  59409. /**
  59410. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59411. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59412. */
  59413. protected _useLinearAlphaFresnel: boolean;
  59414. /**
  59415. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59416. * from cos thetav and roughness:
  59417. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59418. */
  59419. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59420. /**
  59421. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59422. */
  59423. protected _forceIrradianceInFragment: boolean;
  59424. private _realTimeFiltering;
  59425. /**
  59426. * Enables realtime filtering on the texture.
  59427. */
  59428. get realTimeFiltering(): boolean;
  59429. set realTimeFiltering(b: boolean);
  59430. private _realTimeFilteringQuality;
  59431. /**
  59432. * Quality switch for realtime filtering
  59433. */
  59434. get realTimeFilteringQuality(): number;
  59435. set realTimeFilteringQuality(n: number);
  59436. /**
  59437. * Can this material render to several textures at once
  59438. */
  59439. get canRenderToMRT(): boolean;
  59440. /**
  59441. * Force normal to face away from face.
  59442. */
  59443. protected _forceNormalForward: boolean;
  59444. /**
  59445. * Enables specular anti aliasing in the PBR shader.
  59446. * It will both interacts on the Geometry for analytical and IBL lighting.
  59447. * It also prefilter the roughness map based on the bump values.
  59448. */
  59449. protected _enableSpecularAntiAliasing: boolean;
  59450. /**
  59451. * Default configuration related to image processing available in the PBR Material.
  59452. */
  59453. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59454. /**
  59455. * Keep track of the image processing observer to allow dispose and replace.
  59456. */
  59457. private _imageProcessingObserver;
  59458. /**
  59459. * Attaches a new image processing configuration to the PBR Material.
  59460. * @param configuration
  59461. */
  59462. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59463. /**
  59464. * Stores the available render targets.
  59465. */
  59466. private _renderTargets;
  59467. /**
  59468. * Sets the global ambient color for the material used in lighting calculations.
  59469. */
  59470. private _globalAmbientColor;
  59471. /**
  59472. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59473. */
  59474. private _useLogarithmicDepth;
  59475. /**
  59476. * If set to true, no lighting calculations will be applied.
  59477. */
  59478. private _unlit;
  59479. private _debugMode;
  59480. /**
  59481. * @hidden
  59482. * This is reserved for the inspector.
  59483. * Defines the material debug mode.
  59484. * It helps seeing only some components of the material while troubleshooting.
  59485. */
  59486. debugMode: number;
  59487. /**
  59488. * @hidden
  59489. * This is reserved for the inspector.
  59490. * Specify from where on screen the debug mode should start.
  59491. * The value goes from -1 (full screen) to 1 (not visible)
  59492. * It helps with side by side comparison against the final render
  59493. * This defaults to -1
  59494. */
  59495. private debugLimit;
  59496. /**
  59497. * @hidden
  59498. * This is reserved for the inspector.
  59499. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59500. * You can use the factor to better multiply the final value.
  59501. */
  59502. private debugFactor;
  59503. /**
  59504. * Defines the clear coat layer parameters for the material.
  59505. */
  59506. readonly clearCoat: PBRClearCoatConfiguration;
  59507. /**
  59508. * Defines the anisotropic parameters for the material.
  59509. */
  59510. readonly anisotropy: PBRAnisotropicConfiguration;
  59511. /**
  59512. * Defines the BRDF parameters for the material.
  59513. */
  59514. readonly brdf: PBRBRDFConfiguration;
  59515. /**
  59516. * Defines the Sheen parameters for the material.
  59517. */
  59518. readonly sheen: PBRSheenConfiguration;
  59519. /**
  59520. * Defines the SubSurface parameters for the material.
  59521. */
  59522. readonly subSurface: PBRSubSurfaceConfiguration;
  59523. /**
  59524. * Defines the detail map parameters for the material.
  59525. */
  59526. readonly detailMap: DetailMapConfiguration;
  59527. protected _rebuildInParallel: boolean;
  59528. /**
  59529. * Instantiates a new PBRMaterial instance.
  59530. *
  59531. * @param name The material name
  59532. * @param scene The scene the material will be use in.
  59533. */
  59534. constructor(name: string, scene: Scene);
  59535. /**
  59536. * Gets a boolean indicating that current material needs to register RTT
  59537. */
  59538. get hasRenderTargetTextures(): boolean;
  59539. /**
  59540. * Gets the name of the material class.
  59541. */
  59542. getClassName(): string;
  59543. /**
  59544. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59545. */
  59546. get useLogarithmicDepth(): boolean;
  59547. /**
  59548. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59549. */
  59550. set useLogarithmicDepth(value: boolean);
  59551. /**
  59552. * Returns true if alpha blending should be disabled.
  59553. */
  59554. protected get _disableAlphaBlending(): boolean;
  59555. /**
  59556. * Specifies whether or not this material should be rendered in alpha blend mode.
  59557. */
  59558. needAlphaBlending(): boolean;
  59559. /**
  59560. * Specifies whether or not this material should be rendered in alpha test mode.
  59561. */
  59562. needAlphaTesting(): boolean;
  59563. /**
  59564. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59565. */
  59566. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59567. /**
  59568. * Gets the texture used for the alpha test.
  59569. */
  59570. getAlphaTestTexture(): Nullable<BaseTexture>;
  59571. /**
  59572. * Specifies that the submesh is ready to be used.
  59573. * @param mesh - BJS mesh.
  59574. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59575. * @param useInstances - Specifies that instances should be used.
  59576. * @returns - boolean indicating that the submesh is ready or not.
  59577. */
  59578. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59579. /**
  59580. * Specifies if the material uses metallic roughness workflow.
  59581. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59582. */
  59583. isMetallicWorkflow(): boolean;
  59584. private _prepareEffect;
  59585. private _prepareDefines;
  59586. /**
  59587. * Force shader compilation
  59588. */
  59589. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59590. /**
  59591. * Initializes the uniform buffer layout for the shader.
  59592. */
  59593. buildUniformLayout(): void;
  59594. /**
  59595. * Unbinds the material from the mesh
  59596. */
  59597. unbind(): void;
  59598. /**
  59599. * Binds the submesh data.
  59600. * @param world - The world matrix.
  59601. * @param mesh - The BJS mesh.
  59602. * @param subMesh - A submesh of the BJS mesh.
  59603. */
  59604. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59605. /**
  59606. * Returns the animatable textures.
  59607. * @returns - Array of animatable textures.
  59608. */
  59609. getAnimatables(): IAnimatable[];
  59610. /**
  59611. * Returns the texture used for reflections.
  59612. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59613. */
  59614. private _getReflectionTexture;
  59615. /**
  59616. * Returns an array of the actively used textures.
  59617. * @returns - Array of BaseTextures
  59618. */
  59619. getActiveTextures(): BaseTexture[];
  59620. /**
  59621. * Checks to see if a texture is used in the material.
  59622. * @param texture - Base texture to use.
  59623. * @returns - Boolean specifying if a texture is used in the material.
  59624. */
  59625. hasTexture(texture: BaseTexture): boolean;
  59626. /**
  59627. * Sets the required values to the prepass renderer.
  59628. * @param prePassRenderer defines the prepass renderer to setup
  59629. */
  59630. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59631. /**
  59632. * Disposes the resources of the material.
  59633. * @param forceDisposeEffect - Forces the disposal of effects.
  59634. * @param forceDisposeTextures - Forces the disposal of all textures.
  59635. */
  59636. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59637. }
  59638. }
  59639. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59640. import { Nullable } from "babylonjs/types";
  59641. import { Scene } from "babylonjs/scene";
  59642. import { Color3 } from "babylonjs/Maths/math.color";
  59643. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59644. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59645. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59646. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59647. /**
  59648. * The Physically based material of BJS.
  59649. *
  59650. * This offers the main features of a standard PBR material.
  59651. * For more information, please refer to the documentation :
  59652. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59653. */
  59654. export class PBRMaterial extends PBRBaseMaterial {
  59655. /**
  59656. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59657. */
  59658. static readonly PBRMATERIAL_OPAQUE: number;
  59659. /**
  59660. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59661. */
  59662. static readonly PBRMATERIAL_ALPHATEST: number;
  59663. /**
  59664. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59665. */
  59666. static readonly PBRMATERIAL_ALPHABLEND: number;
  59667. /**
  59668. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59669. * They are also discarded below the alpha cutoff threshold to improve performances.
  59670. */
  59671. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59672. /**
  59673. * Defines the default value of how much AO map is occluding the analytical lights
  59674. * (point spot...).
  59675. */
  59676. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59677. /**
  59678. * Intensity of the direct lights e.g. the four lights available in your scene.
  59679. * This impacts both the direct diffuse and specular highlights.
  59680. */
  59681. directIntensity: number;
  59682. /**
  59683. * Intensity of the emissive part of the material.
  59684. * This helps controlling the emissive effect without modifying the emissive color.
  59685. */
  59686. emissiveIntensity: number;
  59687. /**
  59688. * Intensity of the environment e.g. how much the environment will light the object
  59689. * either through harmonics for rough material or through the refelction for shiny ones.
  59690. */
  59691. environmentIntensity: number;
  59692. /**
  59693. * This is a special control allowing the reduction of the specular highlights coming from the
  59694. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59695. */
  59696. specularIntensity: number;
  59697. /**
  59698. * Debug Control allowing disabling the bump map on this material.
  59699. */
  59700. disableBumpMap: boolean;
  59701. /**
  59702. * AKA Diffuse Texture in standard nomenclature.
  59703. */
  59704. albedoTexture: BaseTexture;
  59705. /**
  59706. * AKA Occlusion Texture in other nomenclature.
  59707. */
  59708. ambientTexture: BaseTexture;
  59709. /**
  59710. * AKA Occlusion Texture Intensity in other nomenclature.
  59711. */
  59712. ambientTextureStrength: number;
  59713. /**
  59714. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59715. * 1 means it completely occludes it
  59716. * 0 mean it has no impact
  59717. */
  59718. ambientTextureImpactOnAnalyticalLights: number;
  59719. /**
  59720. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59721. */
  59722. opacityTexture: BaseTexture;
  59723. /**
  59724. * Stores the reflection values in a texture.
  59725. */
  59726. reflectionTexture: Nullable<BaseTexture>;
  59727. /**
  59728. * Stores the emissive values in a texture.
  59729. */
  59730. emissiveTexture: BaseTexture;
  59731. /**
  59732. * AKA Specular texture in other nomenclature.
  59733. */
  59734. reflectivityTexture: BaseTexture;
  59735. /**
  59736. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59737. */
  59738. metallicTexture: BaseTexture;
  59739. /**
  59740. * Specifies the metallic scalar of the metallic/roughness workflow.
  59741. * Can also be used to scale the metalness values of the metallic texture.
  59742. */
  59743. metallic: Nullable<number>;
  59744. /**
  59745. * Specifies the roughness scalar of the metallic/roughness workflow.
  59746. * Can also be used to scale the roughness values of the metallic texture.
  59747. */
  59748. roughness: Nullable<number>;
  59749. /**
  59750. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59751. * By default the indexOfrefraction is used to compute F0;
  59752. *
  59753. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59754. *
  59755. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59756. * F90 = metallicReflectanceColor;
  59757. */
  59758. metallicF0Factor: number;
  59759. /**
  59760. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59761. * By default the F90 is always 1;
  59762. *
  59763. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59764. *
  59765. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59766. * F90 = metallicReflectanceColor;
  59767. */
  59768. metallicReflectanceColor: Color3;
  59769. /**
  59770. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59771. * This is multiply against the scalar values defined in the material.
  59772. */
  59773. metallicReflectanceTexture: Nullable<BaseTexture>;
  59774. /**
  59775. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59776. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59777. */
  59778. microSurfaceTexture: BaseTexture;
  59779. /**
  59780. * Stores surface normal data used to displace a mesh in a texture.
  59781. */
  59782. bumpTexture: BaseTexture;
  59783. /**
  59784. * Stores the pre-calculated light information of a mesh in a texture.
  59785. */
  59786. lightmapTexture: BaseTexture;
  59787. /**
  59788. * Stores the refracted light information in a texture.
  59789. */
  59790. get refractionTexture(): Nullable<BaseTexture>;
  59791. set refractionTexture(value: Nullable<BaseTexture>);
  59792. /**
  59793. * The color of a material in ambient lighting.
  59794. */
  59795. ambientColor: Color3;
  59796. /**
  59797. * AKA Diffuse Color in other nomenclature.
  59798. */
  59799. albedoColor: Color3;
  59800. /**
  59801. * AKA Specular Color in other nomenclature.
  59802. */
  59803. reflectivityColor: Color3;
  59804. /**
  59805. * The color reflected from the material.
  59806. */
  59807. reflectionColor: Color3;
  59808. /**
  59809. * The color emitted from the material.
  59810. */
  59811. emissiveColor: Color3;
  59812. /**
  59813. * AKA Glossiness in other nomenclature.
  59814. */
  59815. microSurface: number;
  59816. /**
  59817. * Index of refraction of the material base layer.
  59818. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59819. *
  59820. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59821. *
  59822. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59823. */
  59824. get indexOfRefraction(): number;
  59825. set indexOfRefraction(value: number);
  59826. /**
  59827. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59828. */
  59829. get invertRefractionY(): boolean;
  59830. set invertRefractionY(value: boolean);
  59831. /**
  59832. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59833. * Materials half opaque for instance using refraction could benefit from this control.
  59834. */
  59835. get linkRefractionWithTransparency(): boolean;
  59836. set linkRefractionWithTransparency(value: boolean);
  59837. /**
  59838. * If true, the light map contains occlusion information instead of lighting info.
  59839. */
  59840. useLightmapAsShadowmap: boolean;
  59841. /**
  59842. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59843. */
  59844. useAlphaFromAlbedoTexture: boolean;
  59845. /**
  59846. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59847. */
  59848. forceAlphaTest: boolean;
  59849. /**
  59850. * Defines the alpha limits in alpha test mode.
  59851. */
  59852. alphaCutOff: number;
  59853. /**
  59854. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59855. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59856. */
  59857. useSpecularOverAlpha: boolean;
  59858. /**
  59859. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59860. */
  59861. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59862. /**
  59863. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59864. */
  59865. useRoughnessFromMetallicTextureAlpha: boolean;
  59866. /**
  59867. * Specifies if the metallic texture contains the roughness information in its green channel.
  59868. */
  59869. useRoughnessFromMetallicTextureGreen: boolean;
  59870. /**
  59871. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59872. */
  59873. useMetallnessFromMetallicTextureBlue: boolean;
  59874. /**
  59875. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59876. */
  59877. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59878. /**
  59879. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59880. */
  59881. useAmbientInGrayScale: boolean;
  59882. /**
  59883. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59884. * The material will try to infer what glossiness each pixel should be.
  59885. */
  59886. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59887. /**
  59888. * BJS is using an harcoded light falloff based on a manually sets up range.
  59889. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59890. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59891. */
  59892. get usePhysicalLightFalloff(): boolean;
  59893. /**
  59894. * BJS is using an harcoded light falloff based on a manually sets up range.
  59895. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59896. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59897. */
  59898. set usePhysicalLightFalloff(value: boolean);
  59899. /**
  59900. * In order to support the falloff compatibility with gltf, a special mode has been added
  59901. * to reproduce the gltf light falloff.
  59902. */
  59903. get useGLTFLightFalloff(): boolean;
  59904. /**
  59905. * In order to support the falloff compatibility with gltf, a special mode has been added
  59906. * to reproduce the gltf light falloff.
  59907. */
  59908. set useGLTFLightFalloff(value: boolean);
  59909. /**
  59910. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59911. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59912. */
  59913. useRadianceOverAlpha: boolean;
  59914. /**
  59915. * Allows using an object space normal map (instead of tangent space).
  59916. */
  59917. useObjectSpaceNormalMap: boolean;
  59918. /**
  59919. * Allows using the bump map in parallax mode.
  59920. */
  59921. useParallax: boolean;
  59922. /**
  59923. * Allows using the bump map in parallax occlusion mode.
  59924. */
  59925. useParallaxOcclusion: boolean;
  59926. /**
  59927. * Controls the scale bias of the parallax mode.
  59928. */
  59929. parallaxScaleBias: number;
  59930. /**
  59931. * If sets to true, disables all the lights affecting the material.
  59932. */
  59933. disableLighting: boolean;
  59934. /**
  59935. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59936. */
  59937. forceIrradianceInFragment: boolean;
  59938. /**
  59939. * Number of Simultaneous lights allowed on the material.
  59940. */
  59941. maxSimultaneousLights: number;
  59942. /**
  59943. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59944. */
  59945. invertNormalMapX: boolean;
  59946. /**
  59947. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59948. */
  59949. invertNormalMapY: boolean;
  59950. /**
  59951. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59952. */
  59953. twoSidedLighting: boolean;
  59954. /**
  59955. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59956. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59957. */
  59958. useAlphaFresnel: boolean;
  59959. /**
  59960. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59961. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59962. */
  59963. useLinearAlphaFresnel: boolean;
  59964. /**
  59965. * Let user defines the brdf lookup texture used for IBL.
  59966. * A default 8bit version is embedded but you could point at :
  59967. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  59968. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  59969. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  59970. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  59971. */
  59972. environmentBRDFTexture: Nullable<BaseTexture>;
  59973. /**
  59974. * Force normal to face away from face.
  59975. */
  59976. forceNormalForward: boolean;
  59977. /**
  59978. * Enables specular anti aliasing in the PBR shader.
  59979. * It will both interacts on the Geometry for analytical and IBL lighting.
  59980. * It also prefilter the roughness map based on the bump values.
  59981. */
  59982. enableSpecularAntiAliasing: boolean;
  59983. /**
  59984. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59985. * makes the reflect vector face the model (under horizon).
  59986. */
  59987. useHorizonOcclusion: boolean;
  59988. /**
  59989. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59990. * too much the area relying on ambient texture to define their ambient occlusion.
  59991. */
  59992. useRadianceOcclusion: boolean;
  59993. /**
  59994. * If set to true, no lighting calculations will be applied.
  59995. */
  59996. unlit: boolean;
  59997. /**
  59998. * Gets the image processing configuration used either in this material.
  59999. */
  60000. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60001. /**
  60002. * Sets the Default image processing configuration used either in the this material.
  60003. *
  60004. * If sets to null, the scene one is in use.
  60005. */
  60006. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60007. /**
  60008. * Gets wether the color curves effect is enabled.
  60009. */
  60010. get cameraColorCurvesEnabled(): boolean;
  60011. /**
  60012. * Sets wether the color curves effect is enabled.
  60013. */
  60014. set cameraColorCurvesEnabled(value: boolean);
  60015. /**
  60016. * Gets wether the color grading effect is enabled.
  60017. */
  60018. get cameraColorGradingEnabled(): boolean;
  60019. /**
  60020. * Gets wether the color grading effect is enabled.
  60021. */
  60022. set cameraColorGradingEnabled(value: boolean);
  60023. /**
  60024. * Gets wether tonemapping is enabled or not.
  60025. */
  60026. get cameraToneMappingEnabled(): boolean;
  60027. /**
  60028. * Sets wether tonemapping is enabled or not
  60029. */
  60030. set cameraToneMappingEnabled(value: boolean);
  60031. /**
  60032. * The camera exposure used on this material.
  60033. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60034. * This corresponds to a photographic exposure.
  60035. */
  60036. get cameraExposure(): number;
  60037. /**
  60038. * The camera exposure used on this material.
  60039. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60040. * This corresponds to a photographic exposure.
  60041. */
  60042. set cameraExposure(value: number);
  60043. /**
  60044. * Gets The camera contrast used on this material.
  60045. */
  60046. get cameraContrast(): number;
  60047. /**
  60048. * Sets The camera contrast used on this material.
  60049. */
  60050. set cameraContrast(value: number);
  60051. /**
  60052. * Gets the Color Grading 2D Lookup Texture.
  60053. */
  60054. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60055. /**
  60056. * Sets the Color Grading 2D Lookup Texture.
  60057. */
  60058. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60059. /**
  60060. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60061. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60062. * 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;
  60063. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60064. */
  60065. get cameraColorCurves(): Nullable<ColorCurves>;
  60066. /**
  60067. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60068. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60069. * 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;
  60070. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60071. */
  60072. set cameraColorCurves(value: Nullable<ColorCurves>);
  60073. /**
  60074. * Instantiates a new PBRMaterial instance.
  60075. *
  60076. * @param name The material name
  60077. * @param scene The scene the material will be use in.
  60078. */
  60079. constructor(name: string, scene: Scene);
  60080. /**
  60081. * Returns the name of this material class.
  60082. */
  60083. getClassName(): string;
  60084. /**
  60085. * Makes a duplicate of the current material.
  60086. * @param name - name to use for the new material.
  60087. */
  60088. clone(name: string): PBRMaterial;
  60089. /**
  60090. * Serializes this PBR Material.
  60091. * @returns - An object with the serialized material.
  60092. */
  60093. serialize(): any;
  60094. /**
  60095. * Parses a PBR Material from a serialized object.
  60096. * @param source - Serialized object.
  60097. * @param scene - BJS scene instance.
  60098. * @param rootUrl - url for the scene object
  60099. * @returns - PBRMaterial
  60100. */
  60101. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  60102. }
  60103. }
  60104. declare module "babylonjs/Misc/dds" {
  60105. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60106. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60107. import { Nullable } from "babylonjs/types";
  60108. import { Scene } from "babylonjs/scene";
  60109. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60110. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60111. /**
  60112. * Direct draw surface info
  60113. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60114. */
  60115. export interface DDSInfo {
  60116. /**
  60117. * Width of the texture
  60118. */
  60119. width: number;
  60120. /**
  60121. * Width of the texture
  60122. */
  60123. height: number;
  60124. /**
  60125. * Number of Mipmaps for the texture
  60126. * @see https://en.wikipedia.org/wiki/Mipmap
  60127. */
  60128. mipmapCount: number;
  60129. /**
  60130. * If the textures format is a known fourCC format
  60131. * @see https://www.fourcc.org/
  60132. */
  60133. isFourCC: boolean;
  60134. /**
  60135. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60136. */
  60137. isRGB: boolean;
  60138. /**
  60139. * If the texture is a lumincance format
  60140. */
  60141. isLuminance: boolean;
  60142. /**
  60143. * If this is a cube texture
  60144. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60145. */
  60146. isCube: boolean;
  60147. /**
  60148. * If the texture is a compressed format eg. FOURCC_DXT1
  60149. */
  60150. isCompressed: boolean;
  60151. /**
  60152. * The dxgiFormat of the texture
  60153. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60154. */
  60155. dxgiFormat: number;
  60156. /**
  60157. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60158. */
  60159. textureType: number;
  60160. /**
  60161. * Sphericle polynomial created for the dds texture
  60162. */
  60163. sphericalPolynomial?: SphericalPolynomial;
  60164. }
  60165. /**
  60166. * Class used to provide DDS decompression tools
  60167. */
  60168. export class DDSTools {
  60169. /**
  60170. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60171. */
  60172. static StoreLODInAlphaChannel: boolean;
  60173. /**
  60174. * Gets DDS information from an array buffer
  60175. * @param data defines the array buffer view to read data from
  60176. * @returns the DDS information
  60177. */
  60178. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60179. private static _FloatView;
  60180. private static _Int32View;
  60181. private static _ToHalfFloat;
  60182. private static _FromHalfFloat;
  60183. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60184. private static _GetHalfFloatRGBAArrayBuffer;
  60185. private static _GetFloatRGBAArrayBuffer;
  60186. private static _GetFloatAsUIntRGBAArrayBuffer;
  60187. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60188. private static _GetRGBAArrayBuffer;
  60189. private static _ExtractLongWordOrder;
  60190. private static _GetRGBArrayBuffer;
  60191. private static _GetLuminanceArrayBuffer;
  60192. /**
  60193. * Uploads DDS Levels to a Babylon Texture
  60194. * @hidden
  60195. */
  60196. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60197. }
  60198. module "babylonjs/Engines/thinEngine" {
  60199. interface ThinEngine {
  60200. /**
  60201. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60202. * @param rootUrl defines the url where the file to load is located
  60203. * @param scene defines the current scene
  60204. * @param lodScale defines scale to apply to the mip map selection
  60205. * @param lodOffset defines offset to apply to the mip map selection
  60206. * @param onLoad defines an optional callback raised when the texture is loaded
  60207. * @param onError defines an optional callback raised if there is an issue to load the texture
  60208. * @param format defines the format of the data
  60209. * @param forcedExtension defines the extension to use to pick the right loader
  60210. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60211. * @returns the cube texture as an InternalTexture
  60212. */
  60213. 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;
  60214. }
  60215. }
  60216. }
  60217. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60218. import { Nullable } from "babylonjs/types";
  60219. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60220. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60221. /**
  60222. * Implementation of the DDS Texture Loader.
  60223. * @hidden
  60224. */
  60225. export class _DDSTextureLoader implements IInternalTextureLoader {
  60226. /**
  60227. * Defines wether the loader supports cascade loading the different faces.
  60228. */
  60229. readonly supportCascades: boolean;
  60230. /**
  60231. * This returns if the loader support the current file information.
  60232. * @param extension defines the file extension of the file being loaded
  60233. * @returns true if the loader can load the specified file
  60234. */
  60235. canLoad(extension: string): boolean;
  60236. /**
  60237. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60238. * @param data contains the texture data
  60239. * @param texture defines the BabylonJS internal texture
  60240. * @param createPolynomials will be true if polynomials have been requested
  60241. * @param onLoad defines the callback to trigger once the texture is ready
  60242. * @param onError defines the callback to trigger in case of error
  60243. */
  60244. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60245. /**
  60246. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60247. * @param data contains the texture data
  60248. * @param texture defines the BabylonJS internal texture
  60249. * @param callback defines the method to call once ready to upload
  60250. */
  60251. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60252. }
  60253. }
  60254. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60255. import { Nullable } from "babylonjs/types";
  60256. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60257. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60258. /**
  60259. * Implementation of the ENV Texture Loader.
  60260. * @hidden
  60261. */
  60262. export class _ENVTextureLoader implements IInternalTextureLoader {
  60263. /**
  60264. * Defines wether the loader supports cascade loading the different faces.
  60265. */
  60266. readonly supportCascades: boolean;
  60267. /**
  60268. * This returns if the loader support the current file information.
  60269. * @param extension defines the file extension of the file being loaded
  60270. * @returns true if the loader can load the specified file
  60271. */
  60272. canLoad(extension: string): boolean;
  60273. /**
  60274. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60275. * @param data contains the texture data
  60276. * @param texture defines the BabylonJS internal texture
  60277. * @param createPolynomials will be true if polynomials have been requested
  60278. * @param onLoad defines the callback to trigger once the texture is ready
  60279. * @param onError defines the callback to trigger in case of error
  60280. */
  60281. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60282. /**
  60283. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60284. * @param data contains the texture data
  60285. * @param texture defines the BabylonJS internal texture
  60286. * @param callback defines the method to call once ready to upload
  60287. */
  60288. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60289. }
  60290. }
  60291. declare module "babylonjs/Misc/khronosTextureContainer" {
  60292. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60293. /**
  60294. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60295. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60296. */
  60297. export class KhronosTextureContainer {
  60298. /** contents of the KTX container file */
  60299. data: ArrayBufferView;
  60300. private static HEADER_LEN;
  60301. private static COMPRESSED_2D;
  60302. private static COMPRESSED_3D;
  60303. private static TEX_2D;
  60304. private static TEX_3D;
  60305. /**
  60306. * Gets the openGL type
  60307. */
  60308. glType: number;
  60309. /**
  60310. * Gets the openGL type size
  60311. */
  60312. glTypeSize: number;
  60313. /**
  60314. * Gets the openGL format
  60315. */
  60316. glFormat: number;
  60317. /**
  60318. * Gets the openGL internal format
  60319. */
  60320. glInternalFormat: number;
  60321. /**
  60322. * Gets the base internal format
  60323. */
  60324. glBaseInternalFormat: number;
  60325. /**
  60326. * Gets image width in pixel
  60327. */
  60328. pixelWidth: number;
  60329. /**
  60330. * Gets image height in pixel
  60331. */
  60332. pixelHeight: number;
  60333. /**
  60334. * Gets image depth in pixels
  60335. */
  60336. pixelDepth: number;
  60337. /**
  60338. * Gets the number of array elements
  60339. */
  60340. numberOfArrayElements: number;
  60341. /**
  60342. * Gets the number of faces
  60343. */
  60344. numberOfFaces: number;
  60345. /**
  60346. * Gets the number of mipmap levels
  60347. */
  60348. numberOfMipmapLevels: number;
  60349. /**
  60350. * Gets the bytes of key value data
  60351. */
  60352. bytesOfKeyValueData: number;
  60353. /**
  60354. * Gets the load type
  60355. */
  60356. loadType: number;
  60357. /**
  60358. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60359. */
  60360. isInvalid: boolean;
  60361. /**
  60362. * Creates a new KhronosTextureContainer
  60363. * @param data contents of the KTX container file
  60364. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60365. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60366. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60367. */
  60368. constructor(
  60369. /** contents of the KTX container file */
  60370. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60371. /**
  60372. * Uploads KTX content to a Babylon Texture.
  60373. * It is assumed that the texture has already been created & is currently bound
  60374. * @hidden
  60375. */
  60376. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60377. private _upload2DCompressedLevels;
  60378. /**
  60379. * Checks if the given data starts with a KTX file identifier.
  60380. * @param data the data to check
  60381. * @returns true if the data is a KTX file or false otherwise
  60382. */
  60383. static IsValid(data: ArrayBufferView): boolean;
  60384. }
  60385. }
  60386. declare module "babylonjs/Misc/workerPool" {
  60387. import { IDisposable } from "babylonjs/scene";
  60388. /**
  60389. * Helper class to push actions to a pool of workers.
  60390. */
  60391. export class WorkerPool implements IDisposable {
  60392. private _workerInfos;
  60393. private _pendingActions;
  60394. /**
  60395. * Constructor
  60396. * @param workers Array of workers to use for actions
  60397. */
  60398. constructor(workers: Array<Worker>);
  60399. /**
  60400. * Terminates all workers and clears any pending actions.
  60401. */
  60402. dispose(): void;
  60403. /**
  60404. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60405. * pended until a worker has completed its action.
  60406. * @param action The action to perform. Call onComplete when the action is complete.
  60407. */
  60408. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60409. private _execute;
  60410. }
  60411. }
  60412. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60413. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60414. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60415. /**
  60416. * Class for loading KTX2 files
  60417. * @hidden
  60418. */
  60419. export class KhronosTextureContainer2 {
  60420. private static _WorkerPoolPromise?;
  60421. private static _Initialized;
  60422. private static _Ktx2Decoder;
  60423. /**
  60424. * URL to use when loading the KTX2 decoder module
  60425. */
  60426. static JSModuleURL: string;
  60427. /**
  60428. * Default number of workers used to handle data decoding
  60429. */
  60430. static DefaultNumWorkers: number;
  60431. private static GetDefaultNumWorkers;
  60432. private _engine;
  60433. private static _CreateWorkerPool;
  60434. /**
  60435. * Constructor
  60436. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60437. */
  60438. constructor(engine: ThinEngine, numWorkers?: number);
  60439. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60440. /**
  60441. * Stop all async operations and release resources.
  60442. */
  60443. dispose(): void;
  60444. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  60445. /**
  60446. * Checks if the given data starts with a KTX2 file identifier.
  60447. * @param data the data to check
  60448. * @returns true if the data is a KTX2 file or false otherwise
  60449. */
  60450. static IsValid(data: ArrayBufferView): boolean;
  60451. }
  60452. export function workerFunc(): void;
  60453. }
  60454. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60455. import { Nullable } from "babylonjs/types";
  60456. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60457. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60458. /**
  60459. * Implementation of the KTX Texture Loader.
  60460. * @hidden
  60461. */
  60462. export class _KTXTextureLoader implements IInternalTextureLoader {
  60463. /**
  60464. * Defines wether the loader supports cascade loading the different faces.
  60465. */
  60466. readonly supportCascades: boolean;
  60467. /**
  60468. * This returns if the loader support the current file information.
  60469. * @param extension defines the file extension of the file being loaded
  60470. * @param mimeType defines the optional mime type of the file being loaded
  60471. * @returns true if the loader can load the specified file
  60472. */
  60473. canLoad(extension: string, mimeType?: string): boolean;
  60474. /**
  60475. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60476. * @param data contains the texture data
  60477. * @param texture defines the BabylonJS internal texture
  60478. * @param createPolynomials will be true if polynomials have been requested
  60479. * @param onLoad defines the callback to trigger once the texture is ready
  60480. * @param onError defines the callback to trigger in case of error
  60481. */
  60482. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60483. /**
  60484. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60485. * @param data contains the texture data
  60486. * @param texture defines the BabylonJS internal texture
  60487. * @param callback defines the method to call once ready to upload
  60488. */
  60489. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60490. }
  60491. }
  60492. declare module "babylonjs/Helpers/sceneHelpers" {
  60493. import { Nullable } from "babylonjs/types";
  60494. import { Mesh } from "babylonjs/Meshes/mesh";
  60495. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60496. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60497. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60498. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60499. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60500. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60501. import "babylonjs/Meshes/Builders/boxBuilder";
  60502. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60503. /** @hidden */
  60504. export var _forceSceneHelpersToBundle: boolean;
  60505. module "babylonjs/scene" {
  60506. interface Scene {
  60507. /**
  60508. * Creates a default light for the scene.
  60509. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60510. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60511. */
  60512. createDefaultLight(replace?: boolean): void;
  60513. /**
  60514. * Creates a default camera for the scene.
  60515. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60516. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60517. * @param replace has default false, when true replaces the active camera in the scene
  60518. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60519. */
  60520. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60521. /**
  60522. * Creates a default camera and a default light.
  60523. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60524. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60525. * @param replace has the default false, when true replaces the active camera/light in the scene
  60526. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60527. */
  60528. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60529. /**
  60530. * Creates a new sky box
  60531. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60532. * @param environmentTexture defines the texture to use as environment texture
  60533. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60534. * @param scale defines the overall scale of the skybox
  60535. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60536. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60537. * @returns a new mesh holding the sky box
  60538. */
  60539. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60540. /**
  60541. * Creates a new environment
  60542. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60543. * @param options defines the options you can use to configure the environment
  60544. * @returns the new EnvironmentHelper
  60545. */
  60546. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60547. /**
  60548. * Creates a new VREXperienceHelper
  60549. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60550. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60551. * @returns a new VREXperienceHelper
  60552. */
  60553. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60554. /**
  60555. * Creates a new WebXRDefaultExperience
  60556. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60557. * @param options experience options
  60558. * @returns a promise for a new WebXRDefaultExperience
  60559. */
  60560. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60561. }
  60562. }
  60563. }
  60564. declare module "babylonjs/Helpers/videoDome" {
  60565. import { Scene } from "babylonjs/scene";
  60566. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60567. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60568. /**
  60569. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60570. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60571. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60572. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60573. */
  60574. export class VideoDome extends TextureDome<VideoTexture> {
  60575. /**
  60576. * Define the video source as a Monoscopic panoramic 360 video.
  60577. */
  60578. static readonly MODE_MONOSCOPIC: number;
  60579. /**
  60580. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60581. */
  60582. static readonly MODE_TOPBOTTOM: number;
  60583. /**
  60584. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60585. */
  60586. static readonly MODE_SIDEBYSIDE: number;
  60587. /**
  60588. * Get the video texture associated with this video dome
  60589. */
  60590. get videoTexture(): VideoTexture;
  60591. /**
  60592. * Get the video mode of this dome
  60593. */
  60594. get videoMode(): number;
  60595. /**
  60596. * Set the video mode of this dome.
  60597. * @see textureMode
  60598. */
  60599. set videoMode(value: number);
  60600. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  60601. }
  60602. }
  60603. declare module "babylonjs/Helpers/index" {
  60604. export * from "babylonjs/Helpers/environmentHelper";
  60605. export * from "babylonjs/Helpers/photoDome";
  60606. export * from "babylonjs/Helpers/sceneHelpers";
  60607. export * from "babylonjs/Helpers/videoDome";
  60608. }
  60609. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60610. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60611. import { IDisposable } from "babylonjs/scene";
  60612. import { Engine } from "babylonjs/Engines/engine";
  60613. /**
  60614. * This class can be used to get instrumentation data from a Babylon engine
  60615. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60616. */
  60617. export class EngineInstrumentation implements IDisposable {
  60618. /**
  60619. * Define the instrumented engine.
  60620. */
  60621. engine: Engine;
  60622. private _captureGPUFrameTime;
  60623. private _gpuFrameTimeToken;
  60624. private _gpuFrameTime;
  60625. private _captureShaderCompilationTime;
  60626. private _shaderCompilationTime;
  60627. private _onBeginFrameObserver;
  60628. private _onEndFrameObserver;
  60629. private _onBeforeShaderCompilationObserver;
  60630. private _onAfterShaderCompilationObserver;
  60631. /**
  60632. * Gets the perf counter used for GPU frame time
  60633. */
  60634. get gpuFrameTimeCounter(): PerfCounter;
  60635. /**
  60636. * Gets the GPU frame time capture status
  60637. */
  60638. get captureGPUFrameTime(): boolean;
  60639. /**
  60640. * Enable or disable the GPU frame time capture
  60641. */
  60642. set captureGPUFrameTime(value: boolean);
  60643. /**
  60644. * Gets the perf counter used for shader compilation time
  60645. */
  60646. get shaderCompilationTimeCounter(): PerfCounter;
  60647. /**
  60648. * Gets the shader compilation time capture status
  60649. */
  60650. get captureShaderCompilationTime(): boolean;
  60651. /**
  60652. * Enable or disable the shader compilation time capture
  60653. */
  60654. set captureShaderCompilationTime(value: boolean);
  60655. /**
  60656. * Instantiates a new engine instrumentation.
  60657. * This class can be used to get instrumentation data from a Babylon engine
  60658. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60659. * @param engine Defines the engine to instrument
  60660. */
  60661. constructor(
  60662. /**
  60663. * Define the instrumented engine.
  60664. */
  60665. engine: Engine);
  60666. /**
  60667. * Dispose and release associated resources.
  60668. */
  60669. dispose(): void;
  60670. }
  60671. }
  60672. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60673. import { Scene, IDisposable } from "babylonjs/scene";
  60674. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60675. /**
  60676. * This class can be used to get instrumentation data from a Babylon engine
  60677. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60678. */
  60679. export class SceneInstrumentation implements IDisposable {
  60680. /**
  60681. * Defines the scene to instrument
  60682. */
  60683. scene: Scene;
  60684. private _captureActiveMeshesEvaluationTime;
  60685. private _activeMeshesEvaluationTime;
  60686. private _captureRenderTargetsRenderTime;
  60687. private _renderTargetsRenderTime;
  60688. private _captureFrameTime;
  60689. private _frameTime;
  60690. private _captureRenderTime;
  60691. private _renderTime;
  60692. private _captureInterFrameTime;
  60693. private _interFrameTime;
  60694. private _captureParticlesRenderTime;
  60695. private _particlesRenderTime;
  60696. private _captureSpritesRenderTime;
  60697. private _spritesRenderTime;
  60698. private _capturePhysicsTime;
  60699. private _physicsTime;
  60700. private _captureAnimationsTime;
  60701. private _animationsTime;
  60702. private _captureCameraRenderTime;
  60703. private _cameraRenderTime;
  60704. private _onBeforeActiveMeshesEvaluationObserver;
  60705. private _onAfterActiveMeshesEvaluationObserver;
  60706. private _onBeforeRenderTargetsRenderObserver;
  60707. private _onAfterRenderTargetsRenderObserver;
  60708. private _onAfterRenderObserver;
  60709. private _onBeforeDrawPhaseObserver;
  60710. private _onAfterDrawPhaseObserver;
  60711. private _onBeforeAnimationsObserver;
  60712. private _onBeforeParticlesRenderingObserver;
  60713. private _onAfterParticlesRenderingObserver;
  60714. private _onBeforeSpritesRenderingObserver;
  60715. private _onAfterSpritesRenderingObserver;
  60716. private _onBeforePhysicsObserver;
  60717. private _onAfterPhysicsObserver;
  60718. private _onAfterAnimationsObserver;
  60719. private _onBeforeCameraRenderObserver;
  60720. private _onAfterCameraRenderObserver;
  60721. /**
  60722. * Gets the perf counter used for active meshes evaluation time
  60723. */
  60724. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60725. /**
  60726. * Gets the active meshes evaluation time capture status
  60727. */
  60728. get captureActiveMeshesEvaluationTime(): boolean;
  60729. /**
  60730. * Enable or disable the active meshes evaluation time capture
  60731. */
  60732. set captureActiveMeshesEvaluationTime(value: boolean);
  60733. /**
  60734. * Gets the perf counter used for render targets render time
  60735. */
  60736. get renderTargetsRenderTimeCounter(): PerfCounter;
  60737. /**
  60738. * Gets the render targets render time capture status
  60739. */
  60740. get captureRenderTargetsRenderTime(): boolean;
  60741. /**
  60742. * Enable or disable the render targets render time capture
  60743. */
  60744. set captureRenderTargetsRenderTime(value: boolean);
  60745. /**
  60746. * Gets the perf counter used for particles render time
  60747. */
  60748. get particlesRenderTimeCounter(): PerfCounter;
  60749. /**
  60750. * Gets the particles render time capture status
  60751. */
  60752. get captureParticlesRenderTime(): boolean;
  60753. /**
  60754. * Enable or disable the particles render time capture
  60755. */
  60756. set captureParticlesRenderTime(value: boolean);
  60757. /**
  60758. * Gets the perf counter used for sprites render time
  60759. */
  60760. get spritesRenderTimeCounter(): PerfCounter;
  60761. /**
  60762. * Gets the sprites render time capture status
  60763. */
  60764. get captureSpritesRenderTime(): boolean;
  60765. /**
  60766. * Enable or disable the sprites render time capture
  60767. */
  60768. set captureSpritesRenderTime(value: boolean);
  60769. /**
  60770. * Gets the perf counter used for physics time
  60771. */
  60772. get physicsTimeCounter(): PerfCounter;
  60773. /**
  60774. * Gets the physics time capture status
  60775. */
  60776. get capturePhysicsTime(): boolean;
  60777. /**
  60778. * Enable or disable the physics time capture
  60779. */
  60780. set capturePhysicsTime(value: boolean);
  60781. /**
  60782. * Gets the perf counter used for animations time
  60783. */
  60784. get animationsTimeCounter(): PerfCounter;
  60785. /**
  60786. * Gets the animations time capture status
  60787. */
  60788. get captureAnimationsTime(): boolean;
  60789. /**
  60790. * Enable or disable the animations time capture
  60791. */
  60792. set captureAnimationsTime(value: boolean);
  60793. /**
  60794. * Gets the perf counter used for frame time capture
  60795. */
  60796. get frameTimeCounter(): PerfCounter;
  60797. /**
  60798. * Gets the frame time capture status
  60799. */
  60800. get captureFrameTime(): boolean;
  60801. /**
  60802. * Enable or disable the frame time capture
  60803. */
  60804. set captureFrameTime(value: boolean);
  60805. /**
  60806. * Gets the perf counter used for inter-frames time capture
  60807. */
  60808. get interFrameTimeCounter(): PerfCounter;
  60809. /**
  60810. * Gets the inter-frames time capture status
  60811. */
  60812. get captureInterFrameTime(): boolean;
  60813. /**
  60814. * Enable or disable the inter-frames time capture
  60815. */
  60816. set captureInterFrameTime(value: boolean);
  60817. /**
  60818. * Gets the perf counter used for render time capture
  60819. */
  60820. get renderTimeCounter(): PerfCounter;
  60821. /**
  60822. * Gets the render time capture status
  60823. */
  60824. get captureRenderTime(): boolean;
  60825. /**
  60826. * Enable or disable the render time capture
  60827. */
  60828. set captureRenderTime(value: boolean);
  60829. /**
  60830. * Gets the perf counter used for camera render time capture
  60831. */
  60832. get cameraRenderTimeCounter(): PerfCounter;
  60833. /**
  60834. * Gets the camera render time capture status
  60835. */
  60836. get captureCameraRenderTime(): boolean;
  60837. /**
  60838. * Enable or disable the camera render time capture
  60839. */
  60840. set captureCameraRenderTime(value: boolean);
  60841. /**
  60842. * Gets the perf counter used for draw calls
  60843. */
  60844. get drawCallsCounter(): PerfCounter;
  60845. /**
  60846. * Instantiates a new scene instrumentation.
  60847. * This class can be used to get instrumentation data from a Babylon engine
  60848. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60849. * @param scene Defines the scene to instrument
  60850. */
  60851. constructor(
  60852. /**
  60853. * Defines the scene to instrument
  60854. */
  60855. scene: Scene);
  60856. /**
  60857. * Dispose and release associated resources.
  60858. */
  60859. dispose(): void;
  60860. }
  60861. }
  60862. declare module "babylonjs/Instrumentation/index" {
  60863. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60864. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60865. export * from "babylonjs/Instrumentation/timeToken";
  60866. }
  60867. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60868. /** @hidden */
  60869. export var glowMapGenerationPixelShader: {
  60870. name: string;
  60871. shader: string;
  60872. };
  60873. }
  60874. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60875. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60876. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60877. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60878. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60879. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60880. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60881. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60882. /** @hidden */
  60883. export var glowMapGenerationVertexShader: {
  60884. name: string;
  60885. shader: string;
  60886. };
  60887. }
  60888. declare module "babylonjs/Layers/effectLayer" {
  60889. import { Observable } from "babylonjs/Misc/observable";
  60890. import { Nullable } from "babylonjs/types";
  60891. import { Camera } from "babylonjs/Cameras/camera";
  60892. import { Scene } from "babylonjs/scene";
  60893. import { ISize } from "babylonjs/Maths/math.size";
  60894. import { Color4 } from "babylonjs/Maths/math.color";
  60895. import { Engine } from "babylonjs/Engines/engine";
  60896. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60898. import { Mesh } from "babylonjs/Meshes/mesh";
  60899. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60900. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60901. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60902. import { Effect } from "babylonjs/Materials/effect";
  60903. import { Material } from "babylonjs/Materials/material";
  60904. import "babylonjs/Shaders/glowMapGeneration.fragment";
  60905. import "babylonjs/Shaders/glowMapGeneration.vertex";
  60906. /**
  60907. * Effect layer options. This helps customizing the behaviour
  60908. * of the effect layer.
  60909. */
  60910. export interface IEffectLayerOptions {
  60911. /**
  60912. * Multiplication factor apply to the canvas size to compute the render target size
  60913. * used to generated the objects (the smaller the faster).
  60914. */
  60915. mainTextureRatio: number;
  60916. /**
  60917. * Enforces a fixed size texture to ensure effect stability across devices.
  60918. */
  60919. mainTextureFixedSize?: number;
  60920. /**
  60921. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  60922. */
  60923. alphaBlendingMode: number;
  60924. /**
  60925. * The camera attached to the layer.
  60926. */
  60927. camera: Nullable<Camera>;
  60928. /**
  60929. * The rendering group to draw the layer in.
  60930. */
  60931. renderingGroupId: number;
  60932. }
  60933. /**
  60934. * The effect layer Helps adding post process effect blended with the main pass.
  60935. *
  60936. * This can be for instance use to generate glow or higlight effects on the scene.
  60937. *
  60938. * The effect layer class can not be used directly and is intented to inherited from to be
  60939. * customized per effects.
  60940. */
  60941. export abstract class EffectLayer {
  60942. private _vertexBuffers;
  60943. private _indexBuffer;
  60944. private _cachedDefines;
  60945. private _effectLayerMapGenerationEffect;
  60946. private _effectLayerOptions;
  60947. private _mergeEffect;
  60948. protected _scene: Scene;
  60949. protected _engine: Engine;
  60950. protected _maxSize: number;
  60951. protected _mainTextureDesiredSize: ISize;
  60952. protected _mainTexture: RenderTargetTexture;
  60953. protected _shouldRender: boolean;
  60954. protected _postProcesses: PostProcess[];
  60955. protected _textures: BaseTexture[];
  60956. protected _emissiveTextureAndColor: {
  60957. texture: Nullable<BaseTexture>;
  60958. color: Color4;
  60959. };
  60960. /**
  60961. * The name of the layer
  60962. */
  60963. name: string;
  60964. /**
  60965. * The clear color of the texture used to generate the glow map.
  60966. */
  60967. neutralColor: Color4;
  60968. /**
  60969. * Specifies whether the highlight layer is enabled or not.
  60970. */
  60971. isEnabled: boolean;
  60972. /**
  60973. * Gets the camera attached to the layer.
  60974. */
  60975. get camera(): Nullable<Camera>;
  60976. /**
  60977. * Gets the rendering group id the layer should render in.
  60978. */
  60979. get renderingGroupId(): number;
  60980. set renderingGroupId(renderingGroupId: number);
  60981. /**
  60982. * An event triggered when the effect layer has been disposed.
  60983. */
  60984. onDisposeObservable: Observable<EffectLayer>;
  60985. /**
  60986. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  60987. */
  60988. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  60989. /**
  60990. * An event triggered when the generated texture is being merged in the scene.
  60991. */
  60992. onBeforeComposeObservable: Observable<EffectLayer>;
  60993. /**
  60994. * An event triggered when the mesh is rendered into the effect render target.
  60995. */
  60996. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  60997. /**
  60998. * An event triggered after the mesh has been rendered into the effect render target.
  60999. */
  61000. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61001. /**
  61002. * An event triggered when the generated texture has been merged in the scene.
  61003. */
  61004. onAfterComposeObservable: Observable<EffectLayer>;
  61005. /**
  61006. * An event triggered when the efffect layer changes its size.
  61007. */
  61008. onSizeChangedObservable: Observable<EffectLayer>;
  61009. /** @hidden */
  61010. static _SceneComponentInitialization: (scene: Scene) => void;
  61011. /**
  61012. * Instantiates a new effect Layer and references it in the scene.
  61013. * @param name The name of the layer
  61014. * @param scene The scene to use the layer in
  61015. */
  61016. constructor(
  61017. /** The Friendly of the effect in the scene */
  61018. name: string, scene: Scene);
  61019. /**
  61020. * Get the effect name of the layer.
  61021. * @return The effect name
  61022. */
  61023. abstract getEffectName(): string;
  61024. /**
  61025. * Checks for the readiness of the element composing the layer.
  61026. * @param subMesh the mesh to check for
  61027. * @param useInstances specify whether or not to use instances to render the mesh
  61028. * @return true if ready otherwise, false
  61029. */
  61030. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61031. /**
  61032. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61033. * @returns true if the effect requires stencil during the main canvas render pass.
  61034. */
  61035. abstract needStencil(): boolean;
  61036. /**
  61037. * Create the merge effect. This is the shader use to blit the information back
  61038. * to the main canvas at the end of the scene rendering.
  61039. * @returns The effect containing the shader used to merge the effect on the main canvas
  61040. */
  61041. protected abstract _createMergeEffect(): Effect;
  61042. /**
  61043. * Creates the render target textures and post processes used in the effect layer.
  61044. */
  61045. protected abstract _createTextureAndPostProcesses(): void;
  61046. /**
  61047. * Implementation specific of rendering the generating effect on the main canvas.
  61048. * @param effect The effect used to render through
  61049. */
  61050. protected abstract _internalRender(effect: Effect): void;
  61051. /**
  61052. * Sets the required values for both the emissive texture and and the main color.
  61053. */
  61054. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61055. /**
  61056. * Free any resources and references associated to a mesh.
  61057. * Internal use
  61058. * @param mesh The mesh to free.
  61059. */
  61060. abstract _disposeMesh(mesh: Mesh): void;
  61061. /**
  61062. * Serializes this layer (Glow or Highlight for example)
  61063. * @returns a serialized layer object
  61064. */
  61065. abstract serialize?(): any;
  61066. /**
  61067. * Initializes the effect layer with the required options.
  61068. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61069. */
  61070. protected _init(options: Partial<IEffectLayerOptions>): void;
  61071. /**
  61072. * Generates the index buffer of the full screen quad blending to the main canvas.
  61073. */
  61074. private _generateIndexBuffer;
  61075. /**
  61076. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61077. */
  61078. private _generateVertexBuffer;
  61079. /**
  61080. * Sets the main texture desired size which is the closest power of two
  61081. * of the engine canvas size.
  61082. */
  61083. private _setMainTextureSize;
  61084. /**
  61085. * Creates the main texture for the effect layer.
  61086. */
  61087. protected _createMainTexture(): void;
  61088. /**
  61089. * Adds specific effects defines.
  61090. * @param defines The defines to add specifics to.
  61091. */
  61092. protected _addCustomEffectDefines(defines: string[]): void;
  61093. /**
  61094. * Checks for the readiness of the element composing the layer.
  61095. * @param subMesh the mesh to check for
  61096. * @param useInstances specify whether or not to use instances to render the mesh
  61097. * @param emissiveTexture the associated emissive texture used to generate the glow
  61098. * @return true if ready otherwise, false
  61099. */
  61100. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61101. /**
  61102. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61103. */
  61104. render(): void;
  61105. /**
  61106. * Determine if a given mesh will be used in the current effect.
  61107. * @param mesh mesh to test
  61108. * @returns true if the mesh will be used
  61109. */
  61110. hasMesh(mesh: AbstractMesh): boolean;
  61111. /**
  61112. * Returns true if the layer contains information to display, otherwise false.
  61113. * @returns true if the glow layer should be rendered
  61114. */
  61115. shouldRender(): boolean;
  61116. /**
  61117. * Returns true if the mesh should render, otherwise false.
  61118. * @param mesh The mesh to render
  61119. * @returns true if it should render otherwise false
  61120. */
  61121. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61122. /**
  61123. * Returns true if the mesh can be rendered, otherwise false.
  61124. * @param mesh The mesh to render
  61125. * @param material The material used on the mesh
  61126. * @returns true if it can be rendered otherwise false
  61127. */
  61128. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61129. /**
  61130. * Returns true if the mesh should render, otherwise false.
  61131. * @param mesh The mesh to render
  61132. * @returns true if it should render otherwise false
  61133. */
  61134. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61135. /**
  61136. * Renders the submesh passed in parameter to the generation map.
  61137. */
  61138. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61139. /**
  61140. * Defines whether the current material of the mesh should be use to render the effect.
  61141. * @param mesh defines the current mesh to render
  61142. */
  61143. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61144. /**
  61145. * Rebuild the required buffers.
  61146. * @hidden Internal use only.
  61147. */
  61148. _rebuild(): void;
  61149. /**
  61150. * Dispose only the render target textures and post process.
  61151. */
  61152. private _disposeTextureAndPostProcesses;
  61153. /**
  61154. * Dispose the highlight layer and free resources.
  61155. */
  61156. dispose(): void;
  61157. /**
  61158. * Gets the class name of the effect layer
  61159. * @returns the string with the class name of the effect layer
  61160. */
  61161. getClassName(): string;
  61162. /**
  61163. * Creates an effect layer from parsed effect layer data
  61164. * @param parsedEffectLayer defines effect layer data
  61165. * @param scene defines the current scene
  61166. * @param rootUrl defines the root URL containing the effect layer information
  61167. * @returns a parsed effect Layer
  61168. */
  61169. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61170. }
  61171. }
  61172. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61173. import { Scene } from "babylonjs/scene";
  61174. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61175. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61176. import { AbstractScene } from "babylonjs/abstractScene";
  61177. module "babylonjs/abstractScene" {
  61178. interface AbstractScene {
  61179. /**
  61180. * The list of effect layers (highlights/glow) added to the scene
  61181. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61182. * @see https://doc.babylonjs.com/how_to/glow_layer
  61183. */
  61184. effectLayers: Array<EffectLayer>;
  61185. /**
  61186. * Removes the given effect layer from this scene.
  61187. * @param toRemove defines the effect layer to remove
  61188. * @returns the index of the removed effect layer
  61189. */
  61190. removeEffectLayer(toRemove: EffectLayer): number;
  61191. /**
  61192. * Adds the given effect layer to this scene
  61193. * @param newEffectLayer defines the effect layer to add
  61194. */
  61195. addEffectLayer(newEffectLayer: EffectLayer): void;
  61196. }
  61197. }
  61198. /**
  61199. * Defines the layer scene component responsible to manage any effect layers
  61200. * in a given scene.
  61201. */
  61202. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61203. /**
  61204. * The component name helpfull to identify the component in the list of scene components.
  61205. */
  61206. readonly name: string;
  61207. /**
  61208. * The scene the component belongs to.
  61209. */
  61210. scene: Scene;
  61211. private _engine;
  61212. private _renderEffects;
  61213. private _needStencil;
  61214. private _previousStencilState;
  61215. /**
  61216. * Creates a new instance of the component for the given scene
  61217. * @param scene Defines the scene to register the component in
  61218. */
  61219. constructor(scene: Scene);
  61220. /**
  61221. * Registers the component in a given scene
  61222. */
  61223. register(): void;
  61224. /**
  61225. * Rebuilds the elements related to this component in case of
  61226. * context lost for instance.
  61227. */
  61228. rebuild(): void;
  61229. /**
  61230. * Serializes the component data to the specified json object
  61231. * @param serializationObject The object to serialize to
  61232. */
  61233. serialize(serializationObject: any): void;
  61234. /**
  61235. * Adds all the elements from the container to the scene
  61236. * @param container the container holding the elements
  61237. */
  61238. addFromContainer(container: AbstractScene): void;
  61239. /**
  61240. * Removes all the elements in the container from the scene
  61241. * @param container contains the elements to remove
  61242. * @param dispose if the removed element should be disposed (default: false)
  61243. */
  61244. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61245. /**
  61246. * Disposes the component and the associated ressources.
  61247. */
  61248. dispose(): void;
  61249. private _isReadyForMesh;
  61250. private _renderMainTexture;
  61251. private _setStencil;
  61252. private _setStencilBack;
  61253. private _draw;
  61254. private _drawCamera;
  61255. private _drawRenderingGroup;
  61256. }
  61257. }
  61258. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61259. /** @hidden */
  61260. export var glowMapMergePixelShader: {
  61261. name: string;
  61262. shader: string;
  61263. };
  61264. }
  61265. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61266. /** @hidden */
  61267. export var glowMapMergeVertexShader: {
  61268. name: string;
  61269. shader: string;
  61270. };
  61271. }
  61272. declare module "babylonjs/Layers/glowLayer" {
  61273. import { Nullable } from "babylonjs/types";
  61274. import { Camera } from "babylonjs/Cameras/camera";
  61275. import { Scene } from "babylonjs/scene";
  61276. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61278. import { Mesh } from "babylonjs/Meshes/mesh";
  61279. import { Texture } from "babylonjs/Materials/Textures/texture";
  61280. import { Effect } from "babylonjs/Materials/effect";
  61281. import { Material } from "babylonjs/Materials/material";
  61282. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61283. import { Color4 } from "babylonjs/Maths/math.color";
  61284. import "babylonjs/Shaders/glowMapMerge.fragment";
  61285. import "babylonjs/Shaders/glowMapMerge.vertex";
  61286. import "babylonjs/Layers/effectLayerSceneComponent";
  61287. module "babylonjs/abstractScene" {
  61288. interface AbstractScene {
  61289. /**
  61290. * Return a the first highlight layer of the scene with a given name.
  61291. * @param name The name of the highlight layer to look for.
  61292. * @return The highlight layer if found otherwise null.
  61293. */
  61294. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61295. }
  61296. }
  61297. /**
  61298. * Glow layer options. This helps customizing the behaviour
  61299. * of the glow layer.
  61300. */
  61301. export interface IGlowLayerOptions {
  61302. /**
  61303. * Multiplication factor apply to the canvas size to compute the render target size
  61304. * used to generated the glowing objects (the smaller the faster).
  61305. */
  61306. mainTextureRatio: number;
  61307. /**
  61308. * Enforces a fixed size texture to ensure resize independant blur.
  61309. */
  61310. mainTextureFixedSize?: number;
  61311. /**
  61312. * How big is the kernel of the blur texture.
  61313. */
  61314. blurKernelSize: number;
  61315. /**
  61316. * The camera attached to the layer.
  61317. */
  61318. camera: Nullable<Camera>;
  61319. /**
  61320. * Enable MSAA by chosing the number of samples.
  61321. */
  61322. mainTextureSamples?: number;
  61323. /**
  61324. * The rendering group to draw the layer in.
  61325. */
  61326. renderingGroupId: number;
  61327. }
  61328. /**
  61329. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61330. *
  61331. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61332. *
  61333. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61334. */
  61335. export class GlowLayer extends EffectLayer {
  61336. /**
  61337. * Effect Name of the layer.
  61338. */
  61339. static readonly EffectName: string;
  61340. /**
  61341. * The default blur kernel size used for the glow.
  61342. */
  61343. static DefaultBlurKernelSize: number;
  61344. /**
  61345. * The default texture size ratio used for the glow.
  61346. */
  61347. static DefaultTextureRatio: number;
  61348. /**
  61349. * Sets the kernel size of the blur.
  61350. */
  61351. set blurKernelSize(value: number);
  61352. /**
  61353. * Gets the kernel size of the blur.
  61354. */
  61355. get blurKernelSize(): number;
  61356. /**
  61357. * Sets the glow intensity.
  61358. */
  61359. set intensity(value: number);
  61360. /**
  61361. * Gets the glow intensity.
  61362. */
  61363. get intensity(): number;
  61364. private _options;
  61365. private _intensity;
  61366. private _horizontalBlurPostprocess1;
  61367. private _verticalBlurPostprocess1;
  61368. private _horizontalBlurPostprocess2;
  61369. private _verticalBlurPostprocess2;
  61370. private _blurTexture1;
  61371. private _blurTexture2;
  61372. private _postProcesses1;
  61373. private _postProcesses2;
  61374. private _includedOnlyMeshes;
  61375. private _excludedMeshes;
  61376. private _meshesUsingTheirOwnMaterials;
  61377. /**
  61378. * Callback used to let the user override the color selection on a per mesh basis
  61379. */
  61380. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61381. /**
  61382. * Callback used to let the user override the texture selection on a per mesh basis
  61383. */
  61384. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61385. /**
  61386. * Instantiates a new glow Layer and references it to the scene.
  61387. * @param name The name of the layer
  61388. * @param scene The scene to use the layer in
  61389. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61390. */
  61391. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61392. /**
  61393. * Get the effect name of the layer.
  61394. * @return The effect name
  61395. */
  61396. getEffectName(): string;
  61397. /**
  61398. * Create the merge effect. This is the shader use to blit the information back
  61399. * to the main canvas at the end of the scene rendering.
  61400. */
  61401. protected _createMergeEffect(): Effect;
  61402. /**
  61403. * Creates the render target textures and post processes used in the glow layer.
  61404. */
  61405. protected _createTextureAndPostProcesses(): void;
  61406. /**
  61407. * Checks for the readiness of the element composing the layer.
  61408. * @param subMesh the mesh to check for
  61409. * @param useInstances specify wether or not to use instances to render the mesh
  61410. * @param emissiveTexture the associated emissive texture used to generate the glow
  61411. * @return true if ready otherwise, false
  61412. */
  61413. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61414. /**
  61415. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61416. */
  61417. needStencil(): boolean;
  61418. /**
  61419. * Returns true if the mesh can be rendered, otherwise false.
  61420. * @param mesh The mesh to render
  61421. * @param material The material used on the mesh
  61422. * @returns true if it can be rendered otherwise false
  61423. */
  61424. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61425. /**
  61426. * Implementation specific of rendering the generating effect on the main canvas.
  61427. * @param effect The effect used to render through
  61428. */
  61429. protected _internalRender(effect: Effect): void;
  61430. /**
  61431. * Sets the required values for both the emissive texture and and the main color.
  61432. */
  61433. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61434. /**
  61435. * Returns true if the mesh should render, otherwise false.
  61436. * @param mesh The mesh to render
  61437. * @returns true if it should render otherwise false
  61438. */
  61439. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61440. /**
  61441. * Adds specific effects defines.
  61442. * @param defines The defines to add specifics to.
  61443. */
  61444. protected _addCustomEffectDefines(defines: string[]): void;
  61445. /**
  61446. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61447. * @param mesh The mesh to exclude from the glow layer
  61448. */
  61449. addExcludedMesh(mesh: Mesh): void;
  61450. /**
  61451. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61452. * @param mesh The mesh to remove
  61453. */
  61454. removeExcludedMesh(mesh: Mesh): void;
  61455. /**
  61456. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61457. * @param mesh The mesh to include in the glow layer
  61458. */
  61459. addIncludedOnlyMesh(mesh: Mesh): void;
  61460. /**
  61461. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61462. * @param mesh The mesh to remove
  61463. */
  61464. removeIncludedOnlyMesh(mesh: Mesh): void;
  61465. /**
  61466. * Determine if a given mesh will be used in the glow layer
  61467. * @param mesh The mesh to test
  61468. * @returns true if the mesh will be highlighted by the current glow layer
  61469. */
  61470. hasMesh(mesh: AbstractMesh): boolean;
  61471. /**
  61472. * Defines whether the current material of the mesh should be use to render the effect.
  61473. * @param mesh defines the current mesh to render
  61474. */
  61475. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61476. /**
  61477. * Add a mesh to be rendered through its own material and not with emissive only.
  61478. * @param mesh The mesh for which we need to use its material
  61479. */
  61480. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61481. /**
  61482. * Remove a mesh from being rendered through its own material and not with emissive only.
  61483. * @param mesh The mesh for which we need to not use its material
  61484. */
  61485. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61486. /**
  61487. * Free any resources and references associated to a mesh.
  61488. * Internal use
  61489. * @param mesh The mesh to free.
  61490. * @hidden
  61491. */
  61492. _disposeMesh(mesh: Mesh): void;
  61493. /**
  61494. * Gets the class name of the effect layer
  61495. * @returns the string with the class name of the effect layer
  61496. */
  61497. getClassName(): string;
  61498. /**
  61499. * Serializes this glow layer
  61500. * @returns a serialized glow layer object
  61501. */
  61502. serialize(): any;
  61503. /**
  61504. * Creates a Glow Layer from parsed glow layer data
  61505. * @param parsedGlowLayer defines glow layer data
  61506. * @param scene defines the current scene
  61507. * @param rootUrl defines the root URL containing the glow layer information
  61508. * @returns a parsed Glow Layer
  61509. */
  61510. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61511. }
  61512. }
  61513. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61514. /** @hidden */
  61515. export var glowBlurPostProcessPixelShader: {
  61516. name: string;
  61517. shader: string;
  61518. };
  61519. }
  61520. declare module "babylonjs/Layers/highlightLayer" {
  61521. import { Observable } from "babylonjs/Misc/observable";
  61522. import { Nullable } from "babylonjs/types";
  61523. import { Camera } from "babylonjs/Cameras/camera";
  61524. import { Scene } from "babylonjs/scene";
  61525. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61527. import { Mesh } from "babylonjs/Meshes/mesh";
  61528. import { Effect } from "babylonjs/Materials/effect";
  61529. import { Material } from "babylonjs/Materials/material";
  61530. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61531. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61532. import "babylonjs/Shaders/glowMapMerge.fragment";
  61533. import "babylonjs/Shaders/glowMapMerge.vertex";
  61534. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61535. module "babylonjs/abstractScene" {
  61536. interface AbstractScene {
  61537. /**
  61538. * Return a the first highlight layer of the scene with a given name.
  61539. * @param name The name of the highlight layer to look for.
  61540. * @return The highlight layer if found otherwise null.
  61541. */
  61542. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61543. }
  61544. }
  61545. /**
  61546. * Highlight layer options. This helps customizing the behaviour
  61547. * of the highlight layer.
  61548. */
  61549. export interface IHighlightLayerOptions {
  61550. /**
  61551. * Multiplication factor apply to the canvas size to compute the render target size
  61552. * used to generated the glowing objects (the smaller the faster).
  61553. */
  61554. mainTextureRatio: number;
  61555. /**
  61556. * Enforces a fixed size texture to ensure resize independant blur.
  61557. */
  61558. mainTextureFixedSize?: number;
  61559. /**
  61560. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61561. * of the picture to blur (the smaller the faster).
  61562. */
  61563. blurTextureSizeRatio: number;
  61564. /**
  61565. * How big in texel of the blur texture is the vertical blur.
  61566. */
  61567. blurVerticalSize: number;
  61568. /**
  61569. * How big in texel of the blur texture is the horizontal blur.
  61570. */
  61571. blurHorizontalSize: number;
  61572. /**
  61573. * Alpha blending mode used to apply the blur. Default is combine.
  61574. */
  61575. alphaBlendingMode: number;
  61576. /**
  61577. * The camera attached to the layer.
  61578. */
  61579. camera: Nullable<Camera>;
  61580. /**
  61581. * Should we display highlight as a solid stroke?
  61582. */
  61583. isStroke?: boolean;
  61584. /**
  61585. * The rendering group to draw the layer in.
  61586. */
  61587. renderingGroupId: number;
  61588. }
  61589. /**
  61590. * The highlight layer Helps adding a glow effect around a mesh.
  61591. *
  61592. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61593. * glowy meshes to your scene.
  61594. *
  61595. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61596. */
  61597. export class HighlightLayer extends EffectLayer {
  61598. name: string;
  61599. /**
  61600. * Effect Name of the highlight layer.
  61601. */
  61602. static readonly EffectName: string;
  61603. /**
  61604. * The neutral color used during the preparation of the glow effect.
  61605. * This is black by default as the blend operation is a blend operation.
  61606. */
  61607. static NeutralColor: Color4;
  61608. /**
  61609. * Stencil value used for glowing meshes.
  61610. */
  61611. static GlowingMeshStencilReference: number;
  61612. /**
  61613. * Stencil value used for the other meshes in the scene.
  61614. */
  61615. static NormalMeshStencilReference: number;
  61616. /**
  61617. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61618. */
  61619. innerGlow: boolean;
  61620. /**
  61621. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61622. */
  61623. outerGlow: boolean;
  61624. /**
  61625. * Specifies the horizontal size of the blur.
  61626. */
  61627. set blurHorizontalSize(value: number);
  61628. /**
  61629. * Specifies the vertical size of the blur.
  61630. */
  61631. set blurVerticalSize(value: number);
  61632. /**
  61633. * Gets the horizontal size of the blur.
  61634. */
  61635. get blurHorizontalSize(): number;
  61636. /**
  61637. * Gets the vertical size of the blur.
  61638. */
  61639. get blurVerticalSize(): number;
  61640. /**
  61641. * An event triggered when the highlight layer is being blurred.
  61642. */
  61643. onBeforeBlurObservable: Observable<HighlightLayer>;
  61644. /**
  61645. * An event triggered when the highlight layer has been blurred.
  61646. */
  61647. onAfterBlurObservable: Observable<HighlightLayer>;
  61648. private _instanceGlowingMeshStencilReference;
  61649. private _options;
  61650. private _downSamplePostprocess;
  61651. private _horizontalBlurPostprocess;
  61652. private _verticalBlurPostprocess;
  61653. private _blurTexture;
  61654. private _meshes;
  61655. private _excludedMeshes;
  61656. /**
  61657. * Instantiates a new highlight Layer and references it to the scene..
  61658. * @param name The name of the layer
  61659. * @param scene The scene to use the layer in
  61660. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61661. */
  61662. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61663. /**
  61664. * Get the effect name of the layer.
  61665. * @return The effect name
  61666. */
  61667. getEffectName(): string;
  61668. /**
  61669. * Create the merge effect. This is the shader use to blit the information back
  61670. * to the main canvas at the end of the scene rendering.
  61671. */
  61672. protected _createMergeEffect(): Effect;
  61673. /**
  61674. * Creates the render target textures and post processes used in the highlight layer.
  61675. */
  61676. protected _createTextureAndPostProcesses(): void;
  61677. /**
  61678. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61679. */
  61680. needStencil(): boolean;
  61681. /**
  61682. * Checks for the readiness of the element composing the layer.
  61683. * @param subMesh the mesh to check for
  61684. * @param useInstances specify wether or not to use instances to render the mesh
  61685. * @param emissiveTexture the associated emissive texture used to generate the glow
  61686. * @return true if ready otherwise, false
  61687. */
  61688. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61689. /**
  61690. * Implementation specific of rendering the generating effect on the main canvas.
  61691. * @param effect The effect used to render through
  61692. */
  61693. protected _internalRender(effect: Effect): void;
  61694. /**
  61695. * Returns true if the layer contains information to display, otherwise false.
  61696. */
  61697. shouldRender(): boolean;
  61698. /**
  61699. * Returns true if the mesh should render, otherwise false.
  61700. * @param mesh The mesh to render
  61701. * @returns true if it should render otherwise false
  61702. */
  61703. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61704. /**
  61705. * Returns true if the mesh can be rendered, otherwise false.
  61706. * @param mesh The mesh to render
  61707. * @param material The material used on the mesh
  61708. * @returns true if it can be rendered otherwise false
  61709. */
  61710. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61711. /**
  61712. * Adds specific effects defines.
  61713. * @param defines The defines to add specifics to.
  61714. */
  61715. protected _addCustomEffectDefines(defines: string[]): void;
  61716. /**
  61717. * Sets the required values for both the emissive texture and and the main color.
  61718. */
  61719. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61720. /**
  61721. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61722. * @param mesh The mesh to exclude from the highlight layer
  61723. */
  61724. addExcludedMesh(mesh: Mesh): void;
  61725. /**
  61726. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61727. * @param mesh The mesh to highlight
  61728. */
  61729. removeExcludedMesh(mesh: Mesh): void;
  61730. /**
  61731. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61732. * @param mesh mesh to test
  61733. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61734. */
  61735. hasMesh(mesh: AbstractMesh): boolean;
  61736. /**
  61737. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61738. * @param mesh The mesh to highlight
  61739. * @param color The color of the highlight
  61740. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61741. */
  61742. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61743. /**
  61744. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61745. * @param mesh The mesh to highlight
  61746. */
  61747. removeMesh(mesh: Mesh): void;
  61748. /**
  61749. * Remove all the meshes currently referenced in the highlight layer
  61750. */
  61751. removeAllMeshes(): void;
  61752. /**
  61753. * Force the stencil to the normal expected value for none glowing parts
  61754. */
  61755. private _defaultStencilReference;
  61756. /**
  61757. * Free any resources and references associated to a mesh.
  61758. * Internal use
  61759. * @param mesh The mesh to free.
  61760. * @hidden
  61761. */
  61762. _disposeMesh(mesh: Mesh): void;
  61763. /**
  61764. * Dispose the highlight layer and free resources.
  61765. */
  61766. dispose(): void;
  61767. /**
  61768. * Gets the class name of the effect layer
  61769. * @returns the string with the class name of the effect layer
  61770. */
  61771. getClassName(): string;
  61772. /**
  61773. * Serializes this Highlight layer
  61774. * @returns a serialized Highlight layer object
  61775. */
  61776. serialize(): any;
  61777. /**
  61778. * Creates a Highlight layer from parsed Highlight layer data
  61779. * @param parsedHightlightLayer defines the Highlight layer data
  61780. * @param scene defines the current scene
  61781. * @param rootUrl defines the root URL containing the Highlight layer information
  61782. * @returns a parsed Highlight layer
  61783. */
  61784. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61785. }
  61786. }
  61787. declare module "babylonjs/Layers/layerSceneComponent" {
  61788. import { Scene } from "babylonjs/scene";
  61789. import { ISceneComponent } from "babylonjs/sceneComponent";
  61790. import { Layer } from "babylonjs/Layers/layer";
  61791. import { AbstractScene } from "babylonjs/abstractScene";
  61792. module "babylonjs/abstractScene" {
  61793. interface AbstractScene {
  61794. /**
  61795. * The list of layers (background and foreground) of the scene
  61796. */
  61797. layers: Array<Layer>;
  61798. }
  61799. }
  61800. /**
  61801. * Defines the layer scene component responsible to manage any layers
  61802. * in a given scene.
  61803. */
  61804. export class LayerSceneComponent implements ISceneComponent {
  61805. /**
  61806. * The component name helpfull to identify the component in the list of scene components.
  61807. */
  61808. readonly name: string;
  61809. /**
  61810. * The scene the component belongs to.
  61811. */
  61812. scene: Scene;
  61813. private _engine;
  61814. /**
  61815. * Creates a new instance of the component for the given scene
  61816. * @param scene Defines the scene to register the component in
  61817. */
  61818. constructor(scene: Scene);
  61819. /**
  61820. * Registers the component in a given scene
  61821. */
  61822. register(): void;
  61823. /**
  61824. * Rebuilds the elements related to this component in case of
  61825. * context lost for instance.
  61826. */
  61827. rebuild(): void;
  61828. /**
  61829. * Disposes the component and the associated ressources.
  61830. */
  61831. dispose(): void;
  61832. private _draw;
  61833. private _drawCameraPredicate;
  61834. private _drawCameraBackground;
  61835. private _drawCameraForeground;
  61836. private _drawRenderTargetPredicate;
  61837. private _drawRenderTargetBackground;
  61838. private _drawRenderTargetForeground;
  61839. /**
  61840. * Adds all the elements from the container to the scene
  61841. * @param container the container holding the elements
  61842. */
  61843. addFromContainer(container: AbstractScene): void;
  61844. /**
  61845. * Removes all the elements in the container from the scene
  61846. * @param container contains the elements to remove
  61847. * @param dispose if the removed element should be disposed (default: false)
  61848. */
  61849. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61850. }
  61851. }
  61852. declare module "babylonjs/Shaders/layer.fragment" {
  61853. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61854. /** @hidden */
  61855. export var layerPixelShader: {
  61856. name: string;
  61857. shader: string;
  61858. };
  61859. }
  61860. declare module "babylonjs/Shaders/layer.vertex" {
  61861. /** @hidden */
  61862. export var layerVertexShader: {
  61863. name: string;
  61864. shader: string;
  61865. };
  61866. }
  61867. declare module "babylonjs/Layers/layer" {
  61868. import { Observable } from "babylonjs/Misc/observable";
  61869. import { Nullable } from "babylonjs/types";
  61870. import { Scene } from "babylonjs/scene";
  61871. import { Vector2 } from "babylonjs/Maths/math.vector";
  61872. import { Color4 } from "babylonjs/Maths/math.color";
  61873. import { Texture } from "babylonjs/Materials/Textures/texture";
  61874. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61875. import "babylonjs/Shaders/layer.fragment";
  61876. import "babylonjs/Shaders/layer.vertex";
  61877. /**
  61878. * This represents a full screen 2d layer.
  61879. * This can be useful to display a picture in the background of your scene for instance.
  61880. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61881. */
  61882. export class Layer {
  61883. /**
  61884. * Define the name of the layer.
  61885. */
  61886. name: string;
  61887. /**
  61888. * Define the texture the layer should display.
  61889. */
  61890. texture: Nullable<Texture>;
  61891. /**
  61892. * Is the layer in background or foreground.
  61893. */
  61894. isBackground: boolean;
  61895. /**
  61896. * Define the color of the layer (instead of texture).
  61897. */
  61898. color: Color4;
  61899. /**
  61900. * Define the scale of the layer in order to zoom in out of the texture.
  61901. */
  61902. scale: Vector2;
  61903. /**
  61904. * Define an offset for the layer in order to shift the texture.
  61905. */
  61906. offset: Vector2;
  61907. /**
  61908. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  61909. */
  61910. alphaBlendingMode: number;
  61911. /**
  61912. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  61913. * Alpha test will not mix with the background color in case of transparency.
  61914. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  61915. */
  61916. alphaTest: boolean;
  61917. /**
  61918. * Define a mask to restrict the layer to only some of the scene cameras.
  61919. */
  61920. layerMask: number;
  61921. /**
  61922. * Define the list of render target the layer is visible into.
  61923. */
  61924. renderTargetTextures: RenderTargetTexture[];
  61925. /**
  61926. * Define if the layer is only used in renderTarget or if it also
  61927. * renders in the main frame buffer of the canvas.
  61928. */
  61929. renderOnlyInRenderTargetTextures: boolean;
  61930. private _scene;
  61931. private _vertexBuffers;
  61932. private _indexBuffer;
  61933. private _effect;
  61934. private _previousDefines;
  61935. /**
  61936. * An event triggered when the layer is disposed.
  61937. */
  61938. onDisposeObservable: Observable<Layer>;
  61939. private _onDisposeObserver;
  61940. /**
  61941. * Back compatibility with callback before the onDisposeObservable existed.
  61942. * The set callback will be triggered when the layer has been disposed.
  61943. */
  61944. set onDispose(callback: () => void);
  61945. /**
  61946. * An event triggered before rendering the scene
  61947. */
  61948. onBeforeRenderObservable: Observable<Layer>;
  61949. private _onBeforeRenderObserver;
  61950. /**
  61951. * Back compatibility with callback before the onBeforeRenderObservable existed.
  61952. * The set callback will be triggered just before rendering the layer.
  61953. */
  61954. set onBeforeRender(callback: () => void);
  61955. /**
  61956. * An event triggered after rendering the scene
  61957. */
  61958. onAfterRenderObservable: Observable<Layer>;
  61959. private _onAfterRenderObserver;
  61960. /**
  61961. * Back compatibility with callback before the onAfterRenderObservable existed.
  61962. * The set callback will be triggered just after rendering the layer.
  61963. */
  61964. set onAfterRender(callback: () => void);
  61965. /**
  61966. * Instantiates a new layer.
  61967. * This represents a full screen 2d layer.
  61968. * This can be useful to display a picture in the background of your scene for instance.
  61969. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61970. * @param name Define the name of the layer in the scene
  61971. * @param imgUrl Define the url of the texture to display in the layer
  61972. * @param scene Define the scene the layer belongs to
  61973. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  61974. * @param color Defines a color for the layer
  61975. */
  61976. constructor(
  61977. /**
  61978. * Define the name of the layer.
  61979. */
  61980. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  61981. private _createIndexBuffer;
  61982. /** @hidden */
  61983. _rebuild(): void;
  61984. /**
  61985. * Renders the layer in the scene.
  61986. */
  61987. render(): void;
  61988. /**
  61989. * Disposes and releases the associated ressources.
  61990. */
  61991. dispose(): void;
  61992. }
  61993. }
  61994. declare module "babylonjs/Layers/index" {
  61995. export * from "babylonjs/Layers/effectLayer";
  61996. export * from "babylonjs/Layers/effectLayerSceneComponent";
  61997. export * from "babylonjs/Layers/glowLayer";
  61998. export * from "babylonjs/Layers/highlightLayer";
  61999. export * from "babylonjs/Layers/layer";
  62000. export * from "babylonjs/Layers/layerSceneComponent";
  62001. }
  62002. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62003. /** @hidden */
  62004. export var lensFlarePixelShader: {
  62005. name: string;
  62006. shader: string;
  62007. };
  62008. }
  62009. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62010. /** @hidden */
  62011. export var lensFlareVertexShader: {
  62012. name: string;
  62013. shader: string;
  62014. };
  62015. }
  62016. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62017. import { Scene } from "babylonjs/scene";
  62018. import { Vector3 } from "babylonjs/Maths/math.vector";
  62019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62020. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62021. import "babylonjs/Shaders/lensFlare.fragment";
  62022. import "babylonjs/Shaders/lensFlare.vertex";
  62023. import { Viewport } from "babylonjs/Maths/math.viewport";
  62024. /**
  62025. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62026. * It is usually composed of several `lensFlare`.
  62027. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62028. */
  62029. export class LensFlareSystem {
  62030. /**
  62031. * Define the name of the lens flare system
  62032. */
  62033. name: string;
  62034. /**
  62035. * List of lens flares used in this system.
  62036. */
  62037. lensFlares: LensFlare[];
  62038. /**
  62039. * Define a limit from the border the lens flare can be visible.
  62040. */
  62041. borderLimit: number;
  62042. /**
  62043. * Define a viewport border we do not want to see the lens flare in.
  62044. */
  62045. viewportBorder: number;
  62046. /**
  62047. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62048. */
  62049. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62050. /**
  62051. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62052. */
  62053. layerMask: number;
  62054. /**
  62055. * Define the id of the lens flare system in the scene.
  62056. * (equal to name by default)
  62057. */
  62058. id: string;
  62059. private _scene;
  62060. private _emitter;
  62061. private _vertexBuffers;
  62062. private _indexBuffer;
  62063. private _effect;
  62064. private _positionX;
  62065. private _positionY;
  62066. private _isEnabled;
  62067. /** @hidden */
  62068. static _SceneComponentInitialization: (scene: Scene) => void;
  62069. /**
  62070. * Instantiates a lens flare system.
  62071. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62072. * It is usually composed of several `lensFlare`.
  62073. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62074. * @param name Define the name of the lens flare system in the scene
  62075. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62076. * @param scene Define the scene the lens flare system belongs to
  62077. */
  62078. constructor(
  62079. /**
  62080. * Define the name of the lens flare system
  62081. */
  62082. name: string, emitter: any, scene: Scene);
  62083. /**
  62084. * Define if the lens flare system is enabled.
  62085. */
  62086. get isEnabled(): boolean;
  62087. set isEnabled(value: boolean);
  62088. /**
  62089. * Get the scene the effects belongs to.
  62090. * @returns the scene holding the lens flare system
  62091. */
  62092. getScene(): Scene;
  62093. /**
  62094. * Get the emitter of the lens flare system.
  62095. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62096. * @returns the emitter of the lens flare system
  62097. */
  62098. getEmitter(): any;
  62099. /**
  62100. * Set the emitter of the lens flare system.
  62101. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62102. * @param newEmitter Define the new emitter of the system
  62103. */
  62104. setEmitter(newEmitter: any): void;
  62105. /**
  62106. * Get the lens flare system emitter position.
  62107. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62108. * @returns the position
  62109. */
  62110. getEmitterPosition(): Vector3;
  62111. /**
  62112. * @hidden
  62113. */
  62114. computeEffectivePosition(globalViewport: Viewport): boolean;
  62115. /** @hidden */
  62116. _isVisible(): boolean;
  62117. /**
  62118. * @hidden
  62119. */
  62120. render(): boolean;
  62121. /**
  62122. * Dispose and release the lens flare with its associated resources.
  62123. */
  62124. dispose(): void;
  62125. /**
  62126. * Parse a lens flare system from a JSON repressentation
  62127. * @param parsedLensFlareSystem Define the JSON to parse
  62128. * @param scene Define the scene the parsed system should be instantiated in
  62129. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62130. * @returns the parsed system
  62131. */
  62132. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62133. /**
  62134. * Serialize the current Lens Flare System into a JSON representation.
  62135. * @returns the serialized JSON
  62136. */
  62137. serialize(): any;
  62138. }
  62139. }
  62140. declare module "babylonjs/LensFlares/lensFlare" {
  62141. import { Nullable } from "babylonjs/types";
  62142. import { Color3 } from "babylonjs/Maths/math.color";
  62143. import { Texture } from "babylonjs/Materials/Textures/texture";
  62144. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62145. /**
  62146. * This represents one of the lens effect in a `lensFlareSystem`.
  62147. * It controls one of the indiviual texture used in the effect.
  62148. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62149. */
  62150. export class LensFlare {
  62151. /**
  62152. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62153. */
  62154. size: number;
  62155. /**
  62156. * 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.
  62157. */
  62158. position: number;
  62159. /**
  62160. * Define the lens color.
  62161. */
  62162. color: Color3;
  62163. /**
  62164. * Define the lens texture.
  62165. */
  62166. texture: Nullable<Texture>;
  62167. /**
  62168. * Define the alpha mode to render this particular lens.
  62169. */
  62170. alphaMode: number;
  62171. private _system;
  62172. /**
  62173. * Creates a new Lens Flare.
  62174. * This represents one of the lens effect in a `lensFlareSystem`.
  62175. * It controls one of the indiviual texture used in the effect.
  62176. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62177. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62178. * @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.
  62179. * @param color Define the lens color
  62180. * @param imgUrl Define the lens texture url
  62181. * @param system Define the `lensFlareSystem` this flare is part of
  62182. * @returns The newly created Lens Flare
  62183. */
  62184. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62185. /**
  62186. * Instantiates a new Lens Flare.
  62187. * This represents one of the lens effect in a `lensFlareSystem`.
  62188. * It controls one of the indiviual texture used in the effect.
  62189. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62190. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62191. * @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.
  62192. * @param color Define the lens color
  62193. * @param imgUrl Define the lens texture url
  62194. * @param system Define the `lensFlareSystem` this flare is part of
  62195. */
  62196. constructor(
  62197. /**
  62198. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62199. */
  62200. size: number,
  62201. /**
  62202. * 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.
  62203. */
  62204. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62205. /**
  62206. * Dispose and release the lens flare with its associated resources.
  62207. */
  62208. dispose(): void;
  62209. }
  62210. }
  62211. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62212. import { Nullable } from "babylonjs/types";
  62213. import { Scene } from "babylonjs/scene";
  62214. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62215. import { AbstractScene } from "babylonjs/abstractScene";
  62216. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62217. module "babylonjs/abstractScene" {
  62218. interface AbstractScene {
  62219. /**
  62220. * The list of lens flare system added to the scene
  62221. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62222. */
  62223. lensFlareSystems: Array<LensFlareSystem>;
  62224. /**
  62225. * Removes the given lens flare system from this scene.
  62226. * @param toRemove The lens flare system to remove
  62227. * @returns The index of the removed lens flare system
  62228. */
  62229. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62230. /**
  62231. * Adds the given lens flare system to this scene
  62232. * @param newLensFlareSystem The lens flare system to add
  62233. */
  62234. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62235. /**
  62236. * Gets a lens flare system using its name
  62237. * @param name defines the name to look for
  62238. * @returns the lens flare system or null if not found
  62239. */
  62240. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62241. /**
  62242. * Gets a lens flare system using its id
  62243. * @param id defines the id to look for
  62244. * @returns the lens flare system or null if not found
  62245. */
  62246. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62247. }
  62248. }
  62249. /**
  62250. * Defines the lens flare scene component responsible to manage any lens flares
  62251. * in a given scene.
  62252. */
  62253. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62254. /**
  62255. * The component name helpfull to identify the component in the list of scene components.
  62256. */
  62257. readonly name: string;
  62258. /**
  62259. * The scene the component belongs to.
  62260. */
  62261. scene: Scene;
  62262. /**
  62263. * Creates a new instance of the component for the given scene
  62264. * @param scene Defines the scene to register the component in
  62265. */
  62266. constructor(scene: Scene);
  62267. /**
  62268. * Registers the component in a given scene
  62269. */
  62270. register(): void;
  62271. /**
  62272. * Rebuilds the elements related to this component in case of
  62273. * context lost for instance.
  62274. */
  62275. rebuild(): void;
  62276. /**
  62277. * Adds all the elements from the container to the scene
  62278. * @param container the container holding the elements
  62279. */
  62280. addFromContainer(container: AbstractScene): void;
  62281. /**
  62282. * Removes all the elements in the container from the scene
  62283. * @param container contains the elements to remove
  62284. * @param dispose if the removed element should be disposed (default: false)
  62285. */
  62286. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62287. /**
  62288. * Serializes the component data to the specified json object
  62289. * @param serializationObject The object to serialize to
  62290. */
  62291. serialize(serializationObject: any): void;
  62292. /**
  62293. * Disposes the component and the associated ressources.
  62294. */
  62295. dispose(): void;
  62296. private _draw;
  62297. }
  62298. }
  62299. declare module "babylonjs/LensFlares/index" {
  62300. export * from "babylonjs/LensFlares/lensFlare";
  62301. export * from "babylonjs/LensFlares/lensFlareSystem";
  62302. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62303. }
  62304. declare module "babylonjs/Shaders/depth.fragment" {
  62305. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62306. /** @hidden */
  62307. export var depthPixelShader: {
  62308. name: string;
  62309. shader: string;
  62310. };
  62311. }
  62312. declare module "babylonjs/Shaders/depth.vertex" {
  62313. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62314. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62315. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62316. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62317. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62318. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62319. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62320. /** @hidden */
  62321. export var depthVertexShader: {
  62322. name: string;
  62323. shader: string;
  62324. };
  62325. }
  62326. declare module "babylonjs/Rendering/depthRenderer" {
  62327. import { Nullable } from "babylonjs/types";
  62328. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62329. import { Scene } from "babylonjs/scene";
  62330. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62331. import { Camera } from "babylonjs/Cameras/camera";
  62332. import "babylonjs/Shaders/depth.fragment";
  62333. import "babylonjs/Shaders/depth.vertex";
  62334. /**
  62335. * This represents a depth renderer in Babylon.
  62336. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62337. */
  62338. export class DepthRenderer {
  62339. private _scene;
  62340. private _depthMap;
  62341. private _effect;
  62342. private readonly _storeNonLinearDepth;
  62343. private readonly _clearColor;
  62344. /** Get if the depth renderer is using packed depth or not */
  62345. readonly isPacked: boolean;
  62346. private _cachedDefines;
  62347. private _camera;
  62348. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62349. enabled: boolean;
  62350. /**
  62351. * Specifiess that the depth renderer will only be used within
  62352. * the camera it is created for.
  62353. * This can help forcing its rendering during the camera processing.
  62354. */
  62355. useOnlyInActiveCamera: boolean;
  62356. /** @hidden */
  62357. static _SceneComponentInitialization: (scene: Scene) => void;
  62358. /**
  62359. * Instantiates a depth renderer
  62360. * @param scene The scene the renderer belongs to
  62361. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62362. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62363. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62364. */
  62365. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62366. /**
  62367. * Creates the depth rendering effect and checks if the effect is ready.
  62368. * @param subMesh The submesh to be used to render the depth map of
  62369. * @param useInstances If multiple world instances should be used
  62370. * @returns if the depth renderer is ready to render the depth map
  62371. */
  62372. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62373. /**
  62374. * Gets the texture which the depth map will be written to.
  62375. * @returns The depth map texture
  62376. */
  62377. getDepthMap(): RenderTargetTexture;
  62378. /**
  62379. * Disposes of the depth renderer.
  62380. */
  62381. dispose(): void;
  62382. }
  62383. }
  62384. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62385. /** @hidden */
  62386. export var minmaxReduxPixelShader: {
  62387. name: string;
  62388. shader: string;
  62389. };
  62390. }
  62391. declare module "babylonjs/Misc/minMaxReducer" {
  62392. import { Nullable } from "babylonjs/types";
  62393. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62394. import { Camera } from "babylonjs/Cameras/camera";
  62395. import { Observer } from "babylonjs/Misc/observable";
  62396. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62397. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62398. import { Observable } from "babylonjs/Misc/observable";
  62399. import "babylonjs/Shaders/minmaxRedux.fragment";
  62400. /**
  62401. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62402. * and maximum values from all values of the texture.
  62403. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62404. * The source values are read from the red channel of the texture.
  62405. */
  62406. export class MinMaxReducer {
  62407. /**
  62408. * Observable triggered when the computation has been performed
  62409. */
  62410. onAfterReductionPerformed: Observable<{
  62411. min: number;
  62412. max: number;
  62413. }>;
  62414. protected _camera: Camera;
  62415. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62416. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62417. protected _postProcessManager: PostProcessManager;
  62418. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62419. protected _forceFullscreenViewport: boolean;
  62420. /**
  62421. * Creates a min/max reducer
  62422. * @param camera The camera to use for the post processes
  62423. */
  62424. constructor(camera: Camera);
  62425. /**
  62426. * Gets the texture used to read the values from.
  62427. */
  62428. get sourceTexture(): Nullable<RenderTargetTexture>;
  62429. /**
  62430. * Sets the source texture to read the values from.
  62431. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62432. * because in such textures '1' value must not be taken into account to compute the maximum
  62433. * as this value is used to clear the texture.
  62434. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62435. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62436. * @param depthRedux Indicates if the texture is a depth texture or not
  62437. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62438. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62439. */
  62440. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62441. /**
  62442. * Defines the refresh rate of the computation.
  62443. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62444. */
  62445. get refreshRate(): number;
  62446. set refreshRate(value: number);
  62447. protected _activated: boolean;
  62448. /**
  62449. * Gets the activation status of the reducer
  62450. */
  62451. get activated(): boolean;
  62452. /**
  62453. * Activates the reduction computation.
  62454. * When activated, the observers registered in onAfterReductionPerformed are
  62455. * called after the compuation is performed
  62456. */
  62457. activate(): void;
  62458. /**
  62459. * Deactivates the reduction computation.
  62460. */
  62461. deactivate(): void;
  62462. /**
  62463. * Disposes the min/max reducer
  62464. * @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.
  62465. */
  62466. dispose(disposeAll?: boolean): void;
  62467. }
  62468. }
  62469. declare module "babylonjs/Misc/depthReducer" {
  62470. import { Nullable } from "babylonjs/types";
  62471. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62472. import { Camera } from "babylonjs/Cameras/camera";
  62473. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62474. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62475. /**
  62476. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62477. */
  62478. export class DepthReducer extends MinMaxReducer {
  62479. private _depthRenderer;
  62480. private _depthRendererId;
  62481. /**
  62482. * Gets the depth renderer used for the computation.
  62483. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62484. */
  62485. get depthRenderer(): Nullable<DepthRenderer>;
  62486. /**
  62487. * Creates a depth reducer
  62488. * @param camera The camera used to render the depth texture
  62489. */
  62490. constructor(camera: Camera);
  62491. /**
  62492. * Sets the depth renderer to use to generate the depth map
  62493. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62494. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62495. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62496. */
  62497. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62498. /** @hidden */
  62499. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62500. /**
  62501. * Activates the reduction computation.
  62502. * When activated, the observers registered in onAfterReductionPerformed are
  62503. * called after the compuation is performed
  62504. */
  62505. activate(): void;
  62506. /**
  62507. * Deactivates the reduction computation.
  62508. */
  62509. deactivate(): void;
  62510. /**
  62511. * Disposes the depth reducer
  62512. * @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.
  62513. */
  62514. dispose(disposeAll?: boolean): void;
  62515. }
  62516. }
  62517. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62518. import { Nullable } from "babylonjs/types";
  62519. import { Scene } from "babylonjs/scene";
  62520. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62521. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62523. import { Effect } from "babylonjs/Materials/effect";
  62524. import "babylonjs/Shaders/shadowMap.fragment";
  62525. import "babylonjs/Shaders/shadowMap.vertex";
  62526. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62527. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62528. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62529. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62530. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62531. /**
  62532. * A CSM implementation allowing casting shadows on large scenes.
  62533. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62534. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62535. */
  62536. export class CascadedShadowGenerator extends ShadowGenerator {
  62537. private static readonly frustumCornersNDCSpace;
  62538. /**
  62539. * Name of the CSM class
  62540. */
  62541. static CLASSNAME: string;
  62542. /**
  62543. * Defines the default number of cascades used by the CSM.
  62544. */
  62545. static readonly DEFAULT_CASCADES_COUNT: number;
  62546. /**
  62547. * Defines the minimum number of cascades used by the CSM.
  62548. */
  62549. static readonly MIN_CASCADES_COUNT: number;
  62550. /**
  62551. * Defines the maximum number of cascades used by the CSM.
  62552. */
  62553. static readonly MAX_CASCADES_COUNT: number;
  62554. protected _validateFilter(filter: number): number;
  62555. /**
  62556. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62557. */
  62558. penumbraDarkness: number;
  62559. private _numCascades;
  62560. /**
  62561. * Gets or set the number of cascades used by the CSM.
  62562. */
  62563. get numCascades(): number;
  62564. set numCascades(value: number);
  62565. /**
  62566. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62567. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62568. */
  62569. stabilizeCascades: boolean;
  62570. private _freezeShadowCastersBoundingInfo;
  62571. private _freezeShadowCastersBoundingInfoObservable;
  62572. /**
  62573. * Enables or disables the shadow casters bounding info computation.
  62574. * If your shadow casters don't move, you can disable this feature.
  62575. * If it is enabled, the bounding box computation is done every frame.
  62576. */
  62577. get freezeShadowCastersBoundingInfo(): boolean;
  62578. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62579. private _scbiMin;
  62580. private _scbiMax;
  62581. protected _computeShadowCastersBoundingInfo(): void;
  62582. protected _shadowCastersBoundingInfo: BoundingInfo;
  62583. /**
  62584. * Gets or sets the shadow casters bounding info.
  62585. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62586. * so that the system won't overwrite the bounds you provide
  62587. */
  62588. get shadowCastersBoundingInfo(): BoundingInfo;
  62589. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62590. protected _breaksAreDirty: boolean;
  62591. protected _minDistance: number;
  62592. protected _maxDistance: number;
  62593. /**
  62594. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62595. *
  62596. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62597. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62598. * @param min minimal distance for the breaks (default to 0.)
  62599. * @param max maximal distance for the breaks (default to 1.)
  62600. */
  62601. setMinMaxDistance(min: number, max: number): void;
  62602. /** Gets the minimal distance used in the cascade break computation */
  62603. get minDistance(): number;
  62604. /** Gets the maximal distance used in the cascade break computation */
  62605. get maxDistance(): number;
  62606. /**
  62607. * Gets the class name of that object
  62608. * @returns "CascadedShadowGenerator"
  62609. */
  62610. getClassName(): string;
  62611. private _cascadeMinExtents;
  62612. private _cascadeMaxExtents;
  62613. /**
  62614. * Gets a cascade minimum extents
  62615. * @param cascadeIndex index of the cascade
  62616. * @returns the minimum cascade extents
  62617. */
  62618. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62619. /**
  62620. * Gets a cascade maximum extents
  62621. * @param cascadeIndex index of the cascade
  62622. * @returns the maximum cascade extents
  62623. */
  62624. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62625. private _cascades;
  62626. private _currentLayer;
  62627. private _viewSpaceFrustumsZ;
  62628. private _viewMatrices;
  62629. private _projectionMatrices;
  62630. private _transformMatrices;
  62631. private _transformMatricesAsArray;
  62632. private _frustumLengths;
  62633. private _lightSizeUVCorrection;
  62634. private _depthCorrection;
  62635. private _frustumCornersWorldSpace;
  62636. private _frustumCenter;
  62637. private _shadowCameraPos;
  62638. private _shadowMaxZ;
  62639. /**
  62640. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62641. * It defaults to camera.maxZ
  62642. */
  62643. get shadowMaxZ(): number;
  62644. /**
  62645. * Sets the shadow max z distance.
  62646. */
  62647. set shadowMaxZ(value: number);
  62648. protected _debug: boolean;
  62649. /**
  62650. * Gets or sets the debug flag.
  62651. * When enabled, the cascades are materialized by different colors on the screen.
  62652. */
  62653. get debug(): boolean;
  62654. set debug(dbg: boolean);
  62655. private _depthClamp;
  62656. /**
  62657. * Gets or sets the depth clamping value.
  62658. *
  62659. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62660. * to account for the shadow casters far away.
  62661. *
  62662. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62663. */
  62664. get depthClamp(): boolean;
  62665. set depthClamp(value: boolean);
  62666. private _cascadeBlendPercentage;
  62667. /**
  62668. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62669. * It defaults to 0.1 (10% blending).
  62670. */
  62671. get cascadeBlendPercentage(): number;
  62672. set cascadeBlendPercentage(value: number);
  62673. private _lambda;
  62674. /**
  62675. * Gets or set the lambda parameter.
  62676. * This parameter is used to split the camera frustum and create the cascades.
  62677. * 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.
  62678. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62679. */
  62680. get lambda(): number;
  62681. set lambda(value: number);
  62682. /**
  62683. * Gets the view matrix corresponding to a given cascade
  62684. * @param cascadeNum cascade to retrieve the view matrix from
  62685. * @returns the cascade view matrix
  62686. */
  62687. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62688. /**
  62689. * Gets the projection matrix corresponding to a given cascade
  62690. * @param cascadeNum cascade to retrieve the projection matrix from
  62691. * @returns the cascade projection matrix
  62692. */
  62693. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62694. /**
  62695. * Gets the transformation matrix corresponding to a given cascade
  62696. * @param cascadeNum cascade to retrieve the transformation matrix from
  62697. * @returns the cascade transformation matrix
  62698. */
  62699. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62700. private _depthRenderer;
  62701. /**
  62702. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62703. *
  62704. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62705. *
  62706. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62707. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62708. * @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
  62709. */
  62710. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62711. private _depthReducer;
  62712. private _autoCalcDepthBounds;
  62713. /**
  62714. * Gets or sets the autoCalcDepthBounds property.
  62715. *
  62716. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62717. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62718. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62719. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62720. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62721. */
  62722. get autoCalcDepthBounds(): boolean;
  62723. set autoCalcDepthBounds(value: boolean);
  62724. /**
  62725. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62726. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62727. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62728. * for setting the refresh rate on the renderer yourself!
  62729. */
  62730. get autoCalcDepthBoundsRefreshRate(): number;
  62731. set autoCalcDepthBoundsRefreshRate(value: number);
  62732. /**
  62733. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62734. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62735. * you change the camera near/far planes!
  62736. */
  62737. splitFrustum(): void;
  62738. private _splitFrustum;
  62739. private _computeMatrices;
  62740. private _computeFrustumInWorldSpace;
  62741. private _computeCascadeFrustum;
  62742. /**
  62743. * Support test.
  62744. */
  62745. static get IsSupported(): boolean;
  62746. /** @hidden */
  62747. static _SceneComponentInitialization: (scene: Scene) => void;
  62748. /**
  62749. * Creates a Cascaded Shadow Generator object.
  62750. * A ShadowGenerator is the required tool to use the shadows.
  62751. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62752. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62753. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62754. * @param light The directional light object generating the shadows.
  62755. * @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.
  62756. */
  62757. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62758. protected _initializeGenerator(): void;
  62759. protected _createTargetRenderTexture(): void;
  62760. protected _initializeShadowMap(): void;
  62761. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62762. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62763. /**
  62764. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62765. * @param defines Defines of the material we want to update
  62766. * @param lightIndex Index of the light in the enabled light list of the material
  62767. */
  62768. prepareDefines(defines: any, lightIndex: number): void;
  62769. /**
  62770. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62771. * defined in the generator but impacting the effect).
  62772. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62773. * @param effect The effect we are binfing the information for
  62774. */
  62775. bindShadowLight(lightIndex: string, effect: Effect): void;
  62776. /**
  62777. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62778. * (eq to view projection * shadow projection matrices)
  62779. * @returns The transform matrix used to create the shadow map
  62780. */
  62781. getTransformMatrix(): Matrix;
  62782. /**
  62783. * Disposes the ShadowGenerator.
  62784. * Returns nothing.
  62785. */
  62786. dispose(): void;
  62787. /**
  62788. * Serializes the shadow generator setup to a json object.
  62789. * @returns The serialized JSON object
  62790. */
  62791. serialize(): any;
  62792. /**
  62793. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62794. * @param parsedShadowGenerator The JSON object to parse
  62795. * @param scene The scene to create the shadow map for
  62796. * @returns The parsed shadow generator
  62797. */
  62798. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62799. }
  62800. }
  62801. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62802. import { Scene } from "babylonjs/scene";
  62803. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62804. import { AbstractScene } from "babylonjs/abstractScene";
  62805. /**
  62806. * Defines the shadow generator component responsible to manage any shadow generators
  62807. * in a given scene.
  62808. */
  62809. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62810. /**
  62811. * The component name helpfull to identify the component in the list of scene components.
  62812. */
  62813. readonly name: string;
  62814. /**
  62815. * The scene the component belongs to.
  62816. */
  62817. scene: Scene;
  62818. /**
  62819. * Creates a new instance of the component for the given scene
  62820. * @param scene Defines the scene to register the component in
  62821. */
  62822. constructor(scene: Scene);
  62823. /**
  62824. * Registers the component in a given scene
  62825. */
  62826. register(): void;
  62827. /**
  62828. * Rebuilds the elements related to this component in case of
  62829. * context lost for instance.
  62830. */
  62831. rebuild(): void;
  62832. /**
  62833. * Serializes the component data to the specified json object
  62834. * @param serializationObject The object to serialize to
  62835. */
  62836. serialize(serializationObject: any): void;
  62837. /**
  62838. * Adds all the elements from the container to the scene
  62839. * @param container the container holding the elements
  62840. */
  62841. addFromContainer(container: AbstractScene): void;
  62842. /**
  62843. * Removes all the elements in the container from the scene
  62844. * @param container contains the elements to remove
  62845. * @param dispose if the removed element should be disposed (default: false)
  62846. */
  62847. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62848. /**
  62849. * Rebuilds the elements related to this component in case of
  62850. * context lost for instance.
  62851. */
  62852. dispose(): void;
  62853. private _gatherRenderTargets;
  62854. }
  62855. }
  62856. declare module "babylonjs/Lights/Shadows/index" {
  62857. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62858. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62859. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62860. }
  62861. declare module "babylonjs/Lights/pointLight" {
  62862. import { Scene } from "babylonjs/scene";
  62863. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62865. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62866. import { Effect } from "babylonjs/Materials/effect";
  62867. /**
  62868. * A point light is a light defined by an unique point in world space.
  62869. * The light is emitted in every direction from this point.
  62870. * A good example of a point light is a standard light bulb.
  62871. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62872. */
  62873. export class PointLight extends ShadowLight {
  62874. private _shadowAngle;
  62875. /**
  62876. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62877. * This specifies what angle the shadow will use to be created.
  62878. *
  62879. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62880. */
  62881. get shadowAngle(): number;
  62882. /**
  62883. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62884. * This specifies what angle the shadow will use to be created.
  62885. *
  62886. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62887. */
  62888. set shadowAngle(value: number);
  62889. /**
  62890. * Gets the direction if it has been set.
  62891. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62892. */
  62893. get direction(): Vector3;
  62894. /**
  62895. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62896. */
  62897. set direction(value: Vector3);
  62898. /**
  62899. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  62900. * A PointLight emits the light in every direction.
  62901. * It can cast shadows.
  62902. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  62903. * ```javascript
  62904. * var pointLight = new PointLight("pl", camera.position, scene);
  62905. * ```
  62906. * Documentation : https://doc.babylonjs.com/babylon101/lights
  62907. * @param name The light friendly name
  62908. * @param position The position of the point light in the scene
  62909. * @param scene The scene the lights belongs to
  62910. */
  62911. constructor(name: string, position: Vector3, scene: Scene);
  62912. /**
  62913. * Returns the string "PointLight"
  62914. * @returns the class name
  62915. */
  62916. getClassName(): string;
  62917. /**
  62918. * Returns the integer 0.
  62919. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  62920. */
  62921. getTypeID(): number;
  62922. /**
  62923. * Specifies wether or not the shadowmap should be a cube texture.
  62924. * @returns true if the shadowmap needs to be a cube texture.
  62925. */
  62926. needCube(): boolean;
  62927. /**
  62928. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  62929. * @param faceIndex The index of the face we are computed the direction to generate shadow
  62930. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  62931. */
  62932. getShadowDirection(faceIndex?: number): Vector3;
  62933. /**
  62934. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  62935. * - fov = PI / 2
  62936. * - aspect ratio : 1.0
  62937. * - z-near and far equal to the active camera minZ and maxZ.
  62938. * Returns the PointLight.
  62939. */
  62940. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  62941. protected _buildUniformLayout(): void;
  62942. /**
  62943. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  62944. * @param effect The effect to update
  62945. * @param lightIndex The index of the light in the effect to update
  62946. * @returns The point light
  62947. */
  62948. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  62949. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  62950. /**
  62951. * Prepares the list of defines specific to the light type.
  62952. * @param defines the list of defines
  62953. * @param lightIndex defines the index of the light for the effect
  62954. */
  62955. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  62956. }
  62957. }
  62958. declare module "babylonjs/Lights/index" {
  62959. export * from "babylonjs/Lights/light";
  62960. export * from "babylonjs/Lights/shadowLight";
  62961. export * from "babylonjs/Lights/Shadows/index";
  62962. export * from "babylonjs/Lights/directionalLight";
  62963. export * from "babylonjs/Lights/hemisphericLight";
  62964. export * from "babylonjs/Lights/pointLight";
  62965. export * from "babylonjs/Lights/spotLight";
  62966. }
  62967. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  62968. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62969. /**
  62970. * Header information of HDR texture files.
  62971. */
  62972. export interface HDRInfo {
  62973. /**
  62974. * The height of the texture in pixels.
  62975. */
  62976. height: number;
  62977. /**
  62978. * The width of the texture in pixels.
  62979. */
  62980. width: number;
  62981. /**
  62982. * The index of the beginning of the data in the binary file.
  62983. */
  62984. dataPosition: number;
  62985. }
  62986. /**
  62987. * This groups tools to convert HDR texture to native colors array.
  62988. */
  62989. export class HDRTools {
  62990. private static Ldexp;
  62991. private static Rgbe2float;
  62992. private static readStringLine;
  62993. /**
  62994. * Reads header information from an RGBE texture stored in a native array.
  62995. * More information on this format are available here:
  62996. * https://en.wikipedia.org/wiki/RGBE_image_format
  62997. *
  62998. * @param uint8array The binary file stored in native array.
  62999. * @return The header information.
  63000. */
  63001. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63002. /**
  63003. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63004. * This RGBE texture needs to store the information as a panorama.
  63005. *
  63006. * More information on this format are available here:
  63007. * https://en.wikipedia.org/wiki/RGBE_image_format
  63008. *
  63009. * @param buffer The binary file stored in an array buffer.
  63010. * @param size The expected size of the extracted cubemap.
  63011. * @return The Cube Map information.
  63012. */
  63013. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63014. /**
  63015. * Returns the pixels data extracted from an RGBE texture.
  63016. * This pixels will be stored left to right up to down in the R G B order in one array.
  63017. *
  63018. * More information on this format are available here:
  63019. * https://en.wikipedia.org/wiki/RGBE_image_format
  63020. *
  63021. * @param uint8array The binary file stored in an array buffer.
  63022. * @param hdrInfo The header information of the file.
  63023. * @return The pixels data in RGB right to left up to down order.
  63024. */
  63025. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63026. private static RGBE_ReadPixels_RLE;
  63027. private static RGBE_ReadPixels_NOT_RLE;
  63028. }
  63029. }
  63030. declare module "babylonjs/Materials/effectRenderer" {
  63031. import { Nullable } from "babylonjs/types";
  63032. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63033. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63034. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63035. import { Viewport } from "babylonjs/Maths/math.viewport";
  63036. import { Observable } from "babylonjs/Misc/observable";
  63037. import { Effect } from "babylonjs/Materials/effect";
  63038. import "babylonjs/Shaders/postprocess.vertex";
  63039. /**
  63040. * Effect Render Options
  63041. */
  63042. export interface IEffectRendererOptions {
  63043. /**
  63044. * Defines the vertices positions.
  63045. */
  63046. positions?: number[];
  63047. /**
  63048. * Defines the indices.
  63049. */
  63050. indices?: number[];
  63051. }
  63052. /**
  63053. * Helper class to render one or more effects.
  63054. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63055. */
  63056. export class EffectRenderer {
  63057. private engine;
  63058. private static _DefaultOptions;
  63059. private _vertexBuffers;
  63060. private _indexBuffer;
  63061. private _fullscreenViewport;
  63062. /**
  63063. * Creates an effect renderer
  63064. * @param engine the engine to use for rendering
  63065. * @param options defines the options of the effect renderer
  63066. */
  63067. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63068. /**
  63069. * Sets the current viewport in normalized coordinates 0-1
  63070. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63071. */
  63072. setViewport(viewport?: Viewport): void;
  63073. /**
  63074. * Binds the embedded attributes buffer to the effect.
  63075. * @param effect Defines the effect to bind the attributes for
  63076. */
  63077. bindBuffers(effect: Effect): void;
  63078. /**
  63079. * Sets the current effect wrapper to use during draw.
  63080. * The effect needs to be ready before calling this api.
  63081. * This also sets the default full screen position attribute.
  63082. * @param effectWrapper Defines the effect to draw with
  63083. */
  63084. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63085. /**
  63086. * Restores engine states
  63087. */
  63088. restoreStates(): void;
  63089. /**
  63090. * Draws a full screen quad.
  63091. */
  63092. draw(): void;
  63093. private isRenderTargetTexture;
  63094. /**
  63095. * renders one or more effects to a specified texture
  63096. * @param effectWrapper the effect to renderer
  63097. * @param outputTexture texture to draw to, if null it will render to the screen.
  63098. */
  63099. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63100. /**
  63101. * Disposes of the effect renderer
  63102. */
  63103. dispose(): void;
  63104. }
  63105. /**
  63106. * Options to create an EffectWrapper
  63107. */
  63108. interface EffectWrapperCreationOptions {
  63109. /**
  63110. * Engine to use to create the effect
  63111. */
  63112. engine: ThinEngine;
  63113. /**
  63114. * Fragment shader for the effect
  63115. */
  63116. fragmentShader: string;
  63117. /**
  63118. * Use the shader store instead of direct source code
  63119. */
  63120. useShaderStore?: boolean;
  63121. /**
  63122. * Vertex shader for the effect
  63123. */
  63124. vertexShader?: string;
  63125. /**
  63126. * Attributes to use in the shader
  63127. */
  63128. attributeNames?: Array<string>;
  63129. /**
  63130. * Uniforms to use in the shader
  63131. */
  63132. uniformNames?: Array<string>;
  63133. /**
  63134. * Texture sampler names to use in the shader
  63135. */
  63136. samplerNames?: Array<string>;
  63137. /**
  63138. * Defines to use in the shader
  63139. */
  63140. defines?: Array<string>;
  63141. /**
  63142. * Callback when effect is compiled
  63143. */
  63144. onCompiled?: Nullable<(effect: Effect) => void>;
  63145. /**
  63146. * The friendly name of the effect displayed in Spector.
  63147. */
  63148. name?: string;
  63149. }
  63150. /**
  63151. * Wraps an effect to be used for rendering
  63152. */
  63153. export class EffectWrapper {
  63154. /**
  63155. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63156. */
  63157. onApplyObservable: Observable<{}>;
  63158. /**
  63159. * The underlying effect
  63160. */
  63161. effect: Effect;
  63162. /**
  63163. * Creates an effect to be renderer
  63164. * @param creationOptions options to create the effect
  63165. */
  63166. constructor(creationOptions: EffectWrapperCreationOptions);
  63167. /**
  63168. * Disposes of the effect wrapper
  63169. */
  63170. dispose(): void;
  63171. }
  63172. }
  63173. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63174. /** @hidden */
  63175. export var hdrFilteringVertexShader: {
  63176. name: string;
  63177. shader: string;
  63178. };
  63179. }
  63180. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63181. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63182. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63183. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63184. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63185. /** @hidden */
  63186. export var hdrFilteringPixelShader: {
  63187. name: string;
  63188. shader: string;
  63189. };
  63190. }
  63191. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63192. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63193. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63194. import { Nullable } from "babylonjs/types";
  63195. import "babylonjs/Shaders/hdrFiltering.vertex";
  63196. import "babylonjs/Shaders/hdrFiltering.fragment";
  63197. /**
  63198. * Options for texture filtering
  63199. */
  63200. interface IHDRFilteringOptions {
  63201. /**
  63202. * Scales pixel intensity for the input HDR map.
  63203. */
  63204. hdrScale?: number;
  63205. /**
  63206. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63207. */
  63208. quality?: number;
  63209. }
  63210. /**
  63211. * Filters HDR maps to get correct renderings of PBR reflections
  63212. */
  63213. export class HDRFiltering {
  63214. private _engine;
  63215. private _effectRenderer;
  63216. private _effectWrapper;
  63217. private _lodGenerationOffset;
  63218. private _lodGenerationScale;
  63219. /**
  63220. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63221. * you care about baking speed.
  63222. */
  63223. quality: number;
  63224. /**
  63225. * Scales pixel intensity for the input HDR map.
  63226. */
  63227. hdrScale: number;
  63228. /**
  63229. * Instantiates HDR filter for reflection maps
  63230. *
  63231. * @param engine Thin engine
  63232. * @param options Options
  63233. */
  63234. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63235. private _createRenderTarget;
  63236. private _prefilterInternal;
  63237. private _createEffect;
  63238. /**
  63239. * Get a value indicating if the filter is ready to be used
  63240. * @param texture Texture to filter
  63241. * @returns true if the filter is ready
  63242. */
  63243. isReady(texture: BaseTexture): boolean;
  63244. /**
  63245. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63246. * Prefiltering will be invoked at the end of next rendering pass.
  63247. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63248. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63249. * @param texture Texture to filter
  63250. * @param onFinished Callback when filtering is done
  63251. * @return Promise called when prefiltering is done
  63252. */
  63253. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63254. }
  63255. }
  63256. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63257. import { Nullable } from "babylonjs/types";
  63258. import { Scene } from "babylonjs/scene";
  63259. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63260. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63261. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63262. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63263. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63264. /**
  63265. * This represents a texture coming from an HDR input.
  63266. *
  63267. * The only supported format is currently panorama picture stored in RGBE format.
  63268. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63269. */
  63270. export class HDRCubeTexture extends BaseTexture {
  63271. private static _facesMapping;
  63272. private _generateHarmonics;
  63273. private _noMipmap;
  63274. private _prefilterOnLoad;
  63275. private _textureMatrix;
  63276. private _size;
  63277. private _onLoad;
  63278. private _onError;
  63279. /**
  63280. * The texture URL.
  63281. */
  63282. url: string;
  63283. protected _isBlocking: boolean;
  63284. /**
  63285. * Sets wether or not the texture is blocking during loading.
  63286. */
  63287. set isBlocking(value: boolean);
  63288. /**
  63289. * Gets wether or not the texture is blocking during loading.
  63290. */
  63291. get isBlocking(): boolean;
  63292. protected _rotationY: number;
  63293. /**
  63294. * Sets texture matrix rotation angle around Y axis in radians.
  63295. */
  63296. set rotationY(value: number);
  63297. /**
  63298. * Gets texture matrix rotation angle around Y axis radians.
  63299. */
  63300. get rotationY(): number;
  63301. /**
  63302. * Gets or sets the center of the bounding box associated with the cube texture
  63303. * It must define where the camera used to render the texture was set
  63304. */
  63305. boundingBoxPosition: Vector3;
  63306. private _boundingBoxSize;
  63307. /**
  63308. * Gets or sets the size of the bounding box associated with the cube texture
  63309. * When defined, the cubemap will switch to local mode
  63310. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63311. * @example https://www.babylonjs-playground.com/#RNASML
  63312. */
  63313. set boundingBoxSize(value: Vector3);
  63314. get boundingBoxSize(): Vector3;
  63315. /**
  63316. * Instantiates an HDRTexture from the following parameters.
  63317. *
  63318. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63319. * @param sceneOrEngine The scene or engine the texture will be used in
  63320. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63321. * @param noMipmap Forces to not generate the mipmap if true
  63322. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63323. * @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)
  63324. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63325. */
  63326. 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>);
  63327. /**
  63328. * Get the current class name of the texture useful for serialization or dynamic coding.
  63329. * @returns "HDRCubeTexture"
  63330. */
  63331. getClassName(): string;
  63332. /**
  63333. * Occurs when the file is raw .hdr file.
  63334. */
  63335. private loadTexture;
  63336. clone(): HDRCubeTexture;
  63337. delayLoad(): void;
  63338. /**
  63339. * Get the texture reflection matrix used to rotate/transform the reflection.
  63340. * @returns the reflection matrix
  63341. */
  63342. getReflectionTextureMatrix(): Matrix;
  63343. /**
  63344. * Set the texture reflection matrix used to rotate/transform the reflection.
  63345. * @param value Define the reflection matrix to set
  63346. */
  63347. setReflectionTextureMatrix(value: Matrix): void;
  63348. /**
  63349. * Parses a JSON representation of an HDR Texture in order to create the texture
  63350. * @param parsedTexture Define the JSON representation
  63351. * @param scene Define the scene the texture should be created in
  63352. * @param rootUrl Define the root url in case we need to load relative dependencies
  63353. * @returns the newly created texture after parsing
  63354. */
  63355. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63356. serialize(): any;
  63357. }
  63358. }
  63359. declare module "babylonjs/Physics/physicsEngine" {
  63360. import { Nullable } from "babylonjs/types";
  63361. import { Vector3 } from "babylonjs/Maths/math.vector";
  63362. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63363. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63364. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63365. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63366. /**
  63367. * Class used to control physics engine
  63368. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63369. */
  63370. export class PhysicsEngine implements IPhysicsEngine {
  63371. private _physicsPlugin;
  63372. /**
  63373. * Global value used to control the smallest number supported by the simulation
  63374. */
  63375. static Epsilon: number;
  63376. private _impostors;
  63377. private _joints;
  63378. private _subTimeStep;
  63379. /**
  63380. * Gets the gravity vector used by the simulation
  63381. */
  63382. gravity: Vector3;
  63383. /**
  63384. * Factory used to create the default physics plugin.
  63385. * @returns The default physics plugin
  63386. */
  63387. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63388. /**
  63389. * Creates a new Physics Engine
  63390. * @param gravity defines the gravity vector used by the simulation
  63391. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63392. */
  63393. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63394. /**
  63395. * Sets the gravity vector used by the simulation
  63396. * @param gravity defines the gravity vector to use
  63397. */
  63398. setGravity(gravity: Vector3): void;
  63399. /**
  63400. * Set the time step of the physics engine.
  63401. * Default is 1/60.
  63402. * To slow it down, enter 1/600 for example.
  63403. * To speed it up, 1/30
  63404. * @param newTimeStep defines the new timestep to apply to this world.
  63405. */
  63406. setTimeStep(newTimeStep?: number): void;
  63407. /**
  63408. * Get the time step of the physics engine.
  63409. * @returns the current time step
  63410. */
  63411. getTimeStep(): number;
  63412. /**
  63413. * Set the sub time step of the physics engine.
  63414. * Default is 0 meaning there is no sub steps
  63415. * To increase physics resolution precision, set a small value (like 1 ms)
  63416. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63417. */
  63418. setSubTimeStep(subTimeStep?: number): void;
  63419. /**
  63420. * Get the sub time step of the physics engine.
  63421. * @returns the current sub time step
  63422. */
  63423. getSubTimeStep(): number;
  63424. /**
  63425. * Release all resources
  63426. */
  63427. dispose(): void;
  63428. /**
  63429. * Gets the name of the current physics plugin
  63430. * @returns the name of the plugin
  63431. */
  63432. getPhysicsPluginName(): string;
  63433. /**
  63434. * Adding a new impostor for the impostor tracking.
  63435. * This will be done by the impostor itself.
  63436. * @param impostor the impostor to add
  63437. */
  63438. addImpostor(impostor: PhysicsImpostor): void;
  63439. /**
  63440. * Remove an impostor from the engine.
  63441. * This impostor and its mesh will not longer be updated by the physics engine.
  63442. * @param impostor the impostor to remove
  63443. */
  63444. removeImpostor(impostor: PhysicsImpostor): void;
  63445. /**
  63446. * Add a joint to the physics engine
  63447. * @param mainImpostor defines the main impostor to which the joint is added.
  63448. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63449. * @param joint defines the joint that will connect both impostors.
  63450. */
  63451. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63452. /**
  63453. * Removes a joint from the simulation
  63454. * @param mainImpostor defines the impostor used with the joint
  63455. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63456. * @param joint defines the joint to remove
  63457. */
  63458. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63459. /**
  63460. * Called by the scene. No need to call it.
  63461. * @param delta defines the timespam between frames
  63462. */
  63463. _step(delta: number): void;
  63464. /**
  63465. * Gets the current plugin used to run the simulation
  63466. * @returns current plugin
  63467. */
  63468. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63469. /**
  63470. * Gets the list of physic impostors
  63471. * @returns an array of PhysicsImpostor
  63472. */
  63473. getImpostors(): Array<PhysicsImpostor>;
  63474. /**
  63475. * Gets the impostor for a physics enabled object
  63476. * @param object defines the object impersonated by the impostor
  63477. * @returns the PhysicsImpostor or null if not found
  63478. */
  63479. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63480. /**
  63481. * Gets the impostor for a physics body object
  63482. * @param body defines physics body used by the impostor
  63483. * @returns the PhysicsImpostor or null if not found
  63484. */
  63485. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63486. /**
  63487. * Does a raycast in the physics world
  63488. * @param from when should the ray start?
  63489. * @param to when should the ray end?
  63490. * @returns PhysicsRaycastResult
  63491. */
  63492. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63493. }
  63494. }
  63495. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63496. import { Nullable } from "babylonjs/types";
  63497. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63499. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63500. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63501. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63502. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63503. /** @hidden */
  63504. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63505. private _useDeltaForWorldStep;
  63506. world: any;
  63507. name: string;
  63508. private _physicsMaterials;
  63509. private _fixedTimeStep;
  63510. private _cannonRaycastResult;
  63511. private _raycastResult;
  63512. private _physicsBodysToRemoveAfterStep;
  63513. private _firstFrame;
  63514. BJSCANNON: any;
  63515. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63516. setGravity(gravity: Vector3): void;
  63517. setTimeStep(timeStep: number): void;
  63518. getTimeStep(): number;
  63519. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63520. private _removeMarkedPhysicsBodiesFromWorld;
  63521. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63522. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63523. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63524. private _processChildMeshes;
  63525. removePhysicsBody(impostor: PhysicsImpostor): void;
  63526. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63527. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63528. private _addMaterial;
  63529. private _checkWithEpsilon;
  63530. private _createShape;
  63531. private _createHeightmap;
  63532. private _minus90X;
  63533. private _plus90X;
  63534. private _tmpPosition;
  63535. private _tmpDeltaPosition;
  63536. private _tmpUnityRotation;
  63537. private _updatePhysicsBodyTransformation;
  63538. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63539. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63540. isSupported(): boolean;
  63541. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63542. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63543. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63544. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63545. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63546. getBodyMass(impostor: PhysicsImpostor): number;
  63547. getBodyFriction(impostor: PhysicsImpostor): number;
  63548. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63549. getBodyRestitution(impostor: PhysicsImpostor): number;
  63550. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63551. sleepBody(impostor: PhysicsImpostor): void;
  63552. wakeUpBody(impostor: PhysicsImpostor): void;
  63553. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63554. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63555. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63556. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63557. getRadius(impostor: PhysicsImpostor): number;
  63558. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63559. dispose(): void;
  63560. private _extendNamespace;
  63561. /**
  63562. * Does a raycast in the physics world
  63563. * @param from when should the ray start?
  63564. * @param to when should the ray end?
  63565. * @returns PhysicsRaycastResult
  63566. */
  63567. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63568. }
  63569. }
  63570. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63571. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63572. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63573. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63575. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63576. import { Nullable } from "babylonjs/types";
  63577. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63578. /** @hidden */
  63579. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63580. private _useDeltaForWorldStep;
  63581. world: any;
  63582. name: string;
  63583. BJSOIMO: any;
  63584. private _raycastResult;
  63585. private _fixedTimeStep;
  63586. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63587. setGravity(gravity: Vector3): void;
  63588. setTimeStep(timeStep: number): void;
  63589. getTimeStep(): number;
  63590. private _tmpImpostorsArray;
  63591. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63592. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63593. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63594. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63595. private _tmpPositionVector;
  63596. removePhysicsBody(impostor: PhysicsImpostor): void;
  63597. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63598. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63599. isSupported(): boolean;
  63600. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63601. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63602. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63603. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63604. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63605. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63606. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63607. getBodyMass(impostor: PhysicsImpostor): number;
  63608. getBodyFriction(impostor: PhysicsImpostor): number;
  63609. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63610. getBodyRestitution(impostor: PhysicsImpostor): number;
  63611. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63612. sleepBody(impostor: PhysicsImpostor): void;
  63613. wakeUpBody(impostor: PhysicsImpostor): void;
  63614. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63615. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63616. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63617. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63618. getRadius(impostor: PhysicsImpostor): number;
  63619. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63620. dispose(): void;
  63621. /**
  63622. * Does a raycast in the physics world
  63623. * @param from when should the ray start?
  63624. * @param to when should the ray end?
  63625. * @returns PhysicsRaycastResult
  63626. */
  63627. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63628. }
  63629. }
  63630. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63631. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63632. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63633. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63634. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63635. import { Nullable } from "babylonjs/types";
  63636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63637. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63638. /**
  63639. * AmmoJS Physics plugin
  63640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63641. * @see https://github.com/kripken/ammo.js/
  63642. */
  63643. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63644. private _useDeltaForWorldStep;
  63645. /**
  63646. * Reference to the Ammo library
  63647. */
  63648. bjsAMMO: any;
  63649. /**
  63650. * Created ammoJS world which physics bodies are added to
  63651. */
  63652. world: any;
  63653. /**
  63654. * Name of the plugin
  63655. */
  63656. name: string;
  63657. private _timeStep;
  63658. private _fixedTimeStep;
  63659. private _maxSteps;
  63660. private _tmpQuaternion;
  63661. private _tmpAmmoTransform;
  63662. private _tmpAmmoQuaternion;
  63663. private _tmpAmmoConcreteContactResultCallback;
  63664. private _collisionConfiguration;
  63665. private _dispatcher;
  63666. private _overlappingPairCache;
  63667. private _solver;
  63668. private _softBodySolver;
  63669. private _tmpAmmoVectorA;
  63670. private _tmpAmmoVectorB;
  63671. private _tmpAmmoVectorC;
  63672. private _tmpAmmoVectorD;
  63673. private _tmpContactCallbackResult;
  63674. private _tmpAmmoVectorRCA;
  63675. private _tmpAmmoVectorRCB;
  63676. private _raycastResult;
  63677. private static readonly DISABLE_COLLISION_FLAG;
  63678. private static readonly KINEMATIC_FLAG;
  63679. private static readonly DISABLE_DEACTIVATION_FLAG;
  63680. /**
  63681. * Initializes the ammoJS plugin
  63682. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63683. * @param ammoInjection can be used to inject your own ammo reference
  63684. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63685. */
  63686. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63687. /**
  63688. * Sets the gravity of the physics world (m/(s^2))
  63689. * @param gravity Gravity to set
  63690. */
  63691. setGravity(gravity: Vector3): void;
  63692. /**
  63693. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63694. * @param timeStep timestep to use in seconds
  63695. */
  63696. setTimeStep(timeStep: number): void;
  63697. /**
  63698. * 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)
  63699. * @param fixedTimeStep fixedTimeStep to use in seconds
  63700. */
  63701. setFixedTimeStep(fixedTimeStep: number): void;
  63702. /**
  63703. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63704. * @param maxSteps the maximum number of steps by the physics engine per frame
  63705. */
  63706. setMaxSteps(maxSteps: number): void;
  63707. /**
  63708. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63709. * @returns the current timestep in seconds
  63710. */
  63711. getTimeStep(): number;
  63712. /**
  63713. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63714. */
  63715. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63716. private _isImpostorInContact;
  63717. private _isImpostorPairInContact;
  63718. private _stepSimulation;
  63719. /**
  63720. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63721. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63722. * After the step the babylon meshes are set to the position of the physics imposters
  63723. * @param delta amount of time to step forward
  63724. * @param impostors array of imposters to update before/after the step
  63725. */
  63726. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63727. /**
  63728. * Update babylon mesh to match physics world object
  63729. * @param impostor imposter to match
  63730. */
  63731. private _afterSoftStep;
  63732. /**
  63733. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63734. * @param impostor imposter to match
  63735. */
  63736. private _ropeStep;
  63737. /**
  63738. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63739. * @param impostor imposter to match
  63740. */
  63741. private _softbodyOrClothStep;
  63742. private _tmpMatrix;
  63743. /**
  63744. * Applies an impulse on the imposter
  63745. * @param impostor imposter to apply impulse to
  63746. * @param force amount of force to be applied to the imposter
  63747. * @param contactPoint the location to apply the impulse on the imposter
  63748. */
  63749. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63750. /**
  63751. * Applies a force on the imposter
  63752. * @param impostor imposter to apply force
  63753. * @param force amount of force to be applied to the imposter
  63754. * @param contactPoint the location to apply the force on the imposter
  63755. */
  63756. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63757. /**
  63758. * Creates a physics body using the plugin
  63759. * @param impostor the imposter to create the physics body on
  63760. */
  63761. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63762. /**
  63763. * Removes the physics body from the imposter and disposes of the body's memory
  63764. * @param impostor imposter to remove the physics body from
  63765. */
  63766. removePhysicsBody(impostor: PhysicsImpostor): void;
  63767. /**
  63768. * Generates a joint
  63769. * @param impostorJoint the imposter joint to create the joint with
  63770. */
  63771. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63772. /**
  63773. * Removes a joint
  63774. * @param impostorJoint the imposter joint to remove the joint from
  63775. */
  63776. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63777. private _addMeshVerts;
  63778. /**
  63779. * Initialise the soft body vertices to match its object's (mesh) vertices
  63780. * Softbody vertices (nodes) are in world space and to match this
  63781. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63782. * @param impostor to create the softbody for
  63783. */
  63784. private _softVertexData;
  63785. /**
  63786. * Create an impostor's soft body
  63787. * @param impostor to create the softbody for
  63788. */
  63789. private _createSoftbody;
  63790. /**
  63791. * Create cloth for an impostor
  63792. * @param impostor to create the softbody for
  63793. */
  63794. private _createCloth;
  63795. /**
  63796. * Create rope for an impostor
  63797. * @param impostor to create the softbody for
  63798. */
  63799. private _createRope;
  63800. /**
  63801. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63802. * @param impostor to create the custom physics shape for
  63803. */
  63804. private _createCustom;
  63805. private _addHullVerts;
  63806. private _createShape;
  63807. /**
  63808. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63809. * @param impostor imposter containing the physics body and babylon object
  63810. */
  63811. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63812. /**
  63813. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63814. * @param impostor imposter containing the physics body and babylon object
  63815. * @param newPosition new position
  63816. * @param newRotation new rotation
  63817. */
  63818. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63819. /**
  63820. * If this plugin is supported
  63821. * @returns true if its supported
  63822. */
  63823. isSupported(): boolean;
  63824. /**
  63825. * Sets the linear velocity of the physics body
  63826. * @param impostor imposter to set the velocity on
  63827. * @param velocity velocity to set
  63828. */
  63829. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63830. /**
  63831. * Sets the angular velocity of the physics body
  63832. * @param impostor imposter to set the velocity on
  63833. * @param velocity velocity to set
  63834. */
  63835. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63836. /**
  63837. * gets the linear velocity
  63838. * @param impostor imposter to get linear velocity from
  63839. * @returns linear velocity
  63840. */
  63841. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63842. /**
  63843. * gets the angular velocity
  63844. * @param impostor imposter to get angular velocity from
  63845. * @returns angular velocity
  63846. */
  63847. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63848. /**
  63849. * Sets the mass of physics body
  63850. * @param impostor imposter to set the mass on
  63851. * @param mass mass to set
  63852. */
  63853. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63854. /**
  63855. * Gets the mass of the physics body
  63856. * @param impostor imposter to get the mass from
  63857. * @returns mass
  63858. */
  63859. getBodyMass(impostor: PhysicsImpostor): number;
  63860. /**
  63861. * Gets friction of the impostor
  63862. * @param impostor impostor to get friction from
  63863. * @returns friction value
  63864. */
  63865. getBodyFriction(impostor: PhysicsImpostor): number;
  63866. /**
  63867. * Sets friction of the impostor
  63868. * @param impostor impostor to set friction on
  63869. * @param friction friction value
  63870. */
  63871. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63872. /**
  63873. * Gets restitution of the impostor
  63874. * @param impostor impostor to get restitution from
  63875. * @returns restitution value
  63876. */
  63877. getBodyRestitution(impostor: PhysicsImpostor): number;
  63878. /**
  63879. * Sets resitution of the impostor
  63880. * @param impostor impostor to set resitution on
  63881. * @param restitution resitution value
  63882. */
  63883. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63884. /**
  63885. * Gets pressure inside the impostor
  63886. * @param impostor impostor to get pressure from
  63887. * @returns pressure value
  63888. */
  63889. getBodyPressure(impostor: PhysicsImpostor): number;
  63890. /**
  63891. * Sets pressure inside a soft body impostor
  63892. * Cloth and rope must remain 0 pressure
  63893. * @param impostor impostor to set pressure on
  63894. * @param pressure pressure value
  63895. */
  63896. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  63897. /**
  63898. * Gets stiffness of the impostor
  63899. * @param impostor impostor to get stiffness from
  63900. * @returns pressure value
  63901. */
  63902. getBodyStiffness(impostor: PhysicsImpostor): number;
  63903. /**
  63904. * Sets stiffness of the impostor
  63905. * @param impostor impostor to set stiffness on
  63906. * @param stiffness stiffness value from 0 to 1
  63907. */
  63908. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  63909. /**
  63910. * Gets velocityIterations of the impostor
  63911. * @param impostor impostor to get velocity iterations from
  63912. * @returns velocityIterations value
  63913. */
  63914. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  63915. /**
  63916. * Sets velocityIterations of the impostor
  63917. * @param impostor impostor to set velocity iterations on
  63918. * @param velocityIterations velocityIterations value
  63919. */
  63920. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  63921. /**
  63922. * Gets positionIterations of the impostor
  63923. * @param impostor impostor to get position iterations from
  63924. * @returns positionIterations value
  63925. */
  63926. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  63927. /**
  63928. * Sets positionIterations of the impostor
  63929. * @param impostor impostor to set position on
  63930. * @param positionIterations positionIterations value
  63931. */
  63932. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  63933. /**
  63934. * Append an anchor to a cloth object
  63935. * @param impostor is the cloth impostor to add anchor to
  63936. * @param otherImpostor is the rigid impostor to anchor to
  63937. * @param width ratio across width from 0 to 1
  63938. * @param height ratio up height from 0 to 1
  63939. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  63940. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63941. */
  63942. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63943. /**
  63944. * Append an hook to a rope object
  63945. * @param impostor is the rope impostor to add hook to
  63946. * @param otherImpostor is the rigid impostor to hook to
  63947. * @param length ratio along the rope from 0 to 1
  63948. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  63949. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63950. */
  63951. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63952. /**
  63953. * Sleeps the physics body and stops it from being active
  63954. * @param impostor impostor to sleep
  63955. */
  63956. sleepBody(impostor: PhysicsImpostor): void;
  63957. /**
  63958. * Activates the physics body
  63959. * @param impostor impostor to activate
  63960. */
  63961. wakeUpBody(impostor: PhysicsImpostor): void;
  63962. /**
  63963. * Updates the distance parameters of the joint
  63964. * @param joint joint to update
  63965. * @param maxDistance maximum distance of the joint
  63966. * @param minDistance minimum distance of the joint
  63967. */
  63968. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63969. /**
  63970. * Sets a motor on the joint
  63971. * @param joint joint to set motor on
  63972. * @param speed speed of the motor
  63973. * @param maxForce maximum force of the motor
  63974. * @param motorIndex index of the motor
  63975. */
  63976. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63977. /**
  63978. * Sets the motors limit
  63979. * @param joint joint to set limit on
  63980. * @param upperLimit upper limit
  63981. * @param lowerLimit lower limit
  63982. */
  63983. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63984. /**
  63985. * Syncs the position and rotation of a mesh with the impostor
  63986. * @param mesh mesh to sync
  63987. * @param impostor impostor to update the mesh with
  63988. */
  63989. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63990. /**
  63991. * Gets the radius of the impostor
  63992. * @param impostor impostor to get radius from
  63993. * @returns the radius
  63994. */
  63995. getRadius(impostor: PhysicsImpostor): number;
  63996. /**
  63997. * Gets the box size of the impostor
  63998. * @param impostor impostor to get box size from
  63999. * @param result the resulting box size
  64000. */
  64001. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64002. /**
  64003. * Disposes of the impostor
  64004. */
  64005. dispose(): void;
  64006. /**
  64007. * Does a raycast in the physics world
  64008. * @param from when should the ray start?
  64009. * @param to when should the ray end?
  64010. * @returns PhysicsRaycastResult
  64011. */
  64012. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64013. }
  64014. }
  64015. declare module "babylonjs/Probes/reflectionProbe" {
  64016. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64017. import { Vector3 } from "babylonjs/Maths/math.vector";
  64018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64019. import { Nullable } from "babylonjs/types";
  64020. import { Scene } from "babylonjs/scene";
  64021. module "babylonjs/abstractScene" {
  64022. interface AbstractScene {
  64023. /**
  64024. * The list of reflection probes added to the scene
  64025. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64026. */
  64027. reflectionProbes: Array<ReflectionProbe>;
  64028. /**
  64029. * Removes the given reflection probe from this scene.
  64030. * @param toRemove The reflection probe to remove
  64031. * @returns The index of the removed reflection probe
  64032. */
  64033. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64034. /**
  64035. * Adds the given reflection probe to this scene.
  64036. * @param newReflectionProbe The reflection probe to add
  64037. */
  64038. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64039. }
  64040. }
  64041. /**
  64042. * Class used to generate realtime reflection / refraction cube textures
  64043. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64044. */
  64045. export class ReflectionProbe {
  64046. /** defines the name of the probe */
  64047. name: string;
  64048. private _scene;
  64049. private _renderTargetTexture;
  64050. private _projectionMatrix;
  64051. private _viewMatrix;
  64052. private _target;
  64053. private _add;
  64054. private _attachedMesh;
  64055. private _invertYAxis;
  64056. /** Gets or sets probe position (center of the cube map) */
  64057. position: Vector3;
  64058. /**
  64059. * Creates a new reflection probe
  64060. * @param name defines the name of the probe
  64061. * @param size defines the texture resolution (for each face)
  64062. * @param scene defines the hosting scene
  64063. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64064. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64065. */
  64066. constructor(
  64067. /** defines the name of the probe */
  64068. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64069. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64070. get samples(): number;
  64071. set samples(value: number);
  64072. /** Gets or sets the refresh rate to use (on every frame by default) */
  64073. get refreshRate(): number;
  64074. set refreshRate(value: number);
  64075. /**
  64076. * Gets the hosting scene
  64077. * @returns a Scene
  64078. */
  64079. getScene(): Scene;
  64080. /** Gets the internal CubeTexture used to render to */
  64081. get cubeTexture(): RenderTargetTexture;
  64082. /** Gets the list of meshes to render */
  64083. get renderList(): Nullable<AbstractMesh[]>;
  64084. /**
  64085. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64086. * @param mesh defines the mesh to attach to
  64087. */
  64088. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64089. /**
  64090. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64091. * @param renderingGroupId The rendering group id corresponding to its index
  64092. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64093. */
  64094. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64095. /**
  64096. * Clean all associated resources
  64097. */
  64098. dispose(): void;
  64099. /**
  64100. * Converts the reflection probe information to a readable string for debug purpose.
  64101. * @param fullDetails Supports for multiple levels of logging within scene loading
  64102. * @returns the human readable reflection probe info
  64103. */
  64104. toString(fullDetails?: boolean): string;
  64105. /**
  64106. * Get the class name of the relfection probe.
  64107. * @returns "ReflectionProbe"
  64108. */
  64109. getClassName(): string;
  64110. /**
  64111. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64112. * @returns The JSON representation of the texture
  64113. */
  64114. serialize(): any;
  64115. /**
  64116. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64117. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64118. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64119. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64120. * @returns The parsed reflection probe if successful
  64121. */
  64122. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64123. }
  64124. }
  64125. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64126. /** @hidden */
  64127. export var _BabylonLoaderRegistered: boolean;
  64128. /**
  64129. * Helps setting up some configuration for the babylon file loader.
  64130. */
  64131. export class BabylonFileLoaderConfiguration {
  64132. /**
  64133. * The loader does not allow injecting custom physix engine into the plugins.
  64134. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64135. * So you could set this variable to your engine import to make it work.
  64136. */
  64137. static LoaderInjectedPhysicsEngine: any;
  64138. }
  64139. }
  64140. declare module "babylonjs/Loading/Plugins/index" {
  64141. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64142. }
  64143. declare module "babylonjs/Loading/index" {
  64144. export * from "babylonjs/Loading/loadingScreen";
  64145. export * from "babylonjs/Loading/Plugins/index";
  64146. export * from "babylonjs/Loading/sceneLoader";
  64147. export * from "babylonjs/Loading/sceneLoaderFlags";
  64148. }
  64149. declare module "babylonjs/Materials/Background/index" {
  64150. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64151. }
  64152. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64153. import { Scene } from "babylonjs/scene";
  64154. import { Color3 } from "babylonjs/Maths/math.color";
  64155. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64156. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64157. /**
  64158. * The Physically based simple base material of BJS.
  64159. *
  64160. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64161. * It is used as the base class for both the specGloss and metalRough conventions.
  64162. */
  64163. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64164. /**
  64165. * Number of Simultaneous lights allowed on the material.
  64166. */
  64167. maxSimultaneousLights: number;
  64168. /**
  64169. * If sets to true, disables all the lights affecting the material.
  64170. */
  64171. disableLighting: boolean;
  64172. /**
  64173. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64174. */
  64175. environmentTexture: BaseTexture;
  64176. /**
  64177. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64178. */
  64179. invertNormalMapX: boolean;
  64180. /**
  64181. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64182. */
  64183. invertNormalMapY: boolean;
  64184. /**
  64185. * Normal map used in the model.
  64186. */
  64187. normalTexture: BaseTexture;
  64188. /**
  64189. * Emissivie color used to self-illuminate the model.
  64190. */
  64191. emissiveColor: Color3;
  64192. /**
  64193. * Emissivie texture used to self-illuminate the model.
  64194. */
  64195. emissiveTexture: BaseTexture;
  64196. /**
  64197. * Occlusion Channel Strenght.
  64198. */
  64199. occlusionStrength: number;
  64200. /**
  64201. * Occlusion Texture of the material (adding extra occlusion effects).
  64202. */
  64203. occlusionTexture: BaseTexture;
  64204. /**
  64205. * Defines the alpha limits in alpha test mode.
  64206. */
  64207. alphaCutOff: number;
  64208. /**
  64209. * Gets the current double sided mode.
  64210. */
  64211. get doubleSided(): boolean;
  64212. /**
  64213. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64214. */
  64215. set doubleSided(value: boolean);
  64216. /**
  64217. * Stores the pre-calculated light information of a mesh in a texture.
  64218. */
  64219. lightmapTexture: BaseTexture;
  64220. /**
  64221. * If true, the light map contains occlusion information instead of lighting info.
  64222. */
  64223. useLightmapAsShadowmap: boolean;
  64224. /**
  64225. * Instantiates a new PBRMaterial instance.
  64226. *
  64227. * @param name The material name
  64228. * @param scene The scene the material will be use in.
  64229. */
  64230. constructor(name: string, scene: Scene);
  64231. getClassName(): string;
  64232. }
  64233. }
  64234. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64235. import { Scene } from "babylonjs/scene";
  64236. import { Color3 } from "babylonjs/Maths/math.color";
  64237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64238. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64239. /**
  64240. * The PBR material of BJS following the metal roughness convention.
  64241. *
  64242. * This fits to the PBR convention in the GLTF definition:
  64243. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64244. */
  64245. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64246. /**
  64247. * The base color has two different interpretations depending on the value of metalness.
  64248. * When the material is a metal, the base color is the specific measured reflectance value
  64249. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64250. * of the material.
  64251. */
  64252. baseColor: Color3;
  64253. /**
  64254. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64255. * well as opacity information in the alpha channel.
  64256. */
  64257. baseTexture: BaseTexture;
  64258. /**
  64259. * Specifies the metallic scalar value of the material.
  64260. * Can also be used to scale the metalness values of the metallic texture.
  64261. */
  64262. metallic: number;
  64263. /**
  64264. * Specifies the roughness scalar value of the material.
  64265. * Can also be used to scale the roughness values of the metallic texture.
  64266. */
  64267. roughness: number;
  64268. /**
  64269. * Texture containing both the metallic value in the B channel and the
  64270. * roughness value in the G channel to keep better precision.
  64271. */
  64272. metallicRoughnessTexture: BaseTexture;
  64273. /**
  64274. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64275. *
  64276. * @param name The material name
  64277. * @param scene The scene the material will be use in.
  64278. */
  64279. constructor(name: string, scene: Scene);
  64280. /**
  64281. * Return the currrent class name of the material.
  64282. */
  64283. getClassName(): string;
  64284. /**
  64285. * Makes a duplicate of the current material.
  64286. * @param name - name to use for the new material.
  64287. */
  64288. clone(name: string): PBRMetallicRoughnessMaterial;
  64289. /**
  64290. * Serialize the material to a parsable JSON object.
  64291. */
  64292. serialize(): any;
  64293. /**
  64294. * Parses a JSON object correponding to the serialize function.
  64295. */
  64296. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64297. }
  64298. }
  64299. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64300. import { Scene } from "babylonjs/scene";
  64301. import { Color3 } from "babylonjs/Maths/math.color";
  64302. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64303. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64304. /**
  64305. * The PBR material of BJS following the specular glossiness convention.
  64306. *
  64307. * This fits to the PBR convention in the GLTF definition:
  64308. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64309. */
  64310. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64311. /**
  64312. * Specifies the diffuse color of the material.
  64313. */
  64314. diffuseColor: Color3;
  64315. /**
  64316. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64317. * channel.
  64318. */
  64319. diffuseTexture: BaseTexture;
  64320. /**
  64321. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64322. */
  64323. specularColor: Color3;
  64324. /**
  64325. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64326. */
  64327. glossiness: number;
  64328. /**
  64329. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64330. */
  64331. specularGlossinessTexture: BaseTexture;
  64332. /**
  64333. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64334. *
  64335. * @param name The material name
  64336. * @param scene The scene the material will be use in.
  64337. */
  64338. constructor(name: string, scene: Scene);
  64339. /**
  64340. * Return the currrent class name of the material.
  64341. */
  64342. getClassName(): string;
  64343. /**
  64344. * Makes a duplicate of the current material.
  64345. * @param name - name to use for the new material.
  64346. */
  64347. clone(name: string): PBRSpecularGlossinessMaterial;
  64348. /**
  64349. * Serialize the material to a parsable JSON object.
  64350. */
  64351. serialize(): any;
  64352. /**
  64353. * Parses a JSON object correponding to the serialize function.
  64354. */
  64355. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64356. }
  64357. }
  64358. declare module "babylonjs/Materials/PBR/index" {
  64359. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64360. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64361. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64362. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64363. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64364. }
  64365. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64366. import { Nullable } from "babylonjs/types";
  64367. import { Scene } from "babylonjs/scene";
  64368. import { Matrix } from "babylonjs/Maths/math.vector";
  64369. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64370. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64371. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64372. /**
  64373. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64374. * It can help converting any input color in a desired output one. This can then be used to create effects
  64375. * from sepia, black and white to sixties or futuristic rendering...
  64376. *
  64377. * The only supported format is currently 3dl.
  64378. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64379. */
  64380. export class ColorGradingTexture extends BaseTexture {
  64381. /**
  64382. * The texture URL.
  64383. */
  64384. url: string;
  64385. /**
  64386. * Empty line regex stored for GC.
  64387. */
  64388. private static _noneEmptyLineRegex;
  64389. private _textureMatrix;
  64390. private _onLoad;
  64391. /**
  64392. * Instantiates a ColorGradingTexture from the following parameters.
  64393. *
  64394. * @param url The location of the color gradind data (currently only supporting 3dl)
  64395. * @param sceneOrEngine The scene or engine the texture will be used in
  64396. * @param onLoad defines a callback triggered when the texture has been loaded
  64397. */
  64398. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64399. /**
  64400. * Fires the onload event from the constructor if requested.
  64401. */
  64402. private _triggerOnLoad;
  64403. /**
  64404. * Returns the texture matrix used in most of the material.
  64405. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64406. */
  64407. getTextureMatrix(): Matrix;
  64408. /**
  64409. * Occurs when the file being loaded is a .3dl LUT file.
  64410. */
  64411. private load3dlTexture;
  64412. /**
  64413. * Starts the loading process of the texture.
  64414. */
  64415. private loadTexture;
  64416. /**
  64417. * Clones the color gradind texture.
  64418. */
  64419. clone(): ColorGradingTexture;
  64420. /**
  64421. * Called during delayed load for textures.
  64422. */
  64423. delayLoad(): void;
  64424. /**
  64425. * Parses a color grading texture serialized by Babylon.
  64426. * @param parsedTexture The texture information being parsedTexture
  64427. * @param scene The scene to load the texture in
  64428. * @param rootUrl The root url of the data assets to load
  64429. * @return A color gradind texture
  64430. */
  64431. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64432. /**
  64433. * Serializes the LUT texture to json format.
  64434. */
  64435. serialize(): any;
  64436. }
  64437. }
  64438. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64439. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64440. import { Scene } from "babylonjs/scene";
  64441. import { Nullable } from "babylonjs/types";
  64442. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64443. /**
  64444. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64445. */
  64446. export class EquiRectangularCubeTexture extends BaseTexture {
  64447. /** The six faces of the cube. */
  64448. private static _FacesMapping;
  64449. private _noMipmap;
  64450. private _onLoad;
  64451. private _onError;
  64452. /** The size of the cubemap. */
  64453. private _size;
  64454. /** The buffer of the image. */
  64455. private _buffer;
  64456. /** The width of the input image. */
  64457. private _width;
  64458. /** The height of the input image. */
  64459. private _height;
  64460. /** The URL to the image. */
  64461. url: string;
  64462. /**
  64463. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64464. * @param url The location of the image
  64465. * @param scene The scene the texture will be used in
  64466. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64467. * @param noMipmap Forces to not generate the mipmap if true
  64468. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64469. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64470. * @param onLoad — defines a callback called when texture is loaded
  64471. * @param onError — defines a callback called if there is an error
  64472. */
  64473. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64474. /**
  64475. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64476. */
  64477. private loadImage;
  64478. /**
  64479. * Convert the image buffer into a cubemap and create a CubeTexture.
  64480. */
  64481. private loadTexture;
  64482. /**
  64483. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64484. * @param buffer The ArrayBuffer that should be converted.
  64485. * @returns The buffer as Float32Array.
  64486. */
  64487. private getFloat32ArrayFromArrayBuffer;
  64488. /**
  64489. * Get the current class name of the texture useful for serialization or dynamic coding.
  64490. * @returns "EquiRectangularCubeTexture"
  64491. */
  64492. getClassName(): string;
  64493. /**
  64494. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64495. * @returns A clone of the current EquiRectangularCubeTexture.
  64496. */
  64497. clone(): EquiRectangularCubeTexture;
  64498. }
  64499. }
  64500. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64501. import { Nullable } from "babylonjs/types";
  64502. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64503. import { Matrix } from "babylonjs/Maths/math.vector";
  64504. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64505. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64506. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64507. import { Scene } from "babylonjs/scene";
  64508. /**
  64509. * Defines the options related to the creation of an HtmlElementTexture
  64510. */
  64511. export interface IHtmlElementTextureOptions {
  64512. /**
  64513. * Defines wether mip maps should be created or not.
  64514. */
  64515. generateMipMaps?: boolean;
  64516. /**
  64517. * Defines the sampling mode of the texture.
  64518. */
  64519. samplingMode?: number;
  64520. /**
  64521. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64522. */
  64523. engine: Nullable<ThinEngine>;
  64524. /**
  64525. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64526. */
  64527. scene: Nullable<Scene>;
  64528. }
  64529. /**
  64530. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64531. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64532. * is automatically managed.
  64533. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64534. * in your application.
  64535. *
  64536. * As the update is not automatic, you need to call them manually.
  64537. */
  64538. export class HtmlElementTexture extends BaseTexture {
  64539. /**
  64540. * The texture URL.
  64541. */
  64542. element: HTMLVideoElement | HTMLCanvasElement;
  64543. private static readonly DefaultOptions;
  64544. private _textureMatrix;
  64545. private _isVideo;
  64546. private _generateMipMaps;
  64547. private _samplingMode;
  64548. /**
  64549. * Instantiates a HtmlElementTexture from the following parameters.
  64550. *
  64551. * @param name Defines the name of the texture
  64552. * @param element Defines the video or canvas the texture is filled with
  64553. * @param options Defines the other none mandatory texture creation options
  64554. */
  64555. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64556. private _createInternalTexture;
  64557. /**
  64558. * Returns the texture matrix used in most of the material.
  64559. */
  64560. getTextureMatrix(): Matrix;
  64561. /**
  64562. * Updates the content of the texture.
  64563. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64564. */
  64565. update(invertY?: Nullable<boolean>): void;
  64566. }
  64567. }
  64568. declare module "babylonjs/Misc/tga" {
  64569. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64570. /**
  64571. * Based on jsTGALoader - Javascript loader for TGA file
  64572. * By Vincent Thibault
  64573. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64574. */
  64575. export class TGATools {
  64576. private static _TYPE_INDEXED;
  64577. private static _TYPE_RGB;
  64578. private static _TYPE_GREY;
  64579. private static _TYPE_RLE_INDEXED;
  64580. private static _TYPE_RLE_RGB;
  64581. private static _TYPE_RLE_GREY;
  64582. private static _ORIGIN_MASK;
  64583. private static _ORIGIN_SHIFT;
  64584. private static _ORIGIN_BL;
  64585. private static _ORIGIN_BR;
  64586. private static _ORIGIN_UL;
  64587. private static _ORIGIN_UR;
  64588. /**
  64589. * Gets the header of a TGA file
  64590. * @param data defines the TGA data
  64591. * @returns the header
  64592. */
  64593. static GetTGAHeader(data: Uint8Array): any;
  64594. /**
  64595. * Uploads TGA content to a Babylon Texture
  64596. * @hidden
  64597. */
  64598. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64599. /** @hidden */
  64600. 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;
  64601. /** @hidden */
  64602. 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;
  64603. /** @hidden */
  64604. 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;
  64605. /** @hidden */
  64606. 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;
  64607. /** @hidden */
  64608. 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;
  64609. /** @hidden */
  64610. 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;
  64611. }
  64612. }
  64613. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64614. import { Nullable } from "babylonjs/types";
  64615. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64616. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64617. /**
  64618. * Implementation of the TGA Texture Loader.
  64619. * @hidden
  64620. */
  64621. export class _TGATextureLoader implements IInternalTextureLoader {
  64622. /**
  64623. * Defines wether the loader supports cascade loading the different faces.
  64624. */
  64625. readonly supportCascades: boolean;
  64626. /**
  64627. * This returns if the loader support the current file information.
  64628. * @param extension defines the file extension of the file being loaded
  64629. * @returns true if the loader can load the specified file
  64630. */
  64631. canLoad(extension: string): boolean;
  64632. /**
  64633. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64634. * @param data contains the texture data
  64635. * @param texture defines the BabylonJS internal texture
  64636. * @param createPolynomials will be true if polynomials have been requested
  64637. * @param onLoad defines the callback to trigger once the texture is ready
  64638. * @param onError defines the callback to trigger in case of error
  64639. */
  64640. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64641. /**
  64642. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64643. * @param data contains the texture data
  64644. * @param texture defines the BabylonJS internal texture
  64645. * @param callback defines the method to call once ready to upload
  64646. */
  64647. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64648. }
  64649. }
  64650. declare module "babylonjs/Misc/basis" {
  64651. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64652. /**
  64653. * Info about the .basis files
  64654. */
  64655. class BasisFileInfo {
  64656. /**
  64657. * If the file has alpha
  64658. */
  64659. hasAlpha: boolean;
  64660. /**
  64661. * Info about each image of the basis file
  64662. */
  64663. images: Array<{
  64664. levels: Array<{
  64665. width: number;
  64666. height: number;
  64667. transcodedPixels: ArrayBufferView;
  64668. }>;
  64669. }>;
  64670. }
  64671. /**
  64672. * Result of transcoding a basis file
  64673. */
  64674. class TranscodeResult {
  64675. /**
  64676. * Info about the .basis file
  64677. */
  64678. fileInfo: BasisFileInfo;
  64679. /**
  64680. * Format to use when loading the file
  64681. */
  64682. format: number;
  64683. }
  64684. /**
  64685. * Configuration options for the Basis transcoder
  64686. */
  64687. export class BasisTranscodeConfiguration {
  64688. /**
  64689. * Supported compression formats used to determine the supported output format of the transcoder
  64690. */
  64691. supportedCompressionFormats?: {
  64692. /**
  64693. * etc1 compression format
  64694. */
  64695. etc1?: boolean;
  64696. /**
  64697. * s3tc compression format
  64698. */
  64699. s3tc?: boolean;
  64700. /**
  64701. * pvrtc compression format
  64702. */
  64703. pvrtc?: boolean;
  64704. /**
  64705. * etc2 compression format
  64706. */
  64707. etc2?: boolean;
  64708. };
  64709. /**
  64710. * If mipmap levels should be loaded for transcoded images (Default: true)
  64711. */
  64712. loadMipmapLevels?: boolean;
  64713. /**
  64714. * Index of a single image to load (Default: all images)
  64715. */
  64716. loadSingleImage?: number;
  64717. }
  64718. /**
  64719. * Used to load .Basis files
  64720. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64721. */
  64722. export class BasisTools {
  64723. private static _IgnoreSupportedFormats;
  64724. /**
  64725. * URL to use when loading the basis transcoder
  64726. */
  64727. static JSModuleURL: string;
  64728. /**
  64729. * URL to use when loading the wasm module for the transcoder
  64730. */
  64731. static WasmModuleURL: string;
  64732. /**
  64733. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64734. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64735. * @returns internal format corresponding to the Basis format
  64736. */
  64737. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64738. private static _WorkerPromise;
  64739. private static _Worker;
  64740. private static _actionId;
  64741. private static _CreateWorkerAsync;
  64742. /**
  64743. * Transcodes a loaded image file to compressed pixel data
  64744. * @param data image data to transcode
  64745. * @param config configuration options for the transcoding
  64746. * @returns a promise resulting in the transcoded image
  64747. */
  64748. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64749. /**
  64750. * Loads a texture from the transcode result
  64751. * @param texture texture load to
  64752. * @param transcodeResult the result of transcoding the basis file to load from
  64753. */
  64754. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64755. }
  64756. }
  64757. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64758. import { Nullable } from "babylonjs/types";
  64759. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64760. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64761. /**
  64762. * Loader for .basis file format
  64763. */
  64764. export class _BasisTextureLoader implements IInternalTextureLoader {
  64765. /**
  64766. * Defines whether the loader supports cascade loading the different faces.
  64767. */
  64768. readonly supportCascades: boolean;
  64769. /**
  64770. * This returns if the loader support the current file information.
  64771. * @param extension defines the file extension of the file being loaded
  64772. * @returns true if the loader can load the specified file
  64773. */
  64774. canLoad(extension: string): boolean;
  64775. /**
  64776. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64777. * @param data contains the texture data
  64778. * @param texture defines the BabylonJS internal texture
  64779. * @param createPolynomials will be true if polynomials have been requested
  64780. * @param onLoad defines the callback to trigger once the texture is ready
  64781. * @param onError defines the callback to trigger in case of error
  64782. */
  64783. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64784. /**
  64785. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64786. * @param data contains the texture data
  64787. * @param texture defines the BabylonJS internal texture
  64788. * @param callback defines the method to call once ready to upload
  64789. */
  64790. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64791. }
  64792. }
  64793. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64794. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64795. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64796. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64797. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64798. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64799. }
  64800. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64801. import { Vector2 } from "babylonjs/Maths/math.vector";
  64802. /**
  64803. * Defines the basic options interface of a TexturePacker Frame
  64804. */
  64805. export interface ITexturePackerFrame {
  64806. /**
  64807. * The frame ID
  64808. */
  64809. id: number;
  64810. /**
  64811. * The frames Scale
  64812. */
  64813. scale: Vector2;
  64814. /**
  64815. * The Frames offset
  64816. */
  64817. offset: Vector2;
  64818. }
  64819. /**
  64820. * This is a support class for frame Data on texture packer sets.
  64821. */
  64822. export class TexturePackerFrame implements ITexturePackerFrame {
  64823. /**
  64824. * The frame ID
  64825. */
  64826. id: number;
  64827. /**
  64828. * The frames Scale
  64829. */
  64830. scale: Vector2;
  64831. /**
  64832. * The Frames offset
  64833. */
  64834. offset: Vector2;
  64835. /**
  64836. * Initializes a texture package frame.
  64837. * @param id The numerical frame identifier
  64838. * @param scale Scalar Vector2 for UV frame
  64839. * @param offset Vector2 for the frame position in UV units.
  64840. * @returns TexturePackerFrame
  64841. */
  64842. constructor(id: number, scale: Vector2, offset: Vector2);
  64843. }
  64844. }
  64845. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64847. import { Scene } from "babylonjs/scene";
  64848. import { Nullable } from "babylonjs/types";
  64849. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64850. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64851. /**
  64852. * Defines the basic options interface of a TexturePacker
  64853. */
  64854. export interface ITexturePackerOptions {
  64855. /**
  64856. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64857. */
  64858. map?: string[];
  64859. /**
  64860. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64861. */
  64862. uvsIn?: string;
  64863. /**
  64864. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64865. */
  64866. uvsOut?: string;
  64867. /**
  64868. * number representing the layout style. Defaults to LAYOUT_STRIP
  64869. */
  64870. layout?: number;
  64871. /**
  64872. * number of columns if using custom column count layout(2). This defaults to 4.
  64873. */
  64874. colnum?: number;
  64875. /**
  64876. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64877. */
  64878. updateInputMeshes?: boolean;
  64879. /**
  64880. * boolean flag to dispose all the source textures. Defaults to true.
  64881. */
  64882. disposeSources?: boolean;
  64883. /**
  64884. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64885. */
  64886. fillBlanks?: boolean;
  64887. /**
  64888. * string value representing the context fill style color. Defaults to 'black'.
  64889. */
  64890. customFillColor?: string;
  64891. /**
  64892. * Width and Height Value of each Frame in the TexturePacker Sets
  64893. */
  64894. frameSize?: number;
  64895. /**
  64896. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  64897. */
  64898. paddingRatio?: number;
  64899. /**
  64900. * Number that declares the fill method for the padding gutter.
  64901. */
  64902. paddingMode?: number;
  64903. /**
  64904. * If in SUBUV_COLOR padding mode what color to use.
  64905. */
  64906. paddingColor?: Color3 | Color4;
  64907. }
  64908. /**
  64909. * Defines the basic interface of a TexturePacker JSON File
  64910. */
  64911. export interface ITexturePackerJSON {
  64912. /**
  64913. * The frame ID
  64914. */
  64915. name: string;
  64916. /**
  64917. * The base64 channel data
  64918. */
  64919. sets: any;
  64920. /**
  64921. * The options of the Packer
  64922. */
  64923. options: ITexturePackerOptions;
  64924. /**
  64925. * The frame data of the Packer
  64926. */
  64927. frames: Array<number>;
  64928. }
  64929. /**
  64930. * This is a support class that generates a series of packed texture sets.
  64931. * @see https://doc.babylonjs.com/babylon101/materials
  64932. */
  64933. export class TexturePacker {
  64934. /** Packer Layout Constant 0 */
  64935. static readonly LAYOUT_STRIP: number;
  64936. /** Packer Layout Constant 1 */
  64937. static readonly LAYOUT_POWER2: number;
  64938. /** Packer Layout Constant 2 */
  64939. static readonly LAYOUT_COLNUM: number;
  64940. /** Packer Layout Constant 0 */
  64941. static readonly SUBUV_WRAP: number;
  64942. /** Packer Layout Constant 1 */
  64943. static readonly SUBUV_EXTEND: number;
  64944. /** Packer Layout Constant 2 */
  64945. static readonly SUBUV_COLOR: number;
  64946. /** The Name of the Texture Package */
  64947. name: string;
  64948. /** The scene scope of the TexturePacker */
  64949. scene: Scene;
  64950. /** The Meshes to target */
  64951. meshes: AbstractMesh[];
  64952. /** Arguments passed with the Constructor */
  64953. options: ITexturePackerOptions;
  64954. /** The promise that is started upon initialization */
  64955. promise: Nullable<Promise<TexturePacker | string>>;
  64956. /** The Container object for the channel sets that are generated */
  64957. sets: object;
  64958. /** The Container array for the frames that are generated */
  64959. frames: TexturePackerFrame[];
  64960. /** The expected number of textures the system is parsing. */
  64961. private _expecting;
  64962. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  64963. private _paddingValue;
  64964. /**
  64965. * Initializes a texture package series from an array of meshes or a single mesh.
  64966. * @param name The name of the package
  64967. * @param meshes The target meshes to compose the package from
  64968. * @param options The arguments that texture packer should follow while building.
  64969. * @param scene The scene which the textures are scoped to.
  64970. * @returns TexturePacker
  64971. */
  64972. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  64973. /**
  64974. * Starts the package process
  64975. * @param resolve The promises resolution function
  64976. * @returns TexturePacker
  64977. */
  64978. private _createFrames;
  64979. /**
  64980. * Calculates the Size of the Channel Sets
  64981. * @returns Vector2
  64982. */
  64983. private _calculateSize;
  64984. /**
  64985. * Calculates the UV data for the frames.
  64986. * @param baseSize the base frameSize
  64987. * @param padding the base frame padding
  64988. * @param dtSize size of the Dynamic Texture for that channel
  64989. * @param dtUnits is 1/dtSize
  64990. * @param update flag to update the input meshes
  64991. */
  64992. private _calculateMeshUVFrames;
  64993. /**
  64994. * Calculates the frames Offset.
  64995. * @param index of the frame
  64996. * @returns Vector2
  64997. */
  64998. private _getFrameOffset;
  64999. /**
  65000. * Updates a Mesh to the frame data
  65001. * @param mesh that is the target
  65002. * @param frameID or the frame index
  65003. */
  65004. private _updateMeshUV;
  65005. /**
  65006. * Updates a Meshes materials to use the texture packer channels
  65007. * @param m is the mesh to target
  65008. * @param force all channels on the packer to be set.
  65009. */
  65010. private _updateTextureReferences;
  65011. /**
  65012. * Public method to set a Mesh to a frame
  65013. * @param m that is the target
  65014. * @param frameID or the frame index
  65015. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65016. */
  65017. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65018. /**
  65019. * Starts the async promise to compile the texture packer.
  65020. * @returns Promise<void>
  65021. */
  65022. processAsync(): Promise<void>;
  65023. /**
  65024. * Disposes all textures associated with this packer
  65025. */
  65026. dispose(): void;
  65027. /**
  65028. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65029. * @param imageType is the image type to use.
  65030. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65031. */
  65032. download(imageType?: string, quality?: number): void;
  65033. /**
  65034. * Public method to load a texturePacker JSON file.
  65035. * @param data of the JSON file in string format.
  65036. */
  65037. updateFromJSON(data: string): void;
  65038. }
  65039. }
  65040. declare module "babylonjs/Materials/Textures/Packer/index" {
  65041. export * from "babylonjs/Materials/Textures/Packer/packer";
  65042. export * from "babylonjs/Materials/Textures/Packer/frame";
  65043. }
  65044. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65045. import { Scene } from "babylonjs/scene";
  65046. import { Texture } from "babylonjs/Materials/Textures/texture";
  65047. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65048. /**
  65049. * 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.
  65050. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65051. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65052. */
  65053. export class CustomProceduralTexture extends ProceduralTexture {
  65054. private _animate;
  65055. private _time;
  65056. private _config;
  65057. private _texturePath;
  65058. /**
  65059. * Instantiates a new Custom Procedural Texture.
  65060. * 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.
  65061. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65062. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65063. * @param name Define the name of the texture
  65064. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65065. * @param size Define the size of the texture to create
  65066. * @param scene Define the scene the texture belongs to
  65067. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65068. * @param generateMipMaps Define if the texture should creates mip maps or not
  65069. */
  65070. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65071. private _loadJson;
  65072. /**
  65073. * Is the texture ready to be used ? (rendered at least once)
  65074. * @returns true if ready, otherwise, false.
  65075. */
  65076. isReady(): boolean;
  65077. /**
  65078. * Render the texture to its associated render target.
  65079. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65080. */
  65081. render(useCameraPostProcess?: boolean): void;
  65082. /**
  65083. * Update the list of dependant textures samplers in the shader.
  65084. */
  65085. updateTextures(): void;
  65086. /**
  65087. * Update the uniform values of the procedural texture in the shader.
  65088. */
  65089. updateShaderUniforms(): void;
  65090. /**
  65091. * Define if the texture animates or not.
  65092. */
  65093. get animate(): boolean;
  65094. set animate(value: boolean);
  65095. }
  65096. }
  65097. declare module "babylonjs/Shaders/noise.fragment" {
  65098. /** @hidden */
  65099. export var noisePixelShader: {
  65100. name: string;
  65101. shader: string;
  65102. };
  65103. }
  65104. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65105. import { Nullable } from "babylonjs/types";
  65106. import { Scene } from "babylonjs/scene";
  65107. import { Texture } from "babylonjs/Materials/Textures/texture";
  65108. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65109. import "babylonjs/Shaders/noise.fragment";
  65110. /**
  65111. * Class used to generate noise procedural textures
  65112. */
  65113. export class NoiseProceduralTexture extends ProceduralTexture {
  65114. /** Gets or sets the start time (default is 0) */
  65115. time: number;
  65116. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65117. brightness: number;
  65118. /** Defines the number of octaves to process */
  65119. octaves: number;
  65120. /** Defines the level of persistence (0.8 by default) */
  65121. persistence: number;
  65122. /** Gets or sets animation speed factor (default is 1) */
  65123. animationSpeedFactor: number;
  65124. /**
  65125. * Creates a new NoiseProceduralTexture
  65126. * @param name defines the name fo the texture
  65127. * @param size defines the size of the texture (default is 256)
  65128. * @param scene defines the hosting scene
  65129. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65130. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65131. */
  65132. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65133. private _updateShaderUniforms;
  65134. protected _getDefines(): string;
  65135. /** Generate the current state of the procedural texture */
  65136. render(useCameraPostProcess?: boolean): void;
  65137. /**
  65138. * Serializes this noise procedural texture
  65139. * @returns a serialized noise procedural texture object
  65140. */
  65141. serialize(): any;
  65142. /**
  65143. * Clone the texture.
  65144. * @returns the cloned texture
  65145. */
  65146. clone(): NoiseProceduralTexture;
  65147. /**
  65148. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65149. * @param parsedTexture defines parsed texture data
  65150. * @param scene defines the current scene
  65151. * @param rootUrl defines the root URL containing noise procedural texture information
  65152. * @returns a parsed NoiseProceduralTexture
  65153. */
  65154. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65155. }
  65156. }
  65157. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65158. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65159. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65160. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65161. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65162. }
  65163. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65164. import { Nullable } from "babylonjs/types";
  65165. import { Scene } from "babylonjs/scene";
  65166. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65167. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65168. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65169. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65170. /**
  65171. * Raw cube texture where the raw buffers are passed in
  65172. */
  65173. export class RawCubeTexture extends CubeTexture {
  65174. /**
  65175. * Creates a cube texture where the raw buffers are passed in.
  65176. * @param scene defines the scene the texture is attached to
  65177. * @param data defines the array of data to use to create each face
  65178. * @param size defines the size of the textures
  65179. * @param format defines the format of the data
  65180. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65181. * @param generateMipMaps defines if the engine should generate the mip levels
  65182. * @param invertY defines if data must be stored with Y axis inverted
  65183. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65184. * @param compression defines the compression used (null by default)
  65185. */
  65186. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65187. /**
  65188. * Updates the raw cube texture.
  65189. * @param data defines the data to store
  65190. * @param format defines the data format
  65191. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65192. * @param invertY defines if data must be stored with Y axis inverted
  65193. * @param compression defines the compression used (null by default)
  65194. * @param level defines which level of the texture to update
  65195. */
  65196. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65197. /**
  65198. * Updates a raw cube texture with RGBD encoded data.
  65199. * @param data defines the array of data [mipmap][face] to use to create each face
  65200. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65201. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65202. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65203. * @returns a promsie that resolves when the operation is complete
  65204. */
  65205. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65206. /**
  65207. * Clones the raw cube texture.
  65208. * @return a new cube texture
  65209. */
  65210. clone(): CubeTexture;
  65211. /** @hidden */
  65212. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65213. }
  65214. }
  65215. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65216. import { Scene } from "babylonjs/scene";
  65217. import { Texture } from "babylonjs/Materials/Textures/texture";
  65218. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65219. /**
  65220. * Class used to store 2D array textures containing user data
  65221. */
  65222. export class RawTexture2DArray extends Texture {
  65223. /** Gets or sets the texture format to use */
  65224. format: number;
  65225. /**
  65226. * Create a new RawTexture2DArray
  65227. * @param data defines the data of the texture
  65228. * @param width defines the width of the texture
  65229. * @param height defines the height of the texture
  65230. * @param depth defines the number of layers of the texture
  65231. * @param format defines the texture format to use
  65232. * @param scene defines the hosting scene
  65233. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65234. * @param invertY defines if texture must be stored with Y axis inverted
  65235. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65236. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65237. */
  65238. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65239. /** Gets or sets the texture format to use */
  65240. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65241. /**
  65242. * Update the texture with new data
  65243. * @param data defines the data to store in the texture
  65244. */
  65245. update(data: ArrayBufferView): void;
  65246. }
  65247. }
  65248. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65249. import { Scene } from "babylonjs/scene";
  65250. import { Texture } from "babylonjs/Materials/Textures/texture";
  65251. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65252. /**
  65253. * Class used to store 3D textures containing user data
  65254. */
  65255. export class RawTexture3D extends Texture {
  65256. /** Gets or sets the texture format to use */
  65257. format: number;
  65258. /**
  65259. * Create a new RawTexture3D
  65260. * @param data defines the data of the texture
  65261. * @param width defines the width of the texture
  65262. * @param height defines the height of the texture
  65263. * @param depth defines the depth of the texture
  65264. * @param format defines the texture format to use
  65265. * @param scene defines the hosting scene
  65266. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65267. * @param invertY defines if texture must be stored with Y axis inverted
  65268. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65269. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65270. */
  65271. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65272. /** Gets or sets the texture format to use */
  65273. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65274. /**
  65275. * Update the texture with new data
  65276. * @param data defines the data to store in the texture
  65277. */
  65278. update(data: ArrayBufferView): void;
  65279. }
  65280. }
  65281. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65282. import { Scene } from "babylonjs/scene";
  65283. import { Plane } from "babylonjs/Maths/math.plane";
  65284. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65285. /**
  65286. * Creates a refraction texture used by refraction channel of the standard material.
  65287. * It is like a mirror but to see through a material.
  65288. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65289. */
  65290. export class RefractionTexture extends RenderTargetTexture {
  65291. /**
  65292. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65293. * 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.
  65294. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65295. */
  65296. refractionPlane: Plane;
  65297. /**
  65298. * Define how deep under the surface we should see.
  65299. */
  65300. depth: number;
  65301. /**
  65302. * Creates a refraction texture used by refraction channel of the standard material.
  65303. * It is like a mirror but to see through a material.
  65304. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65305. * @param name Define the texture name
  65306. * @param size Define the size of the underlying texture
  65307. * @param scene Define the scene the refraction belongs to
  65308. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65309. */
  65310. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65311. /**
  65312. * Clone the refraction texture.
  65313. * @returns the cloned texture
  65314. */
  65315. clone(): RefractionTexture;
  65316. /**
  65317. * Serialize the texture to a JSON representation you could use in Parse later on
  65318. * @returns the serialized JSON representation
  65319. */
  65320. serialize(): any;
  65321. }
  65322. }
  65323. declare module "babylonjs/Materials/Textures/index" {
  65324. export * from "babylonjs/Materials/Textures/baseTexture";
  65325. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65326. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65327. export * from "babylonjs/Materials/Textures/cubeTexture";
  65328. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65329. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65330. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65331. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65332. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65333. export * from "babylonjs/Materials/Textures/internalTexture";
  65334. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65335. export * from "babylonjs/Materials/Textures/Loaders/index";
  65336. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65337. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65338. export * from "babylonjs/Materials/Textures/Packer/index";
  65339. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65340. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65341. export * from "babylonjs/Materials/Textures/rawTexture";
  65342. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65343. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65344. export * from "babylonjs/Materials/Textures/refractionTexture";
  65345. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65346. export * from "babylonjs/Materials/Textures/texture";
  65347. export * from "babylonjs/Materials/Textures/videoTexture";
  65348. }
  65349. declare module "babylonjs/Materials/Node/Enums/index" {
  65350. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65351. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65352. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65353. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65354. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65355. }
  65356. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65357. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65358. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65360. import { Mesh } from "babylonjs/Meshes/mesh";
  65361. import { Effect } from "babylonjs/Materials/effect";
  65362. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65363. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65364. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65365. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65366. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65367. /**
  65368. * Block used to add support for vertex skinning (bones)
  65369. */
  65370. export class BonesBlock extends NodeMaterialBlock {
  65371. /**
  65372. * Creates a new BonesBlock
  65373. * @param name defines the block name
  65374. */
  65375. constructor(name: string);
  65376. /**
  65377. * Initialize the block and prepare the context for build
  65378. * @param state defines the state that will be used for the build
  65379. */
  65380. initialize(state: NodeMaterialBuildState): void;
  65381. /**
  65382. * Gets the current class name
  65383. * @returns the class name
  65384. */
  65385. getClassName(): string;
  65386. /**
  65387. * Gets the matrix indices input component
  65388. */
  65389. get matricesIndices(): NodeMaterialConnectionPoint;
  65390. /**
  65391. * Gets the matrix weights input component
  65392. */
  65393. get matricesWeights(): NodeMaterialConnectionPoint;
  65394. /**
  65395. * Gets the extra matrix indices input component
  65396. */
  65397. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65398. /**
  65399. * Gets the extra matrix weights input component
  65400. */
  65401. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65402. /**
  65403. * Gets the world input component
  65404. */
  65405. get world(): NodeMaterialConnectionPoint;
  65406. /**
  65407. * Gets the output component
  65408. */
  65409. get output(): NodeMaterialConnectionPoint;
  65410. autoConfigure(material: NodeMaterial): void;
  65411. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65412. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65413. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65414. protected _buildBlock(state: NodeMaterialBuildState): this;
  65415. }
  65416. }
  65417. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65418. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65419. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65422. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65423. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65424. /**
  65425. * Block used to add support for instances
  65426. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65427. */
  65428. export class InstancesBlock extends NodeMaterialBlock {
  65429. /**
  65430. * Creates a new InstancesBlock
  65431. * @param name defines the block name
  65432. */
  65433. constructor(name: string);
  65434. /**
  65435. * Gets the current class name
  65436. * @returns the class name
  65437. */
  65438. getClassName(): string;
  65439. /**
  65440. * Gets the first world row input component
  65441. */
  65442. get world0(): NodeMaterialConnectionPoint;
  65443. /**
  65444. * Gets the second world row input component
  65445. */
  65446. get world1(): NodeMaterialConnectionPoint;
  65447. /**
  65448. * Gets the third world row input component
  65449. */
  65450. get world2(): NodeMaterialConnectionPoint;
  65451. /**
  65452. * Gets the forth world row input component
  65453. */
  65454. get world3(): NodeMaterialConnectionPoint;
  65455. /**
  65456. * Gets the world input component
  65457. */
  65458. get world(): NodeMaterialConnectionPoint;
  65459. /**
  65460. * Gets the output component
  65461. */
  65462. get output(): NodeMaterialConnectionPoint;
  65463. /**
  65464. * Gets the isntanceID component
  65465. */
  65466. get instanceID(): NodeMaterialConnectionPoint;
  65467. autoConfigure(material: NodeMaterial): void;
  65468. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65469. protected _buildBlock(state: NodeMaterialBuildState): this;
  65470. }
  65471. }
  65472. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65473. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65474. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65475. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65477. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65478. import { Effect } from "babylonjs/Materials/effect";
  65479. import { Mesh } from "babylonjs/Meshes/mesh";
  65480. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65481. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65482. /**
  65483. * Block used to add morph targets support to vertex shader
  65484. */
  65485. export class MorphTargetsBlock extends NodeMaterialBlock {
  65486. private _repeatableContentAnchor;
  65487. /**
  65488. * Create a new MorphTargetsBlock
  65489. * @param name defines the block name
  65490. */
  65491. constructor(name: string);
  65492. /**
  65493. * Gets the current class name
  65494. * @returns the class name
  65495. */
  65496. getClassName(): string;
  65497. /**
  65498. * Gets the position input component
  65499. */
  65500. get position(): NodeMaterialConnectionPoint;
  65501. /**
  65502. * Gets the normal input component
  65503. */
  65504. get normal(): NodeMaterialConnectionPoint;
  65505. /**
  65506. * Gets the tangent input component
  65507. */
  65508. get tangent(): NodeMaterialConnectionPoint;
  65509. /**
  65510. * Gets the tangent input component
  65511. */
  65512. get uv(): NodeMaterialConnectionPoint;
  65513. /**
  65514. * Gets the position output component
  65515. */
  65516. get positionOutput(): NodeMaterialConnectionPoint;
  65517. /**
  65518. * Gets the normal output component
  65519. */
  65520. get normalOutput(): NodeMaterialConnectionPoint;
  65521. /**
  65522. * Gets the tangent output component
  65523. */
  65524. get tangentOutput(): NodeMaterialConnectionPoint;
  65525. /**
  65526. * Gets the tangent output component
  65527. */
  65528. get uvOutput(): NodeMaterialConnectionPoint;
  65529. initialize(state: NodeMaterialBuildState): void;
  65530. autoConfigure(material: NodeMaterial): void;
  65531. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65532. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65533. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65534. protected _buildBlock(state: NodeMaterialBuildState): this;
  65535. }
  65536. }
  65537. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65541. import { Nullable } from "babylonjs/types";
  65542. import { Scene } from "babylonjs/scene";
  65543. import { Effect } from "babylonjs/Materials/effect";
  65544. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65545. import { Mesh } from "babylonjs/Meshes/mesh";
  65546. import { Light } from "babylonjs/Lights/light";
  65547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65548. /**
  65549. * Block used to get data information from a light
  65550. */
  65551. export class LightInformationBlock extends NodeMaterialBlock {
  65552. private _lightDataUniformName;
  65553. private _lightColorUniformName;
  65554. private _lightTypeDefineName;
  65555. /**
  65556. * Gets or sets the light associated with this block
  65557. */
  65558. light: Nullable<Light>;
  65559. /**
  65560. * Creates a new LightInformationBlock
  65561. * @param name defines the block name
  65562. */
  65563. constructor(name: string);
  65564. /**
  65565. * Gets the current class name
  65566. * @returns the class name
  65567. */
  65568. getClassName(): string;
  65569. /**
  65570. * Gets the world position input component
  65571. */
  65572. get worldPosition(): NodeMaterialConnectionPoint;
  65573. /**
  65574. * Gets the direction output component
  65575. */
  65576. get direction(): NodeMaterialConnectionPoint;
  65577. /**
  65578. * Gets the direction output component
  65579. */
  65580. get color(): NodeMaterialConnectionPoint;
  65581. /**
  65582. * Gets the direction output component
  65583. */
  65584. get intensity(): NodeMaterialConnectionPoint;
  65585. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65586. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65587. protected _buildBlock(state: NodeMaterialBuildState): this;
  65588. serialize(): any;
  65589. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65590. }
  65591. }
  65592. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65593. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65594. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65595. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65596. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65597. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65598. }
  65599. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65600. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65601. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65602. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65604. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65605. import { Effect } from "babylonjs/Materials/effect";
  65606. import { Mesh } from "babylonjs/Meshes/mesh";
  65607. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65608. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65609. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65610. /**
  65611. * Block used to add image processing support to fragment shader
  65612. */
  65613. export class ImageProcessingBlock extends NodeMaterialBlock {
  65614. /**
  65615. * Create a new ImageProcessingBlock
  65616. * @param name defines the block name
  65617. */
  65618. constructor(name: string);
  65619. /**
  65620. * Gets the current class name
  65621. * @returns the class name
  65622. */
  65623. getClassName(): string;
  65624. /**
  65625. * Gets the color input component
  65626. */
  65627. get color(): NodeMaterialConnectionPoint;
  65628. /**
  65629. * Gets the output component
  65630. */
  65631. get output(): NodeMaterialConnectionPoint;
  65632. /**
  65633. * Initialize the block and prepare the context for build
  65634. * @param state defines the state that will be used for the build
  65635. */
  65636. initialize(state: NodeMaterialBuildState): void;
  65637. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65638. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65639. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65640. protected _buildBlock(state: NodeMaterialBuildState): this;
  65641. }
  65642. }
  65643. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65644. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65645. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65646. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65647. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65649. import { Effect } from "babylonjs/Materials/effect";
  65650. import { Mesh } from "babylonjs/Meshes/mesh";
  65651. import { Scene } from "babylonjs/scene";
  65652. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65653. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65654. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65655. /**
  65656. * Block used to pertub normals based on a normal map
  65657. */
  65658. export class PerturbNormalBlock extends NodeMaterialBlock {
  65659. private _tangentSpaceParameterName;
  65660. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65661. invertX: boolean;
  65662. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65663. invertY: boolean;
  65664. /**
  65665. * Create a new PerturbNormalBlock
  65666. * @param name defines the block name
  65667. */
  65668. constructor(name: string);
  65669. /**
  65670. * Gets the current class name
  65671. * @returns the class name
  65672. */
  65673. getClassName(): string;
  65674. /**
  65675. * Gets the world position input component
  65676. */
  65677. get worldPosition(): NodeMaterialConnectionPoint;
  65678. /**
  65679. * Gets the world normal input component
  65680. */
  65681. get worldNormal(): NodeMaterialConnectionPoint;
  65682. /**
  65683. * Gets the world tangent input component
  65684. */
  65685. get worldTangent(): NodeMaterialConnectionPoint;
  65686. /**
  65687. * Gets the uv input component
  65688. */
  65689. get uv(): NodeMaterialConnectionPoint;
  65690. /**
  65691. * Gets the normal map color input component
  65692. */
  65693. get normalMapColor(): NodeMaterialConnectionPoint;
  65694. /**
  65695. * Gets the strength input component
  65696. */
  65697. get strength(): NodeMaterialConnectionPoint;
  65698. /**
  65699. * Gets the output component
  65700. */
  65701. get output(): NodeMaterialConnectionPoint;
  65702. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65703. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65704. autoConfigure(material: NodeMaterial): void;
  65705. protected _buildBlock(state: NodeMaterialBuildState): this;
  65706. protected _dumpPropertiesCode(): string;
  65707. serialize(): any;
  65708. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65709. }
  65710. }
  65711. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65714. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65715. /**
  65716. * Block used to discard a pixel if a value is smaller than a cutoff
  65717. */
  65718. export class DiscardBlock extends NodeMaterialBlock {
  65719. /**
  65720. * Create a new DiscardBlock
  65721. * @param name defines the block name
  65722. */
  65723. constructor(name: string);
  65724. /**
  65725. * Gets the current class name
  65726. * @returns the class name
  65727. */
  65728. getClassName(): string;
  65729. /**
  65730. * Gets the color input component
  65731. */
  65732. get value(): NodeMaterialConnectionPoint;
  65733. /**
  65734. * Gets the cutoff input component
  65735. */
  65736. get cutoff(): NodeMaterialConnectionPoint;
  65737. protected _buildBlock(state: NodeMaterialBuildState): this;
  65738. }
  65739. }
  65740. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65741. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65742. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65743. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65744. /**
  65745. * Block used to test if the fragment shader is front facing
  65746. */
  65747. export class FrontFacingBlock extends NodeMaterialBlock {
  65748. /**
  65749. * Creates a new FrontFacingBlock
  65750. * @param name defines the block name
  65751. */
  65752. constructor(name: string);
  65753. /**
  65754. * Gets the current class name
  65755. * @returns the class name
  65756. */
  65757. getClassName(): string;
  65758. /**
  65759. * Gets the output component
  65760. */
  65761. get output(): NodeMaterialConnectionPoint;
  65762. protected _buildBlock(state: NodeMaterialBuildState): this;
  65763. }
  65764. }
  65765. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65766. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65767. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65768. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65769. /**
  65770. * Block used to get the derivative value on x and y of a given input
  65771. */
  65772. export class DerivativeBlock extends NodeMaterialBlock {
  65773. /**
  65774. * Create a new DerivativeBlock
  65775. * @param name defines the block name
  65776. */
  65777. constructor(name: string);
  65778. /**
  65779. * Gets the current class name
  65780. * @returns the class name
  65781. */
  65782. getClassName(): string;
  65783. /**
  65784. * Gets the input component
  65785. */
  65786. get input(): NodeMaterialConnectionPoint;
  65787. /**
  65788. * Gets the derivative output on x
  65789. */
  65790. get dx(): NodeMaterialConnectionPoint;
  65791. /**
  65792. * Gets the derivative output on y
  65793. */
  65794. get dy(): NodeMaterialConnectionPoint;
  65795. protected _buildBlock(state: NodeMaterialBuildState): this;
  65796. }
  65797. }
  65798. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65799. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65800. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65801. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65802. /**
  65803. * Block used to make gl_FragCoord available
  65804. */
  65805. export class FragCoordBlock extends NodeMaterialBlock {
  65806. /**
  65807. * Creates a new FragCoordBlock
  65808. * @param name defines the block name
  65809. */
  65810. constructor(name: string);
  65811. /**
  65812. * Gets the current class name
  65813. * @returns the class name
  65814. */
  65815. getClassName(): string;
  65816. /**
  65817. * Gets the xy component
  65818. */
  65819. get xy(): NodeMaterialConnectionPoint;
  65820. /**
  65821. * Gets the xyz component
  65822. */
  65823. get xyz(): NodeMaterialConnectionPoint;
  65824. /**
  65825. * Gets the xyzw component
  65826. */
  65827. get xyzw(): NodeMaterialConnectionPoint;
  65828. /**
  65829. * Gets the x component
  65830. */
  65831. get x(): NodeMaterialConnectionPoint;
  65832. /**
  65833. * Gets the y component
  65834. */
  65835. get y(): NodeMaterialConnectionPoint;
  65836. /**
  65837. * Gets the z component
  65838. */
  65839. get z(): NodeMaterialConnectionPoint;
  65840. /**
  65841. * Gets the w component
  65842. */
  65843. get output(): NodeMaterialConnectionPoint;
  65844. protected writeOutputs(state: NodeMaterialBuildState): string;
  65845. protected _buildBlock(state: NodeMaterialBuildState): this;
  65846. }
  65847. }
  65848. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65849. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65850. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65851. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65852. import { Effect } from "babylonjs/Materials/effect";
  65853. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65854. import { Mesh } from "babylonjs/Meshes/mesh";
  65855. /**
  65856. * Block used to get the screen sizes
  65857. */
  65858. export class ScreenSizeBlock extends NodeMaterialBlock {
  65859. private _varName;
  65860. private _scene;
  65861. /**
  65862. * Creates a new ScreenSizeBlock
  65863. * @param name defines the block name
  65864. */
  65865. constructor(name: string);
  65866. /**
  65867. * Gets the current class name
  65868. * @returns the class name
  65869. */
  65870. getClassName(): string;
  65871. /**
  65872. * Gets the xy component
  65873. */
  65874. get xy(): NodeMaterialConnectionPoint;
  65875. /**
  65876. * Gets the x component
  65877. */
  65878. get x(): NodeMaterialConnectionPoint;
  65879. /**
  65880. * Gets the y component
  65881. */
  65882. get y(): NodeMaterialConnectionPoint;
  65883. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65884. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65885. protected _buildBlock(state: NodeMaterialBuildState): this;
  65886. }
  65887. }
  65888. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  65889. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  65890. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  65891. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  65892. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  65893. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  65894. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  65895. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  65896. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  65897. }
  65898. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  65899. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65900. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65901. import { Mesh } from "babylonjs/Meshes/mesh";
  65902. import { Effect } from "babylonjs/Materials/effect";
  65903. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65905. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65906. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  65907. /**
  65908. * Block used to add support for scene fog
  65909. */
  65910. export class FogBlock extends NodeMaterialBlock {
  65911. private _fogDistanceName;
  65912. private _fogParameters;
  65913. /**
  65914. * Create a new FogBlock
  65915. * @param name defines the block name
  65916. */
  65917. constructor(name: string);
  65918. /**
  65919. * Gets the current class name
  65920. * @returns the class name
  65921. */
  65922. getClassName(): string;
  65923. /**
  65924. * Gets the world position input component
  65925. */
  65926. get worldPosition(): NodeMaterialConnectionPoint;
  65927. /**
  65928. * Gets the view input component
  65929. */
  65930. get view(): NodeMaterialConnectionPoint;
  65931. /**
  65932. * Gets the color input component
  65933. */
  65934. get input(): NodeMaterialConnectionPoint;
  65935. /**
  65936. * Gets the fog color input component
  65937. */
  65938. get fogColor(): NodeMaterialConnectionPoint;
  65939. /**
  65940. * Gets the output component
  65941. */
  65942. get output(): NodeMaterialConnectionPoint;
  65943. autoConfigure(material: NodeMaterial): void;
  65944. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65945. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65946. protected _buildBlock(state: NodeMaterialBuildState): this;
  65947. }
  65948. }
  65949. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  65950. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65951. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65952. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65954. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65955. import { Effect } from "babylonjs/Materials/effect";
  65956. import { Mesh } from "babylonjs/Meshes/mesh";
  65957. import { Light } from "babylonjs/Lights/light";
  65958. import { Nullable } from "babylonjs/types";
  65959. import { Scene } from "babylonjs/scene";
  65960. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  65961. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  65962. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  65963. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65964. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  65965. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  65966. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  65967. /**
  65968. * Block used to add light in the fragment shader
  65969. */
  65970. export class LightBlock extends NodeMaterialBlock {
  65971. private _lightId;
  65972. /**
  65973. * Gets or sets the light associated with this block
  65974. */
  65975. light: Nullable<Light>;
  65976. /**
  65977. * Create a new LightBlock
  65978. * @param name defines the block name
  65979. */
  65980. constructor(name: string);
  65981. /**
  65982. * Gets the current class name
  65983. * @returns the class name
  65984. */
  65985. getClassName(): string;
  65986. /**
  65987. * Gets the world position input component
  65988. */
  65989. get worldPosition(): NodeMaterialConnectionPoint;
  65990. /**
  65991. * Gets the world normal input component
  65992. */
  65993. get worldNormal(): NodeMaterialConnectionPoint;
  65994. /**
  65995. * Gets the camera (or eye) position component
  65996. */
  65997. get cameraPosition(): NodeMaterialConnectionPoint;
  65998. /**
  65999. * Gets the glossiness component
  66000. */
  66001. get glossiness(): NodeMaterialConnectionPoint;
  66002. /**
  66003. * Gets the glossinness power component
  66004. */
  66005. get glossPower(): NodeMaterialConnectionPoint;
  66006. /**
  66007. * Gets the diffuse color component
  66008. */
  66009. get diffuseColor(): NodeMaterialConnectionPoint;
  66010. /**
  66011. * Gets the specular color component
  66012. */
  66013. get specularColor(): NodeMaterialConnectionPoint;
  66014. /**
  66015. * Gets the diffuse output component
  66016. */
  66017. get diffuseOutput(): NodeMaterialConnectionPoint;
  66018. /**
  66019. * Gets the specular output component
  66020. */
  66021. get specularOutput(): NodeMaterialConnectionPoint;
  66022. /**
  66023. * Gets the shadow output component
  66024. */
  66025. get shadow(): NodeMaterialConnectionPoint;
  66026. autoConfigure(material: NodeMaterial): void;
  66027. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66028. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66029. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66030. private _injectVertexCode;
  66031. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66032. serialize(): any;
  66033. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66034. }
  66035. }
  66036. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66037. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66038. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66039. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66040. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66041. /**
  66042. * Block used to read a reflection texture from a sampler
  66043. */
  66044. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66045. /**
  66046. * Create a new ReflectionTextureBlock
  66047. * @param name defines the block name
  66048. */
  66049. constructor(name: string);
  66050. /**
  66051. * Gets the current class name
  66052. * @returns the class name
  66053. */
  66054. getClassName(): string;
  66055. /**
  66056. * Gets the world position input component
  66057. */
  66058. get position(): NodeMaterialConnectionPoint;
  66059. /**
  66060. * Gets the world position input component
  66061. */
  66062. get worldPosition(): NodeMaterialConnectionPoint;
  66063. /**
  66064. * Gets the world normal input component
  66065. */
  66066. get worldNormal(): NodeMaterialConnectionPoint;
  66067. /**
  66068. * Gets the world input component
  66069. */
  66070. get world(): NodeMaterialConnectionPoint;
  66071. /**
  66072. * Gets the camera (or eye) position component
  66073. */
  66074. get cameraPosition(): NodeMaterialConnectionPoint;
  66075. /**
  66076. * Gets the view input component
  66077. */
  66078. get view(): NodeMaterialConnectionPoint;
  66079. /**
  66080. * Gets the rgb output component
  66081. */
  66082. get rgb(): NodeMaterialConnectionPoint;
  66083. /**
  66084. * Gets the rgba output component
  66085. */
  66086. get rgba(): NodeMaterialConnectionPoint;
  66087. /**
  66088. * Gets the r output component
  66089. */
  66090. get r(): NodeMaterialConnectionPoint;
  66091. /**
  66092. * Gets the g output component
  66093. */
  66094. get g(): NodeMaterialConnectionPoint;
  66095. /**
  66096. * Gets the b output component
  66097. */
  66098. get b(): NodeMaterialConnectionPoint;
  66099. /**
  66100. * Gets the a output component
  66101. */
  66102. get a(): NodeMaterialConnectionPoint;
  66103. autoConfigure(material: NodeMaterial): void;
  66104. protected _buildBlock(state: NodeMaterialBuildState): this;
  66105. }
  66106. }
  66107. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66108. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66109. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66110. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66111. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66112. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66113. }
  66114. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66115. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66116. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66117. }
  66118. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66119. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66120. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66121. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66122. /**
  66123. * Block used to add 2 vectors
  66124. */
  66125. export class AddBlock extends NodeMaterialBlock {
  66126. /**
  66127. * Creates a new AddBlock
  66128. * @param name defines the block name
  66129. */
  66130. constructor(name: string);
  66131. /**
  66132. * Gets the current class name
  66133. * @returns the class name
  66134. */
  66135. getClassName(): string;
  66136. /**
  66137. * Gets the left operand input component
  66138. */
  66139. get left(): NodeMaterialConnectionPoint;
  66140. /**
  66141. * Gets the right operand input component
  66142. */
  66143. get right(): NodeMaterialConnectionPoint;
  66144. /**
  66145. * Gets the output component
  66146. */
  66147. get output(): NodeMaterialConnectionPoint;
  66148. protected _buildBlock(state: NodeMaterialBuildState): this;
  66149. }
  66150. }
  66151. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66152. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66153. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66154. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66155. /**
  66156. * Block used to scale a vector by a float
  66157. */
  66158. export class ScaleBlock extends NodeMaterialBlock {
  66159. /**
  66160. * Creates a new ScaleBlock
  66161. * @param name defines the block name
  66162. */
  66163. constructor(name: string);
  66164. /**
  66165. * Gets the current class name
  66166. * @returns the class name
  66167. */
  66168. getClassName(): string;
  66169. /**
  66170. * Gets the input component
  66171. */
  66172. get input(): NodeMaterialConnectionPoint;
  66173. /**
  66174. * Gets the factor input component
  66175. */
  66176. get factor(): NodeMaterialConnectionPoint;
  66177. /**
  66178. * Gets the output component
  66179. */
  66180. get output(): NodeMaterialConnectionPoint;
  66181. protected _buildBlock(state: NodeMaterialBuildState): this;
  66182. }
  66183. }
  66184. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66185. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66186. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66187. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66188. import { Scene } from "babylonjs/scene";
  66189. /**
  66190. * Block used to clamp a float
  66191. */
  66192. export class ClampBlock extends NodeMaterialBlock {
  66193. /** Gets or sets the minimum range */
  66194. minimum: number;
  66195. /** Gets or sets the maximum range */
  66196. maximum: number;
  66197. /**
  66198. * Creates a new ClampBlock
  66199. * @param name defines the block name
  66200. */
  66201. constructor(name: string);
  66202. /**
  66203. * Gets the current class name
  66204. * @returns the class name
  66205. */
  66206. getClassName(): string;
  66207. /**
  66208. * Gets the value input component
  66209. */
  66210. get value(): NodeMaterialConnectionPoint;
  66211. /**
  66212. * Gets the output component
  66213. */
  66214. get output(): NodeMaterialConnectionPoint;
  66215. protected _buildBlock(state: NodeMaterialBuildState): this;
  66216. protected _dumpPropertiesCode(): string;
  66217. serialize(): any;
  66218. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66219. }
  66220. }
  66221. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66222. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66223. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66224. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66225. /**
  66226. * Block used to apply a cross product between 2 vectors
  66227. */
  66228. export class CrossBlock extends NodeMaterialBlock {
  66229. /**
  66230. * Creates a new CrossBlock
  66231. * @param name defines the block name
  66232. */
  66233. constructor(name: string);
  66234. /**
  66235. * Gets the current class name
  66236. * @returns the class name
  66237. */
  66238. getClassName(): string;
  66239. /**
  66240. * Gets the left operand input component
  66241. */
  66242. get left(): NodeMaterialConnectionPoint;
  66243. /**
  66244. * Gets the right operand input component
  66245. */
  66246. get right(): NodeMaterialConnectionPoint;
  66247. /**
  66248. * Gets the output component
  66249. */
  66250. get output(): NodeMaterialConnectionPoint;
  66251. protected _buildBlock(state: NodeMaterialBuildState): this;
  66252. }
  66253. }
  66254. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66257. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66258. /**
  66259. * Block used to apply a dot product between 2 vectors
  66260. */
  66261. export class DotBlock extends NodeMaterialBlock {
  66262. /**
  66263. * Creates a new DotBlock
  66264. * @param name defines the block name
  66265. */
  66266. constructor(name: string);
  66267. /**
  66268. * Gets the current class name
  66269. * @returns the class name
  66270. */
  66271. getClassName(): string;
  66272. /**
  66273. * Gets the left operand input component
  66274. */
  66275. get left(): NodeMaterialConnectionPoint;
  66276. /**
  66277. * Gets the right operand input component
  66278. */
  66279. get right(): NodeMaterialConnectionPoint;
  66280. /**
  66281. * Gets the output component
  66282. */
  66283. get output(): NodeMaterialConnectionPoint;
  66284. protected _buildBlock(state: NodeMaterialBuildState): this;
  66285. }
  66286. }
  66287. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66288. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66289. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66290. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66291. /**
  66292. * Block used to normalize a vector
  66293. */
  66294. export class NormalizeBlock extends NodeMaterialBlock {
  66295. /**
  66296. * Creates a new NormalizeBlock
  66297. * @param name defines the block name
  66298. */
  66299. constructor(name: string);
  66300. /**
  66301. * Gets the current class name
  66302. * @returns the class name
  66303. */
  66304. getClassName(): string;
  66305. /**
  66306. * Gets the input component
  66307. */
  66308. get input(): NodeMaterialConnectionPoint;
  66309. /**
  66310. * Gets the output component
  66311. */
  66312. get output(): NodeMaterialConnectionPoint;
  66313. protected _buildBlock(state: NodeMaterialBuildState): this;
  66314. }
  66315. }
  66316. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  66317. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66318. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66319. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66320. import { Scene } from "babylonjs/scene";
  66321. /**
  66322. * Operations supported by the Trigonometry block
  66323. */
  66324. export enum TrigonometryBlockOperations {
  66325. /** Cos */
  66326. Cos = 0,
  66327. /** Sin */
  66328. Sin = 1,
  66329. /** Abs */
  66330. Abs = 2,
  66331. /** Exp */
  66332. Exp = 3,
  66333. /** Exp2 */
  66334. Exp2 = 4,
  66335. /** Round */
  66336. Round = 5,
  66337. /** Floor */
  66338. Floor = 6,
  66339. /** Ceiling */
  66340. Ceiling = 7,
  66341. /** Square root */
  66342. Sqrt = 8,
  66343. /** Log */
  66344. Log = 9,
  66345. /** Tangent */
  66346. Tan = 10,
  66347. /** Arc tangent */
  66348. ArcTan = 11,
  66349. /** Arc cosinus */
  66350. ArcCos = 12,
  66351. /** Arc sinus */
  66352. ArcSin = 13,
  66353. /** Fraction */
  66354. Fract = 14,
  66355. /** Sign */
  66356. Sign = 15,
  66357. /** To radians (from degrees) */
  66358. Radians = 16,
  66359. /** To degrees (from radians) */
  66360. Degrees = 17
  66361. }
  66362. /**
  66363. * Block used to apply trigonometry operation to floats
  66364. */
  66365. export class TrigonometryBlock extends NodeMaterialBlock {
  66366. /**
  66367. * Gets or sets the operation applied by the block
  66368. */
  66369. operation: TrigonometryBlockOperations;
  66370. /**
  66371. * Creates a new TrigonometryBlock
  66372. * @param name defines the block name
  66373. */
  66374. constructor(name: string);
  66375. /**
  66376. * Gets the current class name
  66377. * @returns the class name
  66378. */
  66379. getClassName(): string;
  66380. /**
  66381. * Gets the input component
  66382. */
  66383. get input(): NodeMaterialConnectionPoint;
  66384. /**
  66385. * Gets the output component
  66386. */
  66387. get output(): NodeMaterialConnectionPoint;
  66388. protected _buildBlock(state: NodeMaterialBuildState): this;
  66389. serialize(): any;
  66390. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66391. protected _dumpPropertiesCode(): string;
  66392. }
  66393. }
  66394. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66395. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66396. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66397. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66398. /**
  66399. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66400. */
  66401. export class ColorMergerBlock extends NodeMaterialBlock {
  66402. /**
  66403. * Create a new ColorMergerBlock
  66404. * @param name defines the block name
  66405. */
  66406. constructor(name: string);
  66407. /**
  66408. * Gets the current class name
  66409. * @returns the class name
  66410. */
  66411. getClassName(): string;
  66412. /**
  66413. * Gets the rgb component (input)
  66414. */
  66415. get rgbIn(): NodeMaterialConnectionPoint;
  66416. /**
  66417. * Gets the r component (input)
  66418. */
  66419. get r(): NodeMaterialConnectionPoint;
  66420. /**
  66421. * Gets the g component (input)
  66422. */
  66423. get g(): NodeMaterialConnectionPoint;
  66424. /**
  66425. * Gets the b component (input)
  66426. */
  66427. get b(): NodeMaterialConnectionPoint;
  66428. /**
  66429. * Gets the a component (input)
  66430. */
  66431. get a(): NodeMaterialConnectionPoint;
  66432. /**
  66433. * Gets the rgba component (output)
  66434. */
  66435. get rgba(): NodeMaterialConnectionPoint;
  66436. /**
  66437. * Gets the rgb component (output)
  66438. */
  66439. get rgbOut(): NodeMaterialConnectionPoint;
  66440. /**
  66441. * Gets the rgb component (output)
  66442. * @deprecated Please use rgbOut instead.
  66443. */
  66444. get rgb(): NodeMaterialConnectionPoint;
  66445. protected _buildBlock(state: NodeMaterialBuildState): this;
  66446. }
  66447. }
  66448. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66452. /**
  66453. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66454. */
  66455. export class VectorSplitterBlock extends NodeMaterialBlock {
  66456. /**
  66457. * Create a new VectorSplitterBlock
  66458. * @param name defines the block name
  66459. */
  66460. constructor(name: string);
  66461. /**
  66462. * Gets the current class name
  66463. * @returns the class name
  66464. */
  66465. getClassName(): string;
  66466. /**
  66467. * Gets the xyzw component (input)
  66468. */
  66469. get xyzw(): NodeMaterialConnectionPoint;
  66470. /**
  66471. * Gets the xyz component (input)
  66472. */
  66473. get xyzIn(): NodeMaterialConnectionPoint;
  66474. /**
  66475. * Gets the xy component (input)
  66476. */
  66477. get xyIn(): NodeMaterialConnectionPoint;
  66478. /**
  66479. * Gets the xyz component (output)
  66480. */
  66481. get xyzOut(): NodeMaterialConnectionPoint;
  66482. /**
  66483. * Gets the xy component (output)
  66484. */
  66485. get xyOut(): NodeMaterialConnectionPoint;
  66486. /**
  66487. * Gets the x component (output)
  66488. */
  66489. get x(): NodeMaterialConnectionPoint;
  66490. /**
  66491. * Gets the y component (output)
  66492. */
  66493. get y(): NodeMaterialConnectionPoint;
  66494. /**
  66495. * Gets the z component (output)
  66496. */
  66497. get z(): NodeMaterialConnectionPoint;
  66498. /**
  66499. * Gets the w component (output)
  66500. */
  66501. get w(): NodeMaterialConnectionPoint;
  66502. protected _inputRename(name: string): string;
  66503. protected _outputRename(name: string): string;
  66504. protected _buildBlock(state: NodeMaterialBuildState): this;
  66505. }
  66506. }
  66507. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66508. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66509. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66510. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66511. /**
  66512. * Block used to lerp between 2 values
  66513. */
  66514. export class LerpBlock extends NodeMaterialBlock {
  66515. /**
  66516. * Creates a new LerpBlock
  66517. * @param name defines the block name
  66518. */
  66519. constructor(name: string);
  66520. /**
  66521. * Gets the current class name
  66522. * @returns the class name
  66523. */
  66524. getClassName(): string;
  66525. /**
  66526. * Gets the left operand input component
  66527. */
  66528. get left(): NodeMaterialConnectionPoint;
  66529. /**
  66530. * Gets the right operand input component
  66531. */
  66532. get right(): NodeMaterialConnectionPoint;
  66533. /**
  66534. * Gets the gradient operand input component
  66535. */
  66536. get gradient(): NodeMaterialConnectionPoint;
  66537. /**
  66538. * Gets the output component
  66539. */
  66540. get output(): NodeMaterialConnectionPoint;
  66541. protected _buildBlock(state: NodeMaterialBuildState): this;
  66542. }
  66543. }
  66544. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66545. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66546. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66547. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66548. /**
  66549. * Block used to divide 2 vectors
  66550. */
  66551. export class DivideBlock extends NodeMaterialBlock {
  66552. /**
  66553. * Creates a new DivideBlock
  66554. * @param name defines the block name
  66555. */
  66556. constructor(name: string);
  66557. /**
  66558. * Gets the current class name
  66559. * @returns the class name
  66560. */
  66561. getClassName(): string;
  66562. /**
  66563. * Gets the left operand input component
  66564. */
  66565. get left(): NodeMaterialConnectionPoint;
  66566. /**
  66567. * Gets the right operand input component
  66568. */
  66569. get right(): NodeMaterialConnectionPoint;
  66570. /**
  66571. * Gets the output component
  66572. */
  66573. get output(): NodeMaterialConnectionPoint;
  66574. protected _buildBlock(state: NodeMaterialBuildState): this;
  66575. }
  66576. }
  66577. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66578. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66579. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66580. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66581. /**
  66582. * Block used to subtract 2 vectors
  66583. */
  66584. export class SubtractBlock extends NodeMaterialBlock {
  66585. /**
  66586. * Creates a new SubtractBlock
  66587. * @param name defines the block name
  66588. */
  66589. constructor(name: string);
  66590. /**
  66591. * Gets the current class name
  66592. * @returns the class name
  66593. */
  66594. getClassName(): string;
  66595. /**
  66596. * Gets the left operand input component
  66597. */
  66598. get left(): NodeMaterialConnectionPoint;
  66599. /**
  66600. * Gets the right operand input component
  66601. */
  66602. get right(): NodeMaterialConnectionPoint;
  66603. /**
  66604. * Gets the output component
  66605. */
  66606. get output(): NodeMaterialConnectionPoint;
  66607. protected _buildBlock(state: NodeMaterialBuildState): this;
  66608. }
  66609. }
  66610. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66611. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66612. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66613. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66614. /**
  66615. * Block used to step a value
  66616. */
  66617. export class StepBlock extends NodeMaterialBlock {
  66618. /**
  66619. * Creates a new StepBlock
  66620. * @param name defines the block name
  66621. */
  66622. constructor(name: string);
  66623. /**
  66624. * Gets the current class name
  66625. * @returns the class name
  66626. */
  66627. getClassName(): string;
  66628. /**
  66629. * Gets the value operand input component
  66630. */
  66631. get value(): NodeMaterialConnectionPoint;
  66632. /**
  66633. * Gets the edge operand input component
  66634. */
  66635. get edge(): NodeMaterialConnectionPoint;
  66636. /**
  66637. * Gets the output component
  66638. */
  66639. get output(): NodeMaterialConnectionPoint;
  66640. protected _buildBlock(state: NodeMaterialBuildState): this;
  66641. }
  66642. }
  66643. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66644. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66645. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66646. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66647. /**
  66648. * Block used to get the opposite (1 - x) of a value
  66649. */
  66650. export class OneMinusBlock extends NodeMaterialBlock {
  66651. /**
  66652. * Creates a new OneMinusBlock
  66653. * @param name defines the block name
  66654. */
  66655. constructor(name: string);
  66656. /**
  66657. * Gets the current class name
  66658. * @returns the class name
  66659. */
  66660. getClassName(): string;
  66661. /**
  66662. * Gets the input component
  66663. */
  66664. get input(): NodeMaterialConnectionPoint;
  66665. /**
  66666. * Gets the output component
  66667. */
  66668. get output(): NodeMaterialConnectionPoint;
  66669. protected _buildBlock(state: NodeMaterialBuildState): this;
  66670. }
  66671. }
  66672. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66673. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66674. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66675. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66676. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66677. /**
  66678. * Block used to get the view direction
  66679. */
  66680. export class ViewDirectionBlock extends NodeMaterialBlock {
  66681. /**
  66682. * Creates a new ViewDirectionBlock
  66683. * @param name defines the block name
  66684. */
  66685. constructor(name: string);
  66686. /**
  66687. * Gets the current class name
  66688. * @returns the class name
  66689. */
  66690. getClassName(): string;
  66691. /**
  66692. * Gets the world position component
  66693. */
  66694. get worldPosition(): NodeMaterialConnectionPoint;
  66695. /**
  66696. * Gets the camera position component
  66697. */
  66698. get cameraPosition(): NodeMaterialConnectionPoint;
  66699. /**
  66700. * Gets the output component
  66701. */
  66702. get output(): NodeMaterialConnectionPoint;
  66703. autoConfigure(material: NodeMaterial): void;
  66704. protected _buildBlock(state: NodeMaterialBuildState): this;
  66705. }
  66706. }
  66707. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66708. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66709. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66710. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66711. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66712. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66713. /**
  66714. * Block used to compute fresnel value
  66715. */
  66716. export class FresnelBlock extends NodeMaterialBlock {
  66717. /**
  66718. * Create a new FresnelBlock
  66719. * @param name defines the block name
  66720. */
  66721. constructor(name: string);
  66722. /**
  66723. * Gets the current class name
  66724. * @returns the class name
  66725. */
  66726. getClassName(): string;
  66727. /**
  66728. * Gets the world normal input component
  66729. */
  66730. get worldNormal(): NodeMaterialConnectionPoint;
  66731. /**
  66732. * Gets the view direction input component
  66733. */
  66734. get viewDirection(): NodeMaterialConnectionPoint;
  66735. /**
  66736. * Gets the bias input component
  66737. */
  66738. get bias(): NodeMaterialConnectionPoint;
  66739. /**
  66740. * Gets the camera (or eye) position component
  66741. */
  66742. get power(): NodeMaterialConnectionPoint;
  66743. /**
  66744. * Gets the fresnel output component
  66745. */
  66746. get fresnel(): NodeMaterialConnectionPoint;
  66747. autoConfigure(material: NodeMaterial): void;
  66748. protected _buildBlock(state: NodeMaterialBuildState): this;
  66749. }
  66750. }
  66751. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66752. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66753. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66754. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66755. /**
  66756. * Block used to get the max of 2 values
  66757. */
  66758. export class MaxBlock extends NodeMaterialBlock {
  66759. /**
  66760. * Creates a new MaxBlock
  66761. * @param name defines the block name
  66762. */
  66763. constructor(name: string);
  66764. /**
  66765. * Gets the current class name
  66766. * @returns the class name
  66767. */
  66768. getClassName(): string;
  66769. /**
  66770. * Gets the left operand input component
  66771. */
  66772. get left(): NodeMaterialConnectionPoint;
  66773. /**
  66774. * Gets the right operand input component
  66775. */
  66776. get right(): NodeMaterialConnectionPoint;
  66777. /**
  66778. * Gets the output component
  66779. */
  66780. get output(): NodeMaterialConnectionPoint;
  66781. protected _buildBlock(state: NodeMaterialBuildState): this;
  66782. }
  66783. }
  66784. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66785. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66786. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66787. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66788. /**
  66789. * Block used to get the min of 2 values
  66790. */
  66791. export class MinBlock extends NodeMaterialBlock {
  66792. /**
  66793. * Creates a new MinBlock
  66794. * @param name defines the block name
  66795. */
  66796. constructor(name: string);
  66797. /**
  66798. * Gets the current class name
  66799. * @returns the class name
  66800. */
  66801. getClassName(): string;
  66802. /**
  66803. * Gets the left operand input component
  66804. */
  66805. get left(): NodeMaterialConnectionPoint;
  66806. /**
  66807. * Gets the right operand input component
  66808. */
  66809. get right(): NodeMaterialConnectionPoint;
  66810. /**
  66811. * Gets the output component
  66812. */
  66813. get output(): NodeMaterialConnectionPoint;
  66814. protected _buildBlock(state: NodeMaterialBuildState): this;
  66815. }
  66816. }
  66817. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66818. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66819. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66820. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66821. /**
  66822. * Block used to get the distance between 2 values
  66823. */
  66824. export class DistanceBlock extends NodeMaterialBlock {
  66825. /**
  66826. * Creates a new DistanceBlock
  66827. * @param name defines the block name
  66828. */
  66829. constructor(name: string);
  66830. /**
  66831. * Gets the current class name
  66832. * @returns the class name
  66833. */
  66834. getClassName(): string;
  66835. /**
  66836. * Gets the left operand input component
  66837. */
  66838. get left(): NodeMaterialConnectionPoint;
  66839. /**
  66840. * Gets the right operand input component
  66841. */
  66842. get right(): NodeMaterialConnectionPoint;
  66843. /**
  66844. * Gets the output component
  66845. */
  66846. get output(): NodeMaterialConnectionPoint;
  66847. protected _buildBlock(state: NodeMaterialBuildState): this;
  66848. }
  66849. }
  66850. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66851. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66852. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66853. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66854. /**
  66855. * Block used to get the length of a vector
  66856. */
  66857. export class LengthBlock extends NodeMaterialBlock {
  66858. /**
  66859. * Creates a new LengthBlock
  66860. * @param name defines the block name
  66861. */
  66862. constructor(name: string);
  66863. /**
  66864. * Gets the current class name
  66865. * @returns the class name
  66866. */
  66867. getClassName(): string;
  66868. /**
  66869. * Gets the value input component
  66870. */
  66871. get value(): NodeMaterialConnectionPoint;
  66872. /**
  66873. * Gets the output component
  66874. */
  66875. get output(): NodeMaterialConnectionPoint;
  66876. protected _buildBlock(state: NodeMaterialBuildState): this;
  66877. }
  66878. }
  66879. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66880. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66881. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66882. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66883. /**
  66884. * Block used to get negative version of a value (i.e. x * -1)
  66885. */
  66886. export class NegateBlock extends NodeMaterialBlock {
  66887. /**
  66888. * Creates a new NegateBlock
  66889. * @param name defines the block name
  66890. */
  66891. constructor(name: string);
  66892. /**
  66893. * Gets the current class name
  66894. * @returns the class name
  66895. */
  66896. getClassName(): string;
  66897. /**
  66898. * Gets the value input component
  66899. */
  66900. get value(): NodeMaterialConnectionPoint;
  66901. /**
  66902. * Gets the output component
  66903. */
  66904. get output(): NodeMaterialConnectionPoint;
  66905. protected _buildBlock(state: NodeMaterialBuildState): this;
  66906. }
  66907. }
  66908. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66909. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66910. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66911. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66912. /**
  66913. * Block used to get the value of the first parameter raised to the power of the second
  66914. */
  66915. export class PowBlock extends NodeMaterialBlock {
  66916. /**
  66917. * Creates a new PowBlock
  66918. * @param name defines the block name
  66919. */
  66920. constructor(name: string);
  66921. /**
  66922. * Gets the current class name
  66923. * @returns the class name
  66924. */
  66925. getClassName(): string;
  66926. /**
  66927. * Gets the value operand input component
  66928. */
  66929. get value(): NodeMaterialConnectionPoint;
  66930. /**
  66931. * Gets the power operand input component
  66932. */
  66933. get power(): NodeMaterialConnectionPoint;
  66934. /**
  66935. * Gets the output component
  66936. */
  66937. get output(): NodeMaterialConnectionPoint;
  66938. protected _buildBlock(state: NodeMaterialBuildState): this;
  66939. }
  66940. }
  66941. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66942. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66943. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66944. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66945. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66946. /**
  66947. * Block used to get a random number
  66948. */
  66949. export class RandomNumberBlock extends NodeMaterialBlock {
  66950. /**
  66951. * Creates a new RandomNumberBlock
  66952. * @param name defines the block name
  66953. */
  66954. constructor(name: string);
  66955. /**
  66956. * Gets the current class name
  66957. * @returns the class name
  66958. */
  66959. getClassName(): string;
  66960. /**
  66961. * Gets the seed input component
  66962. */
  66963. get seed(): NodeMaterialConnectionPoint;
  66964. /**
  66965. * Gets the output component
  66966. */
  66967. get output(): NodeMaterialConnectionPoint;
  66968. protected _buildBlock(state: NodeMaterialBuildState): this;
  66969. }
  66970. }
  66971. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  66972. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66973. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66974. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66975. /**
  66976. * Block used to compute arc tangent of 2 values
  66977. */
  66978. export class ArcTan2Block extends NodeMaterialBlock {
  66979. /**
  66980. * Creates a new ArcTan2Block
  66981. * @param name defines the block name
  66982. */
  66983. constructor(name: string);
  66984. /**
  66985. * Gets the current class name
  66986. * @returns the class name
  66987. */
  66988. getClassName(): string;
  66989. /**
  66990. * Gets the x operand input component
  66991. */
  66992. get x(): NodeMaterialConnectionPoint;
  66993. /**
  66994. * Gets the y operand input component
  66995. */
  66996. get y(): NodeMaterialConnectionPoint;
  66997. /**
  66998. * Gets the output component
  66999. */
  67000. get output(): NodeMaterialConnectionPoint;
  67001. protected _buildBlock(state: NodeMaterialBuildState): this;
  67002. }
  67003. }
  67004. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67005. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67006. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67007. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67008. /**
  67009. * Block used to smooth step a value
  67010. */
  67011. export class SmoothStepBlock extends NodeMaterialBlock {
  67012. /**
  67013. * Creates a new SmoothStepBlock
  67014. * @param name defines the block name
  67015. */
  67016. constructor(name: string);
  67017. /**
  67018. * Gets the current class name
  67019. * @returns the class name
  67020. */
  67021. getClassName(): string;
  67022. /**
  67023. * Gets the value operand input component
  67024. */
  67025. get value(): NodeMaterialConnectionPoint;
  67026. /**
  67027. * Gets the first edge operand input component
  67028. */
  67029. get edge0(): NodeMaterialConnectionPoint;
  67030. /**
  67031. * Gets the second edge operand input component
  67032. */
  67033. get edge1(): NodeMaterialConnectionPoint;
  67034. /**
  67035. * Gets the output component
  67036. */
  67037. get output(): NodeMaterialConnectionPoint;
  67038. protected _buildBlock(state: NodeMaterialBuildState): this;
  67039. }
  67040. }
  67041. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67042. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67043. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67044. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67045. /**
  67046. * Block used to get the reciprocal (1 / x) of a value
  67047. */
  67048. export class ReciprocalBlock extends NodeMaterialBlock {
  67049. /**
  67050. * Creates a new ReciprocalBlock
  67051. * @param name defines the block name
  67052. */
  67053. constructor(name: string);
  67054. /**
  67055. * Gets the current class name
  67056. * @returns the class name
  67057. */
  67058. getClassName(): string;
  67059. /**
  67060. * Gets the input component
  67061. */
  67062. get input(): NodeMaterialConnectionPoint;
  67063. /**
  67064. * Gets the output component
  67065. */
  67066. get output(): NodeMaterialConnectionPoint;
  67067. protected _buildBlock(state: NodeMaterialBuildState): this;
  67068. }
  67069. }
  67070. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67071. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67072. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67073. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67074. /**
  67075. * Block used to replace a color by another one
  67076. */
  67077. export class ReplaceColorBlock extends NodeMaterialBlock {
  67078. /**
  67079. * Creates a new ReplaceColorBlock
  67080. * @param name defines the block name
  67081. */
  67082. constructor(name: string);
  67083. /**
  67084. * Gets the current class name
  67085. * @returns the class name
  67086. */
  67087. getClassName(): string;
  67088. /**
  67089. * Gets the value input component
  67090. */
  67091. get value(): NodeMaterialConnectionPoint;
  67092. /**
  67093. * Gets the reference input component
  67094. */
  67095. get reference(): NodeMaterialConnectionPoint;
  67096. /**
  67097. * Gets the distance input component
  67098. */
  67099. get distance(): NodeMaterialConnectionPoint;
  67100. /**
  67101. * Gets the replacement input component
  67102. */
  67103. get replacement(): NodeMaterialConnectionPoint;
  67104. /**
  67105. * Gets the output component
  67106. */
  67107. get output(): NodeMaterialConnectionPoint;
  67108. protected _buildBlock(state: NodeMaterialBuildState): this;
  67109. }
  67110. }
  67111. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67112. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67113. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67114. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67115. /**
  67116. * Block used to posterize a value
  67117. * @see https://en.wikipedia.org/wiki/Posterization
  67118. */
  67119. export class PosterizeBlock extends NodeMaterialBlock {
  67120. /**
  67121. * Creates a new PosterizeBlock
  67122. * @param name defines the block name
  67123. */
  67124. constructor(name: string);
  67125. /**
  67126. * Gets the current class name
  67127. * @returns the class name
  67128. */
  67129. getClassName(): string;
  67130. /**
  67131. * Gets the value input component
  67132. */
  67133. get value(): NodeMaterialConnectionPoint;
  67134. /**
  67135. * Gets the steps input component
  67136. */
  67137. get steps(): NodeMaterialConnectionPoint;
  67138. /**
  67139. * Gets the output component
  67140. */
  67141. get output(): NodeMaterialConnectionPoint;
  67142. protected _buildBlock(state: NodeMaterialBuildState): this;
  67143. }
  67144. }
  67145. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67146. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67147. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67148. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67149. import { Scene } from "babylonjs/scene";
  67150. /**
  67151. * Operations supported by the Wave block
  67152. */
  67153. export enum WaveBlockKind {
  67154. /** SawTooth */
  67155. SawTooth = 0,
  67156. /** Square */
  67157. Square = 1,
  67158. /** Triangle */
  67159. Triangle = 2
  67160. }
  67161. /**
  67162. * Block used to apply wave operation to floats
  67163. */
  67164. export class WaveBlock extends NodeMaterialBlock {
  67165. /**
  67166. * Gets or sets the kibnd of wave to be applied by the block
  67167. */
  67168. kind: WaveBlockKind;
  67169. /**
  67170. * Creates a new WaveBlock
  67171. * @param name defines the block name
  67172. */
  67173. constructor(name: string);
  67174. /**
  67175. * Gets the current class name
  67176. * @returns the class name
  67177. */
  67178. getClassName(): string;
  67179. /**
  67180. * Gets the input component
  67181. */
  67182. get input(): NodeMaterialConnectionPoint;
  67183. /**
  67184. * Gets the output component
  67185. */
  67186. get output(): NodeMaterialConnectionPoint;
  67187. protected _buildBlock(state: NodeMaterialBuildState): this;
  67188. serialize(): any;
  67189. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67190. }
  67191. }
  67192. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67193. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67194. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67195. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67196. import { Color3 } from "babylonjs/Maths/math.color";
  67197. import { Scene } from "babylonjs/scene";
  67198. import { Observable } from "babylonjs/Misc/observable";
  67199. /**
  67200. * Class used to store a color step for the GradientBlock
  67201. */
  67202. export class GradientBlockColorStep {
  67203. private _step;
  67204. /**
  67205. * Gets value indicating which step this color is associated with (between 0 and 1)
  67206. */
  67207. get step(): number;
  67208. /**
  67209. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67210. */
  67211. set step(val: number);
  67212. private _color;
  67213. /**
  67214. * Gets the color associated with this step
  67215. */
  67216. get color(): Color3;
  67217. /**
  67218. * Sets the color associated with this step
  67219. */
  67220. set color(val: Color3);
  67221. /**
  67222. * Creates a new GradientBlockColorStep
  67223. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67224. * @param color defines the color associated with this step
  67225. */
  67226. constructor(step: number, color: Color3);
  67227. }
  67228. /**
  67229. * Block used to return a color from a gradient based on an input value between 0 and 1
  67230. */
  67231. export class GradientBlock extends NodeMaterialBlock {
  67232. /**
  67233. * Gets or sets the list of color steps
  67234. */
  67235. colorSteps: GradientBlockColorStep[];
  67236. /** Gets an observable raised when the value is changed */
  67237. onValueChangedObservable: Observable<GradientBlock>;
  67238. /** calls observable when the value is changed*/
  67239. colorStepsUpdated(): void;
  67240. /**
  67241. * Creates a new GradientBlock
  67242. * @param name defines the block name
  67243. */
  67244. constructor(name: string);
  67245. /**
  67246. * Gets the current class name
  67247. * @returns the class name
  67248. */
  67249. getClassName(): string;
  67250. /**
  67251. * Gets the gradient input component
  67252. */
  67253. get gradient(): NodeMaterialConnectionPoint;
  67254. /**
  67255. * Gets the output component
  67256. */
  67257. get output(): NodeMaterialConnectionPoint;
  67258. private _writeColorConstant;
  67259. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67260. serialize(): any;
  67261. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67262. protected _dumpPropertiesCode(): string;
  67263. }
  67264. }
  67265. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67266. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67267. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67268. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67269. /**
  67270. * Block used to normalize lerp between 2 values
  67271. */
  67272. export class NLerpBlock extends NodeMaterialBlock {
  67273. /**
  67274. * Creates a new NLerpBlock
  67275. * @param name defines the block name
  67276. */
  67277. constructor(name: string);
  67278. /**
  67279. * Gets the current class name
  67280. * @returns the class name
  67281. */
  67282. getClassName(): string;
  67283. /**
  67284. * Gets the left operand input component
  67285. */
  67286. get left(): NodeMaterialConnectionPoint;
  67287. /**
  67288. * Gets the right operand input component
  67289. */
  67290. get right(): NodeMaterialConnectionPoint;
  67291. /**
  67292. * Gets the gradient operand input component
  67293. */
  67294. get gradient(): NodeMaterialConnectionPoint;
  67295. /**
  67296. * Gets the output component
  67297. */
  67298. get output(): NodeMaterialConnectionPoint;
  67299. protected _buildBlock(state: NodeMaterialBuildState): this;
  67300. }
  67301. }
  67302. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67303. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67304. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67305. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67306. import { Scene } from "babylonjs/scene";
  67307. /**
  67308. * block used to Generate a Worley Noise 3D Noise Pattern
  67309. */
  67310. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67311. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67312. manhattanDistance: boolean;
  67313. /**
  67314. * Creates a new WorleyNoise3DBlock
  67315. * @param name defines the block name
  67316. */
  67317. constructor(name: string);
  67318. /**
  67319. * Gets the current class name
  67320. * @returns the class name
  67321. */
  67322. getClassName(): string;
  67323. /**
  67324. * Gets the seed input component
  67325. */
  67326. get seed(): NodeMaterialConnectionPoint;
  67327. /**
  67328. * Gets the jitter input component
  67329. */
  67330. get jitter(): NodeMaterialConnectionPoint;
  67331. /**
  67332. * Gets the output component
  67333. */
  67334. get output(): NodeMaterialConnectionPoint;
  67335. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67336. /**
  67337. * Exposes the properties to the UI?
  67338. */
  67339. protected _dumpPropertiesCode(): string;
  67340. /**
  67341. * Exposes the properties to the Seralize?
  67342. */
  67343. serialize(): any;
  67344. /**
  67345. * Exposes the properties to the deseralize?
  67346. */
  67347. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67348. }
  67349. }
  67350. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67351. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67352. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67353. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67354. /**
  67355. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67356. */
  67357. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67358. /**
  67359. * Creates a new SimplexPerlin3DBlock
  67360. * @param name defines the block name
  67361. */
  67362. constructor(name: string);
  67363. /**
  67364. * Gets the current class name
  67365. * @returns the class name
  67366. */
  67367. getClassName(): string;
  67368. /**
  67369. * Gets the seed operand input component
  67370. */
  67371. get seed(): NodeMaterialConnectionPoint;
  67372. /**
  67373. * Gets the output component
  67374. */
  67375. get output(): NodeMaterialConnectionPoint;
  67376. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67377. }
  67378. }
  67379. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67380. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67381. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67382. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67383. /**
  67384. * Block used to blend normals
  67385. */
  67386. export class NormalBlendBlock extends NodeMaterialBlock {
  67387. /**
  67388. * Creates a new NormalBlendBlock
  67389. * @param name defines the block name
  67390. */
  67391. constructor(name: string);
  67392. /**
  67393. * Gets the current class name
  67394. * @returns the class name
  67395. */
  67396. getClassName(): string;
  67397. /**
  67398. * Gets the first input component
  67399. */
  67400. get normalMap0(): NodeMaterialConnectionPoint;
  67401. /**
  67402. * Gets the second input component
  67403. */
  67404. get normalMap1(): NodeMaterialConnectionPoint;
  67405. /**
  67406. * Gets the output component
  67407. */
  67408. get output(): NodeMaterialConnectionPoint;
  67409. protected _buildBlock(state: NodeMaterialBuildState): this;
  67410. }
  67411. }
  67412. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67413. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67414. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67415. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67416. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67417. /**
  67418. * Block used to rotate a 2d vector by a given angle
  67419. */
  67420. export class Rotate2dBlock extends NodeMaterialBlock {
  67421. /**
  67422. * Creates a new Rotate2dBlock
  67423. * @param name defines the block name
  67424. */
  67425. constructor(name: string);
  67426. /**
  67427. * Gets the current class name
  67428. * @returns the class name
  67429. */
  67430. getClassName(): string;
  67431. /**
  67432. * Gets the input vector
  67433. */
  67434. get input(): NodeMaterialConnectionPoint;
  67435. /**
  67436. * Gets the input angle
  67437. */
  67438. get angle(): NodeMaterialConnectionPoint;
  67439. /**
  67440. * Gets the output component
  67441. */
  67442. get output(): NodeMaterialConnectionPoint;
  67443. autoConfigure(material: NodeMaterial): void;
  67444. protected _buildBlock(state: NodeMaterialBuildState): this;
  67445. }
  67446. }
  67447. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67448. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67449. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67450. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67451. /**
  67452. * Block used to get the reflected vector from a direction and a normal
  67453. */
  67454. export class ReflectBlock extends NodeMaterialBlock {
  67455. /**
  67456. * Creates a new ReflectBlock
  67457. * @param name defines the block name
  67458. */
  67459. constructor(name: string);
  67460. /**
  67461. * Gets the current class name
  67462. * @returns the class name
  67463. */
  67464. getClassName(): string;
  67465. /**
  67466. * Gets the incident component
  67467. */
  67468. get incident(): NodeMaterialConnectionPoint;
  67469. /**
  67470. * Gets the normal component
  67471. */
  67472. get normal(): NodeMaterialConnectionPoint;
  67473. /**
  67474. * Gets the output component
  67475. */
  67476. get output(): NodeMaterialConnectionPoint;
  67477. protected _buildBlock(state: NodeMaterialBuildState): this;
  67478. }
  67479. }
  67480. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67482. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67483. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67484. /**
  67485. * Block used to get the refracted vector from a direction and a normal
  67486. */
  67487. export class RefractBlock extends NodeMaterialBlock {
  67488. /**
  67489. * Creates a new RefractBlock
  67490. * @param name defines the block name
  67491. */
  67492. constructor(name: string);
  67493. /**
  67494. * Gets the current class name
  67495. * @returns the class name
  67496. */
  67497. getClassName(): string;
  67498. /**
  67499. * Gets the incident component
  67500. */
  67501. get incident(): NodeMaterialConnectionPoint;
  67502. /**
  67503. * Gets the normal component
  67504. */
  67505. get normal(): NodeMaterialConnectionPoint;
  67506. /**
  67507. * Gets the index of refraction component
  67508. */
  67509. get ior(): NodeMaterialConnectionPoint;
  67510. /**
  67511. * Gets the output component
  67512. */
  67513. get output(): NodeMaterialConnectionPoint;
  67514. protected _buildBlock(state: NodeMaterialBuildState): this;
  67515. }
  67516. }
  67517. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67518. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67519. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67520. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67521. /**
  67522. * Block used to desaturate a color
  67523. */
  67524. export class DesaturateBlock extends NodeMaterialBlock {
  67525. /**
  67526. * Creates a new DesaturateBlock
  67527. * @param name defines the block name
  67528. */
  67529. constructor(name: string);
  67530. /**
  67531. * Gets the current class name
  67532. * @returns the class name
  67533. */
  67534. getClassName(): string;
  67535. /**
  67536. * Gets the color operand input component
  67537. */
  67538. get color(): NodeMaterialConnectionPoint;
  67539. /**
  67540. * Gets the level operand input component
  67541. */
  67542. get level(): NodeMaterialConnectionPoint;
  67543. /**
  67544. * Gets the output component
  67545. */
  67546. get output(): NodeMaterialConnectionPoint;
  67547. protected _buildBlock(state: NodeMaterialBuildState): this;
  67548. }
  67549. }
  67550. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67551. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67552. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67553. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67554. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67555. import { Nullable } from "babylonjs/types";
  67556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67557. import { Scene } from "babylonjs/scene";
  67558. /**
  67559. * Block used to implement the ambient occlusion module of the PBR material
  67560. */
  67561. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67562. /**
  67563. * Create a new AmbientOcclusionBlock
  67564. * @param name defines the block name
  67565. */
  67566. constructor(name: string);
  67567. /**
  67568. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67569. */
  67570. useAmbientInGrayScale: boolean;
  67571. /**
  67572. * Initialize the block and prepare the context for build
  67573. * @param state defines the state that will be used for the build
  67574. */
  67575. initialize(state: NodeMaterialBuildState): void;
  67576. /**
  67577. * Gets the current class name
  67578. * @returns the class name
  67579. */
  67580. getClassName(): string;
  67581. /**
  67582. * Gets the texture input component
  67583. */
  67584. get texture(): NodeMaterialConnectionPoint;
  67585. /**
  67586. * Gets the texture intensity component
  67587. */
  67588. get intensity(): NodeMaterialConnectionPoint;
  67589. /**
  67590. * Gets the direct light intensity input component
  67591. */
  67592. get directLightIntensity(): NodeMaterialConnectionPoint;
  67593. /**
  67594. * Gets the ambient occlusion object output component
  67595. */
  67596. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67597. /**
  67598. * Gets the main code of the block (fragment side)
  67599. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67600. * @returns the shader code
  67601. */
  67602. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67603. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67604. protected _buildBlock(state: NodeMaterialBuildState): this;
  67605. protected _dumpPropertiesCode(): string;
  67606. serialize(): any;
  67607. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67608. }
  67609. }
  67610. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67611. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67612. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67613. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67614. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67616. import { Nullable } from "babylonjs/types";
  67617. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67618. import { Mesh } from "babylonjs/Meshes/mesh";
  67619. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67620. import { Effect } from "babylonjs/Materials/effect";
  67621. import { Scene } from "babylonjs/scene";
  67622. /**
  67623. * Block used to implement the reflection module of the PBR material
  67624. */
  67625. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67626. /** @hidden */
  67627. _defineLODReflectionAlpha: string;
  67628. /** @hidden */
  67629. _defineLinearSpecularReflection: string;
  67630. private _vEnvironmentIrradianceName;
  67631. /** @hidden */
  67632. _vReflectionMicrosurfaceInfosName: string;
  67633. /** @hidden */
  67634. _vReflectionInfosName: string;
  67635. /** @hidden */
  67636. _vReflectionFilteringInfoName: string;
  67637. private _scene;
  67638. /**
  67639. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67640. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67641. * It's less burden on the user side in the editor part.
  67642. */
  67643. /** @hidden */
  67644. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67645. /** @hidden */
  67646. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67647. /** @hidden */
  67648. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67649. /**
  67650. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67651. * diffuse part of the IBL.
  67652. */
  67653. useSphericalHarmonics: boolean;
  67654. /**
  67655. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67656. */
  67657. forceIrradianceInFragment: boolean;
  67658. /**
  67659. * Create a new ReflectionBlock
  67660. * @param name defines the block name
  67661. */
  67662. constructor(name: string);
  67663. /**
  67664. * Gets the current class name
  67665. * @returns the class name
  67666. */
  67667. getClassName(): string;
  67668. /**
  67669. * Gets the position input component
  67670. */
  67671. get position(): NodeMaterialConnectionPoint;
  67672. /**
  67673. * Gets the world position input component
  67674. */
  67675. get worldPosition(): NodeMaterialConnectionPoint;
  67676. /**
  67677. * Gets the world normal input component
  67678. */
  67679. get worldNormal(): NodeMaterialConnectionPoint;
  67680. /**
  67681. * Gets the world input component
  67682. */
  67683. get world(): NodeMaterialConnectionPoint;
  67684. /**
  67685. * Gets the camera (or eye) position component
  67686. */
  67687. get cameraPosition(): NodeMaterialConnectionPoint;
  67688. /**
  67689. * Gets the view input component
  67690. */
  67691. get view(): NodeMaterialConnectionPoint;
  67692. /**
  67693. * Gets the color input component
  67694. */
  67695. get color(): NodeMaterialConnectionPoint;
  67696. /**
  67697. * Gets the reflection object output component
  67698. */
  67699. get reflection(): NodeMaterialConnectionPoint;
  67700. /**
  67701. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67702. */
  67703. get hasTexture(): boolean;
  67704. /**
  67705. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67706. */
  67707. get reflectionColor(): string;
  67708. protected _getTexture(): Nullable<BaseTexture>;
  67709. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67710. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67711. /**
  67712. * Gets the code to inject in the vertex shader
  67713. * @param state current state of the node material building
  67714. * @returns the shader code
  67715. */
  67716. handleVertexSide(state: NodeMaterialBuildState): string;
  67717. /**
  67718. * Gets the main code of the block (fragment side)
  67719. * @param state current state of the node material building
  67720. * @param normalVarName name of the existing variable corresponding to the normal
  67721. * @returns the shader code
  67722. */
  67723. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67724. protected _buildBlock(state: NodeMaterialBuildState): this;
  67725. protected _dumpPropertiesCode(): string;
  67726. serialize(): any;
  67727. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67728. }
  67729. }
  67730. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67731. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67732. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67733. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67734. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67736. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67737. import { Scene } from "babylonjs/scene";
  67738. import { Nullable } from "babylonjs/types";
  67739. /**
  67740. * Block used to implement the sheen module of the PBR material
  67741. */
  67742. export class SheenBlock extends NodeMaterialBlock {
  67743. /**
  67744. * Create a new SheenBlock
  67745. * @param name defines the block name
  67746. */
  67747. constructor(name: string);
  67748. /**
  67749. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67750. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67751. * making it easier to setup and tweak the effect
  67752. */
  67753. albedoScaling: boolean;
  67754. /**
  67755. * Defines if the sheen is linked to the sheen color.
  67756. */
  67757. linkSheenWithAlbedo: boolean;
  67758. /**
  67759. * Initialize the block and prepare the context for build
  67760. * @param state defines the state that will be used for the build
  67761. */
  67762. initialize(state: NodeMaterialBuildState): void;
  67763. /**
  67764. * Gets the current class name
  67765. * @returns the class name
  67766. */
  67767. getClassName(): string;
  67768. /**
  67769. * Gets the intensity input component
  67770. */
  67771. get intensity(): NodeMaterialConnectionPoint;
  67772. /**
  67773. * Gets the color input component
  67774. */
  67775. get color(): NodeMaterialConnectionPoint;
  67776. /**
  67777. * Gets the roughness input component
  67778. */
  67779. get roughness(): NodeMaterialConnectionPoint;
  67780. /**
  67781. * Gets the sheen object output component
  67782. */
  67783. get sheen(): NodeMaterialConnectionPoint;
  67784. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67785. /**
  67786. * Gets the main code of the block (fragment side)
  67787. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67788. * @returns the shader code
  67789. */
  67790. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67791. protected _buildBlock(state: NodeMaterialBuildState): this;
  67792. protected _dumpPropertiesCode(): string;
  67793. serialize(): any;
  67794. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67795. }
  67796. }
  67797. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67798. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67799. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67800. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67802. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67803. import { Scene } from "babylonjs/scene";
  67804. import { Nullable } from "babylonjs/types";
  67805. import { Mesh } from "babylonjs/Meshes/mesh";
  67806. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67807. import { Effect } from "babylonjs/Materials/effect";
  67808. /**
  67809. * Block used to implement the reflectivity module of the PBR material
  67810. */
  67811. export class ReflectivityBlock extends NodeMaterialBlock {
  67812. private _metallicReflectanceColor;
  67813. private _metallicF0Factor;
  67814. /** @hidden */
  67815. _vMetallicReflectanceFactorsName: string;
  67816. /**
  67817. * The property below is set by the main PBR block prior to calling methods of this class.
  67818. */
  67819. /** @hidden */
  67820. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67821. /**
  67822. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67823. */
  67824. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67825. /**
  67826. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67827. */
  67828. useMetallnessFromMetallicTextureBlue: boolean;
  67829. /**
  67830. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67831. */
  67832. useRoughnessFromMetallicTextureAlpha: boolean;
  67833. /**
  67834. * Specifies if the metallic texture contains the roughness information in its green channel.
  67835. */
  67836. useRoughnessFromMetallicTextureGreen: boolean;
  67837. /**
  67838. * Create a new ReflectivityBlock
  67839. * @param name defines the block name
  67840. */
  67841. constructor(name: string);
  67842. /**
  67843. * Initialize the block and prepare the context for build
  67844. * @param state defines the state that will be used for the build
  67845. */
  67846. initialize(state: NodeMaterialBuildState): void;
  67847. /**
  67848. * Gets the current class name
  67849. * @returns the class name
  67850. */
  67851. getClassName(): string;
  67852. /**
  67853. * Gets the metallic input component
  67854. */
  67855. get metallic(): NodeMaterialConnectionPoint;
  67856. /**
  67857. * Gets the roughness input component
  67858. */
  67859. get roughness(): NodeMaterialConnectionPoint;
  67860. /**
  67861. * Gets the texture input component
  67862. */
  67863. get texture(): NodeMaterialConnectionPoint;
  67864. /**
  67865. * Gets the reflectivity object output component
  67866. */
  67867. get reflectivity(): NodeMaterialConnectionPoint;
  67868. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67869. /**
  67870. * Gets the main code of the block (fragment side)
  67871. * @param state current state of the node material building
  67872. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67873. * @returns the shader code
  67874. */
  67875. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67876. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67877. protected _buildBlock(state: NodeMaterialBuildState): this;
  67878. protected _dumpPropertiesCode(): string;
  67879. serialize(): any;
  67880. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67881. }
  67882. }
  67883. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67884. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67885. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67886. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67887. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67889. /**
  67890. * Block used to implement the anisotropy module of the PBR material
  67891. */
  67892. export class AnisotropyBlock extends NodeMaterialBlock {
  67893. /**
  67894. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67895. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67896. * It's less burden on the user side in the editor part.
  67897. */
  67898. /** @hidden */
  67899. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67900. /** @hidden */
  67901. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67902. /**
  67903. * Create a new AnisotropyBlock
  67904. * @param name defines the block name
  67905. */
  67906. constructor(name: string);
  67907. /**
  67908. * Initialize the block and prepare the context for build
  67909. * @param state defines the state that will be used for the build
  67910. */
  67911. initialize(state: NodeMaterialBuildState): void;
  67912. /**
  67913. * Gets the current class name
  67914. * @returns the class name
  67915. */
  67916. getClassName(): string;
  67917. /**
  67918. * Gets the intensity input component
  67919. */
  67920. get intensity(): NodeMaterialConnectionPoint;
  67921. /**
  67922. * Gets the direction input component
  67923. */
  67924. get direction(): NodeMaterialConnectionPoint;
  67925. /**
  67926. * Gets the texture input component
  67927. */
  67928. get texture(): NodeMaterialConnectionPoint;
  67929. /**
  67930. * Gets the uv input component
  67931. */
  67932. get uv(): NodeMaterialConnectionPoint;
  67933. /**
  67934. * Gets the worldTangent input component
  67935. */
  67936. get worldTangent(): NodeMaterialConnectionPoint;
  67937. /**
  67938. * Gets the anisotropy object output component
  67939. */
  67940. get anisotropy(): NodeMaterialConnectionPoint;
  67941. private _generateTBNSpace;
  67942. /**
  67943. * Gets the main code of the block (fragment side)
  67944. * @param state current state of the node material building
  67945. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67946. * @returns the shader code
  67947. */
  67948. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67949. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67950. protected _buildBlock(state: NodeMaterialBuildState): this;
  67951. }
  67952. }
  67953. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67954. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67955. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67956. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67957. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67959. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67960. import { Nullable } from "babylonjs/types";
  67961. import { Mesh } from "babylonjs/Meshes/mesh";
  67962. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67963. import { Effect } from "babylonjs/Materials/effect";
  67964. /**
  67965. * Block used to implement the clear coat module of the PBR material
  67966. */
  67967. export class ClearCoatBlock extends NodeMaterialBlock {
  67968. private _scene;
  67969. /**
  67970. * Create a new ClearCoatBlock
  67971. * @param name defines the block name
  67972. */
  67973. constructor(name: string);
  67974. /**
  67975. * Initialize the block and prepare the context for build
  67976. * @param state defines the state that will be used for the build
  67977. */
  67978. initialize(state: NodeMaterialBuildState): void;
  67979. /**
  67980. * Gets the current class name
  67981. * @returns the class name
  67982. */
  67983. getClassName(): string;
  67984. /**
  67985. * Gets the intensity input component
  67986. */
  67987. get intensity(): NodeMaterialConnectionPoint;
  67988. /**
  67989. * Gets the roughness input component
  67990. */
  67991. get roughness(): NodeMaterialConnectionPoint;
  67992. /**
  67993. * Gets the ior input component
  67994. */
  67995. get ior(): NodeMaterialConnectionPoint;
  67996. /**
  67997. * Gets the texture input component
  67998. */
  67999. get texture(): NodeMaterialConnectionPoint;
  68000. /**
  68001. * Gets the bump texture input component
  68002. */
  68003. get bumpTexture(): NodeMaterialConnectionPoint;
  68004. /**
  68005. * Gets the uv input component
  68006. */
  68007. get uv(): NodeMaterialConnectionPoint;
  68008. /**
  68009. * Gets the tint color input component
  68010. */
  68011. get tintColor(): NodeMaterialConnectionPoint;
  68012. /**
  68013. * Gets the tint "at distance" input component
  68014. */
  68015. get tintAtDistance(): NodeMaterialConnectionPoint;
  68016. /**
  68017. * Gets the tint thickness input component
  68018. */
  68019. get tintThickness(): NodeMaterialConnectionPoint;
  68020. /**
  68021. * Gets the world tangent input component
  68022. */
  68023. get worldTangent(): NodeMaterialConnectionPoint;
  68024. /**
  68025. * Gets the clear coat object output component
  68026. */
  68027. get clearcoat(): NodeMaterialConnectionPoint;
  68028. autoConfigure(material: NodeMaterial): void;
  68029. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68030. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68031. private _generateTBNSpace;
  68032. /**
  68033. * Gets the main code of the block (fragment side)
  68034. * @param state current state of the node material building
  68035. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68036. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68037. * @param worldPosVarName name of the variable holding the world position
  68038. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68039. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68040. * @param worldNormalVarName name of the variable holding the world normal
  68041. * @returns the shader code
  68042. */
  68043. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68044. protected _buildBlock(state: NodeMaterialBuildState): this;
  68045. }
  68046. }
  68047. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68048. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68049. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68050. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68051. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68053. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68054. import { Nullable } from "babylonjs/types";
  68055. /**
  68056. * Block used to implement the sub surface module of the PBR material
  68057. */
  68058. export class SubSurfaceBlock extends NodeMaterialBlock {
  68059. /**
  68060. * Create a new SubSurfaceBlock
  68061. * @param name defines the block name
  68062. */
  68063. constructor(name: string);
  68064. /**
  68065. * Stores the intensity of the different subsurface effects in the thickness texture.
  68066. * * the green channel is the translucency intensity.
  68067. * * the blue channel is the scattering intensity.
  68068. * * the alpha channel is the refraction intensity.
  68069. */
  68070. useMaskFromThicknessTexture: boolean;
  68071. /**
  68072. * Initialize the block and prepare the context for build
  68073. * @param state defines the state that will be used for the build
  68074. */
  68075. initialize(state: NodeMaterialBuildState): void;
  68076. /**
  68077. * Gets the current class name
  68078. * @returns the class name
  68079. */
  68080. getClassName(): string;
  68081. /**
  68082. * Gets the min thickness input component
  68083. */
  68084. get minThickness(): NodeMaterialConnectionPoint;
  68085. /**
  68086. * Gets the max thickness input component
  68087. */
  68088. get maxThickness(): NodeMaterialConnectionPoint;
  68089. /**
  68090. * Gets the thickness texture component
  68091. */
  68092. get thicknessTexture(): NodeMaterialConnectionPoint;
  68093. /**
  68094. * Gets the tint color input component
  68095. */
  68096. get tintColor(): NodeMaterialConnectionPoint;
  68097. /**
  68098. * Gets the translucency intensity input component
  68099. */
  68100. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68101. /**
  68102. * Gets the translucency diffusion distance input component
  68103. */
  68104. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68105. /**
  68106. * Gets the refraction object parameters
  68107. */
  68108. get refraction(): NodeMaterialConnectionPoint;
  68109. /**
  68110. * Gets the sub surface object output component
  68111. */
  68112. get subsurface(): NodeMaterialConnectionPoint;
  68113. autoConfigure(material: NodeMaterial): void;
  68114. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68115. /**
  68116. * Gets the main code of the block (fragment side)
  68117. * @param state current state of the node material building
  68118. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68119. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68120. * @param worldPosVarName name of the variable holding the world position
  68121. * @returns the shader code
  68122. */
  68123. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68124. protected _buildBlock(state: NodeMaterialBuildState): this;
  68125. }
  68126. }
  68127. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68129. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68130. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68131. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68132. import { Light } from "babylonjs/Lights/light";
  68133. import { Nullable } from "babylonjs/types";
  68134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68135. import { Effect } from "babylonjs/Materials/effect";
  68136. import { Mesh } from "babylonjs/Meshes/mesh";
  68137. import { Scene } from "babylonjs/scene";
  68138. /**
  68139. * Block used to implement the PBR metallic/roughness model
  68140. */
  68141. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68142. /**
  68143. * Gets or sets the light associated with this block
  68144. */
  68145. light: Nullable<Light>;
  68146. private _lightId;
  68147. private _scene;
  68148. private _environmentBRDFTexture;
  68149. private _environmentBrdfSamplerName;
  68150. private _vNormalWName;
  68151. private _invertNormalName;
  68152. /**
  68153. * Create a new ReflectionBlock
  68154. * @param name defines the block name
  68155. */
  68156. constructor(name: string);
  68157. /**
  68158. * Intensity of the direct lights e.g. the four lights available in your scene.
  68159. * This impacts both the direct diffuse and specular highlights.
  68160. */
  68161. directIntensity: number;
  68162. /**
  68163. * Intensity of the environment e.g. how much the environment will light the object
  68164. * either through harmonics for rough material or through the refelction for shiny ones.
  68165. */
  68166. environmentIntensity: number;
  68167. /**
  68168. * This is a special control allowing the reduction of the specular highlights coming from the
  68169. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68170. */
  68171. specularIntensity: number;
  68172. /**
  68173. * Defines the falloff type used in this material.
  68174. * It by default is Physical.
  68175. */
  68176. lightFalloff: number;
  68177. /**
  68178. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68179. */
  68180. useAlphaFromAlbedoTexture: boolean;
  68181. /**
  68182. * Specifies that alpha test should be used
  68183. */
  68184. useAlphaTest: boolean;
  68185. /**
  68186. * Defines the alpha limits in alpha test mode.
  68187. */
  68188. alphaTestCutoff: number;
  68189. /**
  68190. * Specifies that alpha blending should be used
  68191. */
  68192. useAlphaBlending: boolean;
  68193. /**
  68194. * Defines if the alpha value should be determined via the rgb values.
  68195. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68196. */
  68197. opacityRGB: boolean;
  68198. /**
  68199. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68200. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68201. */
  68202. useRadianceOverAlpha: boolean;
  68203. /**
  68204. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68205. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68206. */
  68207. useSpecularOverAlpha: boolean;
  68208. /**
  68209. * Enables specular anti aliasing in the PBR shader.
  68210. * It will both interacts on the Geometry for analytical and IBL lighting.
  68211. * It also prefilter the roughness map based on the bump values.
  68212. */
  68213. enableSpecularAntiAliasing: boolean;
  68214. /**
  68215. * Enables realtime filtering on the texture.
  68216. */
  68217. realTimeFiltering: boolean;
  68218. /**
  68219. * Quality switch for realtime filtering
  68220. */
  68221. realTimeFilteringQuality: number;
  68222. /**
  68223. * Defines if the material uses energy conservation.
  68224. */
  68225. useEnergyConservation: boolean;
  68226. /**
  68227. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68228. * too much the area relying on ambient texture to define their ambient occlusion.
  68229. */
  68230. useRadianceOcclusion: boolean;
  68231. /**
  68232. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68233. * makes the reflect vector face the model (under horizon).
  68234. */
  68235. useHorizonOcclusion: boolean;
  68236. /**
  68237. * If set to true, no lighting calculations will be applied.
  68238. */
  68239. unlit: boolean;
  68240. /**
  68241. * Force normal to face away from face.
  68242. */
  68243. forceNormalForward: boolean;
  68244. /**
  68245. * Defines the material debug mode.
  68246. * It helps seeing only some components of the material while troubleshooting.
  68247. */
  68248. debugMode: number;
  68249. /**
  68250. * Specify from where on screen the debug mode should start.
  68251. * The value goes from -1 (full screen) to 1 (not visible)
  68252. * It helps with side by side comparison against the final render
  68253. * This defaults to 0
  68254. */
  68255. debugLimit: number;
  68256. /**
  68257. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68258. * You can use the factor to better multiply the final value.
  68259. */
  68260. debugFactor: number;
  68261. /**
  68262. * Initialize the block and prepare the context for build
  68263. * @param state defines the state that will be used for the build
  68264. */
  68265. initialize(state: NodeMaterialBuildState): void;
  68266. /**
  68267. * Gets the current class name
  68268. * @returns the class name
  68269. */
  68270. getClassName(): string;
  68271. /**
  68272. * Gets the world position input component
  68273. */
  68274. get worldPosition(): NodeMaterialConnectionPoint;
  68275. /**
  68276. * Gets the world normal input component
  68277. */
  68278. get worldNormal(): NodeMaterialConnectionPoint;
  68279. /**
  68280. * Gets the perturbed normal input component
  68281. */
  68282. get perturbedNormal(): NodeMaterialConnectionPoint;
  68283. /**
  68284. * Gets the camera position input component
  68285. */
  68286. get cameraPosition(): NodeMaterialConnectionPoint;
  68287. /**
  68288. * Gets the base color input component
  68289. */
  68290. get baseColor(): NodeMaterialConnectionPoint;
  68291. /**
  68292. * Gets the opacity texture input component
  68293. */
  68294. get opacityTexture(): NodeMaterialConnectionPoint;
  68295. /**
  68296. * Gets the ambient color input component
  68297. */
  68298. get ambientColor(): NodeMaterialConnectionPoint;
  68299. /**
  68300. * Gets the reflectivity object parameters
  68301. */
  68302. get reflectivity(): NodeMaterialConnectionPoint;
  68303. /**
  68304. * Gets the ambient occlusion object parameters
  68305. */
  68306. get ambientOcclusion(): NodeMaterialConnectionPoint;
  68307. /**
  68308. * Gets the reflection object parameters
  68309. */
  68310. get reflection(): NodeMaterialConnectionPoint;
  68311. /**
  68312. * Gets the sheen object parameters
  68313. */
  68314. get sheen(): NodeMaterialConnectionPoint;
  68315. /**
  68316. * Gets the clear coat object parameters
  68317. */
  68318. get clearcoat(): NodeMaterialConnectionPoint;
  68319. /**
  68320. * Gets the sub surface object parameters
  68321. */
  68322. get subsurface(): NodeMaterialConnectionPoint;
  68323. /**
  68324. * Gets the anisotropy object parameters
  68325. */
  68326. get anisotropy(): NodeMaterialConnectionPoint;
  68327. /**
  68328. * Gets the ambient output component
  68329. */
  68330. get ambient(): NodeMaterialConnectionPoint;
  68331. /**
  68332. * Gets the diffuse output component
  68333. */
  68334. get diffuse(): NodeMaterialConnectionPoint;
  68335. /**
  68336. * Gets the specular output component
  68337. */
  68338. get specular(): NodeMaterialConnectionPoint;
  68339. /**
  68340. * Gets the sheen output component
  68341. */
  68342. get sheenDir(): NodeMaterialConnectionPoint;
  68343. /**
  68344. * Gets the clear coat output component
  68345. */
  68346. get clearcoatDir(): NodeMaterialConnectionPoint;
  68347. /**
  68348. * Gets the indirect diffuse output component
  68349. */
  68350. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68351. /**
  68352. * Gets the indirect specular output component
  68353. */
  68354. get specularIndirect(): NodeMaterialConnectionPoint;
  68355. /**
  68356. * Gets the indirect sheen output component
  68357. */
  68358. get sheenIndirect(): NodeMaterialConnectionPoint;
  68359. /**
  68360. * Gets the indirect clear coat output component
  68361. */
  68362. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68363. /**
  68364. * Gets the refraction output component
  68365. */
  68366. get refraction(): NodeMaterialConnectionPoint;
  68367. /**
  68368. * Gets the global lighting output component
  68369. */
  68370. get lighting(): NodeMaterialConnectionPoint;
  68371. /**
  68372. * Gets the shadow output component
  68373. */
  68374. get shadow(): NodeMaterialConnectionPoint;
  68375. /**
  68376. * Gets the alpha output component
  68377. */
  68378. get alpha(): NodeMaterialConnectionPoint;
  68379. autoConfigure(material: NodeMaterial): void;
  68380. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68381. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68382. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68383. private _injectVertexCode;
  68384. /**
  68385. * Gets the code corresponding to the albedo/opacity module
  68386. * @returns the shader code
  68387. */
  68388. getAlbedoOpacityCode(): string;
  68389. protected _buildBlock(state: NodeMaterialBuildState): this;
  68390. protected _dumpPropertiesCode(): string;
  68391. serialize(): any;
  68392. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68393. }
  68394. }
  68395. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68396. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68397. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68398. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68399. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68400. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68401. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68402. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68403. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68404. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68405. }
  68406. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68407. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68408. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68409. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68410. }
  68411. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68412. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68413. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68414. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68415. /**
  68416. * Block used to compute value of one parameter modulo another
  68417. */
  68418. export class ModBlock extends NodeMaterialBlock {
  68419. /**
  68420. * Creates a new ModBlock
  68421. * @param name defines the block name
  68422. */
  68423. constructor(name: string);
  68424. /**
  68425. * Gets the current class name
  68426. * @returns the class name
  68427. */
  68428. getClassName(): string;
  68429. /**
  68430. * Gets the left operand input component
  68431. */
  68432. get left(): NodeMaterialConnectionPoint;
  68433. /**
  68434. * Gets the right operand input component
  68435. */
  68436. get right(): NodeMaterialConnectionPoint;
  68437. /**
  68438. * Gets the output component
  68439. */
  68440. get output(): NodeMaterialConnectionPoint;
  68441. protected _buildBlock(state: NodeMaterialBuildState): this;
  68442. }
  68443. }
  68444. declare module "babylonjs/Materials/Node/Blocks/index" {
  68445. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68446. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68447. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68448. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68449. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68450. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68451. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68452. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68453. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68454. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68455. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68456. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68457. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68458. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68459. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68460. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68461. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68462. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68463. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68464. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68465. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68466. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68467. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68468. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68469. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68470. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68471. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68472. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68473. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68474. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68475. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68476. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68477. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68478. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68479. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68480. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68481. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68482. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68483. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68484. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68485. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68486. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68487. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68488. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68489. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68490. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68491. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68492. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68493. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68494. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68495. }
  68496. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68497. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68498. }
  68499. declare module "babylonjs/Materials/Node/index" {
  68500. export * from "babylonjs/Materials/Node/Enums/index";
  68501. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68502. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68503. export * from "babylonjs/Materials/Node/nodeMaterial";
  68504. export * from "babylonjs/Materials/Node/Blocks/index";
  68505. export * from "babylonjs/Materials/Node/Optimizers/index";
  68506. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68507. }
  68508. declare module "babylonjs/Materials/index" {
  68509. export * from "babylonjs/Materials/Background/index";
  68510. export * from "babylonjs/Materials/colorCurves";
  68511. export * from "babylonjs/Materials/iEffectFallbacks";
  68512. export * from "babylonjs/Materials/effectFallbacks";
  68513. export * from "babylonjs/Materials/effect";
  68514. export * from "babylonjs/Materials/fresnelParameters";
  68515. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68516. export * from "babylonjs/Materials/material";
  68517. export * from "babylonjs/Materials/materialDefines";
  68518. export * from "babylonjs/Materials/thinMaterialHelper";
  68519. export * from "babylonjs/Materials/materialHelper";
  68520. export * from "babylonjs/Materials/multiMaterial";
  68521. export * from "babylonjs/Materials/PBR/index";
  68522. export * from "babylonjs/Materials/pushMaterial";
  68523. export * from "babylonjs/Materials/shaderMaterial";
  68524. export * from "babylonjs/Materials/standardMaterial";
  68525. export * from "babylonjs/Materials/Textures/index";
  68526. export * from "babylonjs/Materials/uniformBuffer";
  68527. export * from "babylonjs/Materials/materialFlags";
  68528. export * from "babylonjs/Materials/Node/index";
  68529. export * from "babylonjs/Materials/effectRenderer";
  68530. export * from "babylonjs/Materials/shadowDepthWrapper";
  68531. }
  68532. declare module "babylonjs/Maths/index" {
  68533. export * from "babylonjs/Maths/math.scalar";
  68534. export * from "babylonjs/Maths/math";
  68535. export * from "babylonjs/Maths/sphericalPolynomial";
  68536. }
  68537. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68538. import { IDisposable } from "babylonjs/scene";
  68539. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68540. /**
  68541. * Configuration for Draco compression
  68542. */
  68543. export interface IDracoCompressionConfiguration {
  68544. /**
  68545. * Configuration for the decoder.
  68546. */
  68547. decoder: {
  68548. /**
  68549. * The url to the WebAssembly module.
  68550. */
  68551. wasmUrl?: string;
  68552. /**
  68553. * The url to the WebAssembly binary.
  68554. */
  68555. wasmBinaryUrl?: string;
  68556. /**
  68557. * The url to the fallback JavaScript module.
  68558. */
  68559. fallbackUrl?: string;
  68560. };
  68561. }
  68562. /**
  68563. * Draco compression (https://google.github.io/draco/)
  68564. *
  68565. * This class wraps the Draco module.
  68566. *
  68567. * **Encoder**
  68568. *
  68569. * The encoder is not currently implemented.
  68570. *
  68571. * **Decoder**
  68572. *
  68573. * 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.
  68574. *
  68575. * To update the configuration, use the following code:
  68576. * ```javascript
  68577. * DracoCompression.Configuration = {
  68578. * decoder: {
  68579. * wasmUrl: "<url to the WebAssembly library>",
  68580. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68581. * fallbackUrl: "<url to the fallback JavaScript library>",
  68582. * }
  68583. * };
  68584. * ```
  68585. *
  68586. * 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.
  68587. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68588. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68589. *
  68590. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68591. * ```javascript
  68592. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68593. * ```
  68594. *
  68595. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68596. */
  68597. export class DracoCompression implements IDisposable {
  68598. private _workerPoolPromise?;
  68599. private _decoderModulePromise?;
  68600. /**
  68601. * The configuration. Defaults to the following urls:
  68602. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68603. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68604. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68605. */
  68606. static Configuration: IDracoCompressionConfiguration;
  68607. /**
  68608. * Returns true if the decoder configuration is available.
  68609. */
  68610. static get DecoderAvailable(): boolean;
  68611. /**
  68612. * Default number of workers to create when creating the draco compression object.
  68613. */
  68614. static DefaultNumWorkers: number;
  68615. private static GetDefaultNumWorkers;
  68616. private static _Default;
  68617. /**
  68618. * Default instance for the draco compression object.
  68619. */
  68620. static get Default(): DracoCompression;
  68621. /**
  68622. * Constructor
  68623. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68624. */
  68625. constructor(numWorkers?: number);
  68626. /**
  68627. * Stop all async operations and release resources.
  68628. */
  68629. dispose(): void;
  68630. /**
  68631. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68632. * @returns a promise that resolves when ready
  68633. */
  68634. whenReadyAsync(): Promise<void>;
  68635. /**
  68636. * Decode Draco compressed mesh data to vertex data.
  68637. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68638. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68639. * @returns A promise that resolves with the decoded vertex data
  68640. */
  68641. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68642. [kind: string]: number;
  68643. }): Promise<VertexData>;
  68644. }
  68645. }
  68646. declare module "babylonjs/Meshes/Compression/index" {
  68647. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68648. }
  68649. declare module "babylonjs/Meshes/csg" {
  68650. import { Nullable } from "babylonjs/types";
  68651. import { Scene } from "babylonjs/scene";
  68652. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68653. import { Mesh } from "babylonjs/Meshes/mesh";
  68654. import { Material } from "babylonjs/Materials/material";
  68655. /**
  68656. * Class for building Constructive Solid Geometry
  68657. */
  68658. export class CSG {
  68659. private polygons;
  68660. /**
  68661. * The world matrix
  68662. */
  68663. matrix: Matrix;
  68664. /**
  68665. * Stores the position
  68666. */
  68667. position: Vector3;
  68668. /**
  68669. * Stores the rotation
  68670. */
  68671. rotation: Vector3;
  68672. /**
  68673. * Stores the rotation quaternion
  68674. */
  68675. rotationQuaternion: Nullable<Quaternion>;
  68676. /**
  68677. * Stores the scaling vector
  68678. */
  68679. scaling: Vector3;
  68680. /**
  68681. * Convert the Mesh to CSG
  68682. * @param mesh The Mesh to convert to CSG
  68683. * @returns A new CSG from the Mesh
  68684. */
  68685. static FromMesh(mesh: Mesh): CSG;
  68686. /**
  68687. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68688. * @param polygons Polygons used to construct a CSG solid
  68689. */
  68690. private static FromPolygons;
  68691. /**
  68692. * Clones, or makes a deep copy, of the CSG
  68693. * @returns A new CSG
  68694. */
  68695. clone(): CSG;
  68696. /**
  68697. * Unions this CSG with another CSG
  68698. * @param csg The CSG to union against this CSG
  68699. * @returns The unioned CSG
  68700. */
  68701. union(csg: CSG): CSG;
  68702. /**
  68703. * Unions this CSG with another CSG in place
  68704. * @param csg The CSG to union against this CSG
  68705. */
  68706. unionInPlace(csg: CSG): void;
  68707. /**
  68708. * Subtracts this CSG with another CSG
  68709. * @param csg The CSG to subtract against this CSG
  68710. * @returns A new CSG
  68711. */
  68712. subtract(csg: CSG): CSG;
  68713. /**
  68714. * Subtracts this CSG with another CSG in place
  68715. * @param csg The CSG to subtact against this CSG
  68716. */
  68717. subtractInPlace(csg: CSG): void;
  68718. /**
  68719. * Intersect this CSG with another CSG
  68720. * @param csg The CSG to intersect against this CSG
  68721. * @returns A new CSG
  68722. */
  68723. intersect(csg: CSG): CSG;
  68724. /**
  68725. * Intersects this CSG with another CSG in place
  68726. * @param csg The CSG to intersect against this CSG
  68727. */
  68728. intersectInPlace(csg: CSG): void;
  68729. /**
  68730. * Return a new CSG solid with solid and empty space switched. This solid is
  68731. * not modified.
  68732. * @returns A new CSG solid with solid and empty space switched
  68733. */
  68734. inverse(): CSG;
  68735. /**
  68736. * Inverses the CSG in place
  68737. */
  68738. inverseInPlace(): void;
  68739. /**
  68740. * This is used to keep meshes transformations so they can be restored
  68741. * when we build back a Babylon Mesh
  68742. * NB : All CSG operations are performed in world coordinates
  68743. * @param csg The CSG to copy the transform attributes from
  68744. * @returns This CSG
  68745. */
  68746. copyTransformAttributes(csg: CSG): CSG;
  68747. /**
  68748. * Build Raw mesh from CSG
  68749. * Coordinates here are in world space
  68750. * @param name The name of the mesh geometry
  68751. * @param scene The Scene
  68752. * @param keepSubMeshes Specifies if the submeshes should be kept
  68753. * @returns A new Mesh
  68754. */
  68755. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68756. /**
  68757. * Build Mesh from CSG taking material and transforms into account
  68758. * @param name The name of the Mesh
  68759. * @param material The material of the Mesh
  68760. * @param scene The Scene
  68761. * @param keepSubMeshes Specifies if submeshes should be kept
  68762. * @returns The new Mesh
  68763. */
  68764. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68765. }
  68766. }
  68767. declare module "babylonjs/Meshes/trailMesh" {
  68768. import { Mesh } from "babylonjs/Meshes/mesh";
  68769. import { Scene } from "babylonjs/scene";
  68770. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68771. /**
  68772. * Class used to create a trail following a mesh
  68773. */
  68774. export class TrailMesh extends Mesh {
  68775. private _generator;
  68776. private _autoStart;
  68777. private _running;
  68778. private _diameter;
  68779. private _length;
  68780. private _sectionPolygonPointsCount;
  68781. private _sectionVectors;
  68782. private _sectionNormalVectors;
  68783. private _beforeRenderObserver;
  68784. /**
  68785. * @constructor
  68786. * @param name The value used by scene.getMeshByName() to do a lookup.
  68787. * @param generator The mesh or transform node to generate a trail.
  68788. * @param scene The scene to add this mesh to.
  68789. * @param diameter Diameter of trailing mesh. Default is 1.
  68790. * @param length Length of trailing mesh. Default is 60.
  68791. * @param autoStart Automatically start trailing mesh. Default true.
  68792. */
  68793. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68794. /**
  68795. * "TrailMesh"
  68796. * @returns "TrailMesh"
  68797. */
  68798. getClassName(): string;
  68799. private _createMesh;
  68800. /**
  68801. * Start trailing mesh.
  68802. */
  68803. start(): void;
  68804. /**
  68805. * Stop trailing mesh.
  68806. */
  68807. stop(): void;
  68808. /**
  68809. * Update trailing mesh geometry.
  68810. */
  68811. update(): void;
  68812. /**
  68813. * Returns a new TrailMesh object.
  68814. * @param name is a string, the name given to the new mesh
  68815. * @param newGenerator use new generator object for cloned trail mesh
  68816. * @returns a new mesh
  68817. */
  68818. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68819. /**
  68820. * Serializes this trail mesh
  68821. * @param serializationObject object to write serialization to
  68822. */
  68823. serialize(serializationObject: any): void;
  68824. /**
  68825. * Parses a serialized trail mesh
  68826. * @param parsedMesh the serialized mesh
  68827. * @param scene the scene to create the trail mesh in
  68828. * @returns the created trail mesh
  68829. */
  68830. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68831. }
  68832. }
  68833. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68834. import { Nullable } from "babylonjs/types";
  68835. import { Scene } from "babylonjs/scene";
  68836. import { Vector4 } from "babylonjs/Maths/math.vector";
  68837. import { Color4 } from "babylonjs/Maths/math.color";
  68838. import { Mesh } from "babylonjs/Meshes/mesh";
  68839. /**
  68840. * Class containing static functions to help procedurally build meshes
  68841. */
  68842. export class TiledBoxBuilder {
  68843. /**
  68844. * Creates a box mesh
  68845. * 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)
  68846. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68848. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68850. * @param name defines the name of the mesh
  68851. * @param options defines the options used to create the mesh
  68852. * @param scene defines the hosting scene
  68853. * @returns the box mesh
  68854. */
  68855. static CreateTiledBox(name: string, options: {
  68856. pattern?: number;
  68857. width?: number;
  68858. height?: number;
  68859. depth?: number;
  68860. tileSize?: number;
  68861. tileWidth?: number;
  68862. tileHeight?: number;
  68863. alignHorizontal?: number;
  68864. alignVertical?: number;
  68865. faceUV?: Vector4[];
  68866. faceColors?: Color4[];
  68867. sideOrientation?: number;
  68868. updatable?: boolean;
  68869. }, scene?: Nullable<Scene>): Mesh;
  68870. }
  68871. }
  68872. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68873. import { Vector4 } from "babylonjs/Maths/math.vector";
  68874. import { Mesh } from "babylonjs/Meshes/mesh";
  68875. /**
  68876. * Class containing static functions to help procedurally build meshes
  68877. */
  68878. export class TorusKnotBuilder {
  68879. /**
  68880. * Creates a torus knot mesh
  68881. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68882. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68883. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68884. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68888. * @param name defines the name of the mesh
  68889. * @param options defines the options used to create the mesh
  68890. * @param scene defines the hosting scene
  68891. * @returns the torus knot mesh
  68892. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68893. */
  68894. static CreateTorusKnot(name: string, options: {
  68895. radius?: number;
  68896. tube?: number;
  68897. radialSegments?: number;
  68898. tubularSegments?: number;
  68899. p?: number;
  68900. q?: number;
  68901. updatable?: boolean;
  68902. sideOrientation?: number;
  68903. frontUVs?: Vector4;
  68904. backUVs?: Vector4;
  68905. }, scene: any): Mesh;
  68906. }
  68907. }
  68908. declare module "babylonjs/Meshes/polygonMesh" {
  68909. import { Scene } from "babylonjs/scene";
  68910. import { Vector2 } from "babylonjs/Maths/math.vector";
  68911. import { Mesh } from "babylonjs/Meshes/mesh";
  68912. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68913. import { Path2 } from "babylonjs/Maths/math.path";
  68914. /**
  68915. * Polygon
  68916. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68917. */
  68918. export class Polygon {
  68919. /**
  68920. * Creates a rectangle
  68921. * @param xmin bottom X coord
  68922. * @param ymin bottom Y coord
  68923. * @param xmax top X coord
  68924. * @param ymax top Y coord
  68925. * @returns points that make the resulting rectation
  68926. */
  68927. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68928. /**
  68929. * Creates a circle
  68930. * @param radius radius of circle
  68931. * @param cx scale in x
  68932. * @param cy scale in y
  68933. * @param numberOfSides number of sides that make up the circle
  68934. * @returns points that make the resulting circle
  68935. */
  68936. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68937. /**
  68938. * Creates a polygon from input string
  68939. * @param input Input polygon data
  68940. * @returns the parsed points
  68941. */
  68942. static Parse(input: string): Vector2[];
  68943. /**
  68944. * Starts building a polygon from x and y coordinates
  68945. * @param x x coordinate
  68946. * @param y y coordinate
  68947. * @returns the started path2
  68948. */
  68949. static StartingAt(x: number, y: number): Path2;
  68950. }
  68951. /**
  68952. * Builds a polygon
  68953. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68954. */
  68955. export class PolygonMeshBuilder {
  68956. private _points;
  68957. private _outlinepoints;
  68958. private _holes;
  68959. private _name;
  68960. private _scene;
  68961. private _epoints;
  68962. private _eholes;
  68963. private _addToepoint;
  68964. /**
  68965. * Babylon reference to the earcut plugin.
  68966. */
  68967. bjsEarcut: any;
  68968. /**
  68969. * Creates a PolygonMeshBuilder
  68970. * @param name name of the builder
  68971. * @param contours Path of the polygon
  68972. * @param scene scene to add to when creating the mesh
  68973. * @param earcutInjection can be used to inject your own earcut reference
  68974. */
  68975. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  68976. /**
  68977. * Adds a whole within the polygon
  68978. * @param hole Array of points defining the hole
  68979. * @returns this
  68980. */
  68981. addHole(hole: Vector2[]): PolygonMeshBuilder;
  68982. /**
  68983. * Creates the polygon
  68984. * @param updatable If the mesh should be updatable
  68985. * @param depth The depth of the mesh created
  68986. * @returns the created mesh
  68987. */
  68988. build(updatable?: boolean, depth?: number): Mesh;
  68989. /**
  68990. * Creates the polygon
  68991. * @param depth The depth of the mesh created
  68992. * @returns the created VertexData
  68993. */
  68994. buildVertexData(depth?: number): VertexData;
  68995. /**
  68996. * Adds a side to the polygon
  68997. * @param positions points that make the polygon
  68998. * @param normals normals of the polygon
  68999. * @param uvs uvs of the polygon
  69000. * @param indices indices of the polygon
  69001. * @param bounds bounds of the polygon
  69002. * @param points points of the polygon
  69003. * @param depth depth of the polygon
  69004. * @param flip flip of the polygon
  69005. */
  69006. private addSide;
  69007. }
  69008. }
  69009. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69010. import { Scene } from "babylonjs/scene";
  69011. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69012. import { Color4 } from "babylonjs/Maths/math.color";
  69013. import { Mesh } from "babylonjs/Meshes/mesh";
  69014. import { Nullable } from "babylonjs/types";
  69015. /**
  69016. * Class containing static functions to help procedurally build meshes
  69017. */
  69018. export class PolygonBuilder {
  69019. /**
  69020. * Creates a polygon mesh
  69021. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69022. * * 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
  69023. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69025. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69026. * * Remember you can only change the shape positions, not their number when updating a polygon
  69027. * @param name defines the name of the mesh
  69028. * @param options defines the options used to create the mesh
  69029. * @param scene defines the hosting scene
  69030. * @param earcutInjection can be used to inject your own earcut reference
  69031. * @returns the polygon mesh
  69032. */
  69033. static CreatePolygon(name: string, options: {
  69034. shape: Vector3[];
  69035. holes?: Vector3[][];
  69036. depth?: number;
  69037. faceUV?: Vector4[];
  69038. faceColors?: Color4[];
  69039. updatable?: boolean;
  69040. sideOrientation?: number;
  69041. frontUVs?: Vector4;
  69042. backUVs?: Vector4;
  69043. wrap?: boolean;
  69044. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69045. /**
  69046. * Creates an extruded polygon mesh, with depth in the Y direction.
  69047. * * 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)
  69048. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69049. * @param name defines the name of the mesh
  69050. * @param options defines the options used to create the mesh
  69051. * @param scene defines the hosting scene
  69052. * @param earcutInjection can be used to inject your own earcut reference
  69053. * @returns the polygon mesh
  69054. */
  69055. static ExtrudePolygon(name: string, options: {
  69056. shape: Vector3[];
  69057. holes?: Vector3[][];
  69058. depth?: number;
  69059. faceUV?: Vector4[];
  69060. faceColors?: Color4[];
  69061. updatable?: boolean;
  69062. sideOrientation?: number;
  69063. frontUVs?: Vector4;
  69064. backUVs?: Vector4;
  69065. wrap?: boolean;
  69066. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69067. }
  69068. }
  69069. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69070. import { Scene } from "babylonjs/scene";
  69071. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69072. import { Mesh } from "babylonjs/Meshes/mesh";
  69073. import { Nullable } from "babylonjs/types";
  69074. /**
  69075. * Class containing static functions to help procedurally build meshes
  69076. */
  69077. export class LatheBuilder {
  69078. /**
  69079. * Creates lathe mesh.
  69080. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69081. * * 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
  69082. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69083. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69084. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69085. * * 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
  69086. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69087. * * 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
  69088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69089. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69090. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69092. * @param name defines the name of the mesh
  69093. * @param options defines the options used to create the mesh
  69094. * @param scene defines the hosting scene
  69095. * @returns the lathe mesh
  69096. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69097. */
  69098. static CreateLathe(name: string, options: {
  69099. shape: Vector3[];
  69100. radius?: number;
  69101. tessellation?: number;
  69102. clip?: number;
  69103. arc?: number;
  69104. closed?: boolean;
  69105. updatable?: boolean;
  69106. sideOrientation?: number;
  69107. frontUVs?: Vector4;
  69108. backUVs?: Vector4;
  69109. cap?: number;
  69110. invertUV?: boolean;
  69111. }, scene?: Nullable<Scene>): Mesh;
  69112. }
  69113. }
  69114. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69115. import { Nullable } from "babylonjs/types";
  69116. import { Scene } from "babylonjs/scene";
  69117. import { Vector4 } from "babylonjs/Maths/math.vector";
  69118. import { Mesh } from "babylonjs/Meshes/mesh";
  69119. /**
  69120. * Class containing static functions to help procedurally build meshes
  69121. */
  69122. export class TiledPlaneBuilder {
  69123. /**
  69124. * Creates a tiled plane mesh
  69125. * * The parameter `pattern` will, depending on value, do nothing or
  69126. * * * flip (reflect about central vertical) alternate tiles across and up
  69127. * * * flip every tile on alternate rows
  69128. * * * rotate (180 degs) alternate tiles across and up
  69129. * * * rotate every tile on alternate rows
  69130. * * * flip and rotate alternate tiles across and up
  69131. * * * flip and rotate every tile on alternate rows
  69132. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69133. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69135. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69136. * * 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)
  69137. * * 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)
  69138. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69139. * @param name defines the name of the mesh
  69140. * @param options defines the options used to create the mesh
  69141. * @param scene defines the hosting scene
  69142. * @returns the box mesh
  69143. */
  69144. static CreateTiledPlane(name: string, options: {
  69145. pattern?: number;
  69146. tileSize?: number;
  69147. tileWidth?: number;
  69148. tileHeight?: number;
  69149. size?: number;
  69150. width?: number;
  69151. height?: number;
  69152. alignHorizontal?: number;
  69153. alignVertical?: number;
  69154. sideOrientation?: number;
  69155. frontUVs?: Vector4;
  69156. backUVs?: Vector4;
  69157. updatable?: boolean;
  69158. }, scene?: Nullable<Scene>): Mesh;
  69159. }
  69160. }
  69161. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69162. import { Nullable } from "babylonjs/types";
  69163. import { Scene } from "babylonjs/scene";
  69164. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69165. import { Mesh } from "babylonjs/Meshes/mesh";
  69166. /**
  69167. * Class containing static functions to help procedurally build meshes
  69168. */
  69169. export class TubeBuilder {
  69170. /**
  69171. * Creates a tube mesh.
  69172. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69173. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69174. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69175. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69176. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69177. * * 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)
  69178. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69179. * * 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
  69180. * * 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
  69181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69182. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69183. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69185. * @param name defines the name of the mesh
  69186. * @param options defines the options used to create the mesh
  69187. * @param scene defines the hosting scene
  69188. * @returns the tube mesh
  69189. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69190. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69191. */
  69192. static CreateTube(name: string, options: {
  69193. path: Vector3[];
  69194. radius?: number;
  69195. tessellation?: number;
  69196. radiusFunction?: {
  69197. (i: number, distance: number): number;
  69198. };
  69199. cap?: number;
  69200. arc?: number;
  69201. updatable?: boolean;
  69202. sideOrientation?: number;
  69203. frontUVs?: Vector4;
  69204. backUVs?: Vector4;
  69205. instance?: Mesh;
  69206. invertUV?: boolean;
  69207. }, scene?: Nullable<Scene>): Mesh;
  69208. }
  69209. }
  69210. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69211. import { Scene } from "babylonjs/scene";
  69212. import { Vector4 } from "babylonjs/Maths/math.vector";
  69213. import { Mesh } from "babylonjs/Meshes/mesh";
  69214. import { Nullable } from "babylonjs/types";
  69215. /**
  69216. * Class containing static functions to help procedurally build meshes
  69217. */
  69218. export class IcoSphereBuilder {
  69219. /**
  69220. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69221. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69222. * * 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`)
  69223. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69224. * * 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
  69225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69228. * @param name defines the name of the mesh
  69229. * @param options defines the options used to create the mesh
  69230. * @param scene defines the hosting scene
  69231. * @returns the icosahedron mesh
  69232. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69233. */
  69234. static CreateIcoSphere(name: string, options: {
  69235. radius?: number;
  69236. radiusX?: number;
  69237. radiusY?: number;
  69238. radiusZ?: number;
  69239. flat?: boolean;
  69240. subdivisions?: number;
  69241. sideOrientation?: number;
  69242. frontUVs?: Vector4;
  69243. backUVs?: Vector4;
  69244. updatable?: boolean;
  69245. }, scene?: Nullable<Scene>): Mesh;
  69246. }
  69247. }
  69248. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69249. import { Vector3 } from "babylonjs/Maths/math.vector";
  69250. import { Mesh } from "babylonjs/Meshes/mesh";
  69251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69252. /**
  69253. * Class containing static functions to help procedurally build meshes
  69254. */
  69255. export class DecalBuilder {
  69256. /**
  69257. * Creates a decal mesh.
  69258. * 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
  69259. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69260. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69261. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69262. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69263. * @param name defines the name of the mesh
  69264. * @param sourceMesh defines the mesh where the decal must be applied
  69265. * @param options defines the options used to create the mesh
  69266. * @param scene defines the hosting scene
  69267. * @returns the decal mesh
  69268. * @see https://doc.babylonjs.com/how_to/decals
  69269. */
  69270. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69271. position?: Vector3;
  69272. normal?: Vector3;
  69273. size?: Vector3;
  69274. angle?: number;
  69275. }): Mesh;
  69276. }
  69277. }
  69278. declare module "babylonjs/Meshes/meshBuilder" {
  69279. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69280. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69281. import { Nullable } from "babylonjs/types";
  69282. import { Scene } from "babylonjs/scene";
  69283. import { Mesh } from "babylonjs/Meshes/mesh";
  69284. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69285. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69287. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69288. import { Plane } from "babylonjs/Maths/math.plane";
  69289. /**
  69290. * Class containing static functions to help procedurally build meshes
  69291. */
  69292. export class MeshBuilder {
  69293. /**
  69294. * Creates a box mesh
  69295. * * The parameter `size` sets the size (float) of each box side (default 1)
  69296. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69297. * * 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)
  69298. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69302. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69303. * @param name defines the name of the mesh
  69304. * @param options defines the options used to create the mesh
  69305. * @param scene defines the hosting scene
  69306. * @returns the box mesh
  69307. */
  69308. static CreateBox(name: string, options: {
  69309. size?: number;
  69310. width?: number;
  69311. height?: number;
  69312. depth?: number;
  69313. faceUV?: Vector4[];
  69314. faceColors?: Color4[];
  69315. sideOrientation?: number;
  69316. frontUVs?: Vector4;
  69317. backUVs?: Vector4;
  69318. wrap?: boolean;
  69319. topBaseAt?: number;
  69320. bottomBaseAt?: number;
  69321. updatable?: boolean;
  69322. }, scene?: Nullable<Scene>): Mesh;
  69323. /**
  69324. * Creates a tiled box mesh
  69325. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69327. * @param name defines the name of the mesh
  69328. * @param options defines the options used to create the mesh
  69329. * @param scene defines the hosting scene
  69330. * @returns the tiled box mesh
  69331. */
  69332. static CreateTiledBox(name: string, options: {
  69333. pattern?: number;
  69334. size?: number;
  69335. width?: number;
  69336. height?: number;
  69337. depth: number;
  69338. tileSize?: number;
  69339. tileWidth?: number;
  69340. tileHeight?: number;
  69341. faceUV?: Vector4[];
  69342. faceColors?: Color4[];
  69343. alignHorizontal?: number;
  69344. alignVertical?: number;
  69345. sideOrientation?: number;
  69346. updatable?: boolean;
  69347. }, scene?: Nullable<Scene>): Mesh;
  69348. /**
  69349. * Creates a sphere mesh
  69350. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69351. * * 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`)
  69352. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69353. * * 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
  69354. * * 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)
  69355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69356. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69358. * @param name defines the name of the mesh
  69359. * @param options defines the options used to create the mesh
  69360. * @param scene defines the hosting scene
  69361. * @returns the sphere mesh
  69362. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69363. */
  69364. static CreateSphere(name: string, options: {
  69365. segments?: number;
  69366. diameter?: number;
  69367. diameterX?: number;
  69368. diameterY?: number;
  69369. diameterZ?: number;
  69370. arc?: number;
  69371. slice?: number;
  69372. sideOrientation?: number;
  69373. frontUVs?: Vector4;
  69374. backUVs?: Vector4;
  69375. updatable?: boolean;
  69376. }, scene?: Nullable<Scene>): Mesh;
  69377. /**
  69378. * Creates a plane polygonal mesh. By default, this is a disc
  69379. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69380. * * 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
  69381. * * 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
  69382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69385. * @param name defines the name of the mesh
  69386. * @param options defines the options used to create the mesh
  69387. * @param scene defines the hosting scene
  69388. * @returns the plane polygonal mesh
  69389. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69390. */
  69391. static CreateDisc(name: string, options: {
  69392. radius?: number;
  69393. tessellation?: number;
  69394. arc?: number;
  69395. updatable?: boolean;
  69396. sideOrientation?: number;
  69397. frontUVs?: Vector4;
  69398. backUVs?: Vector4;
  69399. }, scene?: Nullable<Scene>): Mesh;
  69400. /**
  69401. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69402. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69403. * * 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`)
  69404. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69405. * * 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
  69406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69407. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69409. * @param name defines the name of the mesh
  69410. * @param options defines the options used to create the mesh
  69411. * @param scene defines the hosting scene
  69412. * @returns the icosahedron mesh
  69413. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69414. */
  69415. static CreateIcoSphere(name: string, options: {
  69416. radius?: number;
  69417. radiusX?: number;
  69418. radiusY?: number;
  69419. radiusZ?: number;
  69420. flat?: boolean;
  69421. subdivisions?: number;
  69422. sideOrientation?: number;
  69423. frontUVs?: Vector4;
  69424. backUVs?: Vector4;
  69425. updatable?: boolean;
  69426. }, scene?: Nullable<Scene>): Mesh;
  69427. /**
  69428. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69429. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69430. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69431. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69432. * * 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
  69433. * * 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
  69434. * * 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
  69435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69436. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69437. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69438. * * 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
  69439. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69440. * * 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
  69441. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69443. * @param name defines the name of the mesh
  69444. * @param options defines the options used to create the mesh
  69445. * @param scene defines the hosting scene
  69446. * @returns the ribbon mesh
  69447. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69448. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69449. */
  69450. static CreateRibbon(name: string, options: {
  69451. pathArray: Vector3[][];
  69452. closeArray?: boolean;
  69453. closePath?: boolean;
  69454. offset?: number;
  69455. updatable?: boolean;
  69456. sideOrientation?: number;
  69457. frontUVs?: Vector4;
  69458. backUVs?: Vector4;
  69459. instance?: Mesh;
  69460. invertUV?: boolean;
  69461. uvs?: Vector2[];
  69462. colors?: Color4[];
  69463. }, scene?: Nullable<Scene>): Mesh;
  69464. /**
  69465. * Creates a cylinder or a cone mesh
  69466. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69467. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69468. * * 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.
  69469. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69470. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69471. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69472. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69473. * * 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).
  69474. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69475. * * 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).
  69476. * * 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
  69477. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69478. * * 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
  69479. * * 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.
  69480. * * If `enclose` is false, a ring surface is one element.
  69481. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69482. * * 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
  69483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69484. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69486. * @param name defines the name of the mesh
  69487. * @param options defines the options used to create the mesh
  69488. * @param scene defines the hosting scene
  69489. * @returns the cylinder mesh
  69490. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69491. */
  69492. static CreateCylinder(name: string, options: {
  69493. height?: number;
  69494. diameterTop?: number;
  69495. diameterBottom?: number;
  69496. diameter?: number;
  69497. tessellation?: number;
  69498. subdivisions?: number;
  69499. arc?: number;
  69500. faceColors?: Color4[];
  69501. faceUV?: Vector4[];
  69502. updatable?: boolean;
  69503. hasRings?: boolean;
  69504. enclose?: boolean;
  69505. cap?: number;
  69506. sideOrientation?: number;
  69507. frontUVs?: Vector4;
  69508. backUVs?: Vector4;
  69509. }, scene?: Nullable<Scene>): Mesh;
  69510. /**
  69511. * Creates a torus mesh
  69512. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69513. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69514. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69516. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69518. * @param name defines the name of the mesh
  69519. * @param options defines the options used to create the mesh
  69520. * @param scene defines the hosting scene
  69521. * @returns the torus mesh
  69522. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69523. */
  69524. static CreateTorus(name: string, options: {
  69525. diameter?: number;
  69526. thickness?: number;
  69527. tessellation?: number;
  69528. updatable?: boolean;
  69529. sideOrientation?: number;
  69530. frontUVs?: Vector4;
  69531. backUVs?: Vector4;
  69532. }, scene?: Nullable<Scene>): Mesh;
  69533. /**
  69534. * Creates a torus knot mesh
  69535. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69536. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69537. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69538. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69542. * @param name defines the name of the mesh
  69543. * @param options defines the options used to create the mesh
  69544. * @param scene defines the hosting scene
  69545. * @returns the torus knot mesh
  69546. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69547. */
  69548. static CreateTorusKnot(name: string, options: {
  69549. radius?: number;
  69550. tube?: number;
  69551. radialSegments?: number;
  69552. tubularSegments?: number;
  69553. p?: number;
  69554. q?: number;
  69555. updatable?: boolean;
  69556. sideOrientation?: number;
  69557. frontUVs?: Vector4;
  69558. backUVs?: Vector4;
  69559. }, scene?: Nullable<Scene>): Mesh;
  69560. /**
  69561. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69562. * * 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
  69563. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69564. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69565. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69566. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69567. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69568. * * 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
  69569. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69571. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69572. * @param name defines the name of the new line system
  69573. * @param options defines the options used to create the line system
  69574. * @param scene defines the hosting scene
  69575. * @returns a new line system mesh
  69576. */
  69577. static CreateLineSystem(name: string, options: {
  69578. lines: Vector3[][];
  69579. updatable?: boolean;
  69580. instance?: Nullable<LinesMesh>;
  69581. colors?: Nullable<Color4[][]>;
  69582. useVertexAlpha?: boolean;
  69583. }, scene: Nullable<Scene>): LinesMesh;
  69584. /**
  69585. * Creates a line mesh
  69586. * 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
  69587. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69588. * * The parameter `points` is an array successive Vector3
  69589. * * 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
  69590. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69591. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69592. * * When updating an instance, remember that only point positions can change, not the number of points
  69593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69594. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69595. * @param name defines the name of the new line system
  69596. * @param options defines the options used to create the line system
  69597. * @param scene defines the hosting scene
  69598. * @returns a new line mesh
  69599. */
  69600. static CreateLines(name: string, options: {
  69601. points: Vector3[];
  69602. updatable?: boolean;
  69603. instance?: Nullable<LinesMesh>;
  69604. colors?: Color4[];
  69605. useVertexAlpha?: boolean;
  69606. }, scene?: Nullable<Scene>): LinesMesh;
  69607. /**
  69608. * Creates a dashed line mesh
  69609. * * 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
  69610. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69611. * * The parameter `points` is an array successive Vector3
  69612. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69613. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69614. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69615. * * 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
  69616. * * When updating an instance, remember that only point positions can change, not the number of points
  69617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69618. * @param name defines the name of the mesh
  69619. * @param options defines the options used to create the mesh
  69620. * @param scene defines the hosting scene
  69621. * @returns the dashed line mesh
  69622. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69623. */
  69624. static CreateDashedLines(name: string, options: {
  69625. points: Vector3[];
  69626. dashSize?: number;
  69627. gapSize?: number;
  69628. dashNb?: number;
  69629. updatable?: boolean;
  69630. instance?: LinesMesh;
  69631. }, scene?: Nullable<Scene>): LinesMesh;
  69632. /**
  69633. * 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.
  69634. * * 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.
  69635. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69636. * * 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.
  69637. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69638. * * 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
  69639. * * 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
  69640. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69642. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69643. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69645. * @param name defines the name of the mesh
  69646. * @param options defines the options used to create the mesh
  69647. * @param scene defines the hosting scene
  69648. * @returns the extruded shape mesh
  69649. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69650. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69651. */
  69652. static ExtrudeShape(name: string, options: {
  69653. shape: Vector3[];
  69654. path: Vector3[];
  69655. scale?: number;
  69656. rotation?: number;
  69657. cap?: number;
  69658. updatable?: boolean;
  69659. sideOrientation?: number;
  69660. frontUVs?: Vector4;
  69661. backUVs?: Vector4;
  69662. instance?: Mesh;
  69663. invertUV?: boolean;
  69664. }, scene?: Nullable<Scene>): Mesh;
  69665. /**
  69666. * Creates an custom extruded shape mesh.
  69667. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69668. * * 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.
  69669. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69670. * * 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
  69671. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69672. * * 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
  69673. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69674. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69675. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69676. * * 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
  69677. * * 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
  69678. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69681. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69683. * @param name defines the name of the mesh
  69684. * @param options defines the options used to create the mesh
  69685. * @param scene defines the hosting scene
  69686. * @returns the custom extruded shape mesh
  69687. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69688. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69689. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69690. */
  69691. static ExtrudeShapeCustom(name: string, options: {
  69692. shape: Vector3[];
  69693. path: Vector3[];
  69694. scaleFunction?: any;
  69695. rotationFunction?: any;
  69696. ribbonCloseArray?: boolean;
  69697. ribbonClosePath?: boolean;
  69698. cap?: number;
  69699. updatable?: boolean;
  69700. sideOrientation?: number;
  69701. frontUVs?: Vector4;
  69702. backUVs?: Vector4;
  69703. instance?: Mesh;
  69704. invertUV?: boolean;
  69705. }, scene?: Nullable<Scene>): Mesh;
  69706. /**
  69707. * Creates lathe mesh.
  69708. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69709. * * 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
  69710. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69711. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69712. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69713. * * 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
  69714. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69715. * * 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
  69716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69718. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69720. * @param name defines the name of the mesh
  69721. * @param options defines the options used to create the mesh
  69722. * @param scene defines the hosting scene
  69723. * @returns the lathe mesh
  69724. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69725. */
  69726. static CreateLathe(name: string, options: {
  69727. shape: Vector3[];
  69728. radius?: number;
  69729. tessellation?: number;
  69730. clip?: number;
  69731. arc?: number;
  69732. closed?: boolean;
  69733. updatable?: boolean;
  69734. sideOrientation?: number;
  69735. frontUVs?: Vector4;
  69736. backUVs?: Vector4;
  69737. cap?: number;
  69738. invertUV?: boolean;
  69739. }, scene?: Nullable<Scene>): Mesh;
  69740. /**
  69741. * Creates a tiled plane mesh
  69742. * * You can set a limited pattern arrangement with the tiles
  69743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69746. * @param name defines the name of the mesh
  69747. * @param options defines the options used to create the mesh
  69748. * @param scene defines the hosting scene
  69749. * @returns the plane mesh
  69750. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69751. */
  69752. static CreateTiledPlane(name: string, options: {
  69753. pattern?: number;
  69754. tileSize?: number;
  69755. tileWidth?: number;
  69756. tileHeight?: number;
  69757. size?: number;
  69758. width?: number;
  69759. height?: number;
  69760. alignHorizontal?: number;
  69761. alignVertical?: number;
  69762. sideOrientation?: number;
  69763. frontUVs?: Vector4;
  69764. backUVs?: Vector4;
  69765. updatable?: boolean;
  69766. }, scene?: Nullable<Scene>): Mesh;
  69767. /**
  69768. * Creates a plane mesh
  69769. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69770. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69771. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69772. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69773. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69775. * @param name defines the name of the mesh
  69776. * @param options defines the options used to create the mesh
  69777. * @param scene defines the hosting scene
  69778. * @returns the plane mesh
  69779. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69780. */
  69781. static CreatePlane(name: string, options: {
  69782. size?: number;
  69783. width?: number;
  69784. height?: number;
  69785. sideOrientation?: number;
  69786. frontUVs?: Vector4;
  69787. backUVs?: Vector4;
  69788. updatable?: boolean;
  69789. sourcePlane?: Plane;
  69790. }, scene?: Nullable<Scene>): Mesh;
  69791. /**
  69792. * Creates a ground mesh
  69793. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69794. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69796. * @param name defines the name of the mesh
  69797. * @param options defines the options used to create the mesh
  69798. * @param scene defines the hosting scene
  69799. * @returns the ground mesh
  69800. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69801. */
  69802. static CreateGround(name: string, options: {
  69803. width?: number;
  69804. height?: number;
  69805. subdivisions?: number;
  69806. subdivisionsX?: number;
  69807. subdivisionsY?: number;
  69808. updatable?: boolean;
  69809. }, scene?: Nullable<Scene>): Mesh;
  69810. /**
  69811. * Creates a tiled ground mesh
  69812. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69813. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69814. * * 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
  69815. * * 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
  69816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69817. * @param name defines the name of the mesh
  69818. * @param options defines the options used to create the mesh
  69819. * @param scene defines the hosting scene
  69820. * @returns the tiled ground mesh
  69821. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69822. */
  69823. static CreateTiledGround(name: string, options: {
  69824. xmin: number;
  69825. zmin: number;
  69826. xmax: number;
  69827. zmax: number;
  69828. subdivisions?: {
  69829. w: number;
  69830. h: number;
  69831. };
  69832. precision?: {
  69833. w: number;
  69834. h: number;
  69835. };
  69836. updatable?: boolean;
  69837. }, scene?: Nullable<Scene>): Mesh;
  69838. /**
  69839. * Creates a ground mesh from a height map
  69840. * * The parameter `url` sets the URL of the height map image resource.
  69841. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69842. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69843. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69844. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69845. * * 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.
  69846. * * 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).
  69847. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69849. * @param name defines the name of the mesh
  69850. * @param url defines the url to the height map
  69851. * @param options defines the options used to create the mesh
  69852. * @param scene defines the hosting scene
  69853. * @returns the ground mesh
  69854. * @see https://doc.babylonjs.com/babylon101/height_map
  69855. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69856. */
  69857. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69858. width?: number;
  69859. height?: number;
  69860. subdivisions?: number;
  69861. minHeight?: number;
  69862. maxHeight?: number;
  69863. colorFilter?: Color3;
  69864. alphaFilter?: number;
  69865. updatable?: boolean;
  69866. onReady?: (mesh: GroundMesh) => void;
  69867. }, scene?: Nullable<Scene>): GroundMesh;
  69868. /**
  69869. * Creates a polygon mesh
  69870. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69871. * * 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
  69872. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69875. * * Remember you can only change the shape positions, not their number when updating a polygon
  69876. * @param name defines the name of the mesh
  69877. * @param options defines the options used to create the mesh
  69878. * @param scene defines the hosting scene
  69879. * @param earcutInjection can be used to inject your own earcut reference
  69880. * @returns the polygon mesh
  69881. */
  69882. static CreatePolygon(name: string, options: {
  69883. shape: Vector3[];
  69884. holes?: Vector3[][];
  69885. depth?: number;
  69886. faceUV?: Vector4[];
  69887. faceColors?: Color4[];
  69888. updatable?: boolean;
  69889. sideOrientation?: number;
  69890. frontUVs?: Vector4;
  69891. backUVs?: Vector4;
  69892. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69893. /**
  69894. * Creates an extruded polygon mesh, with depth in the Y direction.
  69895. * * 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)
  69896. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69897. * @param name defines the name of the mesh
  69898. * @param options defines the options used to create the mesh
  69899. * @param scene defines the hosting scene
  69900. * @param earcutInjection can be used to inject your own earcut reference
  69901. * @returns the polygon mesh
  69902. */
  69903. static ExtrudePolygon(name: string, options: {
  69904. shape: Vector3[];
  69905. holes?: Vector3[][];
  69906. depth?: number;
  69907. faceUV?: Vector4[];
  69908. faceColors?: Color4[];
  69909. updatable?: boolean;
  69910. sideOrientation?: number;
  69911. frontUVs?: Vector4;
  69912. backUVs?: Vector4;
  69913. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69914. /**
  69915. * Creates a tube mesh.
  69916. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69917. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69918. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69919. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69920. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69921. * * 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)
  69922. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69923. * * 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
  69924. * * 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
  69925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69926. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69927. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69929. * @param name defines the name of the mesh
  69930. * @param options defines the options used to create the mesh
  69931. * @param scene defines the hosting scene
  69932. * @returns the tube mesh
  69933. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69934. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69935. */
  69936. static CreateTube(name: string, options: {
  69937. path: Vector3[];
  69938. radius?: number;
  69939. tessellation?: number;
  69940. radiusFunction?: {
  69941. (i: number, distance: number): number;
  69942. };
  69943. cap?: number;
  69944. arc?: number;
  69945. updatable?: boolean;
  69946. sideOrientation?: number;
  69947. frontUVs?: Vector4;
  69948. backUVs?: Vector4;
  69949. instance?: Mesh;
  69950. invertUV?: boolean;
  69951. }, scene?: Nullable<Scene>): Mesh;
  69952. /**
  69953. * Creates a polyhedron mesh
  69954. * * 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
  69955. * * The parameter `size` (positive float, default 1) sets the polygon size
  69956. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69957. * * 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`
  69958. * * 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
  69959. * * 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)`)
  69960. * * 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
  69961. * * 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
  69962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69963. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69965. * @param name defines the name of the mesh
  69966. * @param options defines the options used to create the mesh
  69967. * @param scene defines the hosting scene
  69968. * @returns the polyhedron mesh
  69969. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  69970. */
  69971. static CreatePolyhedron(name: string, options: {
  69972. type?: number;
  69973. size?: number;
  69974. sizeX?: number;
  69975. sizeY?: number;
  69976. sizeZ?: number;
  69977. custom?: any;
  69978. faceUV?: Vector4[];
  69979. faceColors?: Color4[];
  69980. flat?: boolean;
  69981. updatable?: boolean;
  69982. sideOrientation?: number;
  69983. frontUVs?: Vector4;
  69984. backUVs?: Vector4;
  69985. }, scene?: Nullable<Scene>): Mesh;
  69986. /**
  69987. * Creates a decal mesh.
  69988. * 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
  69989. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69990. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69991. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69992. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69993. * @param name defines the name of the mesh
  69994. * @param sourceMesh defines the mesh where the decal must be applied
  69995. * @param options defines the options used to create the mesh
  69996. * @param scene defines the hosting scene
  69997. * @returns the decal mesh
  69998. * @see https://doc.babylonjs.com/how_to/decals
  69999. */
  70000. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70001. position?: Vector3;
  70002. normal?: Vector3;
  70003. size?: Vector3;
  70004. angle?: number;
  70005. }): Mesh;
  70006. /**
  70007. * Creates a Capsule Mesh
  70008. * @param name defines the name of the mesh.
  70009. * @param options the constructors options used to shape the mesh.
  70010. * @param scene defines the scene the mesh is scoped to.
  70011. * @returns the capsule mesh
  70012. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70013. */
  70014. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70015. }
  70016. }
  70017. declare module "babylonjs/Meshes/meshSimplification" {
  70018. import { Mesh } from "babylonjs/Meshes/mesh";
  70019. /**
  70020. * A simplifier interface for future simplification implementations
  70021. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70022. */
  70023. export interface ISimplifier {
  70024. /**
  70025. * Simplification of a given mesh according to the given settings.
  70026. * Since this requires computation, it is assumed that the function runs async.
  70027. * @param settings The settings of the simplification, including quality and distance
  70028. * @param successCallback A callback that will be called after the mesh was simplified.
  70029. * @param errorCallback in case of an error, this callback will be called. optional.
  70030. */
  70031. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70032. }
  70033. /**
  70034. * Expected simplification settings.
  70035. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70036. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70037. */
  70038. export interface ISimplificationSettings {
  70039. /**
  70040. * Gets or sets the expected quality
  70041. */
  70042. quality: number;
  70043. /**
  70044. * Gets or sets the distance when this optimized version should be used
  70045. */
  70046. distance: number;
  70047. /**
  70048. * Gets an already optimized mesh
  70049. */
  70050. optimizeMesh?: boolean;
  70051. }
  70052. /**
  70053. * Class used to specify simplification options
  70054. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70055. */
  70056. export class SimplificationSettings implements ISimplificationSettings {
  70057. /** expected quality */
  70058. quality: number;
  70059. /** distance when this optimized version should be used */
  70060. distance: number;
  70061. /** already optimized mesh */
  70062. optimizeMesh?: boolean | undefined;
  70063. /**
  70064. * Creates a SimplificationSettings
  70065. * @param quality expected quality
  70066. * @param distance distance when this optimized version should be used
  70067. * @param optimizeMesh already optimized mesh
  70068. */
  70069. constructor(
  70070. /** expected quality */
  70071. quality: number,
  70072. /** distance when this optimized version should be used */
  70073. distance: number,
  70074. /** already optimized mesh */
  70075. optimizeMesh?: boolean | undefined);
  70076. }
  70077. /**
  70078. * Interface used to define a simplification task
  70079. */
  70080. export interface ISimplificationTask {
  70081. /**
  70082. * Array of settings
  70083. */
  70084. settings: Array<ISimplificationSettings>;
  70085. /**
  70086. * Simplification type
  70087. */
  70088. simplificationType: SimplificationType;
  70089. /**
  70090. * Mesh to simplify
  70091. */
  70092. mesh: Mesh;
  70093. /**
  70094. * Callback called on success
  70095. */
  70096. successCallback?: () => void;
  70097. /**
  70098. * Defines if parallel processing can be used
  70099. */
  70100. parallelProcessing: boolean;
  70101. }
  70102. /**
  70103. * Queue used to order the simplification tasks
  70104. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70105. */
  70106. export class SimplificationQueue {
  70107. private _simplificationArray;
  70108. /**
  70109. * Gets a boolean indicating that the process is still running
  70110. */
  70111. running: boolean;
  70112. /**
  70113. * Creates a new queue
  70114. */
  70115. constructor();
  70116. /**
  70117. * Adds a new simplification task
  70118. * @param task defines a task to add
  70119. */
  70120. addTask(task: ISimplificationTask): void;
  70121. /**
  70122. * Execute next task
  70123. */
  70124. executeNext(): void;
  70125. /**
  70126. * Execute a simplification task
  70127. * @param task defines the task to run
  70128. */
  70129. runSimplification(task: ISimplificationTask): void;
  70130. private getSimplifier;
  70131. }
  70132. /**
  70133. * The implemented types of simplification
  70134. * At the moment only Quadratic Error Decimation is implemented
  70135. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70136. */
  70137. export enum SimplificationType {
  70138. /** Quadratic error decimation */
  70139. QUADRATIC = 0
  70140. }
  70141. /**
  70142. * An implementation of the Quadratic Error simplification algorithm.
  70143. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70144. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70145. * @author RaananW
  70146. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70147. */
  70148. export class QuadraticErrorSimplification implements ISimplifier {
  70149. private _mesh;
  70150. private triangles;
  70151. private vertices;
  70152. private references;
  70153. private _reconstructedMesh;
  70154. /** Gets or sets the number pf sync interations */
  70155. syncIterations: number;
  70156. /** Gets or sets the aggressiveness of the simplifier */
  70157. aggressiveness: number;
  70158. /** Gets or sets the number of allowed iterations for decimation */
  70159. decimationIterations: number;
  70160. /** Gets or sets the espilon to use for bounding box computation */
  70161. boundingBoxEpsilon: number;
  70162. /**
  70163. * Creates a new QuadraticErrorSimplification
  70164. * @param _mesh defines the target mesh
  70165. */
  70166. constructor(_mesh: Mesh);
  70167. /**
  70168. * Simplification of a given mesh according to the given settings.
  70169. * Since this requires computation, it is assumed that the function runs async.
  70170. * @param settings The settings of the simplification, including quality and distance
  70171. * @param successCallback A callback that will be called after the mesh was simplified.
  70172. */
  70173. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70174. private runDecimation;
  70175. private initWithMesh;
  70176. private init;
  70177. private reconstructMesh;
  70178. private initDecimatedMesh;
  70179. private isFlipped;
  70180. private updateTriangles;
  70181. private identifyBorder;
  70182. private updateMesh;
  70183. private vertexError;
  70184. private calculateError;
  70185. }
  70186. }
  70187. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70188. import { Scene } from "babylonjs/scene";
  70189. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70190. import { ISceneComponent } from "babylonjs/sceneComponent";
  70191. module "babylonjs/scene" {
  70192. interface Scene {
  70193. /** @hidden (Backing field) */
  70194. _simplificationQueue: SimplificationQueue;
  70195. /**
  70196. * Gets or sets the simplification queue attached to the scene
  70197. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70198. */
  70199. simplificationQueue: SimplificationQueue;
  70200. }
  70201. }
  70202. module "babylonjs/Meshes/mesh" {
  70203. interface Mesh {
  70204. /**
  70205. * Simplify the mesh according to the given array of settings.
  70206. * Function will return immediately and will simplify async
  70207. * @param settings a collection of simplification settings
  70208. * @param parallelProcessing should all levels calculate parallel or one after the other
  70209. * @param simplificationType the type of simplification to run
  70210. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70211. * @returns the current mesh
  70212. */
  70213. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70214. }
  70215. }
  70216. /**
  70217. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70218. * created in a scene
  70219. */
  70220. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70221. /**
  70222. * The component name helpfull to identify the component in the list of scene components.
  70223. */
  70224. readonly name: string;
  70225. /**
  70226. * The scene the component belongs to.
  70227. */
  70228. scene: Scene;
  70229. /**
  70230. * Creates a new instance of the component for the given scene
  70231. * @param scene Defines the scene to register the component in
  70232. */
  70233. constructor(scene: Scene);
  70234. /**
  70235. * Registers the component in a given scene
  70236. */
  70237. register(): void;
  70238. /**
  70239. * Rebuilds the elements related to this component in case of
  70240. * context lost for instance.
  70241. */
  70242. rebuild(): void;
  70243. /**
  70244. * Disposes the component and the associated ressources
  70245. */
  70246. dispose(): void;
  70247. private _beforeCameraUpdate;
  70248. }
  70249. }
  70250. declare module "babylonjs/Meshes/Builders/index" {
  70251. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70252. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70253. export * from "babylonjs/Meshes/Builders/discBuilder";
  70254. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70255. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70256. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70257. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70258. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70259. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70260. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70261. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70262. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70263. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70264. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70265. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70266. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70267. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70268. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70269. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70270. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70271. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70272. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70273. }
  70274. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70275. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70276. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70277. import { Matrix } from "babylonjs/Maths/math.vector";
  70278. module "babylonjs/Meshes/mesh" {
  70279. interface Mesh {
  70280. /**
  70281. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70282. */
  70283. thinInstanceEnablePicking: boolean;
  70284. /**
  70285. * Creates a new thin instance
  70286. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70287. * @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
  70288. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70289. */
  70290. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70291. /**
  70292. * Adds the transformation (matrix) of the current mesh as a thin instance
  70293. * @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
  70294. * @returns the thin instance index number
  70295. */
  70296. thinInstanceAddSelf(refresh: boolean): number;
  70297. /**
  70298. * Registers a custom attribute to be used with thin instances
  70299. * @param kind name of the attribute
  70300. * @param stride size in floats of the attribute
  70301. */
  70302. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70303. /**
  70304. * Sets the matrix of a thin instance
  70305. * @param index index of the thin instance
  70306. * @param matrix matrix to set
  70307. * @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
  70308. */
  70309. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70310. /**
  70311. * Sets the value of a custom attribute for a thin instance
  70312. * @param kind name of the attribute
  70313. * @param index index of the thin instance
  70314. * @param value value to set
  70315. * @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
  70316. */
  70317. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70318. /**
  70319. * 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.
  70320. */
  70321. thinInstanceCount: number;
  70322. /**
  70323. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70324. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70325. * @param buffer buffer to set
  70326. * @param stride size in floats of each value of the buffer
  70327. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70328. */
  70329. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70330. /**
  70331. * Gets the list of world matrices
  70332. * @return an array containing all the world matrices from the thin instances
  70333. */
  70334. thinInstanceGetWorldMatrices(): Matrix[];
  70335. /**
  70336. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70337. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70338. */
  70339. thinInstanceBufferUpdated(kind: string): void;
  70340. /**
  70341. * Applies a partial update to a buffer directly on the GPU
  70342. * 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
  70343. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70344. * @param data the data to set in the GPU buffer
  70345. * @param offset the offset in the GPU buffer where to update the data
  70346. */
  70347. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70348. /**
  70349. * Refreshes the bounding info, taking into account all the thin instances defined
  70350. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70351. */
  70352. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70353. /** @hidden */
  70354. _thinInstanceInitializeUserStorage(): void;
  70355. /** @hidden */
  70356. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70357. /** @hidden */
  70358. _userThinInstanceBuffersStorage: {
  70359. data: {
  70360. [key: string]: Float32Array;
  70361. };
  70362. sizes: {
  70363. [key: string]: number;
  70364. };
  70365. vertexBuffers: {
  70366. [key: string]: Nullable<VertexBuffer>;
  70367. };
  70368. strides: {
  70369. [key: string]: number;
  70370. };
  70371. };
  70372. }
  70373. }
  70374. }
  70375. declare module "babylonjs/Meshes/index" {
  70376. export * from "babylonjs/Meshes/abstractMesh";
  70377. export * from "babylonjs/Meshes/buffer";
  70378. export * from "babylonjs/Meshes/Compression/index";
  70379. export * from "babylonjs/Meshes/csg";
  70380. export * from "babylonjs/Meshes/geometry";
  70381. export * from "babylonjs/Meshes/groundMesh";
  70382. export * from "babylonjs/Meshes/trailMesh";
  70383. export * from "babylonjs/Meshes/instancedMesh";
  70384. export * from "babylonjs/Meshes/linesMesh";
  70385. export * from "babylonjs/Meshes/mesh";
  70386. export * from "babylonjs/Meshes/mesh.vertexData";
  70387. export * from "babylonjs/Meshes/meshBuilder";
  70388. export * from "babylonjs/Meshes/meshSimplification";
  70389. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70390. export * from "babylonjs/Meshes/polygonMesh";
  70391. export * from "babylonjs/Meshes/subMesh";
  70392. export * from "babylonjs/Meshes/meshLODLevel";
  70393. export * from "babylonjs/Meshes/transformNode";
  70394. export * from "babylonjs/Meshes/Builders/index";
  70395. export * from "babylonjs/Meshes/dataBuffer";
  70396. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70397. import "babylonjs/Meshes/thinInstanceMesh";
  70398. export * from "babylonjs/Meshes/thinInstanceMesh";
  70399. }
  70400. declare module "babylonjs/Morph/index" {
  70401. export * from "babylonjs/Morph/morphTarget";
  70402. export * from "babylonjs/Morph/morphTargetManager";
  70403. }
  70404. declare module "babylonjs/Navigation/INavigationEngine" {
  70405. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70406. import { Vector3 } from "babylonjs/Maths/math";
  70407. import { Mesh } from "babylonjs/Meshes/mesh";
  70408. import { Scene } from "babylonjs/scene";
  70409. /**
  70410. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70411. */
  70412. export interface INavigationEnginePlugin {
  70413. /**
  70414. * plugin name
  70415. */
  70416. name: string;
  70417. /**
  70418. * Creates a navigation mesh
  70419. * @param meshes array of all the geometry used to compute the navigatio mesh
  70420. * @param parameters bunch of parameters used to filter geometry
  70421. */
  70422. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70423. /**
  70424. * Create a navigation mesh debug mesh
  70425. * @param scene is where the mesh will be added
  70426. * @returns debug display mesh
  70427. */
  70428. createDebugNavMesh(scene: Scene): Mesh;
  70429. /**
  70430. * Get a navigation mesh constrained position, closest to the parameter position
  70431. * @param position world position
  70432. * @returns the closest point to position constrained by the navigation mesh
  70433. */
  70434. getClosestPoint(position: Vector3): Vector3;
  70435. /**
  70436. * Get a navigation mesh constrained position, closest to the parameter position
  70437. * @param position world position
  70438. * @param result output the closest point to position constrained by the navigation mesh
  70439. */
  70440. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70441. /**
  70442. * Get a navigation mesh constrained position, within a particular radius
  70443. * @param position world position
  70444. * @param maxRadius the maximum distance to the constrained world position
  70445. * @returns the closest point to position constrained by the navigation mesh
  70446. */
  70447. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70448. /**
  70449. * Get a navigation mesh constrained position, within a particular radius
  70450. * @param position world position
  70451. * @param maxRadius the maximum distance to the constrained world position
  70452. * @param result output the closest point to position constrained by the navigation mesh
  70453. */
  70454. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70455. /**
  70456. * Compute the final position from a segment made of destination-position
  70457. * @param position world position
  70458. * @param destination world position
  70459. * @returns the resulting point along the navmesh
  70460. */
  70461. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70462. /**
  70463. * Compute the final position from a segment made of destination-position
  70464. * @param position world position
  70465. * @param destination world position
  70466. * @param result output the resulting point along the navmesh
  70467. */
  70468. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70469. /**
  70470. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70471. * @param start world position
  70472. * @param end world position
  70473. * @returns array containing world position composing the path
  70474. */
  70475. computePath(start: Vector3, end: Vector3): Vector3[];
  70476. /**
  70477. * If this plugin is supported
  70478. * @returns true if plugin is supported
  70479. */
  70480. isSupported(): boolean;
  70481. /**
  70482. * Create a new Crowd so you can add agents
  70483. * @param maxAgents the maximum agent count in the crowd
  70484. * @param maxAgentRadius the maximum radius an agent can have
  70485. * @param scene to attach the crowd to
  70486. * @returns the crowd you can add agents to
  70487. */
  70488. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70489. /**
  70490. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70491. * The queries will try to find a solution within those bounds
  70492. * default is (1,1,1)
  70493. * @param extent x,y,z value that define the extent around the queries point of reference
  70494. */
  70495. setDefaultQueryExtent(extent: Vector3): void;
  70496. /**
  70497. * Get the Bounding box extent specified by setDefaultQueryExtent
  70498. * @returns the box extent values
  70499. */
  70500. getDefaultQueryExtent(): Vector3;
  70501. /**
  70502. * build the navmesh from a previously saved state using getNavmeshData
  70503. * @param data the Uint8Array returned by getNavmeshData
  70504. */
  70505. buildFromNavmeshData(data: Uint8Array): void;
  70506. /**
  70507. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70508. * @returns data the Uint8Array that can be saved and reused
  70509. */
  70510. getNavmeshData(): Uint8Array;
  70511. /**
  70512. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70513. * @param result output the box extent values
  70514. */
  70515. getDefaultQueryExtentToRef(result: Vector3): void;
  70516. /**
  70517. * Release all resources
  70518. */
  70519. dispose(): void;
  70520. }
  70521. /**
  70522. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70523. */
  70524. export interface ICrowd {
  70525. /**
  70526. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70527. * You can attach anything to that node. The node position is updated in the scene update tick.
  70528. * @param pos world position that will be constrained by the navigation mesh
  70529. * @param parameters agent parameters
  70530. * @param transform hooked to the agent that will be update by the scene
  70531. * @returns agent index
  70532. */
  70533. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70534. /**
  70535. * Returns the agent position in world space
  70536. * @param index agent index returned by addAgent
  70537. * @returns world space position
  70538. */
  70539. getAgentPosition(index: number): Vector3;
  70540. /**
  70541. * Gets the agent position result in world space
  70542. * @param index agent index returned by addAgent
  70543. * @param result output world space position
  70544. */
  70545. getAgentPositionToRef(index: number, result: Vector3): void;
  70546. /**
  70547. * Gets the agent velocity in world space
  70548. * @param index agent index returned by addAgent
  70549. * @returns world space velocity
  70550. */
  70551. getAgentVelocity(index: number): Vector3;
  70552. /**
  70553. * Gets the agent velocity result in world space
  70554. * @param index agent index returned by addAgent
  70555. * @param result output world space velocity
  70556. */
  70557. getAgentVelocityToRef(index: number, result: Vector3): void;
  70558. /**
  70559. * remove a particular agent previously created
  70560. * @param index agent index returned by addAgent
  70561. */
  70562. removeAgent(index: number): void;
  70563. /**
  70564. * get the list of all agents attached to this crowd
  70565. * @returns list of agent indices
  70566. */
  70567. getAgents(): number[];
  70568. /**
  70569. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70570. * @param deltaTime in seconds
  70571. */
  70572. update(deltaTime: number): void;
  70573. /**
  70574. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70575. * @param index agent index returned by addAgent
  70576. * @param destination targeted world position
  70577. */
  70578. agentGoto(index: number, destination: Vector3): void;
  70579. /**
  70580. * Teleport the agent to a new position
  70581. * @param index agent index returned by addAgent
  70582. * @param destination targeted world position
  70583. */
  70584. agentTeleport(index: number, destination: Vector3): void;
  70585. /**
  70586. * Update agent parameters
  70587. * @param index agent index returned by addAgent
  70588. * @param parameters agent parameters
  70589. */
  70590. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70591. /**
  70592. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70593. * The queries will try to find a solution within those bounds
  70594. * default is (1,1,1)
  70595. * @param extent x,y,z value that define the extent around the queries point of reference
  70596. */
  70597. setDefaultQueryExtent(extent: Vector3): void;
  70598. /**
  70599. * Get the Bounding box extent specified by setDefaultQueryExtent
  70600. * @returns the box extent values
  70601. */
  70602. getDefaultQueryExtent(): Vector3;
  70603. /**
  70604. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70605. * @param result output the box extent values
  70606. */
  70607. getDefaultQueryExtentToRef(result: Vector3): void;
  70608. /**
  70609. * Release all resources
  70610. */
  70611. dispose(): void;
  70612. }
  70613. /**
  70614. * Configures an agent
  70615. */
  70616. export interface IAgentParameters {
  70617. /**
  70618. * Agent radius. [Limit: >= 0]
  70619. */
  70620. radius: number;
  70621. /**
  70622. * Agent height. [Limit: > 0]
  70623. */
  70624. height: number;
  70625. /**
  70626. * Maximum allowed acceleration. [Limit: >= 0]
  70627. */
  70628. maxAcceleration: number;
  70629. /**
  70630. * Maximum allowed speed. [Limit: >= 0]
  70631. */
  70632. maxSpeed: number;
  70633. /**
  70634. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70635. */
  70636. collisionQueryRange: number;
  70637. /**
  70638. * The path visibility optimization range. [Limit: > 0]
  70639. */
  70640. pathOptimizationRange: number;
  70641. /**
  70642. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70643. */
  70644. separationWeight: number;
  70645. }
  70646. /**
  70647. * Configures the navigation mesh creation
  70648. */
  70649. export interface INavMeshParameters {
  70650. /**
  70651. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70652. */
  70653. cs: number;
  70654. /**
  70655. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70656. */
  70657. ch: number;
  70658. /**
  70659. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70660. */
  70661. walkableSlopeAngle: number;
  70662. /**
  70663. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70664. * be considered walkable. [Limit: >= 3] [Units: vx]
  70665. */
  70666. walkableHeight: number;
  70667. /**
  70668. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70669. */
  70670. walkableClimb: number;
  70671. /**
  70672. * The distance to erode/shrink the walkable area of the heightfield away from
  70673. * obstructions. [Limit: >=0] [Units: vx]
  70674. */
  70675. walkableRadius: number;
  70676. /**
  70677. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70678. */
  70679. maxEdgeLen: number;
  70680. /**
  70681. * The maximum distance a simplfied contour's border edges should deviate
  70682. * the original raw contour. [Limit: >=0] [Units: vx]
  70683. */
  70684. maxSimplificationError: number;
  70685. /**
  70686. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70687. */
  70688. minRegionArea: number;
  70689. /**
  70690. * Any regions with a span count smaller than this value will, if possible,
  70691. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70692. */
  70693. mergeRegionArea: number;
  70694. /**
  70695. * The maximum number of vertices allowed for polygons generated during the
  70696. * contour to polygon conversion process. [Limit: >= 3]
  70697. */
  70698. maxVertsPerPoly: number;
  70699. /**
  70700. * Sets the sampling distance to use when generating the detail mesh.
  70701. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70702. */
  70703. detailSampleDist: number;
  70704. /**
  70705. * The maximum distance the detail mesh surface should deviate from heightfield
  70706. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70707. */
  70708. detailSampleMaxError: number;
  70709. }
  70710. }
  70711. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70712. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70713. import { Mesh } from "babylonjs/Meshes/mesh";
  70714. import { Scene } from "babylonjs/scene";
  70715. import { Vector3 } from "babylonjs/Maths/math";
  70716. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70717. /**
  70718. * RecastJS navigation plugin
  70719. */
  70720. export class RecastJSPlugin implements INavigationEnginePlugin {
  70721. /**
  70722. * Reference to the Recast library
  70723. */
  70724. bjsRECAST: any;
  70725. /**
  70726. * plugin name
  70727. */
  70728. name: string;
  70729. /**
  70730. * the first navmesh created. We might extend this to support multiple navmeshes
  70731. */
  70732. navMesh: any;
  70733. /**
  70734. * Initializes the recastJS plugin
  70735. * @param recastInjection can be used to inject your own recast reference
  70736. */
  70737. constructor(recastInjection?: any);
  70738. /**
  70739. * Creates a navigation mesh
  70740. * @param meshes array of all the geometry used to compute the navigatio mesh
  70741. * @param parameters bunch of parameters used to filter geometry
  70742. */
  70743. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70744. /**
  70745. * Create a navigation mesh debug mesh
  70746. * @param scene is where the mesh will be added
  70747. * @returns debug display mesh
  70748. */
  70749. createDebugNavMesh(scene: Scene): Mesh;
  70750. /**
  70751. * Get a navigation mesh constrained position, closest to the parameter position
  70752. * @param position world position
  70753. * @returns the closest point to position constrained by the navigation mesh
  70754. */
  70755. getClosestPoint(position: Vector3): Vector3;
  70756. /**
  70757. * Get a navigation mesh constrained position, closest to the parameter position
  70758. * @param position world position
  70759. * @param result output the closest point to position constrained by the navigation mesh
  70760. */
  70761. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70762. /**
  70763. * Get a navigation mesh constrained position, within a particular radius
  70764. * @param position world position
  70765. * @param maxRadius the maximum distance to the constrained world position
  70766. * @returns the closest point to position constrained by the navigation mesh
  70767. */
  70768. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70769. /**
  70770. * Get a navigation mesh constrained position, within a particular radius
  70771. * @param position world position
  70772. * @param maxRadius the maximum distance to the constrained world position
  70773. * @param result output the closest point to position constrained by the navigation mesh
  70774. */
  70775. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70776. /**
  70777. * Compute the final position from a segment made of destination-position
  70778. * @param position world position
  70779. * @param destination world position
  70780. * @returns the resulting point along the navmesh
  70781. */
  70782. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70783. /**
  70784. * Compute the final position from a segment made of destination-position
  70785. * @param position world position
  70786. * @param destination world position
  70787. * @param result output the resulting point along the navmesh
  70788. */
  70789. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70790. /**
  70791. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70792. * @param start world position
  70793. * @param end world position
  70794. * @returns array containing world position composing the path
  70795. */
  70796. computePath(start: Vector3, end: Vector3): Vector3[];
  70797. /**
  70798. * Create a new Crowd so you can add agents
  70799. * @param maxAgents the maximum agent count in the crowd
  70800. * @param maxAgentRadius the maximum radius an agent can have
  70801. * @param scene to attach the crowd to
  70802. * @returns the crowd you can add agents to
  70803. */
  70804. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70805. /**
  70806. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70807. * The queries will try to find a solution within those bounds
  70808. * default is (1,1,1)
  70809. * @param extent x,y,z value that define the extent around the queries point of reference
  70810. */
  70811. setDefaultQueryExtent(extent: Vector3): void;
  70812. /**
  70813. * Get the Bounding box extent specified by setDefaultQueryExtent
  70814. * @returns the box extent values
  70815. */
  70816. getDefaultQueryExtent(): Vector3;
  70817. /**
  70818. * build the navmesh from a previously saved state using getNavmeshData
  70819. * @param data the Uint8Array returned by getNavmeshData
  70820. */
  70821. buildFromNavmeshData(data: Uint8Array): void;
  70822. /**
  70823. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70824. * @returns data the Uint8Array that can be saved and reused
  70825. */
  70826. getNavmeshData(): Uint8Array;
  70827. /**
  70828. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70829. * @param result output the box extent values
  70830. */
  70831. getDefaultQueryExtentToRef(result: Vector3): void;
  70832. /**
  70833. * Disposes
  70834. */
  70835. dispose(): void;
  70836. /**
  70837. * If this plugin is supported
  70838. * @returns true if plugin is supported
  70839. */
  70840. isSupported(): boolean;
  70841. }
  70842. /**
  70843. * Recast detour crowd implementation
  70844. */
  70845. export class RecastJSCrowd implements ICrowd {
  70846. /**
  70847. * Recast/detour plugin
  70848. */
  70849. bjsRECASTPlugin: RecastJSPlugin;
  70850. /**
  70851. * Link to the detour crowd
  70852. */
  70853. recastCrowd: any;
  70854. /**
  70855. * One transform per agent
  70856. */
  70857. transforms: TransformNode[];
  70858. /**
  70859. * All agents created
  70860. */
  70861. agents: number[];
  70862. /**
  70863. * Link to the scene is kept to unregister the crowd from the scene
  70864. */
  70865. private _scene;
  70866. /**
  70867. * Observer for crowd updates
  70868. */
  70869. private _onBeforeAnimationsObserver;
  70870. /**
  70871. * Constructor
  70872. * @param plugin recastJS plugin
  70873. * @param maxAgents the maximum agent count in the crowd
  70874. * @param maxAgentRadius the maximum radius an agent can have
  70875. * @param scene to attach the crowd to
  70876. * @returns the crowd you can add agents to
  70877. */
  70878. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70879. /**
  70880. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70881. * You can attach anything to that node. The node position is updated in the scene update tick.
  70882. * @param pos world position that will be constrained by the navigation mesh
  70883. * @param parameters agent parameters
  70884. * @param transform hooked to the agent that will be update by the scene
  70885. * @returns agent index
  70886. */
  70887. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70888. /**
  70889. * Returns the agent position in world space
  70890. * @param index agent index returned by addAgent
  70891. * @returns world space position
  70892. */
  70893. getAgentPosition(index: number): Vector3;
  70894. /**
  70895. * Returns the agent position result in world space
  70896. * @param index agent index returned by addAgent
  70897. * @param result output world space position
  70898. */
  70899. getAgentPositionToRef(index: number, result: Vector3): void;
  70900. /**
  70901. * Returns the agent velocity in world space
  70902. * @param index agent index returned by addAgent
  70903. * @returns world space velocity
  70904. */
  70905. getAgentVelocity(index: number): Vector3;
  70906. /**
  70907. * Returns the agent velocity result in world space
  70908. * @param index agent index returned by addAgent
  70909. * @param result output world space velocity
  70910. */
  70911. getAgentVelocityToRef(index: number, result: Vector3): void;
  70912. /**
  70913. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70914. * @param index agent index returned by addAgent
  70915. * @param destination targeted world position
  70916. */
  70917. agentGoto(index: number, destination: Vector3): void;
  70918. /**
  70919. * Teleport the agent to a new position
  70920. * @param index agent index returned by addAgent
  70921. * @param destination targeted world position
  70922. */
  70923. agentTeleport(index: number, destination: Vector3): void;
  70924. /**
  70925. * Update agent parameters
  70926. * @param index agent index returned by addAgent
  70927. * @param parameters agent parameters
  70928. */
  70929. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70930. /**
  70931. * remove a particular agent previously created
  70932. * @param index agent index returned by addAgent
  70933. */
  70934. removeAgent(index: number): void;
  70935. /**
  70936. * get the list of all agents attached to this crowd
  70937. * @returns list of agent indices
  70938. */
  70939. getAgents(): number[];
  70940. /**
  70941. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70942. * @param deltaTime in seconds
  70943. */
  70944. update(deltaTime: number): void;
  70945. /**
  70946. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70947. * The queries will try to find a solution within those bounds
  70948. * default is (1,1,1)
  70949. * @param extent x,y,z value that define the extent around the queries point of reference
  70950. */
  70951. setDefaultQueryExtent(extent: Vector3): void;
  70952. /**
  70953. * Get the Bounding box extent specified by setDefaultQueryExtent
  70954. * @returns the box extent values
  70955. */
  70956. getDefaultQueryExtent(): Vector3;
  70957. /**
  70958. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70959. * @param result output the box extent values
  70960. */
  70961. getDefaultQueryExtentToRef(result: Vector3): void;
  70962. /**
  70963. * Release all resources
  70964. */
  70965. dispose(): void;
  70966. }
  70967. }
  70968. declare module "babylonjs/Navigation/Plugins/index" {
  70969. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  70970. }
  70971. declare module "babylonjs/Navigation/index" {
  70972. export * from "babylonjs/Navigation/INavigationEngine";
  70973. export * from "babylonjs/Navigation/Plugins/index";
  70974. }
  70975. declare module "babylonjs/Offline/database" {
  70976. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  70977. /**
  70978. * Class used to enable access to IndexedDB
  70979. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70980. */
  70981. export class Database implements IOfflineProvider {
  70982. private _callbackManifestChecked;
  70983. private _currentSceneUrl;
  70984. private _db;
  70985. private _enableSceneOffline;
  70986. private _enableTexturesOffline;
  70987. private _manifestVersionFound;
  70988. private _mustUpdateRessources;
  70989. private _hasReachedQuota;
  70990. private _isSupported;
  70991. private _idbFactory;
  70992. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  70993. private static IsUASupportingBlobStorage;
  70994. /**
  70995. * Gets a boolean indicating if Database storate is enabled (off by default)
  70996. */
  70997. static IDBStorageEnabled: boolean;
  70998. /**
  70999. * Gets a boolean indicating if scene must be saved in the database
  71000. */
  71001. get enableSceneOffline(): boolean;
  71002. /**
  71003. * Gets a boolean indicating if textures must be saved in the database
  71004. */
  71005. get enableTexturesOffline(): boolean;
  71006. /**
  71007. * Creates a new Database
  71008. * @param urlToScene defines the url to load the scene
  71009. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71010. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71011. */
  71012. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71013. private static _ParseURL;
  71014. private static _ReturnFullUrlLocation;
  71015. private _checkManifestFile;
  71016. /**
  71017. * Open the database and make it available
  71018. * @param successCallback defines the callback to call on success
  71019. * @param errorCallback defines the callback to call on error
  71020. */
  71021. open(successCallback: () => void, errorCallback: () => void): void;
  71022. /**
  71023. * Loads an image from the database
  71024. * @param url defines the url to load from
  71025. * @param image defines the target DOM image
  71026. */
  71027. loadImage(url: string, image: HTMLImageElement): void;
  71028. private _loadImageFromDBAsync;
  71029. private _saveImageIntoDBAsync;
  71030. private _checkVersionFromDB;
  71031. private _loadVersionFromDBAsync;
  71032. private _saveVersionIntoDBAsync;
  71033. /**
  71034. * Loads a file from database
  71035. * @param url defines the URL to load from
  71036. * @param sceneLoaded defines a callback to call on success
  71037. * @param progressCallBack defines a callback to call when progress changed
  71038. * @param errorCallback defines a callback to call on error
  71039. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71040. */
  71041. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71042. private _loadFileAsync;
  71043. private _saveFileAsync;
  71044. /**
  71045. * Validates if xhr data is correct
  71046. * @param xhr defines the request to validate
  71047. * @param dataType defines the expected data type
  71048. * @returns true if data is correct
  71049. */
  71050. private static _ValidateXHRData;
  71051. }
  71052. }
  71053. declare module "babylonjs/Offline/index" {
  71054. export * from "babylonjs/Offline/database";
  71055. export * from "babylonjs/Offline/IOfflineProvider";
  71056. }
  71057. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71058. /** @hidden */
  71059. export var gpuUpdateParticlesPixelShader: {
  71060. name: string;
  71061. shader: string;
  71062. };
  71063. }
  71064. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71065. /** @hidden */
  71066. export var gpuUpdateParticlesVertexShader: {
  71067. name: string;
  71068. shader: string;
  71069. };
  71070. }
  71071. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71072. /** @hidden */
  71073. export var clipPlaneFragmentDeclaration2: {
  71074. name: string;
  71075. shader: string;
  71076. };
  71077. }
  71078. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71079. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71080. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71081. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71082. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71083. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71084. /** @hidden */
  71085. export var gpuRenderParticlesPixelShader: {
  71086. name: string;
  71087. shader: string;
  71088. };
  71089. }
  71090. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71091. /** @hidden */
  71092. export var clipPlaneVertexDeclaration2: {
  71093. name: string;
  71094. shader: string;
  71095. };
  71096. }
  71097. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71098. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71099. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71100. /** @hidden */
  71101. export var gpuRenderParticlesVertexShader: {
  71102. name: string;
  71103. shader: string;
  71104. };
  71105. }
  71106. declare module "babylonjs/Particles/gpuParticleSystem" {
  71107. import { Nullable } from "babylonjs/types";
  71108. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71109. import { Observable } from "babylonjs/Misc/observable";
  71110. import { Matrix } from "babylonjs/Maths/math.vector";
  71111. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71112. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71113. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71114. import { IDisposable } from "babylonjs/scene";
  71115. import { Effect } from "babylonjs/Materials/effect";
  71116. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71117. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71118. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71119. import { Scene } from "babylonjs/scene";
  71120. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71121. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71122. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71123. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71124. /**
  71125. * This represents a GPU particle system in Babylon
  71126. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71127. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71128. */
  71129. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71130. /**
  71131. * The layer mask we are rendering the particles through.
  71132. */
  71133. layerMask: number;
  71134. private _capacity;
  71135. private _activeCount;
  71136. private _currentActiveCount;
  71137. private _accumulatedCount;
  71138. private _renderEffect;
  71139. private _updateEffect;
  71140. private _buffer0;
  71141. private _buffer1;
  71142. private _spriteBuffer;
  71143. private _updateVAO;
  71144. private _renderVAO;
  71145. private _targetIndex;
  71146. private _sourceBuffer;
  71147. private _targetBuffer;
  71148. private _currentRenderId;
  71149. private _started;
  71150. private _stopped;
  71151. private _timeDelta;
  71152. private _randomTexture;
  71153. private _randomTexture2;
  71154. private _attributesStrideSize;
  71155. private _updateEffectOptions;
  71156. private _randomTextureSize;
  71157. private _actualFrame;
  71158. private _customEffect;
  71159. private readonly _rawTextureWidth;
  71160. /**
  71161. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71162. */
  71163. static get IsSupported(): boolean;
  71164. /**
  71165. * An event triggered when the system is disposed.
  71166. */
  71167. onDisposeObservable: Observable<IParticleSystem>;
  71168. /**
  71169. * Gets the maximum number of particles active at the same time.
  71170. * @returns The max number of active particles.
  71171. */
  71172. getCapacity(): number;
  71173. /**
  71174. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71175. * to override the particles.
  71176. */
  71177. forceDepthWrite: boolean;
  71178. /**
  71179. * Gets or set the number of active particles
  71180. */
  71181. get activeParticleCount(): number;
  71182. set activeParticleCount(value: number);
  71183. private _preWarmDone;
  71184. /**
  71185. * Specifies if the particles are updated in emitter local space or world space.
  71186. */
  71187. isLocal: boolean;
  71188. /** Gets or sets a matrix to use to compute projection */
  71189. defaultProjectionMatrix: Matrix;
  71190. /**
  71191. * Is this system ready to be used/rendered
  71192. * @return true if the system is ready
  71193. */
  71194. isReady(): boolean;
  71195. /**
  71196. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71197. * @returns True if it has been started, otherwise false.
  71198. */
  71199. isStarted(): boolean;
  71200. /**
  71201. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71202. * @returns True if it has been stopped, otherwise false.
  71203. */
  71204. isStopped(): boolean;
  71205. /**
  71206. * Gets a boolean indicating that the system is stopping
  71207. * @returns true if the system is currently stopping
  71208. */
  71209. isStopping(): boolean;
  71210. /**
  71211. * Gets the number of particles active at the same time.
  71212. * @returns The number of active particles.
  71213. */
  71214. getActiveCount(): number;
  71215. /**
  71216. * Starts the particle system and begins to emit
  71217. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71218. */
  71219. start(delay?: number): void;
  71220. /**
  71221. * Stops the particle system.
  71222. */
  71223. stop(): void;
  71224. /**
  71225. * Remove all active particles
  71226. */
  71227. reset(): void;
  71228. /**
  71229. * Returns the string "GPUParticleSystem"
  71230. * @returns a string containing the class name
  71231. */
  71232. getClassName(): string;
  71233. /**
  71234. * Gets the custom effect used to render the particles
  71235. * @param blendMode Blend mode for which the effect should be retrieved
  71236. * @returns The effect
  71237. */
  71238. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71239. /**
  71240. * Sets the custom effect used to render the particles
  71241. * @param effect The effect to set
  71242. * @param blendMode Blend mode for which the effect should be set
  71243. */
  71244. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71245. /** @hidden */
  71246. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71247. /**
  71248. * Observable that will be called just before the particles are drawn
  71249. */
  71250. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71251. /**
  71252. * Gets the name of the particle vertex shader
  71253. */
  71254. get vertexShaderName(): string;
  71255. private _colorGradientsTexture;
  71256. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71257. /**
  71258. * Adds a new color gradient
  71259. * @param gradient defines the gradient to use (between 0 and 1)
  71260. * @param color1 defines the color to affect to the specified gradient
  71261. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71262. * @returns the current particle system
  71263. */
  71264. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71265. private _refreshColorGradient;
  71266. /** Force the system to rebuild all gradients that need to be resync */
  71267. forceRefreshGradients(): void;
  71268. /**
  71269. * Remove a specific color gradient
  71270. * @param gradient defines the gradient to remove
  71271. * @returns the current particle system
  71272. */
  71273. removeColorGradient(gradient: number): GPUParticleSystem;
  71274. private _angularSpeedGradientsTexture;
  71275. private _sizeGradientsTexture;
  71276. private _velocityGradientsTexture;
  71277. private _limitVelocityGradientsTexture;
  71278. private _dragGradientsTexture;
  71279. private _addFactorGradient;
  71280. /**
  71281. * Adds a new size gradient
  71282. * @param gradient defines the gradient to use (between 0 and 1)
  71283. * @param factor defines the size factor to affect to the specified gradient
  71284. * @returns the current particle system
  71285. */
  71286. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71287. /**
  71288. * Remove a specific size gradient
  71289. * @param gradient defines the gradient to remove
  71290. * @returns the current particle system
  71291. */
  71292. removeSizeGradient(gradient: number): GPUParticleSystem;
  71293. private _refreshFactorGradient;
  71294. /**
  71295. * Adds a new angular speed gradient
  71296. * @param gradient defines the gradient to use (between 0 and 1)
  71297. * @param factor defines the angular speed to affect to the specified gradient
  71298. * @returns the current particle system
  71299. */
  71300. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71301. /**
  71302. * Remove a specific angular speed gradient
  71303. * @param gradient defines the gradient to remove
  71304. * @returns the current particle system
  71305. */
  71306. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71307. /**
  71308. * Adds a new velocity gradient
  71309. * @param gradient defines the gradient to use (between 0 and 1)
  71310. * @param factor defines the velocity to affect to the specified gradient
  71311. * @returns the current particle system
  71312. */
  71313. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71314. /**
  71315. * Remove a specific velocity gradient
  71316. * @param gradient defines the gradient to remove
  71317. * @returns the current particle system
  71318. */
  71319. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71320. /**
  71321. * Adds a new limit velocity gradient
  71322. * @param gradient defines the gradient to use (between 0 and 1)
  71323. * @param factor defines the limit velocity value to affect to the specified gradient
  71324. * @returns the current particle system
  71325. */
  71326. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71327. /**
  71328. * Remove a specific limit velocity gradient
  71329. * @param gradient defines the gradient to remove
  71330. * @returns the current particle system
  71331. */
  71332. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71333. /**
  71334. * Adds a new drag gradient
  71335. * @param gradient defines the gradient to use (between 0 and 1)
  71336. * @param factor defines the drag value to affect to the specified gradient
  71337. * @returns the current particle system
  71338. */
  71339. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71340. /**
  71341. * Remove a specific drag gradient
  71342. * @param gradient defines the gradient to remove
  71343. * @returns the current particle system
  71344. */
  71345. removeDragGradient(gradient: number): GPUParticleSystem;
  71346. /**
  71347. * Not supported by GPUParticleSystem
  71348. * @param gradient defines the gradient to use (between 0 and 1)
  71349. * @param factor defines the emit rate value to affect to the specified gradient
  71350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71351. * @returns the current particle system
  71352. */
  71353. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71354. /**
  71355. * Not supported by GPUParticleSystem
  71356. * @param gradient defines the gradient to remove
  71357. * @returns the current particle system
  71358. */
  71359. removeEmitRateGradient(gradient: number): IParticleSystem;
  71360. /**
  71361. * Not supported by GPUParticleSystem
  71362. * @param gradient defines the gradient to use (between 0 and 1)
  71363. * @param factor defines the start size value to affect to the specified gradient
  71364. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71365. * @returns the current particle system
  71366. */
  71367. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71368. /**
  71369. * Not supported by GPUParticleSystem
  71370. * @param gradient defines the gradient to remove
  71371. * @returns the current particle system
  71372. */
  71373. removeStartSizeGradient(gradient: number): IParticleSystem;
  71374. /**
  71375. * Not supported by GPUParticleSystem
  71376. * @param gradient defines the gradient to use (between 0 and 1)
  71377. * @param min defines the color remap minimal range
  71378. * @param max defines the color remap maximal range
  71379. * @returns the current particle system
  71380. */
  71381. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71382. /**
  71383. * Not supported by GPUParticleSystem
  71384. * @param gradient defines the gradient to remove
  71385. * @returns the current particle system
  71386. */
  71387. removeColorRemapGradient(): IParticleSystem;
  71388. /**
  71389. * Not supported by GPUParticleSystem
  71390. * @param gradient defines the gradient to use (between 0 and 1)
  71391. * @param min defines the alpha remap minimal range
  71392. * @param max defines the alpha remap maximal range
  71393. * @returns the current particle system
  71394. */
  71395. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71396. /**
  71397. * Not supported by GPUParticleSystem
  71398. * @param gradient defines the gradient to remove
  71399. * @returns the current particle system
  71400. */
  71401. removeAlphaRemapGradient(): IParticleSystem;
  71402. /**
  71403. * Not supported by GPUParticleSystem
  71404. * @param gradient defines the gradient to use (between 0 and 1)
  71405. * @param color defines the color to affect to the specified gradient
  71406. * @returns the current particle system
  71407. */
  71408. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71409. /**
  71410. * Not supported by GPUParticleSystem
  71411. * @param gradient defines the gradient to remove
  71412. * @returns the current particle system
  71413. */
  71414. removeRampGradient(): IParticleSystem;
  71415. /**
  71416. * Not supported by GPUParticleSystem
  71417. * @returns the list of ramp gradients
  71418. */
  71419. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71420. /**
  71421. * Not supported by GPUParticleSystem
  71422. * Gets or sets a boolean indicating that ramp gradients must be used
  71423. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71424. */
  71425. get useRampGradients(): boolean;
  71426. set useRampGradients(value: boolean);
  71427. /**
  71428. * Not supported by GPUParticleSystem
  71429. * @param gradient defines the gradient to use (between 0 and 1)
  71430. * @param factor defines the life time factor to affect to the specified gradient
  71431. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71432. * @returns the current particle system
  71433. */
  71434. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71435. /**
  71436. * Not supported by GPUParticleSystem
  71437. * @param gradient defines the gradient to remove
  71438. * @returns the current particle system
  71439. */
  71440. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71441. /**
  71442. * Instantiates a GPU particle system.
  71443. * 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.
  71444. * @param name The name of the particle system
  71445. * @param options The options used to create the system
  71446. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71447. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71448. * @param customEffect a custom effect used to change the way particles are rendered by default
  71449. */
  71450. constructor(name: string, options: Partial<{
  71451. capacity: number;
  71452. randomTextureSize: number;
  71453. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71454. protected _reset(): void;
  71455. private _createUpdateVAO;
  71456. private _createRenderVAO;
  71457. private _initialize;
  71458. /** @hidden */
  71459. _recreateUpdateEffect(): void;
  71460. private _getEffect;
  71461. /**
  71462. * Fill the defines array according to the current settings of the particle system
  71463. * @param defines Array to be updated
  71464. * @param blendMode blend mode to take into account when updating the array
  71465. */
  71466. fillDefines(defines: Array<string>, blendMode?: number): void;
  71467. /**
  71468. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71469. * @param uniforms Uniforms array to fill
  71470. * @param attributes Attributes array to fill
  71471. * @param samplers Samplers array to fill
  71472. */
  71473. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71474. /** @hidden */
  71475. _recreateRenderEffect(): Effect;
  71476. /**
  71477. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71478. * @param preWarm defines if we are in the pre-warmimg phase
  71479. */
  71480. animate(preWarm?: boolean): void;
  71481. private _createFactorGradientTexture;
  71482. private _createSizeGradientTexture;
  71483. private _createAngularSpeedGradientTexture;
  71484. private _createVelocityGradientTexture;
  71485. private _createLimitVelocityGradientTexture;
  71486. private _createDragGradientTexture;
  71487. private _createColorGradientTexture;
  71488. /**
  71489. * Renders the particle system in its current state
  71490. * @param preWarm defines if the system should only update the particles but not render them
  71491. * @returns the current number of particles
  71492. */
  71493. render(preWarm?: boolean): number;
  71494. /**
  71495. * Rebuilds the particle system
  71496. */
  71497. rebuild(): void;
  71498. private _releaseBuffers;
  71499. private _releaseVAOs;
  71500. /**
  71501. * Disposes the particle system and free the associated resources
  71502. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71503. */
  71504. dispose(disposeTexture?: boolean): void;
  71505. /**
  71506. * Clones the particle system.
  71507. * @param name The name of the cloned object
  71508. * @param newEmitter The new emitter to use
  71509. * @returns the cloned particle system
  71510. */
  71511. clone(name: string, newEmitter: any): GPUParticleSystem;
  71512. /**
  71513. * Serializes the particle system to a JSON object
  71514. * @param serializeTexture defines if the texture must be serialized as well
  71515. * @returns the JSON object
  71516. */
  71517. serialize(serializeTexture?: boolean): any;
  71518. /**
  71519. * Parses a JSON object to create a GPU particle system.
  71520. * @param parsedParticleSystem The JSON object to parse
  71521. * @param sceneOrEngine The scene or the engine to create the particle system in
  71522. * @param rootUrl The root url to use to load external dependencies like texture
  71523. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71524. * @returns the parsed GPU particle system
  71525. */
  71526. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71527. }
  71528. }
  71529. declare module "babylonjs/Particles/particleSystemSet" {
  71530. import { Nullable } from "babylonjs/types";
  71531. import { Color3 } from "babylonjs/Maths/math.color";
  71532. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71534. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71535. import { Scene, IDisposable } from "babylonjs/scene";
  71536. /**
  71537. * Represents a set of particle systems working together to create a specific effect
  71538. */
  71539. export class ParticleSystemSet implements IDisposable {
  71540. /**
  71541. * Gets or sets base Assets URL
  71542. */
  71543. static BaseAssetsUrl: string;
  71544. private _emitterCreationOptions;
  71545. private _emitterNode;
  71546. /**
  71547. * Gets the particle system list
  71548. */
  71549. systems: IParticleSystem[];
  71550. /**
  71551. * Gets the emitter node used with this set
  71552. */
  71553. get emitterNode(): Nullable<TransformNode>;
  71554. /**
  71555. * Creates a new emitter mesh as a sphere
  71556. * @param options defines the options used to create the sphere
  71557. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71558. * @param scene defines the hosting scene
  71559. */
  71560. setEmitterAsSphere(options: {
  71561. diameter: number;
  71562. segments: number;
  71563. color: Color3;
  71564. }, renderingGroupId: number, scene: Scene): void;
  71565. /**
  71566. * Starts all particle systems of the set
  71567. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71568. */
  71569. start(emitter?: AbstractMesh): void;
  71570. /**
  71571. * Release all associated resources
  71572. */
  71573. dispose(): void;
  71574. /**
  71575. * Serialize the set into a JSON compatible object
  71576. * @param serializeTexture defines if the texture must be serialized as well
  71577. * @returns a JSON compatible representation of the set
  71578. */
  71579. serialize(serializeTexture?: boolean): any;
  71580. /**
  71581. * Parse a new ParticleSystemSet from a serialized source
  71582. * @param data defines a JSON compatible representation of the set
  71583. * @param scene defines the hosting scene
  71584. * @param gpu defines if we want GPU particles or CPU particles
  71585. * @returns a new ParticleSystemSet
  71586. */
  71587. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71588. }
  71589. }
  71590. declare module "babylonjs/Particles/particleHelper" {
  71591. import { Nullable } from "babylonjs/types";
  71592. import { Scene } from "babylonjs/scene";
  71593. import { Vector3 } from "babylonjs/Maths/math.vector";
  71594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71595. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71596. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71597. /**
  71598. * This class is made for on one-liner static method to help creating particle system set.
  71599. */
  71600. export class ParticleHelper {
  71601. /**
  71602. * Gets or sets base Assets URL
  71603. */
  71604. static BaseAssetsUrl: string;
  71605. /** Define the Url to load snippets */
  71606. static SnippetUrl: string;
  71607. /**
  71608. * Create a default particle system that you can tweak
  71609. * @param emitter defines the emitter to use
  71610. * @param capacity defines the system capacity (default is 500 particles)
  71611. * @param scene defines the hosting scene
  71612. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71613. * @returns the new Particle system
  71614. */
  71615. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71616. /**
  71617. * This is the main static method (one-liner) of this helper to create different particle systems
  71618. * @param type This string represents the type to the particle system to create
  71619. * @param scene The scene where the particle system should live
  71620. * @param gpu If the system will use gpu
  71621. * @returns the ParticleSystemSet created
  71622. */
  71623. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71624. /**
  71625. * Static function used to export a particle system to a ParticleSystemSet variable.
  71626. * Please note that the emitter shape is not exported
  71627. * @param systems defines the particle systems to export
  71628. * @returns the created particle system set
  71629. */
  71630. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71631. /**
  71632. * Creates a particle system from a snippet saved in a remote file
  71633. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71634. * @param url defines the url to load from
  71635. * @param scene defines the hosting scene
  71636. * @param gpu If the system will use gpu
  71637. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71638. * @returns a promise that will resolve to the new particle system
  71639. */
  71640. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71641. /**
  71642. * Creates a particle system from a snippet saved by the particle system editor
  71643. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71644. * @param scene defines the hosting scene
  71645. * @param gpu If the system will use gpu
  71646. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71647. * @returns a promise that will resolve to the new particle system
  71648. */
  71649. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71650. }
  71651. }
  71652. declare module "babylonjs/Particles/particleSystemComponent" {
  71653. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71654. import { Effect } from "babylonjs/Materials/effect";
  71655. import "babylonjs/Shaders/particles.vertex";
  71656. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71657. module "babylonjs/Engines/engine" {
  71658. interface Engine {
  71659. /**
  71660. * Create an effect to use with particle systems.
  71661. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71662. * the particle system for which you want to create a custom effect in the last parameter
  71663. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71664. * @param uniformsNames defines a list of attribute names
  71665. * @param samplers defines an array of string used to represent textures
  71666. * @param defines defines the string containing the defines to use to compile the shaders
  71667. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71668. * @param onCompiled defines a function to call when the effect creation is successful
  71669. * @param onError defines a function to call when the effect creation has failed
  71670. * @param particleSystem the particle system you want to create the effect for
  71671. * @returns the new Effect
  71672. */
  71673. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71674. }
  71675. }
  71676. module "babylonjs/Meshes/mesh" {
  71677. interface Mesh {
  71678. /**
  71679. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71680. * @returns an array of IParticleSystem
  71681. */
  71682. getEmittedParticleSystems(): IParticleSystem[];
  71683. /**
  71684. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71685. * @returns an array of IParticleSystem
  71686. */
  71687. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71688. }
  71689. }
  71690. }
  71691. declare module "babylonjs/Particles/pointsCloudSystem" {
  71692. import { Color4 } from "babylonjs/Maths/math";
  71693. import { Mesh } from "babylonjs/Meshes/mesh";
  71694. import { Scene, IDisposable } from "babylonjs/scene";
  71695. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71696. /** Defines the 4 color options */
  71697. export enum PointColor {
  71698. /** color value */
  71699. Color = 2,
  71700. /** uv value */
  71701. UV = 1,
  71702. /** random value */
  71703. Random = 0,
  71704. /** stated value */
  71705. Stated = 3
  71706. }
  71707. /**
  71708. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71709. * 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.
  71710. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71711. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71712. *
  71713. * Full documentation here : TO BE ENTERED
  71714. */
  71715. export class PointsCloudSystem implements IDisposable {
  71716. /**
  71717. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71718. * Example : var p = SPS.particles[i];
  71719. */
  71720. particles: CloudPoint[];
  71721. /**
  71722. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71723. */
  71724. nbParticles: number;
  71725. /**
  71726. * This a counter for your own usage. It's not set by any SPS functions.
  71727. */
  71728. counter: number;
  71729. /**
  71730. * The PCS name. This name is also given to the underlying mesh.
  71731. */
  71732. name: string;
  71733. /**
  71734. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71735. */
  71736. mesh: Mesh;
  71737. /**
  71738. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71739. * Please read :
  71740. */
  71741. vars: any;
  71742. /**
  71743. * @hidden
  71744. */
  71745. _size: number;
  71746. private _scene;
  71747. private _promises;
  71748. private _positions;
  71749. private _indices;
  71750. private _normals;
  71751. private _colors;
  71752. private _uvs;
  71753. private _indices32;
  71754. private _positions32;
  71755. private _colors32;
  71756. private _uvs32;
  71757. private _updatable;
  71758. private _isVisibilityBoxLocked;
  71759. private _alwaysVisible;
  71760. private _groups;
  71761. private _groupCounter;
  71762. private _computeParticleColor;
  71763. private _computeParticleTexture;
  71764. private _computeParticleRotation;
  71765. private _computeBoundingBox;
  71766. private _isReady;
  71767. /**
  71768. * Creates a PCS (Points Cloud System) object
  71769. * @param name (String) is the PCS name, this will be the underlying mesh name
  71770. * @param pointSize (number) is the size for each point
  71771. * @param scene (Scene) is the scene in which the PCS is added
  71772. * @param options defines the options of the PCS e.g.
  71773. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71774. */
  71775. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71776. updatable?: boolean;
  71777. });
  71778. /**
  71779. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71780. * If no points were added to the PCS, the returned mesh is just a single point.
  71781. * @returns a promise for the created mesh
  71782. */
  71783. buildMeshAsync(): Promise<Mesh>;
  71784. /**
  71785. * @hidden
  71786. */
  71787. private _buildMesh;
  71788. private _addParticle;
  71789. private _randomUnitVector;
  71790. private _getColorIndicesForCoord;
  71791. private _setPointsColorOrUV;
  71792. private _colorFromTexture;
  71793. private _calculateDensity;
  71794. /**
  71795. * Adds points to the PCS in random positions within a unit sphere
  71796. * @param nb (positive integer) the number of particles to be created from this model
  71797. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71798. * @returns the number of groups in the system
  71799. */
  71800. addPoints(nb: number, pointFunction?: any): number;
  71801. /**
  71802. * Adds points to the PCS from the surface of the model shape
  71803. * @param mesh is any Mesh object that will be used as a surface model for the points
  71804. * @param nb (positive integer) the number of particles to be created from this model
  71805. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71806. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71807. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71808. * @returns the number of groups in the system
  71809. */
  71810. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71811. /**
  71812. * Adds points to the PCS inside the model shape
  71813. * @param mesh is any Mesh object that will be used as a surface model for the points
  71814. * @param nb (positive integer) the number of particles to be created from this model
  71815. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71816. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71817. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71818. * @returns the number of groups in the system
  71819. */
  71820. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71821. /**
  71822. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71823. * This method calls `updateParticle()` for each particle of the SPS.
  71824. * For an animated SPS, it is usually called within the render loop.
  71825. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71826. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71827. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71828. * @returns the PCS.
  71829. */
  71830. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71831. /**
  71832. * Disposes the PCS.
  71833. */
  71834. dispose(): void;
  71835. /**
  71836. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71837. * doc :
  71838. * @returns the PCS.
  71839. */
  71840. refreshVisibleSize(): PointsCloudSystem;
  71841. /**
  71842. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71843. * @param size the size (float) of the visibility box
  71844. * note : this doesn't lock the PCS mesh bounding box.
  71845. * doc :
  71846. */
  71847. setVisibilityBox(size: number): void;
  71848. /**
  71849. * Gets whether the PCS is always visible or not
  71850. * doc :
  71851. */
  71852. get isAlwaysVisible(): boolean;
  71853. /**
  71854. * Sets the PCS as always visible or not
  71855. * doc :
  71856. */
  71857. set isAlwaysVisible(val: boolean);
  71858. /**
  71859. * Tells to `setParticles()` to compute the particle rotations or not
  71860. * Default value : false. The PCS is faster when it's set to false
  71861. * Note : particle rotations are only applied to parent particles
  71862. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71863. */
  71864. set computeParticleRotation(val: boolean);
  71865. /**
  71866. * Tells to `setParticles()` to compute the particle colors or not.
  71867. * Default value : true. The PCS is faster when it's set to false.
  71868. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71869. */
  71870. set computeParticleColor(val: boolean);
  71871. set computeParticleTexture(val: boolean);
  71872. /**
  71873. * Gets if `setParticles()` computes the particle colors or not.
  71874. * Default value : false. The PCS is faster when it's set to false.
  71875. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71876. */
  71877. get computeParticleColor(): boolean;
  71878. /**
  71879. * Gets if `setParticles()` computes the particle textures or not.
  71880. * Default value : false. The PCS is faster when it's set to false.
  71881. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71882. */
  71883. get computeParticleTexture(): boolean;
  71884. /**
  71885. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71886. */
  71887. set computeBoundingBox(val: boolean);
  71888. /**
  71889. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71890. */
  71891. get computeBoundingBox(): boolean;
  71892. /**
  71893. * This function does nothing. It may be overwritten to set all the particle first values.
  71894. * The PCS doesn't call this function, you may have to call it by your own.
  71895. * doc :
  71896. */
  71897. initParticles(): void;
  71898. /**
  71899. * This function does nothing. It may be overwritten to recycle a particle
  71900. * The PCS doesn't call this function, you can to call it
  71901. * doc :
  71902. * @param particle The particle to recycle
  71903. * @returns the recycled particle
  71904. */
  71905. recycleParticle(particle: CloudPoint): CloudPoint;
  71906. /**
  71907. * Updates a particle : this function should be overwritten by the user.
  71908. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71909. * doc :
  71910. * @example : just set a particle position or velocity and recycle conditions
  71911. * @param particle The particle to update
  71912. * @returns the updated particle
  71913. */
  71914. updateParticle(particle: CloudPoint): CloudPoint;
  71915. /**
  71916. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71917. * This does nothing and may be overwritten by the user.
  71918. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71919. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71920. * @param update the boolean update value actually passed to setParticles()
  71921. */
  71922. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71923. /**
  71924. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71925. * This will be passed three parameters.
  71926. * This does nothing and may be overwritten by the user.
  71927. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71928. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71929. * @param update the boolean update value actually passed to setParticles()
  71930. */
  71931. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71932. }
  71933. }
  71934. declare module "babylonjs/Particles/cloudPoint" {
  71935. import { Nullable } from "babylonjs/types";
  71936. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71937. import { Mesh } from "babylonjs/Meshes/mesh";
  71938. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71939. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71940. /**
  71941. * Represents one particle of a points cloud system.
  71942. */
  71943. export class CloudPoint {
  71944. /**
  71945. * particle global index
  71946. */
  71947. idx: number;
  71948. /**
  71949. * The color of the particle
  71950. */
  71951. color: Nullable<Color4>;
  71952. /**
  71953. * The world space position of the particle.
  71954. */
  71955. position: Vector3;
  71956. /**
  71957. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71958. */
  71959. rotation: Vector3;
  71960. /**
  71961. * The world space rotation quaternion of the particle.
  71962. */
  71963. rotationQuaternion: Nullable<Quaternion>;
  71964. /**
  71965. * The uv of the particle.
  71966. */
  71967. uv: Nullable<Vector2>;
  71968. /**
  71969. * The current speed of the particle.
  71970. */
  71971. velocity: Vector3;
  71972. /**
  71973. * The pivot point in the particle local space.
  71974. */
  71975. pivot: Vector3;
  71976. /**
  71977. * Must the particle be translated from its pivot point in its local space ?
  71978. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  71979. * Default : false
  71980. */
  71981. translateFromPivot: boolean;
  71982. /**
  71983. * Index of this particle in the global "positions" array (Internal use)
  71984. * @hidden
  71985. */
  71986. _pos: number;
  71987. /**
  71988. * @hidden Index of this particle in the global "indices" array (Internal use)
  71989. */
  71990. _ind: number;
  71991. /**
  71992. * Group this particle belongs to
  71993. */
  71994. _group: PointsGroup;
  71995. /**
  71996. * Group id of this particle
  71997. */
  71998. groupId: number;
  71999. /**
  72000. * Index of the particle in its group id (Internal use)
  72001. */
  72002. idxInGroup: number;
  72003. /**
  72004. * @hidden Particle BoundingInfo object (Internal use)
  72005. */
  72006. _boundingInfo: BoundingInfo;
  72007. /**
  72008. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72009. */
  72010. _pcs: PointsCloudSystem;
  72011. /**
  72012. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72013. */
  72014. _stillInvisible: boolean;
  72015. /**
  72016. * @hidden Last computed particle rotation matrix
  72017. */
  72018. _rotationMatrix: number[];
  72019. /**
  72020. * Parent particle Id, if any.
  72021. * Default null.
  72022. */
  72023. parentId: Nullable<number>;
  72024. /**
  72025. * @hidden Internal global position in the PCS.
  72026. */
  72027. _globalPosition: Vector3;
  72028. /**
  72029. * Creates a Point Cloud object.
  72030. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72031. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72032. * @param group (PointsGroup) is the group the particle belongs to
  72033. * @param groupId (integer) is the group identifier in the PCS.
  72034. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72035. * @param pcs defines the PCS it is associated to
  72036. */
  72037. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72038. /**
  72039. * get point size
  72040. */
  72041. get size(): Vector3;
  72042. /**
  72043. * Set point size
  72044. */
  72045. set size(scale: Vector3);
  72046. /**
  72047. * Legacy support, changed quaternion to rotationQuaternion
  72048. */
  72049. get quaternion(): Nullable<Quaternion>;
  72050. /**
  72051. * Legacy support, changed quaternion to rotationQuaternion
  72052. */
  72053. set quaternion(q: Nullable<Quaternion>);
  72054. /**
  72055. * Returns a boolean. True if the particle intersects a mesh, else false
  72056. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72057. * @param target is the object (point or mesh) what the intersection is computed against
  72058. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72059. * @returns true if it intersects
  72060. */
  72061. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72062. /**
  72063. * get the rotation matrix of the particle
  72064. * @hidden
  72065. */
  72066. getRotationMatrix(m: Matrix): void;
  72067. }
  72068. /**
  72069. * Represents a group of points in a points cloud system
  72070. * * PCS internal tool, don't use it manually.
  72071. */
  72072. export class PointsGroup {
  72073. /**
  72074. * The group id
  72075. * @hidden
  72076. */
  72077. groupID: number;
  72078. /**
  72079. * image data for group (internal use)
  72080. * @hidden
  72081. */
  72082. _groupImageData: Nullable<ArrayBufferView>;
  72083. /**
  72084. * Image Width (internal use)
  72085. * @hidden
  72086. */
  72087. _groupImgWidth: number;
  72088. /**
  72089. * Image Height (internal use)
  72090. * @hidden
  72091. */
  72092. _groupImgHeight: number;
  72093. /**
  72094. * Custom position function (internal use)
  72095. * @hidden
  72096. */
  72097. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72098. /**
  72099. * density per facet for surface points
  72100. * @hidden
  72101. */
  72102. _groupDensity: number[];
  72103. /**
  72104. * Only when points are colored by texture carries pointer to texture list array
  72105. * @hidden
  72106. */
  72107. _textureNb: number;
  72108. /**
  72109. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72110. * PCS internal tool, don't use it manually.
  72111. * @hidden
  72112. */
  72113. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72114. }
  72115. }
  72116. declare module "babylonjs/Particles/index" {
  72117. export * from "babylonjs/Particles/baseParticleSystem";
  72118. export * from "babylonjs/Particles/EmitterTypes/index";
  72119. export * from "babylonjs/Particles/gpuParticleSystem";
  72120. export * from "babylonjs/Particles/IParticleSystem";
  72121. export * from "babylonjs/Particles/particle";
  72122. export * from "babylonjs/Particles/particleHelper";
  72123. export * from "babylonjs/Particles/particleSystem";
  72124. import "babylonjs/Particles/particleSystemComponent";
  72125. export * from "babylonjs/Particles/particleSystemComponent";
  72126. export * from "babylonjs/Particles/particleSystemSet";
  72127. export * from "babylonjs/Particles/solidParticle";
  72128. export * from "babylonjs/Particles/solidParticleSystem";
  72129. export * from "babylonjs/Particles/cloudPoint";
  72130. export * from "babylonjs/Particles/pointsCloudSystem";
  72131. export * from "babylonjs/Particles/subEmitter";
  72132. }
  72133. declare module "babylonjs/Physics/physicsEngineComponent" {
  72134. import { Nullable } from "babylonjs/types";
  72135. import { Observable, Observer } from "babylonjs/Misc/observable";
  72136. import { Vector3 } from "babylonjs/Maths/math.vector";
  72137. import { Mesh } from "babylonjs/Meshes/mesh";
  72138. import { ISceneComponent } from "babylonjs/sceneComponent";
  72139. import { Scene } from "babylonjs/scene";
  72140. import { Node } from "babylonjs/node";
  72141. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72142. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72143. module "babylonjs/scene" {
  72144. interface Scene {
  72145. /** @hidden (Backing field) */
  72146. _physicsEngine: Nullable<IPhysicsEngine>;
  72147. /** @hidden */
  72148. _physicsTimeAccumulator: number;
  72149. /**
  72150. * Gets the current physics engine
  72151. * @returns a IPhysicsEngine or null if none attached
  72152. */
  72153. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72154. /**
  72155. * Enables physics to the current scene
  72156. * @param gravity defines the scene's gravity for the physics engine
  72157. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72158. * @return a boolean indicating if the physics engine was initialized
  72159. */
  72160. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72161. /**
  72162. * Disables and disposes the physics engine associated with the scene
  72163. */
  72164. disablePhysicsEngine(): void;
  72165. /**
  72166. * Gets a boolean indicating if there is an active physics engine
  72167. * @returns a boolean indicating if there is an active physics engine
  72168. */
  72169. isPhysicsEnabled(): boolean;
  72170. /**
  72171. * Deletes a physics compound impostor
  72172. * @param compound defines the compound to delete
  72173. */
  72174. deleteCompoundImpostor(compound: any): void;
  72175. /**
  72176. * An event triggered when physic simulation is about to be run
  72177. */
  72178. onBeforePhysicsObservable: Observable<Scene>;
  72179. /**
  72180. * An event triggered when physic simulation has been done
  72181. */
  72182. onAfterPhysicsObservable: Observable<Scene>;
  72183. }
  72184. }
  72185. module "babylonjs/Meshes/abstractMesh" {
  72186. interface AbstractMesh {
  72187. /** @hidden */
  72188. _physicsImpostor: Nullable<PhysicsImpostor>;
  72189. /**
  72190. * Gets or sets impostor used for physic simulation
  72191. * @see https://doc.babylonjs.com/features/physics_engine
  72192. */
  72193. physicsImpostor: Nullable<PhysicsImpostor>;
  72194. /**
  72195. * Gets the current physics impostor
  72196. * @see https://doc.babylonjs.com/features/physics_engine
  72197. * @returns a physics impostor or null
  72198. */
  72199. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72200. /** Apply a physic impulse to the mesh
  72201. * @param force defines the force to apply
  72202. * @param contactPoint defines where to apply the force
  72203. * @returns the current mesh
  72204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72205. */
  72206. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72207. /**
  72208. * Creates a physic joint between two meshes
  72209. * @param otherMesh defines the other mesh to use
  72210. * @param pivot1 defines the pivot to use on this mesh
  72211. * @param pivot2 defines the pivot to use on the other mesh
  72212. * @param options defines additional options (can be plugin dependent)
  72213. * @returns the current mesh
  72214. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72215. */
  72216. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72217. /** @hidden */
  72218. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72219. }
  72220. }
  72221. /**
  72222. * Defines the physics engine scene component responsible to manage a physics engine
  72223. */
  72224. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72225. /**
  72226. * The component name helpful to identify the component in the list of scene components.
  72227. */
  72228. readonly name: string;
  72229. /**
  72230. * The scene the component belongs to.
  72231. */
  72232. scene: Scene;
  72233. /**
  72234. * Creates a new instance of the component for the given scene
  72235. * @param scene Defines the scene to register the component in
  72236. */
  72237. constructor(scene: Scene);
  72238. /**
  72239. * Registers the component in a given scene
  72240. */
  72241. register(): void;
  72242. /**
  72243. * Rebuilds the elements related to this component in case of
  72244. * context lost for instance.
  72245. */
  72246. rebuild(): void;
  72247. /**
  72248. * Disposes the component and the associated ressources
  72249. */
  72250. dispose(): void;
  72251. }
  72252. }
  72253. declare module "babylonjs/Physics/physicsHelper" {
  72254. import { Nullable } from "babylonjs/types";
  72255. import { Vector3 } from "babylonjs/Maths/math.vector";
  72256. import { Mesh } from "babylonjs/Meshes/mesh";
  72257. import { Scene } from "babylonjs/scene";
  72258. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72259. /**
  72260. * A helper for physics simulations
  72261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72262. */
  72263. export class PhysicsHelper {
  72264. private _scene;
  72265. private _physicsEngine;
  72266. /**
  72267. * Initializes the Physics helper
  72268. * @param scene Babylon.js scene
  72269. */
  72270. constructor(scene: Scene);
  72271. /**
  72272. * Applies a radial explosion impulse
  72273. * @param origin the origin of the explosion
  72274. * @param radiusOrEventOptions the radius or the options of radial explosion
  72275. * @param strength the explosion strength
  72276. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72277. * @returns A physics radial explosion event, or null
  72278. */
  72279. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72280. /**
  72281. * Applies a radial explosion force
  72282. * @param origin the origin of the explosion
  72283. * @param radiusOrEventOptions the radius or the options of radial explosion
  72284. * @param strength the explosion strength
  72285. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72286. * @returns A physics radial explosion event, or null
  72287. */
  72288. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72289. /**
  72290. * Creates a gravitational field
  72291. * @param origin the origin of the explosion
  72292. * @param radiusOrEventOptions the radius or the options of radial explosion
  72293. * @param strength the explosion strength
  72294. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72295. * @returns A physics gravitational field event, or null
  72296. */
  72297. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72298. /**
  72299. * Creates a physics updraft event
  72300. * @param origin the origin of the updraft
  72301. * @param radiusOrEventOptions the radius or the options of the updraft
  72302. * @param strength the strength of the updraft
  72303. * @param height the height of the updraft
  72304. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72305. * @returns A physics updraft event, or null
  72306. */
  72307. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72308. /**
  72309. * Creates a physics vortex event
  72310. * @param origin the of the vortex
  72311. * @param radiusOrEventOptions the radius or the options of the vortex
  72312. * @param strength the strength of the vortex
  72313. * @param height the height of the vortex
  72314. * @returns a Physics vortex event, or null
  72315. * A physics vortex event or null
  72316. */
  72317. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72318. }
  72319. /**
  72320. * Represents a physics radial explosion event
  72321. */
  72322. class PhysicsRadialExplosionEvent {
  72323. private _scene;
  72324. private _options;
  72325. private _sphere;
  72326. private _dataFetched;
  72327. /**
  72328. * Initializes a radial explosioin event
  72329. * @param _scene BabylonJS scene
  72330. * @param _options The options for the vortex event
  72331. */
  72332. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72333. /**
  72334. * Returns the data related to the radial explosion event (sphere).
  72335. * @returns The radial explosion event data
  72336. */
  72337. getData(): PhysicsRadialExplosionEventData;
  72338. /**
  72339. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72340. * @param impostor A physics imposter
  72341. * @param origin the origin of the explosion
  72342. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72343. */
  72344. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72345. /**
  72346. * Triggers affecterd impostors callbacks
  72347. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72348. */
  72349. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72350. /**
  72351. * Disposes the sphere.
  72352. * @param force Specifies if the sphere should be disposed by force
  72353. */
  72354. dispose(force?: boolean): void;
  72355. /*** Helpers ***/
  72356. private _prepareSphere;
  72357. private _intersectsWithSphere;
  72358. }
  72359. /**
  72360. * Represents a gravitational field event
  72361. */
  72362. class PhysicsGravitationalFieldEvent {
  72363. private _physicsHelper;
  72364. private _scene;
  72365. private _origin;
  72366. private _options;
  72367. private _tickCallback;
  72368. private _sphere;
  72369. private _dataFetched;
  72370. /**
  72371. * Initializes the physics gravitational field event
  72372. * @param _physicsHelper A physics helper
  72373. * @param _scene BabylonJS scene
  72374. * @param _origin The origin position of the gravitational field event
  72375. * @param _options The options for the vortex event
  72376. */
  72377. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72378. /**
  72379. * Returns the data related to the gravitational field event (sphere).
  72380. * @returns A gravitational field event
  72381. */
  72382. getData(): PhysicsGravitationalFieldEventData;
  72383. /**
  72384. * Enables the gravitational field.
  72385. */
  72386. enable(): void;
  72387. /**
  72388. * Disables the gravitational field.
  72389. */
  72390. disable(): void;
  72391. /**
  72392. * Disposes the sphere.
  72393. * @param force The force to dispose from the gravitational field event
  72394. */
  72395. dispose(force?: boolean): void;
  72396. private _tick;
  72397. }
  72398. /**
  72399. * Represents a physics updraft event
  72400. */
  72401. class PhysicsUpdraftEvent {
  72402. private _scene;
  72403. private _origin;
  72404. private _options;
  72405. private _physicsEngine;
  72406. private _originTop;
  72407. private _originDirection;
  72408. private _tickCallback;
  72409. private _cylinder;
  72410. private _cylinderPosition;
  72411. private _dataFetched;
  72412. /**
  72413. * Initializes the physics updraft event
  72414. * @param _scene BabylonJS scene
  72415. * @param _origin The origin position of the updraft
  72416. * @param _options The options for the updraft event
  72417. */
  72418. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72419. /**
  72420. * Returns the data related to the updraft event (cylinder).
  72421. * @returns A physics updraft event
  72422. */
  72423. getData(): PhysicsUpdraftEventData;
  72424. /**
  72425. * Enables the updraft.
  72426. */
  72427. enable(): void;
  72428. /**
  72429. * Disables the updraft.
  72430. */
  72431. disable(): void;
  72432. /**
  72433. * Disposes the cylinder.
  72434. * @param force Specifies if the updraft should be disposed by force
  72435. */
  72436. dispose(force?: boolean): void;
  72437. private getImpostorHitData;
  72438. private _tick;
  72439. /*** Helpers ***/
  72440. private _prepareCylinder;
  72441. private _intersectsWithCylinder;
  72442. }
  72443. /**
  72444. * Represents a physics vortex event
  72445. */
  72446. class PhysicsVortexEvent {
  72447. private _scene;
  72448. private _origin;
  72449. private _options;
  72450. private _physicsEngine;
  72451. private _originTop;
  72452. private _tickCallback;
  72453. private _cylinder;
  72454. private _cylinderPosition;
  72455. private _dataFetched;
  72456. /**
  72457. * Initializes the physics vortex event
  72458. * @param _scene The BabylonJS scene
  72459. * @param _origin The origin position of the vortex
  72460. * @param _options The options for the vortex event
  72461. */
  72462. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72463. /**
  72464. * Returns the data related to the vortex event (cylinder).
  72465. * @returns The physics vortex event data
  72466. */
  72467. getData(): PhysicsVortexEventData;
  72468. /**
  72469. * Enables the vortex.
  72470. */
  72471. enable(): void;
  72472. /**
  72473. * Disables the cortex.
  72474. */
  72475. disable(): void;
  72476. /**
  72477. * Disposes the sphere.
  72478. * @param force
  72479. */
  72480. dispose(force?: boolean): void;
  72481. private getImpostorHitData;
  72482. private _tick;
  72483. /*** Helpers ***/
  72484. private _prepareCylinder;
  72485. private _intersectsWithCylinder;
  72486. }
  72487. /**
  72488. * Options fot the radial explosion event
  72489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72490. */
  72491. export class PhysicsRadialExplosionEventOptions {
  72492. /**
  72493. * The radius of the sphere for the radial explosion.
  72494. */
  72495. radius: number;
  72496. /**
  72497. * The strenth of the explosion.
  72498. */
  72499. strength: number;
  72500. /**
  72501. * The strenght of the force in correspondence to the distance of the affected object
  72502. */
  72503. falloff: PhysicsRadialImpulseFalloff;
  72504. /**
  72505. * Sphere options for the radial explosion.
  72506. */
  72507. sphere: {
  72508. segments: number;
  72509. diameter: number;
  72510. };
  72511. /**
  72512. * Sphere options for the radial explosion.
  72513. */
  72514. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72515. }
  72516. /**
  72517. * Options fot the updraft event
  72518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72519. */
  72520. export class PhysicsUpdraftEventOptions {
  72521. /**
  72522. * The radius of the cylinder for the vortex
  72523. */
  72524. radius: number;
  72525. /**
  72526. * The strenth of the updraft.
  72527. */
  72528. strength: number;
  72529. /**
  72530. * The height of the cylinder for the updraft.
  72531. */
  72532. height: number;
  72533. /**
  72534. * The mode for the the updraft.
  72535. */
  72536. updraftMode: PhysicsUpdraftMode;
  72537. }
  72538. /**
  72539. * Options fot the vortex event
  72540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72541. */
  72542. export class PhysicsVortexEventOptions {
  72543. /**
  72544. * The radius of the cylinder for the vortex
  72545. */
  72546. radius: number;
  72547. /**
  72548. * The strenth of the vortex.
  72549. */
  72550. strength: number;
  72551. /**
  72552. * The height of the cylinder for the vortex.
  72553. */
  72554. height: number;
  72555. /**
  72556. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72557. */
  72558. centripetalForceThreshold: number;
  72559. /**
  72560. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72561. */
  72562. centripetalForceMultiplier: number;
  72563. /**
  72564. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72565. */
  72566. centrifugalForceMultiplier: number;
  72567. /**
  72568. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72569. */
  72570. updraftForceMultiplier: number;
  72571. }
  72572. /**
  72573. * The strenght of the force in correspondence to the distance of the affected object
  72574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72575. */
  72576. export enum PhysicsRadialImpulseFalloff {
  72577. /** Defines that impulse is constant in strength across it's whole radius */
  72578. Constant = 0,
  72579. /** Defines that impulse gets weaker if it's further from the origin */
  72580. Linear = 1
  72581. }
  72582. /**
  72583. * The strength of the force in correspondence to the distance of the affected object
  72584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72585. */
  72586. export enum PhysicsUpdraftMode {
  72587. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72588. Center = 0,
  72589. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72590. Perpendicular = 1
  72591. }
  72592. /**
  72593. * Interface for a physics hit data
  72594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72595. */
  72596. export interface PhysicsHitData {
  72597. /**
  72598. * The force applied at the contact point
  72599. */
  72600. force: Vector3;
  72601. /**
  72602. * The contact point
  72603. */
  72604. contactPoint: Vector3;
  72605. /**
  72606. * The distance from the origin to the contact point
  72607. */
  72608. distanceFromOrigin: number;
  72609. }
  72610. /**
  72611. * Interface for radial explosion event data
  72612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72613. */
  72614. export interface PhysicsRadialExplosionEventData {
  72615. /**
  72616. * A sphere used for the radial explosion event
  72617. */
  72618. sphere: Mesh;
  72619. }
  72620. /**
  72621. * Interface for gravitational field event data
  72622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72623. */
  72624. export interface PhysicsGravitationalFieldEventData {
  72625. /**
  72626. * A sphere mesh used for the gravitational field event
  72627. */
  72628. sphere: Mesh;
  72629. }
  72630. /**
  72631. * Interface for updraft event data
  72632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72633. */
  72634. export interface PhysicsUpdraftEventData {
  72635. /**
  72636. * A cylinder used for the updraft event
  72637. */
  72638. cylinder: Mesh;
  72639. }
  72640. /**
  72641. * Interface for vortex event data
  72642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72643. */
  72644. export interface PhysicsVortexEventData {
  72645. /**
  72646. * A cylinder used for the vortex event
  72647. */
  72648. cylinder: Mesh;
  72649. }
  72650. /**
  72651. * Interface for an affected physics impostor
  72652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72653. */
  72654. export interface PhysicsAffectedImpostorWithData {
  72655. /**
  72656. * The impostor affected by the effect
  72657. */
  72658. impostor: PhysicsImpostor;
  72659. /**
  72660. * The data about the hit/horce from the explosion
  72661. */
  72662. hitData: PhysicsHitData;
  72663. }
  72664. }
  72665. declare module "babylonjs/Physics/Plugins/index" {
  72666. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72667. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72668. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72669. }
  72670. declare module "babylonjs/Physics/index" {
  72671. export * from "babylonjs/Physics/IPhysicsEngine";
  72672. export * from "babylonjs/Physics/physicsEngine";
  72673. export * from "babylonjs/Physics/physicsEngineComponent";
  72674. export * from "babylonjs/Physics/physicsHelper";
  72675. export * from "babylonjs/Physics/physicsImpostor";
  72676. export * from "babylonjs/Physics/physicsJoint";
  72677. export * from "babylonjs/Physics/Plugins/index";
  72678. }
  72679. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72680. /** @hidden */
  72681. export var blackAndWhitePixelShader: {
  72682. name: string;
  72683. shader: string;
  72684. };
  72685. }
  72686. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72687. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72688. import { Camera } from "babylonjs/Cameras/camera";
  72689. import { Engine } from "babylonjs/Engines/engine";
  72690. import "babylonjs/Shaders/blackAndWhite.fragment";
  72691. import { Nullable } from "babylonjs/types";
  72692. import { Scene } from "babylonjs/scene";
  72693. /**
  72694. * Post process used to render in black and white
  72695. */
  72696. export class BlackAndWhitePostProcess extends PostProcess {
  72697. /**
  72698. * Linear about to convert he result to black and white (default: 1)
  72699. */
  72700. degree: number;
  72701. /**
  72702. * Gets a string identifying the name of the class
  72703. * @returns "BlackAndWhitePostProcess" string
  72704. */
  72705. getClassName(): string;
  72706. /**
  72707. * Creates a black and white post process
  72708. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72709. * @param name The name of the effect.
  72710. * @param options The required width/height ratio to downsize to before computing the render pass.
  72711. * @param camera The camera to apply the render pass to.
  72712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72713. * @param engine The engine which the post process will be applied. (default: current engine)
  72714. * @param reusable If the post process can be reused on the same frame. (default: false)
  72715. */
  72716. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72717. /** @hidden */
  72718. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72719. }
  72720. }
  72721. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72722. import { Nullable } from "babylonjs/types";
  72723. import { Camera } from "babylonjs/Cameras/camera";
  72724. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72725. import { Engine } from "babylonjs/Engines/engine";
  72726. /**
  72727. * This represents a set of one or more post processes in Babylon.
  72728. * A post process can be used to apply a shader to a texture after it is rendered.
  72729. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72730. */
  72731. export class PostProcessRenderEffect {
  72732. private _postProcesses;
  72733. private _getPostProcesses;
  72734. private _singleInstance;
  72735. private _cameras;
  72736. private _indicesForCamera;
  72737. /**
  72738. * Name of the effect
  72739. * @hidden
  72740. */
  72741. _name: string;
  72742. /**
  72743. * Instantiates a post process render effect.
  72744. * A post process can be used to apply a shader to a texture after it is rendered.
  72745. * @param engine The engine the effect is tied to
  72746. * @param name The name of the effect
  72747. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72748. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72749. */
  72750. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72751. /**
  72752. * Checks if all the post processes in the effect are supported.
  72753. */
  72754. get isSupported(): boolean;
  72755. /**
  72756. * Updates the current state of the effect
  72757. * @hidden
  72758. */
  72759. _update(): void;
  72760. /**
  72761. * Attaches the effect on cameras
  72762. * @param cameras The camera to attach to.
  72763. * @hidden
  72764. */
  72765. _attachCameras(cameras: Camera): void;
  72766. /**
  72767. * Attaches the effect on cameras
  72768. * @param cameras The camera to attach to.
  72769. * @hidden
  72770. */
  72771. _attachCameras(cameras: Camera[]): void;
  72772. /**
  72773. * Detaches the effect on cameras
  72774. * @param cameras The camera to detatch from.
  72775. * @hidden
  72776. */
  72777. _detachCameras(cameras: Camera): void;
  72778. /**
  72779. * Detatches the effect on cameras
  72780. * @param cameras The camera to detatch from.
  72781. * @hidden
  72782. */
  72783. _detachCameras(cameras: Camera[]): void;
  72784. /**
  72785. * Enables the effect on given cameras
  72786. * @param cameras The camera to enable.
  72787. * @hidden
  72788. */
  72789. _enable(cameras: Camera): void;
  72790. /**
  72791. * Enables the effect on given cameras
  72792. * @param cameras The camera to enable.
  72793. * @hidden
  72794. */
  72795. _enable(cameras: Nullable<Camera[]>): void;
  72796. /**
  72797. * Disables the effect on the given cameras
  72798. * @param cameras The camera to disable.
  72799. * @hidden
  72800. */
  72801. _disable(cameras: Camera): void;
  72802. /**
  72803. * Disables the effect on the given cameras
  72804. * @param cameras The camera to disable.
  72805. * @hidden
  72806. */
  72807. _disable(cameras: Nullable<Camera[]>): void;
  72808. /**
  72809. * Gets a list of the post processes contained in the effect.
  72810. * @param camera The camera to get the post processes on.
  72811. * @returns The list of the post processes in the effect.
  72812. */
  72813. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72814. }
  72815. }
  72816. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72817. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72818. /** @hidden */
  72819. export var extractHighlightsPixelShader: {
  72820. name: string;
  72821. shader: string;
  72822. };
  72823. }
  72824. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72825. import { Nullable } from "babylonjs/types";
  72826. import { Camera } from "babylonjs/Cameras/camera";
  72827. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72828. import { Engine } from "babylonjs/Engines/engine";
  72829. import "babylonjs/Shaders/extractHighlights.fragment";
  72830. /**
  72831. * 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.
  72832. */
  72833. export class ExtractHighlightsPostProcess extends PostProcess {
  72834. /**
  72835. * The luminance threshold, pixels below this value will be set to black.
  72836. */
  72837. threshold: number;
  72838. /** @hidden */
  72839. _exposure: number;
  72840. /**
  72841. * Post process which has the input texture to be used when performing highlight extraction
  72842. * @hidden
  72843. */
  72844. _inputPostProcess: Nullable<PostProcess>;
  72845. /**
  72846. * Gets a string identifying the name of the class
  72847. * @returns "ExtractHighlightsPostProcess" string
  72848. */
  72849. getClassName(): string;
  72850. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72851. }
  72852. }
  72853. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72854. /** @hidden */
  72855. export var bloomMergePixelShader: {
  72856. name: string;
  72857. shader: string;
  72858. };
  72859. }
  72860. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72861. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72862. import { Nullable } from "babylonjs/types";
  72863. import { Engine } from "babylonjs/Engines/engine";
  72864. import { Camera } from "babylonjs/Cameras/camera";
  72865. import "babylonjs/Shaders/bloomMerge.fragment";
  72866. /**
  72867. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72868. */
  72869. export class BloomMergePostProcess extends PostProcess {
  72870. /** Weight of the bloom to be added to the original input. */
  72871. weight: number;
  72872. /**
  72873. * Gets a string identifying the name of the class
  72874. * @returns "BloomMergePostProcess" string
  72875. */
  72876. getClassName(): string;
  72877. /**
  72878. * Creates a new instance of @see BloomMergePostProcess
  72879. * @param name The name of the effect.
  72880. * @param originalFromInput Post process which's input will be used for the merge.
  72881. * @param blurred Blurred highlights post process which's output will be used.
  72882. * @param weight Weight of the bloom to be added to the original input.
  72883. * @param options The required width/height ratio to downsize to before computing the render pass.
  72884. * @param camera The camera to apply the render pass to.
  72885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72886. * @param engine The engine which the post process will be applied. (default: current engine)
  72887. * @param reusable If the post process can be reused on the same frame. (default: false)
  72888. * @param textureType Type of textures used when performing the post process. (default: 0)
  72889. * @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)
  72890. */
  72891. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72892. /** Weight of the bloom to be added to the original input. */
  72893. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72894. }
  72895. }
  72896. declare module "babylonjs/PostProcesses/bloomEffect" {
  72897. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72898. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72899. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72900. import { Camera } from "babylonjs/Cameras/camera";
  72901. import { Scene } from "babylonjs/scene";
  72902. /**
  72903. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72904. */
  72905. export class BloomEffect extends PostProcessRenderEffect {
  72906. private bloomScale;
  72907. /**
  72908. * @hidden Internal
  72909. */
  72910. _effects: Array<PostProcess>;
  72911. /**
  72912. * @hidden Internal
  72913. */
  72914. _downscale: ExtractHighlightsPostProcess;
  72915. private _blurX;
  72916. private _blurY;
  72917. private _merge;
  72918. /**
  72919. * The luminance threshold to find bright areas of the image to bloom.
  72920. */
  72921. get threshold(): number;
  72922. set threshold(value: number);
  72923. /**
  72924. * The strength of the bloom.
  72925. */
  72926. get weight(): number;
  72927. set weight(value: number);
  72928. /**
  72929. * Specifies the size of the bloom blur kernel, relative to the final output size
  72930. */
  72931. get kernel(): number;
  72932. set kernel(value: number);
  72933. /**
  72934. * Creates a new instance of @see BloomEffect
  72935. * @param scene The scene the effect belongs to.
  72936. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72937. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72938. * @param bloomWeight The the strength of bloom.
  72939. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72940. * @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)
  72941. */
  72942. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72943. /**
  72944. * Disposes each of the internal effects for a given camera.
  72945. * @param camera The camera to dispose the effect on.
  72946. */
  72947. disposeEffects(camera: Camera): void;
  72948. /**
  72949. * @hidden Internal
  72950. */
  72951. _updateEffects(): void;
  72952. /**
  72953. * Internal
  72954. * @returns if all the contained post processes are ready.
  72955. * @hidden
  72956. */
  72957. _isReady(): boolean;
  72958. }
  72959. }
  72960. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72961. /** @hidden */
  72962. export var chromaticAberrationPixelShader: {
  72963. name: string;
  72964. shader: string;
  72965. };
  72966. }
  72967. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  72968. import { Vector2 } from "babylonjs/Maths/math.vector";
  72969. import { Nullable } from "babylonjs/types";
  72970. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72971. import { Camera } from "babylonjs/Cameras/camera";
  72972. import { Engine } from "babylonjs/Engines/engine";
  72973. import "babylonjs/Shaders/chromaticAberration.fragment";
  72974. import { Scene } from "babylonjs/scene";
  72975. /**
  72976. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  72977. */
  72978. export class ChromaticAberrationPostProcess extends PostProcess {
  72979. /**
  72980. * The amount of seperation of rgb channels (default: 30)
  72981. */
  72982. aberrationAmount: number;
  72983. /**
  72984. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  72985. */
  72986. radialIntensity: number;
  72987. /**
  72988. * 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))
  72989. */
  72990. direction: Vector2;
  72991. /**
  72992. * 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))
  72993. */
  72994. centerPosition: Vector2;
  72995. /** The width of the screen to apply the effect on */
  72996. screenWidth: number;
  72997. /** The height of the screen to apply the effect on */
  72998. screenHeight: number;
  72999. /**
  73000. * Gets a string identifying the name of the class
  73001. * @returns "ChromaticAberrationPostProcess" string
  73002. */
  73003. getClassName(): string;
  73004. /**
  73005. * Creates a new instance ChromaticAberrationPostProcess
  73006. * @param name The name of the effect.
  73007. * @param screenWidth The width of the screen to apply the effect on.
  73008. * @param screenHeight The height of the screen to apply the effect on.
  73009. * @param options The required width/height ratio to downsize to before computing the render pass.
  73010. * @param camera The camera to apply the render pass to.
  73011. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73012. * @param engine The engine which the post process will be applied. (default: current engine)
  73013. * @param reusable If the post process can be reused on the same frame. (default: false)
  73014. * @param textureType Type of textures used when performing the post process. (default: 0)
  73015. * @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)
  73016. */
  73017. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73018. /** @hidden */
  73019. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73020. }
  73021. }
  73022. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73023. /** @hidden */
  73024. export var circleOfConfusionPixelShader: {
  73025. name: string;
  73026. shader: string;
  73027. };
  73028. }
  73029. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73030. import { Nullable } from "babylonjs/types";
  73031. import { Engine } from "babylonjs/Engines/engine";
  73032. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73033. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73034. import { Camera } from "babylonjs/Cameras/camera";
  73035. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73036. /**
  73037. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73038. */
  73039. export class CircleOfConfusionPostProcess extends PostProcess {
  73040. /**
  73041. * 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.
  73042. */
  73043. lensSize: number;
  73044. /**
  73045. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73046. */
  73047. fStop: number;
  73048. /**
  73049. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73050. */
  73051. focusDistance: number;
  73052. /**
  73053. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73054. */
  73055. focalLength: number;
  73056. /**
  73057. * Gets a string identifying the name of the class
  73058. * @returns "CircleOfConfusionPostProcess" string
  73059. */
  73060. getClassName(): string;
  73061. private _depthTexture;
  73062. /**
  73063. * Creates a new instance CircleOfConfusionPostProcess
  73064. * @param name The name of the effect.
  73065. * @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.
  73066. * @param options The required width/height ratio to downsize to before computing the render pass.
  73067. * @param camera The camera to apply the render pass to.
  73068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73069. * @param engine The engine which the post process will be applied. (default: current engine)
  73070. * @param reusable If the post process can be reused on the same frame. (default: false)
  73071. * @param textureType Type of textures used when performing the post process. (default: 0)
  73072. * @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)
  73073. */
  73074. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73075. /**
  73076. * 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.
  73077. */
  73078. set depthTexture(value: RenderTargetTexture);
  73079. }
  73080. }
  73081. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73082. /** @hidden */
  73083. export var colorCorrectionPixelShader: {
  73084. name: string;
  73085. shader: string;
  73086. };
  73087. }
  73088. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73089. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73090. import { Engine } from "babylonjs/Engines/engine";
  73091. import { Camera } from "babylonjs/Cameras/camera";
  73092. import "babylonjs/Shaders/colorCorrection.fragment";
  73093. import { Nullable } from "babylonjs/types";
  73094. import { Scene } from "babylonjs/scene";
  73095. /**
  73096. *
  73097. * This post-process allows the modification of rendered colors by using
  73098. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73099. *
  73100. * The object needs to be provided an url to a texture containing the color
  73101. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73102. * Use an image editing software to tweak the LUT to match your needs.
  73103. *
  73104. * For an example of a color LUT, see here:
  73105. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73106. * For explanations on color grading, see here:
  73107. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73108. *
  73109. */
  73110. export class ColorCorrectionPostProcess extends PostProcess {
  73111. private _colorTableTexture;
  73112. /**
  73113. * Gets the color table url used to create the LUT texture
  73114. */
  73115. colorTableUrl: string;
  73116. /**
  73117. * Gets a string identifying the name of the class
  73118. * @returns "ColorCorrectionPostProcess" string
  73119. */
  73120. getClassName(): string;
  73121. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73122. /** @hidden */
  73123. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73124. }
  73125. }
  73126. declare module "babylonjs/Shaders/convolution.fragment" {
  73127. /** @hidden */
  73128. export var convolutionPixelShader: {
  73129. name: string;
  73130. shader: string;
  73131. };
  73132. }
  73133. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73134. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73135. import { Nullable } from "babylonjs/types";
  73136. import { Camera } from "babylonjs/Cameras/camera";
  73137. import { Engine } from "babylonjs/Engines/engine";
  73138. import "babylonjs/Shaders/convolution.fragment";
  73139. import { Scene } from "babylonjs/scene";
  73140. /**
  73141. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73142. * input texture to perform effects such as edge detection or sharpening
  73143. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73144. */
  73145. export class ConvolutionPostProcess extends PostProcess {
  73146. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73147. kernel: number[];
  73148. /**
  73149. * Gets a string identifying the name of the class
  73150. * @returns "ConvolutionPostProcess" string
  73151. */
  73152. getClassName(): string;
  73153. /**
  73154. * Creates a new instance ConvolutionPostProcess
  73155. * @param name The name of the effect.
  73156. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73157. * @param options The required width/height ratio to downsize to before computing the render pass.
  73158. * @param camera The camera to apply the render pass to.
  73159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73160. * @param engine The engine which the post process will be applied. (default: current engine)
  73161. * @param reusable If the post process can be reused on the same frame. (default: false)
  73162. * @param textureType Type of textures used when performing the post process. (default: 0)
  73163. */
  73164. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73165. /** @hidden */
  73166. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73167. /**
  73168. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73169. */
  73170. static EdgeDetect0Kernel: number[];
  73171. /**
  73172. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73173. */
  73174. static EdgeDetect1Kernel: number[];
  73175. /**
  73176. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73177. */
  73178. static EdgeDetect2Kernel: number[];
  73179. /**
  73180. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73181. */
  73182. static SharpenKernel: number[];
  73183. /**
  73184. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73185. */
  73186. static EmbossKernel: number[];
  73187. /**
  73188. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73189. */
  73190. static GaussianKernel: number[];
  73191. }
  73192. }
  73193. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73194. import { Nullable } from "babylonjs/types";
  73195. import { Vector2 } from "babylonjs/Maths/math.vector";
  73196. import { Camera } from "babylonjs/Cameras/camera";
  73197. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73198. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73199. import { Engine } from "babylonjs/Engines/engine";
  73200. import { Scene } from "babylonjs/scene";
  73201. /**
  73202. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73203. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73204. * based on samples that have a large difference in distance than the center pixel.
  73205. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73206. */
  73207. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73208. /**
  73209. * The direction the blur should be applied
  73210. */
  73211. direction: Vector2;
  73212. /**
  73213. * Gets a string identifying the name of the class
  73214. * @returns "DepthOfFieldBlurPostProcess" string
  73215. */
  73216. getClassName(): string;
  73217. /**
  73218. * Creates a new instance CircleOfConfusionPostProcess
  73219. * @param name The name of the effect.
  73220. * @param scene The scene the effect belongs to.
  73221. * @param direction The direction the blur should be applied.
  73222. * @param kernel The size of the kernel used to blur.
  73223. * @param options The required width/height ratio to downsize to before computing the render pass.
  73224. * @param camera The camera to apply the render pass to.
  73225. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73226. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73228. * @param engine The engine which the post process will be applied. (default: current engine)
  73229. * @param reusable If the post process can be reused on the same frame. (default: false)
  73230. * @param textureType Type of textures used when performing the post process. (default: 0)
  73231. * @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)
  73232. */
  73233. 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);
  73234. }
  73235. }
  73236. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73237. /** @hidden */
  73238. export var depthOfFieldMergePixelShader: {
  73239. name: string;
  73240. shader: string;
  73241. };
  73242. }
  73243. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73244. import { Nullable } from "babylonjs/types";
  73245. import { Camera } from "babylonjs/Cameras/camera";
  73246. import { Effect } from "babylonjs/Materials/effect";
  73247. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73248. import { Engine } from "babylonjs/Engines/engine";
  73249. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73250. /**
  73251. * Options to be set when merging outputs from the default pipeline.
  73252. */
  73253. export class DepthOfFieldMergePostProcessOptions {
  73254. /**
  73255. * The original image to merge on top of
  73256. */
  73257. originalFromInput: PostProcess;
  73258. /**
  73259. * Parameters to perform the merge of the depth of field effect
  73260. */
  73261. depthOfField?: {
  73262. circleOfConfusion: PostProcess;
  73263. blurSteps: Array<PostProcess>;
  73264. };
  73265. /**
  73266. * Parameters to perform the merge of bloom effect
  73267. */
  73268. bloom?: {
  73269. blurred: PostProcess;
  73270. weight: number;
  73271. };
  73272. }
  73273. /**
  73274. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73275. */
  73276. export class DepthOfFieldMergePostProcess extends PostProcess {
  73277. private blurSteps;
  73278. /**
  73279. * Gets a string identifying the name of the class
  73280. * @returns "DepthOfFieldMergePostProcess" string
  73281. */
  73282. getClassName(): string;
  73283. /**
  73284. * Creates a new instance of DepthOfFieldMergePostProcess
  73285. * @param name The name of the effect.
  73286. * @param originalFromInput Post process which's input will be used for the merge.
  73287. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73288. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73289. * @param options The required width/height ratio to downsize to before computing the render pass.
  73290. * @param camera The camera to apply the render pass to.
  73291. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73292. * @param engine The engine which the post process will be applied. (default: current engine)
  73293. * @param reusable If the post process can be reused on the same frame. (default: false)
  73294. * @param textureType Type of textures used when performing the post process. (default: 0)
  73295. * @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)
  73296. */
  73297. 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);
  73298. /**
  73299. * Updates the effect with the current post process compile time values and recompiles the shader.
  73300. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73301. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73302. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73303. * @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
  73304. * @param onCompiled Called when the shader has been compiled.
  73305. * @param onError Called if there is an error when compiling a shader.
  73306. */
  73307. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73308. }
  73309. }
  73310. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73311. import { Nullable } from "babylonjs/types";
  73312. import { Camera } from "babylonjs/Cameras/camera";
  73313. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73314. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73315. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73316. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73317. import { Scene } from "babylonjs/scene";
  73318. /**
  73319. * Specifies the level of max blur that should be applied when using the depth of field effect
  73320. */
  73321. export enum DepthOfFieldEffectBlurLevel {
  73322. /**
  73323. * Subtle blur
  73324. */
  73325. Low = 0,
  73326. /**
  73327. * Medium blur
  73328. */
  73329. Medium = 1,
  73330. /**
  73331. * Large blur
  73332. */
  73333. High = 2
  73334. }
  73335. /**
  73336. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73337. */
  73338. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73339. private _circleOfConfusion;
  73340. /**
  73341. * @hidden Internal, blurs from high to low
  73342. */
  73343. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73344. private _depthOfFieldBlurY;
  73345. private _dofMerge;
  73346. /**
  73347. * @hidden Internal post processes in depth of field effect
  73348. */
  73349. _effects: Array<PostProcess>;
  73350. /**
  73351. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73352. */
  73353. set focalLength(value: number);
  73354. get focalLength(): number;
  73355. /**
  73356. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73357. */
  73358. set fStop(value: number);
  73359. get fStop(): number;
  73360. /**
  73361. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73362. */
  73363. set focusDistance(value: number);
  73364. get focusDistance(): number;
  73365. /**
  73366. * 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.
  73367. */
  73368. set lensSize(value: number);
  73369. get lensSize(): number;
  73370. /**
  73371. * Creates a new instance DepthOfFieldEffect
  73372. * @param scene The scene the effect belongs to.
  73373. * @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.
  73374. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73375. * @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)
  73376. */
  73377. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73378. /**
  73379. * Get the current class name of the current effet
  73380. * @returns "DepthOfFieldEffect"
  73381. */
  73382. getClassName(): string;
  73383. /**
  73384. * 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.
  73385. */
  73386. set depthTexture(value: RenderTargetTexture);
  73387. /**
  73388. * Disposes each of the internal effects for a given camera.
  73389. * @param camera The camera to dispose the effect on.
  73390. */
  73391. disposeEffects(camera: Camera): void;
  73392. /**
  73393. * @hidden Internal
  73394. */
  73395. _updateEffects(): void;
  73396. /**
  73397. * Internal
  73398. * @returns if all the contained post processes are ready.
  73399. * @hidden
  73400. */
  73401. _isReady(): boolean;
  73402. }
  73403. }
  73404. declare module "babylonjs/Shaders/displayPass.fragment" {
  73405. /** @hidden */
  73406. export var displayPassPixelShader: {
  73407. name: string;
  73408. shader: string;
  73409. };
  73410. }
  73411. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73412. import { Nullable } from "babylonjs/types";
  73413. import { Camera } from "babylonjs/Cameras/camera";
  73414. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73415. import { Engine } from "babylonjs/Engines/engine";
  73416. import "babylonjs/Shaders/displayPass.fragment";
  73417. import { Scene } from "babylonjs/scene";
  73418. /**
  73419. * DisplayPassPostProcess which produces an output the same as it's input
  73420. */
  73421. export class DisplayPassPostProcess extends PostProcess {
  73422. /**
  73423. * Gets a string identifying the name of the class
  73424. * @returns "DisplayPassPostProcess" string
  73425. */
  73426. getClassName(): string;
  73427. /**
  73428. * Creates the DisplayPassPostProcess
  73429. * @param name The name of the effect.
  73430. * @param options The required width/height ratio to downsize to before computing the render pass.
  73431. * @param camera The camera to apply the render pass to.
  73432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73433. * @param engine The engine which the post process will be applied. (default: current engine)
  73434. * @param reusable If the post process can be reused on the same frame. (default: false)
  73435. */
  73436. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73437. /** @hidden */
  73438. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73439. }
  73440. }
  73441. declare module "babylonjs/Shaders/filter.fragment" {
  73442. /** @hidden */
  73443. export var filterPixelShader: {
  73444. name: string;
  73445. shader: string;
  73446. };
  73447. }
  73448. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73449. import { Nullable } from "babylonjs/types";
  73450. import { Matrix } from "babylonjs/Maths/math.vector";
  73451. import { Camera } from "babylonjs/Cameras/camera";
  73452. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73453. import { Engine } from "babylonjs/Engines/engine";
  73454. import "babylonjs/Shaders/filter.fragment";
  73455. import { Scene } from "babylonjs/scene";
  73456. /**
  73457. * Applies a kernel filter to the image
  73458. */
  73459. export class FilterPostProcess extends PostProcess {
  73460. /** The matrix to be applied to the image */
  73461. kernelMatrix: Matrix;
  73462. /**
  73463. * Gets a string identifying the name of the class
  73464. * @returns "FilterPostProcess" string
  73465. */
  73466. getClassName(): string;
  73467. /**
  73468. *
  73469. * @param name The name of the effect.
  73470. * @param kernelMatrix The matrix to be applied to the image
  73471. * @param options The required width/height ratio to downsize to before computing the render pass.
  73472. * @param camera The camera to apply the render pass to.
  73473. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73474. * @param engine The engine which the post process will be applied. (default: current engine)
  73475. * @param reusable If the post process can be reused on the same frame. (default: false)
  73476. */
  73477. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73478. /** @hidden */
  73479. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73480. }
  73481. }
  73482. declare module "babylonjs/Shaders/fxaa.fragment" {
  73483. /** @hidden */
  73484. export var fxaaPixelShader: {
  73485. name: string;
  73486. shader: string;
  73487. };
  73488. }
  73489. declare module "babylonjs/Shaders/fxaa.vertex" {
  73490. /** @hidden */
  73491. export var fxaaVertexShader: {
  73492. name: string;
  73493. shader: string;
  73494. };
  73495. }
  73496. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73497. import { Nullable } from "babylonjs/types";
  73498. import { Camera } from "babylonjs/Cameras/camera";
  73499. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73500. import { Engine } from "babylonjs/Engines/engine";
  73501. import "babylonjs/Shaders/fxaa.fragment";
  73502. import "babylonjs/Shaders/fxaa.vertex";
  73503. import { Scene } from "babylonjs/scene";
  73504. /**
  73505. * Fxaa post process
  73506. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73507. */
  73508. export class FxaaPostProcess extends PostProcess {
  73509. /**
  73510. * Gets a string identifying the name of the class
  73511. * @returns "FxaaPostProcess" string
  73512. */
  73513. getClassName(): string;
  73514. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73515. private _getDefines;
  73516. /** @hidden */
  73517. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73518. }
  73519. }
  73520. declare module "babylonjs/Shaders/grain.fragment" {
  73521. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73522. /** @hidden */
  73523. export var grainPixelShader: {
  73524. name: string;
  73525. shader: string;
  73526. };
  73527. }
  73528. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73529. import { Nullable } from "babylonjs/types";
  73530. import { Camera } from "babylonjs/Cameras/camera";
  73531. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73532. import { Engine } from "babylonjs/Engines/engine";
  73533. import "babylonjs/Shaders/grain.fragment";
  73534. import { Scene } from "babylonjs/scene";
  73535. /**
  73536. * The GrainPostProcess adds noise to the image at mid luminance levels
  73537. */
  73538. export class GrainPostProcess extends PostProcess {
  73539. /**
  73540. * The intensity of the grain added (default: 30)
  73541. */
  73542. intensity: number;
  73543. /**
  73544. * If the grain should be randomized on every frame
  73545. */
  73546. animated: boolean;
  73547. /**
  73548. * Gets a string identifying the name of the class
  73549. * @returns "GrainPostProcess" string
  73550. */
  73551. getClassName(): string;
  73552. /**
  73553. * Creates a new instance of @see GrainPostProcess
  73554. * @param name The name of the effect.
  73555. * @param options The required width/height ratio to downsize to before computing the render pass.
  73556. * @param camera The camera to apply the render pass to.
  73557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73558. * @param engine The engine which the post process will be applied. (default: current engine)
  73559. * @param reusable If the post process can be reused on the same frame. (default: false)
  73560. * @param textureType Type of textures used when performing the post process. (default: 0)
  73561. * @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)
  73562. */
  73563. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73564. /** @hidden */
  73565. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73566. }
  73567. }
  73568. declare module "babylonjs/Shaders/highlights.fragment" {
  73569. /** @hidden */
  73570. export var highlightsPixelShader: {
  73571. name: string;
  73572. shader: string;
  73573. };
  73574. }
  73575. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73576. import { Nullable } from "babylonjs/types";
  73577. import { Camera } from "babylonjs/Cameras/camera";
  73578. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73579. import { Engine } from "babylonjs/Engines/engine";
  73580. import "babylonjs/Shaders/highlights.fragment";
  73581. /**
  73582. * Extracts highlights from the image
  73583. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73584. */
  73585. export class HighlightsPostProcess extends PostProcess {
  73586. /**
  73587. * Gets a string identifying the name of the class
  73588. * @returns "HighlightsPostProcess" string
  73589. */
  73590. getClassName(): string;
  73591. /**
  73592. * Extracts highlights from the image
  73593. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73594. * @param name The name of the effect.
  73595. * @param options The required width/height ratio to downsize to before computing the render pass.
  73596. * @param camera The camera to apply the render pass to.
  73597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73598. * @param engine The engine which the post process will be applied. (default: current engine)
  73599. * @param reusable If the post process can be reused on the same frame. (default: false)
  73600. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73601. */
  73602. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73603. }
  73604. }
  73605. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73606. /** @hidden */
  73607. export var mrtFragmentDeclaration: {
  73608. name: string;
  73609. shader: string;
  73610. };
  73611. }
  73612. declare module "babylonjs/Shaders/geometry.fragment" {
  73613. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73614. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73615. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73616. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73617. /** @hidden */
  73618. export var geometryPixelShader: {
  73619. name: string;
  73620. shader: string;
  73621. };
  73622. }
  73623. declare module "babylonjs/Shaders/geometry.vertex" {
  73624. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73625. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73626. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73627. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73628. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73629. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73630. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73631. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73632. /** @hidden */
  73633. export var geometryVertexShader: {
  73634. name: string;
  73635. shader: string;
  73636. };
  73637. }
  73638. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73639. import { Matrix } from "babylonjs/Maths/math.vector";
  73640. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73641. import { Mesh } from "babylonjs/Meshes/mesh";
  73642. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73643. import { Effect } from "babylonjs/Materials/effect";
  73644. import { Scene } from "babylonjs/scene";
  73645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73646. import "babylonjs/Shaders/geometry.fragment";
  73647. import "babylonjs/Shaders/geometry.vertex";
  73648. /** @hidden */
  73649. interface ISavedTransformationMatrix {
  73650. world: Matrix;
  73651. viewProjection: Matrix;
  73652. }
  73653. /**
  73654. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73655. */
  73656. export class GeometryBufferRenderer {
  73657. /**
  73658. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73659. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73660. */
  73661. static readonly POSITION_TEXTURE_TYPE: number;
  73662. /**
  73663. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73664. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73665. */
  73666. static readonly VELOCITY_TEXTURE_TYPE: number;
  73667. /**
  73668. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73669. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73670. */
  73671. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73672. /**
  73673. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73674. * in order to compute objects velocities when enableVelocity is set to "true"
  73675. * @hidden
  73676. */
  73677. _previousTransformationMatrices: {
  73678. [index: number]: ISavedTransformationMatrix;
  73679. };
  73680. /**
  73681. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73682. * in order to compute objects velocities when enableVelocity is set to "true"
  73683. * @hidden
  73684. */
  73685. _previousBonesTransformationMatrices: {
  73686. [index: number]: Float32Array;
  73687. };
  73688. /**
  73689. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73690. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73691. */
  73692. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73693. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73694. renderTransparentMeshes: boolean;
  73695. private _scene;
  73696. private _resizeObserver;
  73697. private _multiRenderTarget;
  73698. private _ratio;
  73699. private _enablePosition;
  73700. private _enableVelocity;
  73701. private _enableReflectivity;
  73702. private _positionIndex;
  73703. private _velocityIndex;
  73704. private _reflectivityIndex;
  73705. protected _effect: Effect;
  73706. protected _cachedDefines: string;
  73707. /**
  73708. * Set the render list (meshes to be rendered) used in the G buffer.
  73709. */
  73710. set renderList(meshes: Mesh[]);
  73711. /**
  73712. * Gets wether or not G buffer are supported by the running hardware.
  73713. * This requires draw buffer supports
  73714. */
  73715. get isSupported(): boolean;
  73716. /**
  73717. * Returns the index of the given texture type in the G-Buffer textures array
  73718. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73719. * @returns the index of the given texture type in the G-Buffer textures array
  73720. */
  73721. getTextureIndex(textureType: number): number;
  73722. /**
  73723. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73724. */
  73725. get enablePosition(): boolean;
  73726. /**
  73727. * Sets whether or not objects positions are enabled for the G buffer.
  73728. */
  73729. set enablePosition(enable: boolean);
  73730. /**
  73731. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73732. */
  73733. get enableVelocity(): boolean;
  73734. /**
  73735. * Sets wether or not objects velocities are enabled for the G buffer.
  73736. */
  73737. set enableVelocity(enable: boolean);
  73738. /**
  73739. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73740. */
  73741. get enableReflectivity(): boolean;
  73742. /**
  73743. * Sets wether or not objects roughness are enabled for the G buffer.
  73744. */
  73745. set enableReflectivity(enable: boolean);
  73746. /**
  73747. * Gets the scene associated with the buffer.
  73748. */
  73749. get scene(): Scene;
  73750. /**
  73751. * Gets the ratio used by the buffer during its creation.
  73752. * How big is the buffer related to the main canvas.
  73753. */
  73754. get ratio(): number;
  73755. /** @hidden */
  73756. static _SceneComponentInitialization: (scene: Scene) => void;
  73757. /**
  73758. * Creates a new G Buffer for the scene
  73759. * @param scene The scene the buffer belongs to
  73760. * @param ratio How big is the buffer related to the main canvas.
  73761. */
  73762. constructor(scene: Scene, ratio?: number);
  73763. /**
  73764. * Checks wether everything is ready to render a submesh to the G buffer.
  73765. * @param subMesh the submesh to check readiness for
  73766. * @param useInstances is the mesh drawn using instance or not
  73767. * @returns true if ready otherwise false
  73768. */
  73769. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73770. /**
  73771. * Gets the current underlying G Buffer.
  73772. * @returns the buffer
  73773. */
  73774. getGBuffer(): MultiRenderTarget;
  73775. /**
  73776. * Gets the number of samples used to render the buffer (anti aliasing).
  73777. */
  73778. get samples(): number;
  73779. /**
  73780. * Sets the number of samples used to render the buffer (anti aliasing).
  73781. */
  73782. set samples(value: number);
  73783. /**
  73784. * Disposes the renderer and frees up associated resources.
  73785. */
  73786. dispose(): void;
  73787. protected _createRenderTargets(): void;
  73788. private _copyBonesTransformationMatrices;
  73789. }
  73790. }
  73791. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73792. import { Nullable } from "babylonjs/types";
  73793. import { Scene } from "babylonjs/scene";
  73794. import { ISceneComponent } from "babylonjs/sceneComponent";
  73795. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73796. module "babylonjs/scene" {
  73797. interface Scene {
  73798. /** @hidden (Backing field) */
  73799. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73800. /**
  73801. * Gets or Sets the current geometry buffer associated to the scene.
  73802. */
  73803. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73804. /**
  73805. * Enables a GeometryBufferRender and associates it with the scene
  73806. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73807. * @returns the GeometryBufferRenderer
  73808. */
  73809. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73810. /**
  73811. * Disables the GeometryBufferRender associated with the scene
  73812. */
  73813. disableGeometryBufferRenderer(): void;
  73814. }
  73815. }
  73816. /**
  73817. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73818. * in several rendering techniques.
  73819. */
  73820. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73821. /**
  73822. * The component name helpful to identify the component in the list of scene components.
  73823. */
  73824. readonly name: string;
  73825. /**
  73826. * The scene the component belongs to.
  73827. */
  73828. scene: Scene;
  73829. /**
  73830. * Creates a new instance of the component for the given scene
  73831. * @param scene Defines the scene to register the component in
  73832. */
  73833. constructor(scene: Scene);
  73834. /**
  73835. * Registers the component in a given scene
  73836. */
  73837. register(): void;
  73838. /**
  73839. * Rebuilds the elements related to this component in case of
  73840. * context lost for instance.
  73841. */
  73842. rebuild(): void;
  73843. /**
  73844. * Disposes the component and the associated ressources
  73845. */
  73846. dispose(): void;
  73847. private _gatherRenderTargets;
  73848. }
  73849. }
  73850. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73851. /** @hidden */
  73852. export var motionBlurPixelShader: {
  73853. name: string;
  73854. shader: string;
  73855. };
  73856. }
  73857. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73858. import { Nullable } from "babylonjs/types";
  73859. import { Camera } from "babylonjs/Cameras/camera";
  73860. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73862. import "babylonjs/Animations/animatable";
  73863. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73864. import "babylonjs/Shaders/motionBlur.fragment";
  73865. import { Engine } from "babylonjs/Engines/engine";
  73866. import { Scene } from "babylonjs/scene";
  73867. /**
  73868. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73869. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73870. * As an example, all you have to do is to create the post-process:
  73871. * var mb = new BABYLON.MotionBlurPostProcess(
  73872. * 'mb', // The name of the effect.
  73873. * scene, // The scene containing the objects to blur according to their velocity.
  73874. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73875. * camera // The camera to apply the render pass to.
  73876. * );
  73877. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73878. */
  73879. export class MotionBlurPostProcess extends PostProcess {
  73880. /**
  73881. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73882. */
  73883. motionStrength: number;
  73884. /**
  73885. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73886. */
  73887. get motionBlurSamples(): number;
  73888. /**
  73889. * Sets the number of iterations to be used for motion blur quality
  73890. */
  73891. set motionBlurSamples(samples: number);
  73892. private _motionBlurSamples;
  73893. private _geometryBufferRenderer;
  73894. /**
  73895. * Gets a string identifying the name of the class
  73896. * @returns "MotionBlurPostProcess" string
  73897. */
  73898. getClassName(): string;
  73899. /**
  73900. * Creates a new instance MotionBlurPostProcess
  73901. * @param name The name of the effect.
  73902. * @param scene The scene containing the objects to blur according to their velocity.
  73903. * @param options The required width/height ratio to downsize to before computing the render pass.
  73904. * @param camera The camera to apply the render pass to.
  73905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73906. * @param engine The engine which the post process will be applied. (default: current engine)
  73907. * @param reusable If the post process can be reused on the same frame. (default: false)
  73908. * @param textureType Type of textures used when performing the post process. (default: 0)
  73909. * @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)
  73910. */
  73911. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73912. /**
  73913. * Excludes the given skinned mesh from computing bones velocities.
  73914. * 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.
  73915. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73916. */
  73917. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73918. /**
  73919. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73920. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73921. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73922. */
  73923. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73924. /**
  73925. * Disposes the post process.
  73926. * @param camera The camera to dispose the post process on.
  73927. */
  73928. dispose(camera?: Camera): void;
  73929. /** @hidden */
  73930. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  73931. }
  73932. }
  73933. declare module "babylonjs/Shaders/refraction.fragment" {
  73934. /** @hidden */
  73935. export var refractionPixelShader: {
  73936. name: string;
  73937. shader: string;
  73938. };
  73939. }
  73940. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73941. import { Color3 } from "babylonjs/Maths/math.color";
  73942. import { Camera } from "babylonjs/Cameras/camera";
  73943. import { Texture } from "babylonjs/Materials/Textures/texture";
  73944. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73945. import { Engine } from "babylonjs/Engines/engine";
  73946. import "babylonjs/Shaders/refraction.fragment";
  73947. import { Scene } from "babylonjs/scene";
  73948. /**
  73949. * Post process which applies a refractin texture
  73950. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73951. */
  73952. export class RefractionPostProcess extends PostProcess {
  73953. private _refTexture;
  73954. private _ownRefractionTexture;
  73955. /** the base color of the refraction (used to taint the rendering) */
  73956. color: Color3;
  73957. /** simulated refraction depth */
  73958. depth: number;
  73959. /** the coefficient of the base color (0 to remove base color tainting) */
  73960. colorLevel: number;
  73961. /** Gets the url used to load the refraction texture */
  73962. refractionTextureUrl: string;
  73963. /**
  73964. * Gets or sets the refraction texture
  73965. * Please note that you are responsible for disposing the texture if you set it manually
  73966. */
  73967. get refractionTexture(): Texture;
  73968. set refractionTexture(value: Texture);
  73969. /**
  73970. * Gets a string identifying the name of the class
  73971. * @returns "RefractionPostProcess" string
  73972. */
  73973. getClassName(): string;
  73974. /**
  73975. * Initializes the RefractionPostProcess
  73976. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73977. * @param name The name of the effect.
  73978. * @param refractionTextureUrl Url of the refraction texture to use
  73979. * @param color the base color of the refraction (used to taint the rendering)
  73980. * @param depth simulated refraction depth
  73981. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  73982. * @param camera The camera to apply the render pass to.
  73983. * @param options The required width/height ratio to downsize to before computing the render pass.
  73984. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73985. * @param engine The engine which the post process will be applied. (default: current engine)
  73986. * @param reusable If the post process can be reused on the same frame. (default: false)
  73987. */
  73988. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73989. /**
  73990. * Disposes of the post process
  73991. * @param camera Camera to dispose post process on
  73992. */
  73993. dispose(camera: Camera): void;
  73994. /** @hidden */
  73995. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  73996. }
  73997. }
  73998. declare module "babylonjs/Shaders/sharpen.fragment" {
  73999. /** @hidden */
  74000. export var sharpenPixelShader: {
  74001. name: string;
  74002. shader: string;
  74003. };
  74004. }
  74005. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74006. import { Nullable } from "babylonjs/types";
  74007. import { Camera } from "babylonjs/Cameras/camera";
  74008. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74009. import "babylonjs/Shaders/sharpen.fragment";
  74010. import { Engine } from "babylonjs/Engines/engine";
  74011. import { Scene } from "babylonjs/scene";
  74012. /**
  74013. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74014. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74015. */
  74016. export class SharpenPostProcess extends PostProcess {
  74017. /**
  74018. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74019. */
  74020. colorAmount: number;
  74021. /**
  74022. * How much sharpness should be applied (default: 0.3)
  74023. */
  74024. edgeAmount: number;
  74025. /**
  74026. * Gets a string identifying the name of the class
  74027. * @returns "SharpenPostProcess" string
  74028. */
  74029. getClassName(): string;
  74030. /**
  74031. * Creates a new instance ConvolutionPostProcess
  74032. * @param name The name of the effect.
  74033. * @param options The required width/height ratio to downsize to before computing the render pass.
  74034. * @param camera The camera to apply the render pass to.
  74035. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74036. * @param engine The engine which the post process will be applied. (default: current engine)
  74037. * @param reusable If the post process can be reused on the same frame. (default: false)
  74038. * @param textureType Type of textures used when performing the post process. (default: 0)
  74039. * @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)
  74040. */
  74041. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74042. /** @hidden */
  74043. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74044. }
  74045. }
  74046. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74047. import { Nullable } from "babylonjs/types";
  74048. import { Camera } from "babylonjs/Cameras/camera";
  74049. import { Engine } from "babylonjs/Engines/engine";
  74050. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74051. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74052. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74053. /**
  74054. * PostProcessRenderPipeline
  74055. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74056. */
  74057. export class PostProcessRenderPipeline {
  74058. private engine;
  74059. private _renderEffects;
  74060. private _renderEffectsForIsolatedPass;
  74061. /**
  74062. * List of inspectable custom properties (used by the Inspector)
  74063. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74064. */
  74065. inspectableCustomProperties: IInspectable[];
  74066. /**
  74067. * @hidden
  74068. */
  74069. protected _cameras: Camera[];
  74070. /** @hidden */
  74071. _name: string;
  74072. /**
  74073. * Gets pipeline name
  74074. */
  74075. get name(): string;
  74076. /** Gets the list of attached cameras */
  74077. get cameras(): Camera[];
  74078. /**
  74079. * Initializes a PostProcessRenderPipeline
  74080. * @param engine engine to add the pipeline to
  74081. * @param name name of the pipeline
  74082. */
  74083. constructor(engine: Engine, name: string);
  74084. /**
  74085. * Gets the class name
  74086. * @returns "PostProcessRenderPipeline"
  74087. */
  74088. getClassName(): string;
  74089. /**
  74090. * If all the render effects in the pipeline are supported
  74091. */
  74092. get isSupported(): boolean;
  74093. /**
  74094. * Adds an effect to the pipeline
  74095. * @param renderEffect the effect to add
  74096. */
  74097. addEffect(renderEffect: PostProcessRenderEffect): void;
  74098. /** @hidden */
  74099. _rebuild(): void;
  74100. /** @hidden */
  74101. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74102. /** @hidden */
  74103. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74104. /** @hidden */
  74105. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74106. /** @hidden */
  74107. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74108. /** @hidden */
  74109. _attachCameras(cameras: Camera, unique: boolean): void;
  74110. /** @hidden */
  74111. _attachCameras(cameras: Camera[], unique: boolean): void;
  74112. /** @hidden */
  74113. _detachCameras(cameras: Camera): void;
  74114. /** @hidden */
  74115. _detachCameras(cameras: Nullable<Camera[]>): void;
  74116. /** @hidden */
  74117. _update(): void;
  74118. /** @hidden */
  74119. _reset(): void;
  74120. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74121. /**
  74122. * Sets the required values to the prepass renderer.
  74123. * @param prePassRenderer defines the prepass renderer to setup.
  74124. * @returns true if the pre pass is needed.
  74125. */
  74126. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74127. /**
  74128. * Disposes of the pipeline
  74129. */
  74130. dispose(): void;
  74131. }
  74132. }
  74133. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74134. import { Camera } from "babylonjs/Cameras/camera";
  74135. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74136. /**
  74137. * PostProcessRenderPipelineManager class
  74138. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74139. */
  74140. export class PostProcessRenderPipelineManager {
  74141. private _renderPipelines;
  74142. /**
  74143. * Initializes a PostProcessRenderPipelineManager
  74144. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74145. */
  74146. constructor();
  74147. /**
  74148. * Gets the list of supported render pipelines
  74149. */
  74150. get supportedPipelines(): PostProcessRenderPipeline[];
  74151. /**
  74152. * Adds a pipeline to the manager
  74153. * @param renderPipeline The pipeline to add
  74154. */
  74155. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74156. /**
  74157. * Attaches a camera to the pipeline
  74158. * @param renderPipelineName The name of the pipeline to attach to
  74159. * @param cameras the camera to attach
  74160. * @param unique if the camera can be attached multiple times to the pipeline
  74161. */
  74162. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74163. /**
  74164. * Detaches a camera from the pipeline
  74165. * @param renderPipelineName The name of the pipeline to detach from
  74166. * @param cameras the camera to detach
  74167. */
  74168. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74169. /**
  74170. * Enables an effect by name on a pipeline
  74171. * @param renderPipelineName the name of the pipeline to enable the effect in
  74172. * @param renderEffectName the name of the effect to enable
  74173. * @param cameras the cameras that the effect should be enabled on
  74174. */
  74175. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74176. /**
  74177. * Disables an effect by name on a pipeline
  74178. * @param renderPipelineName the name of the pipeline to disable the effect in
  74179. * @param renderEffectName the name of the effect to disable
  74180. * @param cameras the cameras that the effect should be disabled on
  74181. */
  74182. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74183. /**
  74184. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74185. */
  74186. update(): void;
  74187. /** @hidden */
  74188. _rebuild(): void;
  74189. /**
  74190. * Disposes of the manager and pipelines
  74191. */
  74192. dispose(): void;
  74193. }
  74194. }
  74195. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74196. import { ISceneComponent } from "babylonjs/sceneComponent";
  74197. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74198. import { Scene } from "babylonjs/scene";
  74199. module "babylonjs/scene" {
  74200. interface Scene {
  74201. /** @hidden (Backing field) */
  74202. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74203. /**
  74204. * Gets the postprocess render pipeline manager
  74205. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74206. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74207. */
  74208. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74209. }
  74210. }
  74211. /**
  74212. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74213. */
  74214. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74215. /**
  74216. * The component name helpfull to identify the component in the list of scene components.
  74217. */
  74218. readonly name: string;
  74219. /**
  74220. * The scene the component belongs to.
  74221. */
  74222. scene: Scene;
  74223. /**
  74224. * Creates a new instance of the component for the given scene
  74225. * @param scene Defines the scene to register the component in
  74226. */
  74227. constructor(scene: Scene);
  74228. /**
  74229. * Registers the component in a given scene
  74230. */
  74231. register(): void;
  74232. /**
  74233. * Rebuilds the elements related to this component in case of
  74234. * context lost for instance.
  74235. */
  74236. rebuild(): void;
  74237. /**
  74238. * Disposes the component and the associated ressources
  74239. */
  74240. dispose(): void;
  74241. private _gatherRenderTargets;
  74242. }
  74243. }
  74244. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74245. import { Nullable } from "babylonjs/types";
  74246. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74247. import { Camera } from "babylonjs/Cameras/camera";
  74248. import { IDisposable } from "babylonjs/scene";
  74249. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74250. import { Scene } from "babylonjs/scene";
  74251. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74252. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74253. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74254. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74255. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74256. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74257. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74258. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74259. import { Animation } from "babylonjs/Animations/animation";
  74260. /**
  74261. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74262. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74263. */
  74264. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74265. private _scene;
  74266. private _camerasToBeAttached;
  74267. /**
  74268. * ID of the sharpen post process,
  74269. */
  74270. private readonly SharpenPostProcessId;
  74271. /**
  74272. * @ignore
  74273. * ID of the image processing post process;
  74274. */
  74275. readonly ImageProcessingPostProcessId: string;
  74276. /**
  74277. * @ignore
  74278. * ID of the Fast Approximate Anti-Aliasing post process;
  74279. */
  74280. readonly FxaaPostProcessId: string;
  74281. /**
  74282. * ID of the chromatic aberration post process,
  74283. */
  74284. private readonly ChromaticAberrationPostProcessId;
  74285. /**
  74286. * ID of the grain post process
  74287. */
  74288. private readonly GrainPostProcessId;
  74289. /**
  74290. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74291. */
  74292. sharpen: SharpenPostProcess;
  74293. private _sharpenEffect;
  74294. private bloom;
  74295. /**
  74296. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74297. */
  74298. depthOfField: DepthOfFieldEffect;
  74299. /**
  74300. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74301. */
  74302. fxaa: FxaaPostProcess;
  74303. /**
  74304. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74305. */
  74306. imageProcessing: ImageProcessingPostProcess;
  74307. /**
  74308. * Chromatic aberration post process which will shift rgb colors in the image
  74309. */
  74310. chromaticAberration: ChromaticAberrationPostProcess;
  74311. private _chromaticAberrationEffect;
  74312. /**
  74313. * Grain post process which add noise to the image
  74314. */
  74315. grain: GrainPostProcess;
  74316. private _grainEffect;
  74317. /**
  74318. * Glow post process which adds a glow to emissive areas of the image
  74319. */
  74320. private _glowLayer;
  74321. /**
  74322. * Animations which can be used to tweak settings over a period of time
  74323. */
  74324. animations: Animation[];
  74325. private _imageProcessingConfigurationObserver;
  74326. private _sharpenEnabled;
  74327. private _bloomEnabled;
  74328. private _depthOfFieldEnabled;
  74329. private _depthOfFieldBlurLevel;
  74330. private _fxaaEnabled;
  74331. private _imageProcessingEnabled;
  74332. private _defaultPipelineTextureType;
  74333. private _bloomScale;
  74334. private _chromaticAberrationEnabled;
  74335. private _grainEnabled;
  74336. private _buildAllowed;
  74337. /**
  74338. * Gets active scene
  74339. */
  74340. get scene(): Scene;
  74341. /**
  74342. * Enable or disable the sharpen process from the pipeline
  74343. */
  74344. set sharpenEnabled(enabled: boolean);
  74345. get sharpenEnabled(): boolean;
  74346. private _resizeObserver;
  74347. private _hardwareScaleLevel;
  74348. private _bloomKernel;
  74349. /**
  74350. * Specifies the size of the bloom blur kernel, relative to the final output size
  74351. */
  74352. get bloomKernel(): number;
  74353. set bloomKernel(value: number);
  74354. /**
  74355. * Specifies the weight of the bloom in the final rendering
  74356. */
  74357. private _bloomWeight;
  74358. /**
  74359. * Specifies the luma threshold for the area that will be blurred by the bloom
  74360. */
  74361. private _bloomThreshold;
  74362. private _hdr;
  74363. /**
  74364. * The strength of the bloom.
  74365. */
  74366. set bloomWeight(value: number);
  74367. get bloomWeight(): number;
  74368. /**
  74369. * The strength of the bloom.
  74370. */
  74371. set bloomThreshold(value: number);
  74372. get bloomThreshold(): number;
  74373. /**
  74374. * The scale of the bloom, lower value will provide better performance.
  74375. */
  74376. set bloomScale(value: number);
  74377. get bloomScale(): number;
  74378. /**
  74379. * Enable or disable the bloom from the pipeline
  74380. */
  74381. set bloomEnabled(enabled: boolean);
  74382. get bloomEnabled(): boolean;
  74383. private _rebuildBloom;
  74384. /**
  74385. * If the depth of field is enabled.
  74386. */
  74387. get depthOfFieldEnabled(): boolean;
  74388. set depthOfFieldEnabled(enabled: boolean);
  74389. /**
  74390. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74391. */
  74392. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74393. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74394. /**
  74395. * If the anti aliasing is enabled.
  74396. */
  74397. set fxaaEnabled(enabled: boolean);
  74398. get fxaaEnabled(): boolean;
  74399. private _samples;
  74400. /**
  74401. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74402. */
  74403. set samples(sampleCount: number);
  74404. get samples(): number;
  74405. /**
  74406. * If image processing is enabled.
  74407. */
  74408. set imageProcessingEnabled(enabled: boolean);
  74409. get imageProcessingEnabled(): boolean;
  74410. /**
  74411. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74412. */
  74413. set glowLayerEnabled(enabled: boolean);
  74414. get glowLayerEnabled(): boolean;
  74415. /**
  74416. * Gets the glow layer (or null if not defined)
  74417. */
  74418. get glowLayer(): Nullable<GlowLayer>;
  74419. /**
  74420. * Enable or disable the chromaticAberration process from the pipeline
  74421. */
  74422. set chromaticAberrationEnabled(enabled: boolean);
  74423. get chromaticAberrationEnabled(): boolean;
  74424. /**
  74425. * Enable or disable the grain process from the pipeline
  74426. */
  74427. set grainEnabled(enabled: boolean);
  74428. get grainEnabled(): boolean;
  74429. /**
  74430. * @constructor
  74431. * @param name - The rendering pipeline name (default: "")
  74432. * @param hdr - If high dynamic range textures should be used (default: true)
  74433. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74434. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74435. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74436. */
  74437. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74438. /**
  74439. * Get the class name
  74440. * @returns "DefaultRenderingPipeline"
  74441. */
  74442. getClassName(): string;
  74443. /**
  74444. * Force the compilation of the entire pipeline.
  74445. */
  74446. prepare(): void;
  74447. private _hasCleared;
  74448. private _prevPostProcess;
  74449. private _prevPrevPostProcess;
  74450. private _setAutoClearAndTextureSharing;
  74451. private _depthOfFieldSceneObserver;
  74452. private _buildPipeline;
  74453. private _disposePostProcesses;
  74454. /**
  74455. * Adds a camera to the pipeline
  74456. * @param camera the camera to be added
  74457. */
  74458. addCamera(camera: Camera): void;
  74459. /**
  74460. * Removes a camera from the pipeline
  74461. * @param camera the camera to remove
  74462. */
  74463. removeCamera(camera: Camera): void;
  74464. /**
  74465. * Dispose of the pipeline and stop all post processes
  74466. */
  74467. dispose(): void;
  74468. /**
  74469. * Serialize the rendering pipeline (Used when exporting)
  74470. * @returns the serialized object
  74471. */
  74472. serialize(): any;
  74473. /**
  74474. * Parse the serialized pipeline
  74475. * @param source Source pipeline.
  74476. * @param scene The scene to load the pipeline to.
  74477. * @param rootUrl The URL of the serialized pipeline.
  74478. * @returns An instantiated pipeline from the serialized object.
  74479. */
  74480. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74481. }
  74482. }
  74483. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74484. /** @hidden */
  74485. export var lensHighlightsPixelShader: {
  74486. name: string;
  74487. shader: string;
  74488. };
  74489. }
  74490. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74491. /** @hidden */
  74492. export var depthOfFieldPixelShader: {
  74493. name: string;
  74494. shader: string;
  74495. };
  74496. }
  74497. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74498. import { Camera } from "babylonjs/Cameras/camera";
  74499. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74500. import { Scene } from "babylonjs/scene";
  74501. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74502. import "babylonjs/Shaders/chromaticAberration.fragment";
  74503. import "babylonjs/Shaders/lensHighlights.fragment";
  74504. import "babylonjs/Shaders/depthOfField.fragment";
  74505. /**
  74506. * BABYLON.JS Chromatic Aberration GLSL Shader
  74507. * Author: Olivier Guyot
  74508. * Separates very slightly R, G and B colors on the edges of the screen
  74509. * Inspired by Francois Tarlier & Martins Upitis
  74510. */
  74511. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74512. /**
  74513. * @ignore
  74514. * The chromatic aberration PostProcess id in the pipeline
  74515. */
  74516. LensChromaticAberrationEffect: string;
  74517. /**
  74518. * @ignore
  74519. * The highlights enhancing PostProcess id in the pipeline
  74520. */
  74521. HighlightsEnhancingEffect: string;
  74522. /**
  74523. * @ignore
  74524. * The depth-of-field PostProcess id in the pipeline
  74525. */
  74526. LensDepthOfFieldEffect: string;
  74527. private _scene;
  74528. private _depthTexture;
  74529. private _grainTexture;
  74530. private _chromaticAberrationPostProcess;
  74531. private _highlightsPostProcess;
  74532. private _depthOfFieldPostProcess;
  74533. private _edgeBlur;
  74534. private _grainAmount;
  74535. private _chromaticAberration;
  74536. private _distortion;
  74537. private _highlightsGain;
  74538. private _highlightsThreshold;
  74539. private _dofDistance;
  74540. private _dofAperture;
  74541. private _dofDarken;
  74542. private _dofPentagon;
  74543. private _blurNoise;
  74544. /**
  74545. * @constructor
  74546. *
  74547. * Effect parameters are as follow:
  74548. * {
  74549. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74550. * edge_blur: number; // from 0 to x (1 for realism)
  74551. * distortion: number; // from 0 to x (1 for realism)
  74552. * grain_amount: number; // from 0 to 1
  74553. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74554. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74555. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74556. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74557. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74558. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74559. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74560. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74561. * }
  74562. * Note: if an effect parameter is unset, effect is disabled
  74563. *
  74564. * @param name The rendering pipeline name
  74565. * @param parameters - An object containing all parameters (see above)
  74566. * @param scene The scene linked to this pipeline
  74567. * @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)
  74568. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74569. */
  74570. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74571. /**
  74572. * Get the class name
  74573. * @returns "LensRenderingPipeline"
  74574. */
  74575. getClassName(): string;
  74576. /**
  74577. * Gets associated scene
  74578. */
  74579. get scene(): Scene;
  74580. /**
  74581. * Gets or sets the edge blur
  74582. */
  74583. get edgeBlur(): number;
  74584. set edgeBlur(value: number);
  74585. /**
  74586. * Gets or sets the grain amount
  74587. */
  74588. get grainAmount(): number;
  74589. set grainAmount(value: number);
  74590. /**
  74591. * Gets or sets the chromatic aberration amount
  74592. */
  74593. get chromaticAberration(): number;
  74594. set chromaticAberration(value: number);
  74595. /**
  74596. * Gets or sets the depth of field aperture
  74597. */
  74598. get dofAperture(): number;
  74599. set dofAperture(value: number);
  74600. /**
  74601. * Gets or sets the edge distortion
  74602. */
  74603. get edgeDistortion(): number;
  74604. set edgeDistortion(value: number);
  74605. /**
  74606. * Gets or sets the depth of field distortion
  74607. */
  74608. get dofDistortion(): number;
  74609. set dofDistortion(value: number);
  74610. /**
  74611. * Gets or sets the darken out of focus amount
  74612. */
  74613. get darkenOutOfFocus(): number;
  74614. set darkenOutOfFocus(value: number);
  74615. /**
  74616. * Gets or sets a boolean indicating if blur noise is enabled
  74617. */
  74618. get blurNoise(): boolean;
  74619. set blurNoise(value: boolean);
  74620. /**
  74621. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74622. */
  74623. get pentagonBokeh(): boolean;
  74624. set pentagonBokeh(value: boolean);
  74625. /**
  74626. * Gets or sets the highlight grain amount
  74627. */
  74628. get highlightsGain(): number;
  74629. set highlightsGain(value: number);
  74630. /**
  74631. * Gets or sets the highlight threshold
  74632. */
  74633. get highlightsThreshold(): number;
  74634. set highlightsThreshold(value: number);
  74635. /**
  74636. * Sets the amount of blur at the edges
  74637. * @param amount blur amount
  74638. */
  74639. setEdgeBlur(amount: number): void;
  74640. /**
  74641. * Sets edge blur to 0
  74642. */
  74643. disableEdgeBlur(): void;
  74644. /**
  74645. * Sets the amout of grain
  74646. * @param amount Amount of grain
  74647. */
  74648. setGrainAmount(amount: number): void;
  74649. /**
  74650. * Set grain amount to 0
  74651. */
  74652. disableGrain(): void;
  74653. /**
  74654. * Sets the chromatic aberration amount
  74655. * @param amount amount of chromatic aberration
  74656. */
  74657. setChromaticAberration(amount: number): void;
  74658. /**
  74659. * Sets chromatic aberration amount to 0
  74660. */
  74661. disableChromaticAberration(): void;
  74662. /**
  74663. * Sets the EdgeDistortion amount
  74664. * @param amount amount of EdgeDistortion
  74665. */
  74666. setEdgeDistortion(amount: number): void;
  74667. /**
  74668. * Sets edge distortion to 0
  74669. */
  74670. disableEdgeDistortion(): void;
  74671. /**
  74672. * Sets the FocusDistance amount
  74673. * @param amount amount of FocusDistance
  74674. */
  74675. setFocusDistance(amount: number): void;
  74676. /**
  74677. * Disables depth of field
  74678. */
  74679. disableDepthOfField(): void;
  74680. /**
  74681. * Sets the Aperture amount
  74682. * @param amount amount of Aperture
  74683. */
  74684. setAperture(amount: number): void;
  74685. /**
  74686. * Sets the DarkenOutOfFocus amount
  74687. * @param amount amount of DarkenOutOfFocus
  74688. */
  74689. setDarkenOutOfFocus(amount: number): void;
  74690. private _pentagonBokehIsEnabled;
  74691. /**
  74692. * Creates a pentagon bokeh effect
  74693. */
  74694. enablePentagonBokeh(): void;
  74695. /**
  74696. * Disables the pentagon bokeh effect
  74697. */
  74698. disablePentagonBokeh(): void;
  74699. /**
  74700. * Enables noise blur
  74701. */
  74702. enableNoiseBlur(): void;
  74703. /**
  74704. * Disables noise blur
  74705. */
  74706. disableNoiseBlur(): void;
  74707. /**
  74708. * Sets the HighlightsGain amount
  74709. * @param amount amount of HighlightsGain
  74710. */
  74711. setHighlightsGain(amount: number): void;
  74712. /**
  74713. * Sets the HighlightsThreshold amount
  74714. * @param amount amount of HighlightsThreshold
  74715. */
  74716. setHighlightsThreshold(amount: number): void;
  74717. /**
  74718. * Disables highlights
  74719. */
  74720. disableHighlights(): void;
  74721. /**
  74722. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74723. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74724. */
  74725. dispose(disableDepthRender?: boolean): void;
  74726. private _createChromaticAberrationPostProcess;
  74727. private _createHighlightsPostProcess;
  74728. private _createDepthOfFieldPostProcess;
  74729. private _createGrainTexture;
  74730. }
  74731. }
  74732. declare module "babylonjs/Shaders/ssao2.fragment" {
  74733. /** @hidden */
  74734. export var ssao2PixelShader: {
  74735. name: string;
  74736. shader: string;
  74737. };
  74738. }
  74739. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74740. /** @hidden */
  74741. export var ssaoCombinePixelShader: {
  74742. name: string;
  74743. shader: string;
  74744. };
  74745. }
  74746. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74747. import { Camera } from "babylonjs/Cameras/camera";
  74748. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74749. import { Scene } from "babylonjs/scene";
  74750. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74751. import "babylonjs/Shaders/ssao2.fragment";
  74752. import "babylonjs/Shaders/ssaoCombine.fragment";
  74753. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74754. /**
  74755. * Render pipeline to produce ssao effect
  74756. */
  74757. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74758. /**
  74759. * @ignore
  74760. * The PassPostProcess id in the pipeline that contains the original scene color
  74761. */
  74762. SSAOOriginalSceneColorEffect: string;
  74763. /**
  74764. * @ignore
  74765. * The SSAO PostProcess id in the pipeline
  74766. */
  74767. SSAORenderEffect: string;
  74768. /**
  74769. * @ignore
  74770. * The horizontal blur PostProcess id in the pipeline
  74771. */
  74772. SSAOBlurHRenderEffect: string;
  74773. /**
  74774. * @ignore
  74775. * The vertical blur PostProcess id in the pipeline
  74776. */
  74777. SSAOBlurVRenderEffect: string;
  74778. /**
  74779. * @ignore
  74780. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74781. */
  74782. SSAOCombineRenderEffect: string;
  74783. /**
  74784. * The output strength of the SSAO post-process. Default value is 1.0.
  74785. */
  74786. totalStrength: number;
  74787. /**
  74788. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74789. */
  74790. maxZ: number;
  74791. /**
  74792. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74793. */
  74794. minZAspect: number;
  74795. private _samples;
  74796. /**
  74797. * Number of samples used for the SSAO calculations. Default value is 8
  74798. */
  74799. set samples(n: number);
  74800. get samples(): number;
  74801. private _textureSamples;
  74802. /**
  74803. * Number of samples to use for antialiasing
  74804. */
  74805. set textureSamples(n: number);
  74806. get textureSamples(): number;
  74807. /**
  74808. * Force rendering the geometry through geometry buffer
  74809. */
  74810. private _forceGeometryBuffer;
  74811. /**
  74812. * Ratio object used for SSAO ratio and blur ratio
  74813. */
  74814. private _ratio;
  74815. /**
  74816. * Dynamically generated sphere sampler.
  74817. */
  74818. private _sampleSphere;
  74819. /**
  74820. * Blur filter offsets
  74821. */
  74822. private _samplerOffsets;
  74823. private _expensiveBlur;
  74824. /**
  74825. * If bilateral blur should be used
  74826. */
  74827. set expensiveBlur(b: boolean);
  74828. get expensiveBlur(): boolean;
  74829. /**
  74830. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74831. */
  74832. radius: number;
  74833. /**
  74834. * The base color of the SSAO post-process
  74835. * The final result is "base + ssao" between [0, 1]
  74836. */
  74837. base: number;
  74838. /**
  74839. * Support test.
  74840. */
  74841. static get IsSupported(): boolean;
  74842. private _scene;
  74843. private _randomTexture;
  74844. private _originalColorPostProcess;
  74845. private _ssaoPostProcess;
  74846. private _blurHPostProcess;
  74847. private _blurVPostProcess;
  74848. private _ssaoCombinePostProcess;
  74849. private _prePassRenderer;
  74850. /**
  74851. * Gets active scene
  74852. */
  74853. get scene(): Scene;
  74854. /**
  74855. * @constructor
  74856. * @param name The rendering pipeline name
  74857. * @param scene The scene linked to this pipeline
  74858. * @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 }
  74859. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74860. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74861. */
  74862. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74863. /**
  74864. * Get the class name
  74865. * @returns "SSAO2RenderingPipeline"
  74866. */
  74867. getClassName(): string;
  74868. /**
  74869. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74870. */
  74871. dispose(disableGeometryBufferRenderer?: boolean): void;
  74872. private _createBlurPostProcess;
  74873. /** @hidden */
  74874. _rebuild(): void;
  74875. private _bits;
  74876. private _radicalInverse_VdC;
  74877. private _hammersley;
  74878. private _hemisphereSample_uniform;
  74879. private _generateHemisphere;
  74880. private _getDefinesForSSAO;
  74881. private _createSSAOPostProcess;
  74882. private _createSSAOCombinePostProcess;
  74883. private _createRandomTexture;
  74884. /**
  74885. * Serialize the rendering pipeline (Used when exporting)
  74886. * @returns the serialized object
  74887. */
  74888. serialize(): any;
  74889. /**
  74890. * Parse the serialized pipeline
  74891. * @param source Source pipeline.
  74892. * @param scene The scene to load the pipeline to.
  74893. * @param rootUrl The URL of the serialized pipeline.
  74894. * @returns An instantiated pipeline from the serialized object.
  74895. */
  74896. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74897. /**
  74898. * Sets the required values to the prepass renderer.
  74899. * @param prePassRenderer defines the prepass renderer to setup
  74900. * @returns true if the pre pass is needed.
  74901. */
  74902. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74903. }
  74904. }
  74905. declare module "babylonjs/Shaders/ssao.fragment" {
  74906. /** @hidden */
  74907. export var ssaoPixelShader: {
  74908. name: string;
  74909. shader: string;
  74910. };
  74911. }
  74912. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74913. import { Camera } from "babylonjs/Cameras/camera";
  74914. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74915. import { Scene } from "babylonjs/scene";
  74916. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74917. import "babylonjs/Shaders/ssao.fragment";
  74918. import "babylonjs/Shaders/ssaoCombine.fragment";
  74919. /**
  74920. * Render pipeline to produce ssao effect
  74921. */
  74922. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74923. /**
  74924. * @ignore
  74925. * The PassPostProcess id in the pipeline that contains the original scene color
  74926. */
  74927. SSAOOriginalSceneColorEffect: string;
  74928. /**
  74929. * @ignore
  74930. * The SSAO PostProcess id in the pipeline
  74931. */
  74932. SSAORenderEffect: string;
  74933. /**
  74934. * @ignore
  74935. * The horizontal blur PostProcess id in the pipeline
  74936. */
  74937. SSAOBlurHRenderEffect: string;
  74938. /**
  74939. * @ignore
  74940. * The vertical blur PostProcess id in the pipeline
  74941. */
  74942. SSAOBlurVRenderEffect: string;
  74943. /**
  74944. * @ignore
  74945. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74946. */
  74947. SSAOCombineRenderEffect: string;
  74948. /**
  74949. * The output strength of the SSAO post-process. Default value is 1.0.
  74950. */
  74951. totalStrength: number;
  74952. /**
  74953. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74954. */
  74955. radius: number;
  74956. /**
  74957. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74958. * Must not be equal to fallOff and superior to fallOff.
  74959. * Default value is 0.0075
  74960. */
  74961. area: number;
  74962. /**
  74963. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74964. * Must not be equal to area and inferior to area.
  74965. * Default value is 0.000001
  74966. */
  74967. fallOff: number;
  74968. /**
  74969. * The base color of the SSAO post-process
  74970. * The final result is "base + ssao" between [0, 1]
  74971. */
  74972. base: number;
  74973. private _scene;
  74974. private _depthTexture;
  74975. private _randomTexture;
  74976. private _originalColorPostProcess;
  74977. private _ssaoPostProcess;
  74978. private _blurHPostProcess;
  74979. private _blurVPostProcess;
  74980. private _ssaoCombinePostProcess;
  74981. private _firstUpdate;
  74982. /**
  74983. * Gets active scene
  74984. */
  74985. get scene(): Scene;
  74986. /**
  74987. * @constructor
  74988. * @param name - The rendering pipeline name
  74989. * @param scene - The scene linked to this pipeline
  74990. * @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 }
  74991. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  74992. */
  74993. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  74994. /**
  74995. * Get the class name
  74996. * @returns "SSAORenderingPipeline"
  74997. */
  74998. getClassName(): string;
  74999. /**
  75000. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75001. */
  75002. dispose(disableDepthRender?: boolean): void;
  75003. private _createBlurPostProcess;
  75004. /** @hidden */
  75005. _rebuild(): void;
  75006. private _createSSAOPostProcess;
  75007. private _createSSAOCombinePostProcess;
  75008. private _createRandomTexture;
  75009. }
  75010. }
  75011. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75012. /** @hidden */
  75013. export var screenSpaceReflectionPixelShader: {
  75014. name: string;
  75015. shader: string;
  75016. };
  75017. }
  75018. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75019. import { Nullable } from "babylonjs/types";
  75020. import { Camera } from "babylonjs/Cameras/camera";
  75021. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75022. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75023. import { Engine } from "babylonjs/Engines/engine";
  75024. import { Scene } from "babylonjs/scene";
  75025. /**
  75026. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75027. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75028. */
  75029. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75030. /**
  75031. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75032. */
  75033. threshold: number;
  75034. /**
  75035. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75036. */
  75037. strength: number;
  75038. /**
  75039. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75040. */
  75041. reflectionSpecularFalloffExponent: number;
  75042. /**
  75043. * 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]
  75044. */
  75045. step: number;
  75046. /**
  75047. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75048. */
  75049. roughnessFactor: number;
  75050. private _geometryBufferRenderer;
  75051. private _enableSmoothReflections;
  75052. private _reflectionSamples;
  75053. private _smoothSteps;
  75054. /**
  75055. * Gets a string identifying the name of the class
  75056. * @returns "ScreenSpaceReflectionPostProcess" string
  75057. */
  75058. getClassName(): string;
  75059. /**
  75060. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75061. * @param name The name of the effect.
  75062. * @param scene The scene containing the objects to calculate reflections.
  75063. * @param options The required width/height ratio to downsize to before computing the render pass.
  75064. * @param camera The camera to apply the render pass to.
  75065. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75066. * @param engine The engine which the post process will be applied. (default: current engine)
  75067. * @param reusable If the post process can be reused on the same frame. (default: false)
  75068. * @param textureType Type of textures used when performing the post process. (default: 0)
  75069. * @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)
  75070. */
  75071. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75072. /**
  75073. * Gets wether or not smoothing reflections is enabled.
  75074. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75075. */
  75076. get enableSmoothReflections(): boolean;
  75077. /**
  75078. * Sets wether or not smoothing reflections is enabled.
  75079. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75080. */
  75081. set enableSmoothReflections(enabled: boolean);
  75082. /**
  75083. * Gets the number of samples taken while computing reflections. More samples count is high,
  75084. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75085. */
  75086. get reflectionSamples(): number;
  75087. /**
  75088. * Sets the number of samples taken while computing reflections. More samples count is high,
  75089. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75090. */
  75091. set reflectionSamples(samples: number);
  75092. /**
  75093. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75094. * more the post-process will require GPU power and can generate a drop in FPS.
  75095. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75096. */
  75097. get smoothSteps(): number;
  75098. set smoothSteps(steps: number);
  75099. private _updateEffectDefines;
  75100. /** @hidden */
  75101. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75102. }
  75103. }
  75104. declare module "babylonjs/Shaders/standard.fragment" {
  75105. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75106. /** @hidden */
  75107. export var standardPixelShader: {
  75108. name: string;
  75109. shader: string;
  75110. };
  75111. }
  75112. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75113. import { Nullable } from "babylonjs/types";
  75114. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75115. import { Camera } from "babylonjs/Cameras/camera";
  75116. import { Texture } from "babylonjs/Materials/Textures/texture";
  75117. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75118. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75119. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75120. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75121. import { IDisposable } from "babylonjs/scene";
  75122. import { SpotLight } from "babylonjs/Lights/spotLight";
  75123. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75124. import { Scene } from "babylonjs/scene";
  75125. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75126. import { Animation } from "babylonjs/Animations/animation";
  75127. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75128. import "babylonjs/Shaders/standard.fragment";
  75129. /**
  75130. * Standard rendering pipeline
  75131. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75132. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75133. */
  75134. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75135. /**
  75136. * Public members
  75137. */
  75138. /**
  75139. * Post-process which contains the original scene color before the pipeline applies all the effects
  75140. */
  75141. originalPostProcess: Nullable<PostProcess>;
  75142. /**
  75143. * Post-process used to down scale an image x4
  75144. */
  75145. downSampleX4PostProcess: Nullable<PostProcess>;
  75146. /**
  75147. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75148. */
  75149. brightPassPostProcess: Nullable<PostProcess>;
  75150. /**
  75151. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75152. */
  75153. blurHPostProcesses: PostProcess[];
  75154. /**
  75155. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75156. */
  75157. blurVPostProcesses: PostProcess[];
  75158. /**
  75159. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75160. */
  75161. textureAdderPostProcess: Nullable<PostProcess>;
  75162. /**
  75163. * Post-process used to create volumetric lighting effect
  75164. */
  75165. volumetricLightPostProcess: Nullable<PostProcess>;
  75166. /**
  75167. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75168. */
  75169. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75170. /**
  75171. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75172. */
  75173. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75174. /**
  75175. * Post-process used to merge the volumetric light effect and the real scene color
  75176. */
  75177. volumetricLightMergePostProces: Nullable<PostProcess>;
  75178. /**
  75179. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75180. */
  75181. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75182. /**
  75183. * Base post-process used to calculate the average luminance of the final image for HDR
  75184. */
  75185. luminancePostProcess: Nullable<PostProcess>;
  75186. /**
  75187. * Post-processes used to create down sample post-processes in order to get
  75188. * the average luminance of the final image for HDR
  75189. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75190. */
  75191. luminanceDownSamplePostProcesses: PostProcess[];
  75192. /**
  75193. * Post-process used to create a HDR effect (light adaptation)
  75194. */
  75195. hdrPostProcess: Nullable<PostProcess>;
  75196. /**
  75197. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75198. */
  75199. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75200. /**
  75201. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75202. */
  75203. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75204. /**
  75205. * Post-process used to merge the final HDR post-process and the real scene color
  75206. */
  75207. hdrFinalPostProcess: Nullable<PostProcess>;
  75208. /**
  75209. * Post-process used to create a lens flare effect
  75210. */
  75211. lensFlarePostProcess: Nullable<PostProcess>;
  75212. /**
  75213. * Post-process that merges the result of the lens flare post-process and the real scene color
  75214. */
  75215. lensFlareComposePostProcess: Nullable<PostProcess>;
  75216. /**
  75217. * Post-process used to create a motion blur effect
  75218. */
  75219. motionBlurPostProcess: Nullable<PostProcess>;
  75220. /**
  75221. * Post-process used to create a depth of field effect
  75222. */
  75223. depthOfFieldPostProcess: Nullable<PostProcess>;
  75224. /**
  75225. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75226. */
  75227. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75228. /**
  75229. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75230. */
  75231. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75232. /**
  75233. * Represents the brightness threshold in order to configure the illuminated surfaces
  75234. */
  75235. brightThreshold: number;
  75236. /**
  75237. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75238. */
  75239. blurWidth: number;
  75240. /**
  75241. * Sets if the blur for highlighted surfaces must be only horizontal
  75242. */
  75243. horizontalBlur: boolean;
  75244. /**
  75245. * Gets the overall exposure used by the pipeline
  75246. */
  75247. get exposure(): number;
  75248. /**
  75249. * Sets the overall exposure used by the pipeline
  75250. */
  75251. set exposure(value: number);
  75252. /**
  75253. * Texture used typically to simulate "dirty" on camera lens
  75254. */
  75255. lensTexture: Nullable<Texture>;
  75256. /**
  75257. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75258. */
  75259. volumetricLightCoefficient: number;
  75260. /**
  75261. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75262. */
  75263. volumetricLightPower: number;
  75264. /**
  75265. * Used the set the blur intensity to smooth the volumetric lights
  75266. */
  75267. volumetricLightBlurScale: number;
  75268. /**
  75269. * Light (spot or directional) used to generate the volumetric lights rays
  75270. * The source light must have a shadow generate so the pipeline can get its
  75271. * depth map
  75272. */
  75273. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75274. /**
  75275. * For eye adaptation, represents the minimum luminance the eye can see
  75276. */
  75277. hdrMinimumLuminance: number;
  75278. /**
  75279. * For eye adaptation, represents the decrease luminance speed
  75280. */
  75281. hdrDecreaseRate: number;
  75282. /**
  75283. * For eye adaptation, represents the increase luminance speed
  75284. */
  75285. hdrIncreaseRate: number;
  75286. /**
  75287. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75288. */
  75289. get hdrAutoExposure(): boolean;
  75290. /**
  75291. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75292. */
  75293. set hdrAutoExposure(value: boolean);
  75294. /**
  75295. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75296. */
  75297. lensColorTexture: Nullable<Texture>;
  75298. /**
  75299. * The overall strengh for the lens flare effect
  75300. */
  75301. lensFlareStrength: number;
  75302. /**
  75303. * Dispersion coefficient for lens flare ghosts
  75304. */
  75305. lensFlareGhostDispersal: number;
  75306. /**
  75307. * Main lens flare halo width
  75308. */
  75309. lensFlareHaloWidth: number;
  75310. /**
  75311. * Based on the lens distortion effect, defines how much the lens flare result
  75312. * is distorted
  75313. */
  75314. lensFlareDistortionStrength: number;
  75315. /**
  75316. * Configures the blur intensity used for for lens flare (halo)
  75317. */
  75318. lensFlareBlurWidth: number;
  75319. /**
  75320. * Lens star texture must be used to simulate rays on the flares and is available
  75321. * in the documentation
  75322. */
  75323. lensStarTexture: Nullable<Texture>;
  75324. /**
  75325. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75326. * flare effect by taking account of the dirt texture
  75327. */
  75328. lensFlareDirtTexture: Nullable<Texture>;
  75329. /**
  75330. * Represents the focal length for the depth of field effect
  75331. */
  75332. depthOfFieldDistance: number;
  75333. /**
  75334. * Represents the blur intensity for the blurred part of the depth of field effect
  75335. */
  75336. depthOfFieldBlurWidth: number;
  75337. /**
  75338. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75339. */
  75340. get motionStrength(): number;
  75341. /**
  75342. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75343. */
  75344. set motionStrength(strength: number);
  75345. /**
  75346. * Gets wether or not the motion blur post-process is object based or screen based.
  75347. */
  75348. get objectBasedMotionBlur(): boolean;
  75349. /**
  75350. * Sets wether or not the motion blur post-process should be object based or screen based
  75351. */
  75352. set objectBasedMotionBlur(value: boolean);
  75353. /**
  75354. * List of animations for the pipeline (IAnimatable implementation)
  75355. */
  75356. animations: Animation[];
  75357. /**
  75358. * Private members
  75359. */
  75360. private _scene;
  75361. private _currentDepthOfFieldSource;
  75362. private _basePostProcess;
  75363. private _fixedExposure;
  75364. private _currentExposure;
  75365. private _hdrAutoExposure;
  75366. private _hdrCurrentLuminance;
  75367. private _motionStrength;
  75368. private _isObjectBasedMotionBlur;
  75369. private _floatTextureType;
  75370. private _camerasToBeAttached;
  75371. private _ratio;
  75372. private _bloomEnabled;
  75373. private _depthOfFieldEnabled;
  75374. private _vlsEnabled;
  75375. private _lensFlareEnabled;
  75376. private _hdrEnabled;
  75377. private _motionBlurEnabled;
  75378. private _fxaaEnabled;
  75379. private _screenSpaceReflectionsEnabled;
  75380. private _motionBlurSamples;
  75381. private _volumetricLightStepsCount;
  75382. private _samples;
  75383. /**
  75384. * @ignore
  75385. * Specifies if the bloom pipeline is enabled
  75386. */
  75387. get BloomEnabled(): boolean;
  75388. set BloomEnabled(enabled: boolean);
  75389. /**
  75390. * @ignore
  75391. * Specifies if the depth of field pipeline is enabed
  75392. */
  75393. get DepthOfFieldEnabled(): boolean;
  75394. set DepthOfFieldEnabled(enabled: boolean);
  75395. /**
  75396. * @ignore
  75397. * Specifies if the lens flare pipeline is enabed
  75398. */
  75399. get LensFlareEnabled(): boolean;
  75400. set LensFlareEnabled(enabled: boolean);
  75401. /**
  75402. * @ignore
  75403. * Specifies if the HDR pipeline is enabled
  75404. */
  75405. get HDREnabled(): boolean;
  75406. set HDREnabled(enabled: boolean);
  75407. /**
  75408. * @ignore
  75409. * Specifies if the volumetric lights scattering effect is enabled
  75410. */
  75411. get VLSEnabled(): boolean;
  75412. set VLSEnabled(enabled: boolean);
  75413. /**
  75414. * @ignore
  75415. * Specifies if the motion blur effect is enabled
  75416. */
  75417. get MotionBlurEnabled(): boolean;
  75418. set MotionBlurEnabled(enabled: boolean);
  75419. /**
  75420. * Specifies if anti-aliasing is enabled
  75421. */
  75422. get fxaaEnabled(): boolean;
  75423. set fxaaEnabled(enabled: boolean);
  75424. /**
  75425. * Specifies if screen space reflections are enabled.
  75426. */
  75427. get screenSpaceReflectionsEnabled(): boolean;
  75428. set screenSpaceReflectionsEnabled(enabled: boolean);
  75429. /**
  75430. * Specifies the number of steps used to calculate the volumetric lights
  75431. * Typically in interval [50, 200]
  75432. */
  75433. get volumetricLightStepsCount(): number;
  75434. set volumetricLightStepsCount(count: number);
  75435. /**
  75436. * Specifies the number of samples used for the motion blur effect
  75437. * Typically in interval [16, 64]
  75438. */
  75439. get motionBlurSamples(): number;
  75440. set motionBlurSamples(samples: number);
  75441. /**
  75442. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75443. */
  75444. get samples(): number;
  75445. set samples(sampleCount: number);
  75446. /**
  75447. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75448. * @constructor
  75449. * @param name The rendering pipeline name
  75450. * @param scene The scene linked to this pipeline
  75451. * @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)
  75452. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75453. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75454. */
  75455. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75456. private _buildPipeline;
  75457. private _createDownSampleX4PostProcess;
  75458. private _createBrightPassPostProcess;
  75459. private _createBlurPostProcesses;
  75460. private _createTextureAdderPostProcess;
  75461. private _createVolumetricLightPostProcess;
  75462. private _createLuminancePostProcesses;
  75463. private _createHdrPostProcess;
  75464. private _createLensFlarePostProcess;
  75465. private _createDepthOfFieldPostProcess;
  75466. private _createMotionBlurPostProcess;
  75467. private _getDepthTexture;
  75468. private _disposePostProcesses;
  75469. /**
  75470. * Dispose of the pipeline and stop all post processes
  75471. */
  75472. dispose(): void;
  75473. /**
  75474. * Serialize the rendering pipeline (Used when exporting)
  75475. * @returns the serialized object
  75476. */
  75477. serialize(): any;
  75478. /**
  75479. * Parse the serialized pipeline
  75480. * @param source Source pipeline.
  75481. * @param scene The scene to load the pipeline to.
  75482. * @param rootUrl The URL of the serialized pipeline.
  75483. * @returns An instantiated pipeline from the serialized object.
  75484. */
  75485. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75486. /**
  75487. * Luminance steps
  75488. */
  75489. static LuminanceSteps: number;
  75490. }
  75491. }
  75492. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75493. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75494. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75495. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75496. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75497. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75498. }
  75499. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75500. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75501. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75502. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75503. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75504. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75505. }
  75506. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75507. /** @hidden */
  75508. export var stereoscopicInterlacePixelShader: {
  75509. name: string;
  75510. shader: string;
  75511. };
  75512. }
  75513. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75514. import { Camera } from "babylonjs/Cameras/camera";
  75515. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75516. import { Engine } from "babylonjs/Engines/engine";
  75517. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75518. /**
  75519. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75520. */
  75521. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75522. private _stepSize;
  75523. private _passedProcess;
  75524. /**
  75525. * Gets a string identifying the name of the class
  75526. * @returns "StereoscopicInterlacePostProcessI" string
  75527. */
  75528. getClassName(): string;
  75529. /**
  75530. * Initializes a StereoscopicInterlacePostProcessI
  75531. * @param name The name of the effect.
  75532. * @param rigCameras The rig cameras to be appled to the post process
  75533. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75534. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75535. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75536. * @param engine The engine which the post process will be applied. (default: current engine)
  75537. * @param reusable If the post process can be reused on the same frame. (default: false)
  75538. */
  75539. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75540. }
  75541. /**
  75542. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75543. */
  75544. export class StereoscopicInterlacePostProcess extends PostProcess {
  75545. private _stepSize;
  75546. private _passedProcess;
  75547. /**
  75548. * Gets a string identifying the name of the class
  75549. * @returns "StereoscopicInterlacePostProcess" string
  75550. */
  75551. getClassName(): string;
  75552. /**
  75553. * Initializes a StereoscopicInterlacePostProcess
  75554. * @param name The name of the effect.
  75555. * @param rigCameras The rig cameras to be appled to the post process
  75556. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75558. * @param engine The engine which the post process will be applied. (default: current engine)
  75559. * @param reusable If the post process can be reused on the same frame. (default: false)
  75560. */
  75561. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75562. }
  75563. }
  75564. declare module "babylonjs/Shaders/tonemap.fragment" {
  75565. /** @hidden */
  75566. export var tonemapPixelShader: {
  75567. name: string;
  75568. shader: string;
  75569. };
  75570. }
  75571. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75572. import { Camera } from "babylonjs/Cameras/camera";
  75573. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75574. import "babylonjs/Shaders/tonemap.fragment";
  75575. import { Engine } from "babylonjs/Engines/engine";
  75576. /** Defines operator used for tonemapping */
  75577. export enum TonemappingOperator {
  75578. /** Hable */
  75579. Hable = 0,
  75580. /** Reinhard */
  75581. Reinhard = 1,
  75582. /** HejiDawson */
  75583. HejiDawson = 2,
  75584. /** Photographic */
  75585. Photographic = 3
  75586. }
  75587. /**
  75588. * Defines a post process to apply tone mapping
  75589. */
  75590. export class TonemapPostProcess extends PostProcess {
  75591. private _operator;
  75592. /** Defines the required exposure adjustement */
  75593. exposureAdjustment: number;
  75594. /**
  75595. * Gets a string identifying the name of the class
  75596. * @returns "TonemapPostProcess" string
  75597. */
  75598. getClassName(): string;
  75599. /**
  75600. * Creates a new TonemapPostProcess
  75601. * @param name defines the name of the postprocess
  75602. * @param _operator defines the operator to use
  75603. * @param exposureAdjustment defines the required exposure adjustement
  75604. * @param camera defines the camera to use (can be null)
  75605. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75606. * @param engine defines the hosting engine (can be ignore if camera is set)
  75607. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75608. */
  75609. constructor(name: string, _operator: TonemappingOperator,
  75610. /** Defines the required exposure adjustement */
  75611. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75612. }
  75613. }
  75614. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75615. /** @hidden */
  75616. export var volumetricLightScatteringPixelShader: {
  75617. name: string;
  75618. shader: string;
  75619. };
  75620. }
  75621. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75622. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75623. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75624. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75625. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75626. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75627. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75628. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75629. /** @hidden */
  75630. export var volumetricLightScatteringPassVertexShader: {
  75631. name: string;
  75632. shader: string;
  75633. };
  75634. }
  75635. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75636. /** @hidden */
  75637. export var volumetricLightScatteringPassPixelShader: {
  75638. name: string;
  75639. shader: string;
  75640. };
  75641. }
  75642. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75643. import { Vector3 } from "babylonjs/Maths/math.vector";
  75644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75645. import { Mesh } from "babylonjs/Meshes/mesh";
  75646. import { Camera } from "babylonjs/Cameras/camera";
  75647. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75648. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75649. import { Scene } from "babylonjs/scene";
  75650. import "babylonjs/Meshes/Builders/planeBuilder";
  75651. import "babylonjs/Shaders/depth.vertex";
  75652. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75653. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75654. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75655. import { Engine } from "babylonjs/Engines/engine";
  75656. /**
  75657. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75658. */
  75659. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75660. private _volumetricLightScatteringPass;
  75661. private _volumetricLightScatteringRTT;
  75662. private _viewPort;
  75663. private _screenCoordinates;
  75664. private _cachedDefines;
  75665. /**
  75666. * If not undefined, the mesh position is computed from the attached node position
  75667. */
  75668. attachedNode: {
  75669. position: Vector3;
  75670. };
  75671. /**
  75672. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75673. */
  75674. customMeshPosition: Vector3;
  75675. /**
  75676. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75677. */
  75678. useCustomMeshPosition: boolean;
  75679. /**
  75680. * If the post-process should inverse the light scattering direction
  75681. */
  75682. invert: boolean;
  75683. /**
  75684. * The internal mesh used by the post-process
  75685. */
  75686. mesh: Mesh;
  75687. /**
  75688. * @hidden
  75689. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75690. */
  75691. get useDiffuseColor(): boolean;
  75692. set useDiffuseColor(useDiffuseColor: boolean);
  75693. /**
  75694. * Array containing the excluded meshes not rendered in the internal pass
  75695. */
  75696. excludedMeshes: AbstractMesh[];
  75697. /**
  75698. * Controls the overall intensity of the post-process
  75699. */
  75700. exposure: number;
  75701. /**
  75702. * Dissipates each sample's contribution in range [0, 1]
  75703. */
  75704. decay: number;
  75705. /**
  75706. * Controls the overall intensity of each sample
  75707. */
  75708. weight: number;
  75709. /**
  75710. * Controls the density of each sample
  75711. */
  75712. density: number;
  75713. /**
  75714. * @constructor
  75715. * @param name The post-process name
  75716. * @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)
  75717. * @param camera The camera that the post-process will be attached to
  75718. * @param mesh The mesh used to create the light scattering
  75719. * @param samples The post-process quality, default 100
  75720. * @param samplingModeThe post-process filtering mode
  75721. * @param engine The babylon engine
  75722. * @param reusable If the post-process is reusable
  75723. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75724. */
  75725. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75726. /**
  75727. * Returns the string "VolumetricLightScatteringPostProcess"
  75728. * @returns "VolumetricLightScatteringPostProcess"
  75729. */
  75730. getClassName(): string;
  75731. private _isReady;
  75732. /**
  75733. * Sets the new light position for light scattering effect
  75734. * @param position The new custom light position
  75735. */
  75736. setCustomMeshPosition(position: Vector3): void;
  75737. /**
  75738. * Returns the light position for light scattering effect
  75739. * @return Vector3 The custom light position
  75740. */
  75741. getCustomMeshPosition(): Vector3;
  75742. /**
  75743. * Disposes the internal assets and detaches the post-process from the camera
  75744. */
  75745. dispose(camera: Camera): void;
  75746. /**
  75747. * Returns the render target texture used by the post-process
  75748. * @return the render target texture used by the post-process
  75749. */
  75750. getPass(): RenderTargetTexture;
  75751. private _meshExcluded;
  75752. private _createPass;
  75753. private _updateMeshScreenCoordinates;
  75754. /**
  75755. * Creates a default mesh for the Volumeric Light Scattering post-process
  75756. * @param name The mesh name
  75757. * @param scene The scene where to create the mesh
  75758. * @return the default mesh
  75759. */
  75760. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75761. }
  75762. }
  75763. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75764. /** @hidden */
  75765. export var screenSpaceCurvaturePixelShader: {
  75766. name: string;
  75767. shader: string;
  75768. };
  75769. }
  75770. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75771. import { Nullable } from "babylonjs/types";
  75772. import { Camera } from "babylonjs/Cameras/camera";
  75773. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75774. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75775. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75776. import { Engine } from "babylonjs/Engines/engine";
  75777. import { Scene } from "babylonjs/scene";
  75778. /**
  75779. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75780. */
  75781. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75782. /**
  75783. * Defines how much ridge the curvature effect displays.
  75784. */
  75785. ridge: number;
  75786. /**
  75787. * Defines how much valley the curvature effect displays.
  75788. */
  75789. valley: number;
  75790. private _geometryBufferRenderer;
  75791. /**
  75792. * Gets a string identifying the name of the class
  75793. * @returns "ScreenSpaceCurvaturePostProcess" string
  75794. */
  75795. getClassName(): string;
  75796. /**
  75797. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75798. * @param name The name of the effect.
  75799. * @param scene The scene containing the objects to blur according to their velocity.
  75800. * @param options The required width/height ratio to downsize to before computing the render pass.
  75801. * @param camera The camera to apply the render pass to.
  75802. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75803. * @param engine The engine which the post process will be applied. (default: current engine)
  75804. * @param reusable If the post process can be reused on the same frame. (default: false)
  75805. * @param textureType Type of textures used when performing the post process. (default: 0)
  75806. * @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)
  75807. */
  75808. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75809. /**
  75810. * Support test.
  75811. */
  75812. static get IsSupported(): boolean;
  75813. /** @hidden */
  75814. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75815. }
  75816. }
  75817. declare module "babylonjs/PostProcesses/index" {
  75818. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75819. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75820. export * from "babylonjs/PostProcesses/bloomEffect";
  75821. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75822. export * from "babylonjs/PostProcesses/blurPostProcess";
  75823. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75824. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75825. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75826. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75827. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75828. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75829. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75830. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75831. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75832. export * from "babylonjs/PostProcesses/filterPostProcess";
  75833. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75834. export * from "babylonjs/PostProcesses/grainPostProcess";
  75835. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75836. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75837. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75838. export * from "babylonjs/PostProcesses/passPostProcess";
  75839. export * from "babylonjs/PostProcesses/postProcess";
  75840. export * from "babylonjs/PostProcesses/postProcessManager";
  75841. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75842. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75843. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75844. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75845. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75846. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75847. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75848. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75849. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75850. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75851. }
  75852. declare module "babylonjs/Probes/index" {
  75853. export * from "babylonjs/Probes/reflectionProbe";
  75854. }
  75855. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75856. import { Scene } from "babylonjs/scene";
  75857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75858. import { SmartArray } from "babylonjs/Misc/smartArray";
  75859. import { ISceneComponent } from "babylonjs/sceneComponent";
  75860. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75861. import "babylonjs/Meshes/Builders/boxBuilder";
  75862. import "babylonjs/Shaders/color.fragment";
  75863. import "babylonjs/Shaders/color.vertex";
  75864. import { Color3 } from "babylonjs/Maths/math.color";
  75865. import { Observable } from "babylonjs/Misc/observable";
  75866. module "babylonjs/scene" {
  75867. interface Scene {
  75868. /** @hidden (Backing field) */
  75869. _boundingBoxRenderer: BoundingBoxRenderer;
  75870. /** @hidden (Backing field) */
  75871. _forceShowBoundingBoxes: boolean;
  75872. /**
  75873. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75874. */
  75875. forceShowBoundingBoxes: boolean;
  75876. /**
  75877. * Gets the bounding box renderer associated with the scene
  75878. * @returns a BoundingBoxRenderer
  75879. */
  75880. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75881. }
  75882. }
  75883. module "babylonjs/Meshes/abstractMesh" {
  75884. interface AbstractMesh {
  75885. /** @hidden (Backing field) */
  75886. _showBoundingBox: boolean;
  75887. /**
  75888. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75889. */
  75890. showBoundingBox: boolean;
  75891. }
  75892. }
  75893. /**
  75894. * Component responsible of rendering the bounding box of the meshes in a scene.
  75895. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75896. */
  75897. export class BoundingBoxRenderer implements ISceneComponent {
  75898. /**
  75899. * The component name helpfull to identify the component in the list of scene components.
  75900. */
  75901. readonly name: string;
  75902. /**
  75903. * The scene the component belongs to.
  75904. */
  75905. scene: Scene;
  75906. /**
  75907. * Color of the bounding box lines placed in front of an object
  75908. */
  75909. frontColor: Color3;
  75910. /**
  75911. * Color of the bounding box lines placed behind an object
  75912. */
  75913. backColor: Color3;
  75914. /**
  75915. * Defines if the renderer should show the back lines or not
  75916. */
  75917. showBackLines: boolean;
  75918. /**
  75919. * Observable raised before rendering a bounding box
  75920. */
  75921. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75922. /**
  75923. * Observable raised after rendering a bounding box
  75924. */
  75925. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75926. /**
  75927. * @hidden
  75928. */
  75929. renderList: SmartArray<BoundingBox>;
  75930. private _colorShader;
  75931. private _vertexBuffers;
  75932. private _indexBuffer;
  75933. private _fillIndexBuffer;
  75934. private _fillIndexData;
  75935. /**
  75936. * Instantiates a new bounding box renderer in a scene.
  75937. * @param scene the scene the renderer renders in
  75938. */
  75939. constructor(scene: Scene);
  75940. /**
  75941. * Registers the component in a given scene
  75942. */
  75943. register(): void;
  75944. private _evaluateSubMesh;
  75945. private _activeMesh;
  75946. private _prepareRessources;
  75947. private _createIndexBuffer;
  75948. /**
  75949. * Rebuilds the elements related to this component in case of
  75950. * context lost for instance.
  75951. */
  75952. rebuild(): void;
  75953. /**
  75954. * @hidden
  75955. */
  75956. reset(): void;
  75957. /**
  75958. * Render the bounding boxes of a specific rendering group
  75959. * @param renderingGroupId defines the rendering group to render
  75960. */
  75961. render(renderingGroupId: number): void;
  75962. /**
  75963. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75964. * @param mesh Define the mesh to render the occlusion bounding box for
  75965. */
  75966. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  75967. /**
  75968. * Dispose and release the resources attached to this renderer.
  75969. */
  75970. dispose(): void;
  75971. }
  75972. }
  75973. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  75974. import { Nullable } from "babylonjs/types";
  75975. import { Scene } from "babylonjs/scene";
  75976. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  75977. import { Camera } from "babylonjs/Cameras/camera";
  75978. import { ISceneComponent } from "babylonjs/sceneComponent";
  75979. module "babylonjs/scene" {
  75980. interface Scene {
  75981. /** @hidden (Backing field) */
  75982. _depthRenderer: {
  75983. [id: string]: DepthRenderer;
  75984. };
  75985. /**
  75986. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  75987. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  75988. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  75989. * @returns the created depth renderer
  75990. */
  75991. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  75992. /**
  75993. * Disables a depth renderer for a given camera
  75994. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  75995. */
  75996. disableDepthRenderer(camera?: Nullable<Camera>): void;
  75997. }
  75998. }
  75999. /**
  76000. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76001. * in several rendering techniques.
  76002. */
  76003. export class DepthRendererSceneComponent implements ISceneComponent {
  76004. /**
  76005. * The component name helpfull to identify the component in the list of scene components.
  76006. */
  76007. readonly name: string;
  76008. /**
  76009. * The scene the component belongs to.
  76010. */
  76011. scene: Scene;
  76012. /**
  76013. * Creates a new instance of the component for the given scene
  76014. * @param scene Defines the scene to register the component in
  76015. */
  76016. constructor(scene: Scene);
  76017. /**
  76018. * Registers the component in a given scene
  76019. */
  76020. register(): void;
  76021. /**
  76022. * Rebuilds the elements related to this component in case of
  76023. * context lost for instance.
  76024. */
  76025. rebuild(): void;
  76026. /**
  76027. * Disposes the component and the associated ressources
  76028. */
  76029. dispose(): void;
  76030. private _gatherRenderTargets;
  76031. private _gatherActiveCameraRenderTargets;
  76032. }
  76033. }
  76034. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76035. import { Nullable } from "babylonjs/types";
  76036. import { Scene } from "babylonjs/scene";
  76037. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76038. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76039. import { AbstractScene } from "babylonjs/abstractScene";
  76040. module "babylonjs/abstractScene" {
  76041. interface AbstractScene {
  76042. /** @hidden (Backing field) */
  76043. _prePassRenderer: Nullable<PrePassRenderer>;
  76044. /**
  76045. * Gets or Sets the current prepass renderer associated to the scene.
  76046. */
  76047. prePassRenderer: Nullable<PrePassRenderer>;
  76048. /**
  76049. * Enables the prepass and associates it with the scene
  76050. * @returns the PrePassRenderer
  76051. */
  76052. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76053. /**
  76054. * Disables the prepass associated with the scene
  76055. */
  76056. disablePrePassRenderer(): void;
  76057. }
  76058. }
  76059. /**
  76060. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76061. * in several rendering techniques.
  76062. */
  76063. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  76064. /**
  76065. * The component name helpful to identify the component in the list of scene components.
  76066. */
  76067. readonly name: string;
  76068. /**
  76069. * The scene the component belongs to.
  76070. */
  76071. scene: Scene;
  76072. /**
  76073. * Creates a new instance of the component for the given scene
  76074. * @param scene Defines the scene to register the component in
  76075. */
  76076. constructor(scene: Scene);
  76077. /**
  76078. * Registers the component in a given scene
  76079. */
  76080. register(): void;
  76081. private _beforeCameraDraw;
  76082. private _afterCameraDraw;
  76083. private _beforeClearStage;
  76084. /**
  76085. * Serializes the component data to the specified json object
  76086. * @param serializationObject The object to serialize to
  76087. */
  76088. serialize(serializationObject: any): void;
  76089. /**
  76090. * Adds all the elements from the container to the scene
  76091. * @param container the container holding the elements
  76092. */
  76093. addFromContainer(container: AbstractScene): void;
  76094. /**
  76095. * Removes all the elements in the container from the scene
  76096. * @param container contains the elements to remove
  76097. * @param dispose if the removed element should be disposed (default: false)
  76098. */
  76099. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76100. /**
  76101. * Rebuilds the elements related to this component in case of
  76102. * context lost for instance.
  76103. */
  76104. rebuild(): void;
  76105. /**
  76106. * Disposes the component and the associated ressources
  76107. */
  76108. dispose(): void;
  76109. }
  76110. }
  76111. declare module "babylonjs/Shaders/outline.fragment" {
  76112. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76113. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76114. /** @hidden */
  76115. export var outlinePixelShader: {
  76116. name: string;
  76117. shader: string;
  76118. };
  76119. }
  76120. declare module "babylonjs/Shaders/outline.vertex" {
  76121. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76122. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76123. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76124. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76125. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76126. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76127. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76128. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76129. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76130. /** @hidden */
  76131. export var outlineVertexShader: {
  76132. name: string;
  76133. shader: string;
  76134. };
  76135. }
  76136. declare module "babylonjs/Rendering/outlineRenderer" {
  76137. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76138. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76139. import { Scene } from "babylonjs/scene";
  76140. import { ISceneComponent } from "babylonjs/sceneComponent";
  76141. import "babylonjs/Shaders/outline.fragment";
  76142. import "babylonjs/Shaders/outline.vertex";
  76143. module "babylonjs/scene" {
  76144. interface Scene {
  76145. /** @hidden */
  76146. _outlineRenderer: OutlineRenderer;
  76147. /**
  76148. * Gets the outline renderer associated with the scene
  76149. * @returns a OutlineRenderer
  76150. */
  76151. getOutlineRenderer(): OutlineRenderer;
  76152. }
  76153. }
  76154. module "babylonjs/Meshes/abstractMesh" {
  76155. interface AbstractMesh {
  76156. /** @hidden (Backing field) */
  76157. _renderOutline: boolean;
  76158. /**
  76159. * Gets or sets a boolean indicating if the outline must be rendered as well
  76160. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76161. */
  76162. renderOutline: boolean;
  76163. /** @hidden (Backing field) */
  76164. _renderOverlay: boolean;
  76165. /**
  76166. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76167. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76168. */
  76169. renderOverlay: boolean;
  76170. }
  76171. }
  76172. /**
  76173. * This class is responsible to draw bothe outline/overlay of meshes.
  76174. * It should not be used directly but through the available method on mesh.
  76175. */
  76176. export class OutlineRenderer implements ISceneComponent {
  76177. /**
  76178. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76179. */
  76180. private static _StencilReference;
  76181. /**
  76182. * The name of the component. Each component must have a unique name.
  76183. */
  76184. name: string;
  76185. /**
  76186. * The scene the component belongs to.
  76187. */
  76188. scene: Scene;
  76189. /**
  76190. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76191. */
  76192. zOffset: number;
  76193. private _engine;
  76194. private _effect;
  76195. private _cachedDefines;
  76196. private _savedDepthWrite;
  76197. /**
  76198. * Instantiates a new outline renderer. (There could be only one per scene).
  76199. * @param scene Defines the scene it belongs to
  76200. */
  76201. constructor(scene: Scene);
  76202. /**
  76203. * Register the component to one instance of a scene.
  76204. */
  76205. register(): void;
  76206. /**
  76207. * Rebuilds the elements related to this component in case of
  76208. * context lost for instance.
  76209. */
  76210. rebuild(): void;
  76211. /**
  76212. * Disposes the component and the associated ressources.
  76213. */
  76214. dispose(): void;
  76215. /**
  76216. * Renders the outline in the canvas.
  76217. * @param subMesh Defines the sumesh to render
  76218. * @param batch Defines the batch of meshes in case of instances
  76219. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76220. */
  76221. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76222. /**
  76223. * Returns whether or not the outline renderer is ready for a given submesh.
  76224. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76225. * @param subMesh Defines the submesh to check readyness for
  76226. * @param useInstances Defines wheter wee are trying to render instances or not
  76227. * @returns true if ready otherwise false
  76228. */
  76229. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76230. private _beforeRenderingMesh;
  76231. private _afterRenderingMesh;
  76232. }
  76233. }
  76234. declare module "babylonjs/Rendering/index" {
  76235. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76236. export * from "babylonjs/Rendering/depthRenderer";
  76237. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76238. export * from "babylonjs/Rendering/edgesRenderer";
  76239. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76240. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76241. export * from "babylonjs/Rendering/prePassRenderer";
  76242. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76243. export * from "babylonjs/Rendering/outlineRenderer";
  76244. export * from "babylonjs/Rendering/renderingGroup";
  76245. export * from "babylonjs/Rendering/renderingManager";
  76246. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76247. }
  76248. declare module "babylonjs/Sprites/ISprites" {
  76249. /**
  76250. * Defines the basic options interface of a Sprite Frame Source Size.
  76251. */
  76252. export interface ISpriteJSONSpriteSourceSize {
  76253. /**
  76254. * number of the original width of the Frame
  76255. */
  76256. w: number;
  76257. /**
  76258. * number of the original height of the Frame
  76259. */
  76260. h: number;
  76261. }
  76262. /**
  76263. * Defines the basic options interface of a Sprite Frame Data.
  76264. */
  76265. export interface ISpriteJSONSpriteFrameData {
  76266. /**
  76267. * number of the x offset of the Frame
  76268. */
  76269. x: number;
  76270. /**
  76271. * number of the y offset of the Frame
  76272. */
  76273. y: number;
  76274. /**
  76275. * number of the width of the Frame
  76276. */
  76277. w: number;
  76278. /**
  76279. * number of the height of the Frame
  76280. */
  76281. h: number;
  76282. }
  76283. /**
  76284. * Defines the basic options interface of a JSON Sprite.
  76285. */
  76286. export interface ISpriteJSONSprite {
  76287. /**
  76288. * string name of the Frame
  76289. */
  76290. filename: string;
  76291. /**
  76292. * ISpriteJSONSpriteFrame basic object of the frame data
  76293. */
  76294. frame: ISpriteJSONSpriteFrameData;
  76295. /**
  76296. * boolean to flag is the frame was rotated.
  76297. */
  76298. rotated: boolean;
  76299. /**
  76300. * boolean to flag is the frame was trimmed.
  76301. */
  76302. trimmed: boolean;
  76303. /**
  76304. * ISpriteJSONSpriteFrame basic object of the source data
  76305. */
  76306. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76307. /**
  76308. * ISpriteJSONSpriteFrame basic object of the source data
  76309. */
  76310. sourceSize: ISpriteJSONSpriteSourceSize;
  76311. }
  76312. /**
  76313. * Defines the basic options interface of a JSON atlas.
  76314. */
  76315. export interface ISpriteJSONAtlas {
  76316. /**
  76317. * Array of objects that contain the frame data.
  76318. */
  76319. frames: Array<ISpriteJSONSprite>;
  76320. /**
  76321. * object basic object containing the sprite meta data.
  76322. */
  76323. meta?: object;
  76324. }
  76325. }
  76326. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76327. /** @hidden */
  76328. export var spriteMapPixelShader: {
  76329. name: string;
  76330. shader: string;
  76331. };
  76332. }
  76333. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76334. /** @hidden */
  76335. export var spriteMapVertexShader: {
  76336. name: string;
  76337. shader: string;
  76338. };
  76339. }
  76340. declare module "babylonjs/Sprites/spriteMap" {
  76341. import { IDisposable, Scene } from "babylonjs/scene";
  76342. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76343. import { Texture } from "babylonjs/Materials/Textures/texture";
  76344. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76345. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76346. import "babylonjs/Meshes/Builders/planeBuilder";
  76347. import "babylonjs/Shaders/spriteMap.fragment";
  76348. import "babylonjs/Shaders/spriteMap.vertex";
  76349. /**
  76350. * Defines the basic options interface of a SpriteMap
  76351. */
  76352. export interface ISpriteMapOptions {
  76353. /**
  76354. * Vector2 of the number of cells in the grid.
  76355. */
  76356. stageSize?: Vector2;
  76357. /**
  76358. * Vector2 of the size of the output plane in World Units.
  76359. */
  76360. outputSize?: Vector2;
  76361. /**
  76362. * Vector3 of the position of the output plane in World Units.
  76363. */
  76364. outputPosition?: Vector3;
  76365. /**
  76366. * Vector3 of the rotation of the output plane.
  76367. */
  76368. outputRotation?: Vector3;
  76369. /**
  76370. * number of layers that the system will reserve in resources.
  76371. */
  76372. layerCount?: number;
  76373. /**
  76374. * number of max animation frames a single cell will reserve in resources.
  76375. */
  76376. maxAnimationFrames?: number;
  76377. /**
  76378. * number cell index of the base tile when the system compiles.
  76379. */
  76380. baseTile?: number;
  76381. /**
  76382. * boolean flip the sprite after its been repositioned by the framing data.
  76383. */
  76384. flipU?: boolean;
  76385. /**
  76386. * Vector3 scalar of the global RGB values of the SpriteMap.
  76387. */
  76388. colorMultiply?: Vector3;
  76389. }
  76390. /**
  76391. * Defines the IDisposable interface in order to be cleanable from resources.
  76392. */
  76393. export interface ISpriteMap extends IDisposable {
  76394. /**
  76395. * String name of the SpriteMap.
  76396. */
  76397. name: string;
  76398. /**
  76399. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76400. */
  76401. atlasJSON: ISpriteJSONAtlas;
  76402. /**
  76403. * Texture of the SpriteMap.
  76404. */
  76405. spriteSheet: Texture;
  76406. /**
  76407. * The parameters to initialize the SpriteMap with.
  76408. */
  76409. options: ISpriteMapOptions;
  76410. }
  76411. /**
  76412. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76413. */
  76414. export class SpriteMap implements ISpriteMap {
  76415. /** The Name of the spriteMap */
  76416. name: string;
  76417. /** The JSON file with the frame and meta data */
  76418. atlasJSON: ISpriteJSONAtlas;
  76419. /** The systems Sprite Sheet Texture */
  76420. spriteSheet: Texture;
  76421. /** Arguments passed with the Constructor */
  76422. options: ISpriteMapOptions;
  76423. /** Public Sprite Storage array, parsed from atlasJSON */
  76424. sprites: Array<ISpriteJSONSprite>;
  76425. /** Returns the Number of Sprites in the System */
  76426. get spriteCount(): number;
  76427. /** Returns the Position of Output Plane*/
  76428. get position(): Vector3;
  76429. /** Returns the Position of Output Plane*/
  76430. set position(v: Vector3);
  76431. /** Returns the Rotation of Output Plane*/
  76432. get rotation(): Vector3;
  76433. /** Returns the Rotation of Output Plane*/
  76434. set rotation(v: Vector3);
  76435. /** Sets the AnimationMap*/
  76436. get animationMap(): RawTexture;
  76437. /** Sets the AnimationMap*/
  76438. set animationMap(v: RawTexture);
  76439. /** Scene that the SpriteMap was created in */
  76440. private _scene;
  76441. /** Texture Buffer of Float32 that holds tile frame data*/
  76442. private _frameMap;
  76443. /** Texture Buffers of Float32 that holds tileMap data*/
  76444. private _tileMaps;
  76445. /** Texture Buffer of Float32 that holds Animation Data*/
  76446. private _animationMap;
  76447. /** Custom ShaderMaterial Central to the System*/
  76448. private _material;
  76449. /** Custom ShaderMaterial Central to the System*/
  76450. private _output;
  76451. /** Systems Time Ticker*/
  76452. private _time;
  76453. /**
  76454. * Creates a new SpriteMap
  76455. * @param name defines the SpriteMaps Name
  76456. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76457. * @param spriteSheet is the Texture that the Sprites are on.
  76458. * @param options a basic deployment configuration
  76459. * @param scene The Scene that the map is deployed on
  76460. */
  76461. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76462. /**
  76463. * Returns tileID location
  76464. * @returns Vector2 the cell position ID
  76465. */
  76466. getTileID(): Vector2;
  76467. /**
  76468. * Gets the UV location of the mouse over the SpriteMap.
  76469. * @returns Vector2 the UV position of the mouse interaction
  76470. */
  76471. getMousePosition(): Vector2;
  76472. /**
  76473. * Creates the "frame" texture Buffer
  76474. * -------------------------------------
  76475. * Structure of frames
  76476. * "filename": "Falling-Water-2.png",
  76477. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76478. * "rotated": true,
  76479. * "trimmed": true,
  76480. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76481. * "sourceSize": {"w":32,"h":32}
  76482. * @returns RawTexture of the frameMap
  76483. */
  76484. private _createFrameBuffer;
  76485. /**
  76486. * Creates the tileMap texture Buffer
  76487. * @param buffer normally and array of numbers, or a false to generate from scratch
  76488. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76489. * @returns RawTexture of the tileMap
  76490. */
  76491. private _createTileBuffer;
  76492. /**
  76493. * Modifies the data of the tileMaps
  76494. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76495. * @param pos is the iVector2 Coordinates of the Tile
  76496. * @param tile The SpriteIndex of the new Tile
  76497. */
  76498. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76499. /**
  76500. * Creates the animationMap texture Buffer
  76501. * @param buffer normally and array of numbers, or a false to generate from scratch
  76502. * @returns RawTexture of the animationMap
  76503. */
  76504. private _createTileAnimationBuffer;
  76505. /**
  76506. * Modifies the data of the animationMap
  76507. * @param cellID is the Index of the Sprite
  76508. * @param _frame is the target Animation frame
  76509. * @param toCell is the Target Index of the next frame of the animation
  76510. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76511. * @param speed is a global scalar of the time variable on the map.
  76512. */
  76513. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76514. /**
  76515. * Exports the .tilemaps file
  76516. */
  76517. saveTileMaps(): void;
  76518. /**
  76519. * Imports the .tilemaps file
  76520. * @param url of the .tilemaps file
  76521. */
  76522. loadTileMaps(url: string): void;
  76523. /**
  76524. * Release associated resources
  76525. */
  76526. dispose(): void;
  76527. }
  76528. }
  76529. declare module "babylonjs/Sprites/spritePackedManager" {
  76530. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  76531. import { Scene } from "babylonjs/scene";
  76532. /**
  76533. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76534. * @see https://doc.babylonjs.com/babylon101/sprites
  76535. */
  76536. export class SpritePackedManager extends SpriteManager {
  76537. /** defines the packed manager's name */
  76538. name: string;
  76539. /**
  76540. * Creates a new sprite manager from a packed sprite sheet
  76541. * @param name defines the manager's name
  76542. * @param imgUrl defines the sprite sheet url
  76543. * @param capacity defines the maximum allowed number of sprites
  76544. * @param scene defines the hosting scene
  76545. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76546. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76547. * @param samplingMode defines the smapling mode to use with spritesheet
  76548. * @param fromPacked set to true; do not alter
  76549. */
  76550. constructor(
  76551. /** defines the packed manager's name */
  76552. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76553. }
  76554. }
  76555. declare module "babylonjs/Sprites/index" {
  76556. export * from "babylonjs/Sprites/sprite";
  76557. export * from "babylonjs/Sprites/ISprites";
  76558. export * from "babylonjs/Sprites/spriteManager";
  76559. export * from "babylonjs/Sprites/spriteMap";
  76560. export * from "babylonjs/Sprites/spritePackedManager";
  76561. export * from "babylonjs/Sprites/spriteSceneComponent";
  76562. }
  76563. declare module "babylonjs/States/index" {
  76564. export * from "babylonjs/States/alphaCullingState";
  76565. export * from "babylonjs/States/depthCullingState";
  76566. export * from "babylonjs/States/stencilState";
  76567. }
  76568. declare module "babylonjs/Misc/assetsManager" {
  76569. import { Scene } from "babylonjs/scene";
  76570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76571. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76572. import { Skeleton } from "babylonjs/Bones/skeleton";
  76573. import { Observable } from "babylonjs/Misc/observable";
  76574. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  76575. import { Texture } from "babylonjs/Materials/Textures/texture";
  76576. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  76577. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  76578. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  76579. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  76580. import { AssetContainer } from "babylonjs/assetContainer";
  76581. /**
  76582. * Defines the list of states available for a task inside a AssetsManager
  76583. */
  76584. export enum AssetTaskState {
  76585. /**
  76586. * Initialization
  76587. */
  76588. INIT = 0,
  76589. /**
  76590. * Running
  76591. */
  76592. RUNNING = 1,
  76593. /**
  76594. * Done
  76595. */
  76596. DONE = 2,
  76597. /**
  76598. * Error
  76599. */
  76600. ERROR = 3
  76601. }
  76602. /**
  76603. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76604. */
  76605. export abstract class AbstractAssetTask {
  76606. /**
  76607. * Task name
  76608. */ name: string;
  76609. /**
  76610. * Callback called when the task is successful
  76611. */
  76612. onSuccess: (task: any) => void;
  76613. /**
  76614. * Callback called when the task is not successful
  76615. */
  76616. onError: (task: any, message?: string, exception?: any) => void;
  76617. /**
  76618. * Creates a new AssetsManager
  76619. * @param name defines the name of the task
  76620. */
  76621. constructor(
  76622. /**
  76623. * Task name
  76624. */ name: string);
  76625. private _isCompleted;
  76626. private _taskState;
  76627. private _errorObject;
  76628. /**
  76629. * Get if the task is completed
  76630. */
  76631. get isCompleted(): boolean;
  76632. /**
  76633. * Gets the current state of the task
  76634. */
  76635. get taskState(): AssetTaskState;
  76636. /**
  76637. * Gets the current error object (if task is in error)
  76638. */
  76639. get errorObject(): {
  76640. message?: string;
  76641. exception?: any;
  76642. };
  76643. /**
  76644. * Internal only
  76645. * @hidden
  76646. */
  76647. _setErrorObject(message?: string, exception?: any): void;
  76648. /**
  76649. * Execute the current task
  76650. * @param scene defines the scene where you want your assets to be loaded
  76651. * @param onSuccess is a callback called when the task is successfully executed
  76652. * @param onError is a callback called if an error occurs
  76653. */
  76654. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76655. /**
  76656. * Execute the current task
  76657. * @param scene defines the scene where you want your assets to be loaded
  76658. * @param onSuccess is a callback called when the task is successfully executed
  76659. * @param onError is a callback called if an error occurs
  76660. */
  76661. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76662. /**
  76663. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76664. * This can be used with failed tasks that have the reason for failure fixed.
  76665. */
  76666. reset(): void;
  76667. private onErrorCallback;
  76668. private onDoneCallback;
  76669. }
  76670. /**
  76671. * Define the interface used by progress events raised during assets loading
  76672. */
  76673. export interface IAssetsProgressEvent {
  76674. /**
  76675. * Defines the number of remaining tasks to process
  76676. */
  76677. remainingCount: number;
  76678. /**
  76679. * Defines the total number of tasks
  76680. */
  76681. totalCount: number;
  76682. /**
  76683. * Defines the task that was just processed
  76684. */
  76685. task: AbstractAssetTask;
  76686. }
  76687. /**
  76688. * Class used to share progress information about assets loading
  76689. */
  76690. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76691. /**
  76692. * Defines the number of remaining tasks to process
  76693. */
  76694. remainingCount: number;
  76695. /**
  76696. * Defines the total number of tasks
  76697. */
  76698. totalCount: number;
  76699. /**
  76700. * Defines the task that was just processed
  76701. */
  76702. task: AbstractAssetTask;
  76703. /**
  76704. * Creates a AssetsProgressEvent
  76705. * @param remainingCount defines the number of remaining tasks to process
  76706. * @param totalCount defines the total number of tasks
  76707. * @param task defines the task that was just processed
  76708. */
  76709. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76710. }
  76711. /**
  76712. * Define a task used by AssetsManager to load assets into a container
  76713. */
  76714. export class ContainerAssetTask extends AbstractAssetTask {
  76715. /**
  76716. * Defines the name of the task
  76717. */
  76718. name: string;
  76719. /**
  76720. * Defines the list of mesh's names you want to load
  76721. */
  76722. meshesNames: any;
  76723. /**
  76724. * Defines the root url to use as a base to load your meshes and associated resources
  76725. */
  76726. rootUrl: string;
  76727. /**
  76728. * Defines the filename or File of the scene to load from
  76729. */
  76730. sceneFilename: string | File;
  76731. /**
  76732. * Get the loaded asset container
  76733. */
  76734. loadedContainer: AssetContainer;
  76735. /**
  76736. * Gets the list of loaded meshes
  76737. */
  76738. loadedMeshes: Array<AbstractMesh>;
  76739. /**
  76740. * Gets the list of loaded particle systems
  76741. */
  76742. loadedParticleSystems: Array<IParticleSystem>;
  76743. /**
  76744. * Gets the list of loaded skeletons
  76745. */
  76746. loadedSkeletons: Array<Skeleton>;
  76747. /**
  76748. * Gets the list of loaded animation groups
  76749. */
  76750. loadedAnimationGroups: Array<AnimationGroup>;
  76751. /**
  76752. * Callback called when the task is successful
  76753. */
  76754. onSuccess: (task: ContainerAssetTask) => void;
  76755. /**
  76756. * Callback called when the task is successful
  76757. */
  76758. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76759. /**
  76760. * Creates a new ContainerAssetTask
  76761. * @param name defines the name of the task
  76762. * @param meshesNames defines the list of mesh's names you want to load
  76763. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76764. * @param sceneFilename defines the filename or File of the scene to load from
  76765. */
  76766. constructor(
  76767. /**
  76768. * Defines the name of the task
  76769. */
  76770. name: string,
  76771. /**
  76772. * Defines the list of mesh's names you want to load
  76773. */
  76774. meshesNames: any,
  76775. /**
  76776. * Defines the root url to use as a base to load your meshes and associated resources
  76777. */
  76778. rootUrl: string,
  76779. /**
  76780. * Defines the filename or File of the scene to load from
  76781. */
  76782. sceneFilename: string | File);
  76783. /**
  76784. * Execute the current task
  76785. * @param scene defines the scene where you want your assets to be loaded
  76786. * @param onSuccess is a callback called when the task is successfully executed
  76787. * @param onError is a callback called if an error occurs
  76788. */
  76789. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76790. }
  76791. /**
  76792. * Define a task used by AssetsManager to load meshes
  76793. */
  76794. export class MeshAssetTask extends AbstractAssetTask {
  76795. /**
  76796. * Defines the name of the task
  76797. */
  76798. name: string;
  76799. /**
  76800. * Defines the list of mesh's names you want to load
  76801. */
  76802. meshesNames: any;
  76803. /**
  76804. * Defines the root url to use as a base to load your meshes and associated resources
  76805. */
  76806. rootUrl: string;
  76807. /**
  76808. * Defines the filename or File of the scene to load from
  76809. */
  76810. sceneFilename: string | File;
  76811. /**
  76812. * Gets the list of loaded meshes
  76813. */
  76814. loadedMeshes: Array<AbstractMesh>;
  76815. /**
  76816. * Gets the list of loaded particle systems
  76817. */
  76818. loadedParticleSystems: Array<IParticleSystem>;
  76819. /**
  76820. * Gets the list of loaded skeletons
  76821. */
  76822. loadedSkeletons: Array<Skeleton>;
  76823. /**
  76824. * Gets the list of loaded animation groups
  76825. */
  76826. loadedAnimationGroups: Array<AnimationGroup>;
  76827. /**
  76828. * Callback called when the task is successful
  76829. */
  76830. onSuccess: (task: MeshAssetTask) => void;
  76831. /**
  76832. * Callback called when the task is successful
  76833. */
  76834. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  76835. /**
  76836. * Creates a new MeshAssetTask
  76837. * @param name defines the name of the task
  76838. * @param meshesNames defines the list of mesh's names you want to load
  76839. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76840. * @param sceneFilename defines the filename or File of the scene to load from
  76841. */
  76842. constructor(
  76843. /**
  76844. * Defines the name of the task
  76845. */
  76846. name: string,
  76847. /**
  76848. * Defines the list of mesh's names you want to load
  76849. */
  76850. meshesNames: any,
  76851. /**
  76852. * Defines the root url to use as a base to load your meshes and associated resources
  76853. */
  76854. rootUrl: string,
  76855. /**
  76856. * Defines the filename or File of the scene to load from
  76857. */
  76858. sceneFilename: string | File);
  76859. /**
  76860. * Execute the current task
  76861. * @param scene defines the scene where you want your assets to be loaded
  76862. * @param onSuccess is a callback called when the task is successfully executed
  76863. * @param onError is a callback called if an error occurs
  76864. */
  76865. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76866. }
  76867. /**
  76868. * Define a task used by AssetsManager to load text content
  76869. */
  76870. export class TextFileAssetTask extends AbstractAssetTask {
  76871. /**
  76872. * Defines the name of the task
  76873. */
  76874. name: string;
  76875. /**
  76876. * Defines the location of the file to load
  76877. */
  76878. url: string;
  76879. /**
  76880. * Gets the loaded text string
  76881. */
  76882. text: string;
  76883. /**
  76884. * Callback called when the task is successful
  76885. */
  76886. onSuccess: (task: TextFileAssetTask) => void;
  76887. /**
  76888. * Callback called when the task is successful
  76889. */
  76890. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  76891. /**
  76892. * Creates a new TextFileAssetTask object
  76893. * @param name defines the name of the task
  76894. * @param url defines the location of the file to load
  76895. */
  76896. constructor(
  76897. /**
  76898. * Defines the name of the task
  76899. */
  76900. name: string,
  76901. /**
  76902. * Defines the location of the file to load
  76903. */
  76904. url: string);
  76905. /**
  76906. * Execute the current task
  76907. * @param scene defines the scene where you want your assets to be loaded
  76908. * @param onSuccess is a callback called when the task is successfully executed
  76909. * @param onError is a callback called if an error occurs
  76910. */
  76911. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76912. }
  76913. /**
  76914. * Define a task used by AssetsManager to load binary data
  76915. */
  76916. export class BinaryFileAssetTask extends AbstractAssetTask {
  76917. /**
  76918. * Defines the name of the task
  76919. */
  76920. name: string;
  76921. /**
  76922. * Defines the location of the file to load
  76923. */
  76924. url: string;
  76925. /**
  76926. * Gets the lodaded data (as an array buffer)
  76927. */
  76928. data: ArrayBuffer;
  76929. /**
  76930. * Callback called when the task is successful
  76931. */
  76932. onSuccess: (task: BinaryFileAssetTask) => void;
  76933. /**
  76934. * Callback called when the task is successful
  76935. */
  76936. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  76937. /**
  76938. * Creates a new BinaryFileAssetTask object
  76939. * @param name defines the name of the new task
  76940. * @param url defines the location of the file to load
  76941. */
  76942. constructor(
  76943. /**
  76944. * Defines the name of the task
  76945. */
  76946. name: string,
  76947. /**
  76948. * Defines the location of the file to load
  76949. */
  76950. url: string);
  76951. /**
  76952. * Execute the current task
  76953. * @param scene defines the scene where you want your assets to be loaded
  76954. * @param onSuccess is a callback called when the task is successfully executed
  76955. * @param onError is a callback called if an error occurs
  76956. */
  76957. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76958. }
  76959. /**
  76960. * Define a task used by AssetsManager to load images
  76961. */
  76962. export class ImageAssetTask extends AbstractAssetTask {
  76963. /**
  76964. * Defines the name of the task
  76965. */
  76966. name: string;
  76967. /**
  76968. * Defines the location of the image to load
  76969. */
  76970. url: string;
  76971. /**
  76972. * Gets the loaded images
  76973. */
  76974. image: HTMLImageElement;
  76975. /**
  76976. * Callback called when the task is successful
  76977. */
  76978. onSuccess: (task: ImageAssetTask) => void;
  76979. /**
  76980. * Callback called when the task is successful
  76981. */
  76982. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  76983. /**
  76984. * Creates a new ImageAssetTask
  76985. * @param name defines the name of the task
  76986. * @param url defines the location of the image to load
  76987. */
  76988. constructor(
  76989. /**
  76990. * Defines the name of the task
  76991. */
  76992. name: string,
  76993. /**
  76994. * Defines the location of the image to load
  76995. */
  76996. url: string);
  76997. /**
  76998. * Execute the current task
  76999. * @param scene defines the scene where you want your assets to be loaded
  77000. * @param onSuccess is a callback called when the task is successfully executed
  77001. * @param onError is a callback called if an error occurs
  77002. */
  77003. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77004. }
  77005. /**
  77006. * Defines the interface used by texture loading tasks
  77007. */
  77008. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77009. /**
  77010. * Gets the loaded texture
  77011. */
  77012. texture: TEX;
  77013. }
  77014. /**
  77015. * Define a task used by AssetsManager to load 2D textures
  77016. */
  77017. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77018. /**
  77019. * Defines the name of the task
  77020. */
  77021. name: string;
  77022. /**
  77023. * Defines the location of the file to load
  77024. */
  77025. url: string;
  77026. /**
  77027. * Defines if mipmap should not be generated (default is false)
  77028. */
  77029. noMipmap?: boolean | undefined;
  77030. /**
  77031. * Defines if texture must be inverted on Y axis (default is true)
  77032. */
  77033. invertY: boolean;
  77034. /**
  77035. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77036. */
  77037. samplingMode: number;
  77038. /**
  77039. * Gets the loaded texture
  77040. */
  77041. texture: Texture;
  77042. /**
  77043. * Callback called when the task is successful
  77044. */
  77045. onSuccess: (task: TextureAssetTask) => void;
  77046. /**
  77047. * Callback called when the task is successful
  77048. */
  77049. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77050. /**
  77051. * Creates a new TextureAssetTask object
  77052. * @param name defines the name of the task
  77053. * @param url defines the location of the file to load
  77054. * @param noMipmap defines if mipmap should not be generated (default is false)
  77055. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77056. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77057. */
  77058. constructor(
  77059. /**
  77060. * Defines the name of the task
  77061. */
  77062. name: string,
  77063. /**
  77064. * Defines the location of the file to load
  77065. */
  77066. url: string,
  77067. /**
  77068. * Defines if mipmap should not be generated (default is false)
  77069. */
  77070. noMipmap?: boolean | undefined,
  77071. /**
  77072. * Defines if texture must be inverted on Y axis (default is true)
  77073. */
  77074. invertY?: boolean,
  77075. /**
  77076. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77077. */
  77078. samplingMode?: number);
  77079. /**
  77080. * Execute the current task
  77081. * @param scene defines the scene where you want your assets to be loaded
  77082. * @param onSuccess is a callback called when the task is successfully executed
  77083. * @param onError is a callback called if an error occurs
  77084. */
  77085. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77086. }
  77087. /**
  77088. * Define a task used by AssetsManager to load cube textures
  77089. */
  77090. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77091. /**
  77092. * Defines the name of the task
  77093. */
  77094. name: string;
  77095. /**
  77096. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77097. */
  77098. url: string;
  77099. /**
  77100. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77101. */
  77102. extensions?: string[] | undefined;
  77103. /**
  77104. * Defines if mipmaps should not be generated (default is false)
  77105. */
  77106. noMipmap?: boolean | undefined;
  77107. /**
  77108. * Defines the explicit list of files (undefined by default)
  77109. */
  77110. files?: string[] | undefined;
  77111. /**
  77112. * Gets the loaded texture
  77113. */
  77114. texture: CubeTexture;
  77115. /**
  77116. * Callback called when the task is successful
  77117. */
  77118. onSuccess: (task: CubeTextureAssetTask) => void;
  77119. /**
  77120. * Callback called when the task is successful
  77121. */
  77122. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77123. /**
  77124. * Creates a new CubeTextureAssetTask
  77125. * @param name defines the name of the task
  77126. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77127. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77128. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77129. * @param files defines the explicit list of files (undefined by default)
  77130. */
  77131. constructor(
  77132. /**
  77133. * Defines the name of the task
  77134. */
  77135. name: string,
  77136. /**
  77137. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77138. */
  77139. url: string,
  77140. /**
  77141. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77142. */
  77143. extensions?: string[] | undefined,
  77144. /**
  77145. * Defines if mipmaps should not be generated (default is false)
  77146. */
  77147. noMipmap?: boolean | undefined,
  77148. /**
  77149. * Defines the explicit list of files (undefined by default)
  77150. */
  77151. files?: string[] | undefined);
  77152. /**
  77153. * Execute the current task
  77154. * @param scene defines the scene where you want your assets to be loaded
  77155. * @param onSuccess is a callback called when the task is successfully executed
  77156. * @param onError is a callback called if an error occurs
  77157. */
  77158. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77159. }
  77160. /**
  77161. * Define a task used by AssetsManager to load HDR cube textures
  77162. */
  77163. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77164. /**
  77165. * Defines the name of the task
  77166. */
  77167. name: string;
  77168. /**
  77169. * Defines the location of the file to load
  77170. */
  77171. url: string;
  77172. /**
  77173. * Defines the desired size (the more it increases the longer the generation will be)
  77174. */
  77175. size: number;
  77176. /**
  77177. * Defines if mipmaps should not be generated (default is false)
  77178. */
  77179. noMipmap: boolean;
  77180. /**
  77181. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77182. */
  77183. generateHarmonics: boolean;
  77184. /**
  77185. * 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)
  77186. */
  77187. gammaSpace: boolean;
  77188. /**
  77189. * Internal Use Only
  77190. */
  77191. reserved: boolean;
  77192. /**
  77193. * Gets the loaded texture
  77194. */
  77195. texture: HDRCubeTexture;
  77196. /**
  77197. * Callback called when the task is successful
  77198. */
  77199. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77200. /**
  77201. * Callback called when the task is successful
  77202. */
  77203. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77204. /**
  77205. * Creates a new HDRCubeTextureAssetTask object
  77206. * @param name defines the name of the task
  77207. * @param url defines the location of the file to load
  77208. * @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.
  77209. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77210. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77211. * @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)
  77212. * @param reserved Internal use only
  77213. */
  77214. constructor(
  77215. /**
  77216. * Defines the name of the task
  77217. */
  77218. name: string,
  77219. /**
  77220. * Defines the location of the file to load
  77221. */
  77222. url: string,
  77223. /**
  77224. * Defines the desired size (the more it increases the longer the generation will be)
  77225. */
  77226. size: number,
  77227. /**
  77228. * Defines if mipmaps should not be generated (default is false)
  77229. */
  77230. noMipmap?: boolean,
  77231. /**
  77232. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77233. */
  77234. generateHarmonics?: boolean,
  77235. /**
  77236. * 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)
  77237. */
  77238. gammaSpace?: boolean,
  77239. /**
  77240. * Internal Use Only
  77241. */
  77242. reserved?: boolean);
  77243. /**
  77244. * Execute the current task
  77245. * @param scene defines the scene where you want your assets to be loaded
  77246. * @param onSuccess is a callback called when the task is successfully executed
  77247. * @param onError is a callback called if an error occurs
  77248. */
  77249. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77250. }
  77251. /**
  77252. * Define a task used by AssetsManager to load Equirectangular cube textures
  77253. */
  77254. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77255. /**
  77256. * Defines the name of the task
  77257. */
  77258. name: string;
  77259. /**
  77260. * Defines the location of the file to load
  77261. */
  77262. url: string;
  77263. /**
  77264. * Defines the desired size (the more it increases the longer the generation will be)
  77265. */
  77266. size: number;
  77267. /**
  77268. * Defines if mipmaps should not be generated (default is false)
  77269. */
  77270. noMipmap: boolean;
  77271. /**
  77272. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77273. * but the standard material would require them in Gamma space) (default is true)
  77274. */
  77275. gammaSpace: boolean;
  77276. /**
  77277. * Gets the loaded texture
  77278. */
  77279. texture: EquiRectangularCubeTexture;
  77280. /**
  77281. * Callback called when the task is successful
  77282. */
  77283. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77284. /**
  77285. * Callback called when the task is successful
  77286. */
  77287. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77288. /**
  77289. * Creates a new EquiRectangularCubeTextureAssetTask object
  77290. * @param name defines the name of the task
  77291. * @param url defines the location of the file to load
  77292. * @param size defines the desired size (the more it increases the longer the generation will be)
  77293. * If the size is omitted this implies you are using a preprocessed cubemap.
  77294. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77295. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77296. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77297. * (default is true)
  77298. */
  77299. constructor(
  77300. /**
  77301. * Defines the name of the task
  77302. */
  77303. name: string,
  77304. /**
  77305. * Defines the location of the file to load
  77306. */
  77307. url: string,
  77308. /**
  77309. * Defines the desired size (the more it increases the longer the generation will be)
  77310. */
  77311. size: number,
  77312. /**
  77313. * Defines if mipmaps should not be generated (default is false)
  77314. */
  77315. noMipmap?: boolean,
  77316. /**
  77317. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77318. * but the standard material would require them in Gamma space) (default is true)
  77319. */
  77320. gammaSpace?: boolean);
  77321. /**
  77322. * Execute the current task
  77323. * @param scene defines the scene where you want your assets to be loaded
  77324. * @param onSuccess is a callback called when the task is successfully executed
  77325. * @param onError is a callback called if an error occurs
  77326. */
  77327. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77328. }
  77329. /**
  77330. * This class can be used to easily import assets into a scene
  77331. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77332. */
  77333. export class AssetsManager {
  77334. private _scene;
  77335. private _isLoading;
  77336. protected _tasks: AbstractAssetTask[];
  77337. protected _waitingTasksCount: number;
  77338. protected _totalTasksCount: number;
  77339. /**
  77340. * Callback called when all tasks are processed
  77341. */
  77342. onFinish: (tasks: AbstractAssetTask[]) => void;
  77343. /**
  77344. * Callback called when a task is successful
  77345. */
  77346. onTaskSuccess: (task: AbstractAssetTask) => void;
  77347. /**
  77348. * Callback called when a task had an error
  77349. */
  77350. onTaskError: (task: AbstractAssetTask) => void;
  77351. /**
  77352. * Callback called when a task is done (whatever the result is)
  77353. */
  77354. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77355. /**
  77356. * Observable called when all tasks are processed
  77357. */
  77358. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77359. /**
  77360. * Observable called when a task had an error
  77361. */
  77362. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77363. /**
  77364. * Observable called when all tasks were executed
  77365. */
  77366. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77367. /**
  77368. * Observable called when a task is done (whatever the result is)
  77369. */
  77370. onProgressObservable: Observable<IAssetsProgressEvent>;
  77371. /**
  77372. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77373. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77374. */
  77375. useDefaultLoadingScreen: boolean;
  77376. /**
  77377. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77378. * when all assets have been downloaded.
  77379. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77380. */
  77381. autoHideLoadingUI: boolean;
  77382. /**
  77383. * Creates a new AssetsManager
  77384. * @param scene defines the scene to work on
  77385. */
  77386. constructor(scene: Scene);
  77387. /**
  77388. * Add a ContainerAssetTask to the list of active tasks
  77389. * @param taskName defines the name of the new task
  77390. * @param meshesNames defines the name of meshes to load
  77391. * @param rootUrl defines the root url to use to locate files
  77392. * @param sceneFilename defines the filename of the scene file
  77393. * @returns a new ContainerAssetTask object
  77394. */
  77395. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77396. /**
  77397. * Add a MeshAssetTask to the list of active tasks
  77398. * @param taskName defines the name of the new task
  77399. * @param meshesNames defines the name of meshes to load
  77400. * @param rootUrl defines the root url to use to locate files
  77401. * @param sceneFilename defines the filename of the scene file
  77402. * @returns a new MeshAssetTask object
  77403. */
  77404. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77405. /**
  77406. * Add a TextFileAssetTask to the list of active tasks
  77407. * @param taskName defines the name of the new task
  77408. * @param url defines the url of the file to load
  77409. * @returns a new TextFileAssetTask object
  77410. */
  77411. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77412. /**
  77413. * Add a BinaryFileAssetTask to the list of active tasks
  77414. * @param taskName defines the name of the new task
  77415. * @param url defines the url of the file to load
  77416. * @returns a new BinaryFileAssetTask object
  77417. */
  77418. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77419. /**
  77420. * Add a ImageAssetTask to the list of active tasks
  77421. * @param taskName defines the name of the new task
  77422. * @param url defines the url of the file to load
  77423. * @returns a new ImageAssetTask object
  77424. */
  77425. addImageTask(taskName: string, url: string): ImageAssetTask;
  77426. /**
  77427. * Add a TextureAssetTask to the list of active tasks
  77428. * @param taskName defines the name of the new task
  77429. * @param url defines the url of the file to load
  77430. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77431. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77432. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77433. * @returns a new TextureAssetTask object
  77434. */
  77435. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77436. /**
  77437. * Add a CubeTextureAssetTask to the list of active tasks
  77438. * @param taskName defines the name of the new task
  77439. * @param url defines the url of the file to load
  77440. * @param extensions defines the extension to use to load the cube map (can be null)
  77441. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77442. * @param files defines the list of files to load (can be null)
  77443. * @returns a new CubeTextureAssetTask object
  77444. */
  77445. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77446. /**
  77447. *
  77448. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77449. * @param taskName defines the name of the new task
  77450. * @param url defines the url of the file to load
  77451. * @param size defines the size you want for the cubemap (can be null)
  77452. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77453. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77454. * @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)
  77455. * @param reserved Internal use only
  77456. * @returns a new HDRCubeTextureAssetTask object
  77457. */
  77458. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77459. /**
  77460. *
  77461. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77462. * @param taskName defines the name of the new task
  77463. * @param url defines the url of the file to load
  77464. * @param size defines the size you want for the cubemap (can be null)
  77465. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77466. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77467. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77468. * @returns a new EquiRectangularCubeTextureAssetTask object
  77469. */
  77470. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77471. /**
  77472. * Remove a task from the assets manager.
  77473. * @param task the task to remove
  77474. */
  77475. removeTask(task: AbstractAssetTask): void;
  77476. private _decreaseWaitingTasksCount;
  77477. private _runTask;
  77478. /**
  77479. * Reset the AssetsManager and remove all tasks
  77480. * @return the current instance of the AssetsManager
  77481. */
  77482. reset(): AssetsManager;
  77483. /**
  77484. * Start the loading process
  77485. * @return the current instance of the AssetsManager
  77486. */
  77487. load(): AssetsManager;
  77488. /**
  77489. * Start the loading process as an async operation
  77490. * @return a promise returning the list of failed tasks
  77491. */
  77492. loadAsync(): Promise<void>;
  77493. }
  77494. }
  77495. declare module "babylonjs/Misc/deferred" {
  77496. /**
  77497. * Wrapper class for promise with external resolve and reject.
  77498. */
  77499. export class Deferred<T> {
  77500. /**
  77501. * The promise associated with this deferred object.
  77502. */
  77503. readonly promise: Promise<T>;
  77504. private _resolve;
  77505. private _reject;
  77506. /**
  77507. * The resolve method of the promise associated with this deferred object.
  77508. */
  77509. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  77510. /**
  77511. * The reject method of the promise associated with this deferred object.
  77512. */
  77513. get reject(): (reason?: any) => void;
  77514. /**
  77515. * Constructor for this deferred object.
  77516. */
  77517. constructor();
  77518. }
  77519. }
  77520. declare module "babylonjs/Misc/meshExploder" {
  77521. import { Mesh } from "babylonjs/Meshes/mesh";
  77522. /**
  77523. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77524. */
  77525. export class MeshExploder {
  77526. private _centerMesh;
  77527. private _meshes;
  77528. private _meshesOrigins;
  77529. private _toCenterVectors;
  77530. private _scaledDirection;
  77531. private _newPosition;
  77532. private _centerPosition;
  77533. /**
  77534. * Explodes meshes from a center mesh.
  77535. * @param meshes The meshes to explode.
  77536. * @param centerMesh The mesh to be center of explosion.
  77537. */
  77538. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77539. private _setCenterMesh;
  77540. /**
  77541. * Get class name
  77542. * @returns "MeshExploder"
  77543. */
  77544. getClassName(): string;
  77545. /**
  77546. * "Exploded meshes"
  77547. * @returns Array of meshes with the centerMesh at index 0.
  77548. */
  77549. getMeshes(): Array<Mesh>;
  77550. /**
  77551. * Explodes meshes giving a specific direction
  77552. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77553. */
  77554. explode(direction?: number): void;
  77555. }
  77556. }
  77557. declare module "babylonjs/Misc/filesInput" {
  77558. import { Engine } from "babylonjs/Engines/engine";
  77559. import { Scene } from "babylonjs/scene";
  77560. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  77561. import { Nullable } from "babylonjs/types";
  77562. /**
  77563. * Class used to help managing file picking and drag'n'drop
  77564. */
  77565. export class FilesInput {
  77566. /**
  77567. * List of files ready to be loaded
  77568. */
  77569. static get FilesToLoad(): {
  77570. [key: string]: File;
  77571. };
  77572. /**
  77573. * Callback called when a file is processed
  77574. */
  77575. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  77576. private _engine;
  77577. private _currentScene;
  77578. private _sceneLoadedCallback;
  77579. private _progressCallback;
  77580. private _additionalRenderLoopLogicCallback;
  77581. private _textureLoadingCallback;
  77582. private _startingProcessingFilesCallback;
  77583. private _onReloadCallback;
  77584. private _errorCallback;
  77585. private _elementToMonitor;
  77586. private _sceneFileToLoad;
  77587. private _filesToLoad;
  77588. /**
  77589. * Creates a new FilesInput
  77590. * @param engine defines the rendering engine
  77591. * @param scene defines the hosting scene
  77592. * @param sceneLoadedCallback callback called when scene is loaded
  77593. * @param progressCallback callback called to track progress
  77594. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77595. * @param textureLoadingCallback callback called when a texture is loading
  77596. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77597. * @param onReloadCallback callback called when a reload is requested
  77598. * @param errorCallback callback call if an error occurs
  77599. */
  77600. 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>);
  77601. private _dragEnterHandler;
  77602. private _dragOverHandler;
  77603. private _dropHandler;
  77604. /**
  77605. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77606. * @param elementToMonitor defines the DOM element to track
  77607. */
  77608. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77609. /** Gets the current list of files to load */
  77610. get filesToLoad(): File[];
  77611. /**
  77612. * Release all associated resources
  77613. */
  77614. dispose(): void;
  77615. private renderFunction;
  77616. private drag;
  77617. private drop;
  77618. private _traverseFolder;
  77619. private _processFiles;
  77620. /**
  77621. * Load files from a drop event
  77622. * @param event defines the drop event to use as source
  77623. */
  77624. loadFiles(event: any): void;
  77625. private _processReload;
  77626. /**
  77627. * Reload the current scene from the loaded files
  77628. */
  77629. reload(): void;
  77630. }
  77631. }
  77632. declare module "babylonjs/Misc/HighDynamicRange/index" {
  77633. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  77634. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  77635. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  77636. }
  77637. declare module "babylonjs/Misc/sceneOptimizer" {
  77638. import { Scene, IDisposable } from "babylonjs/scene";
  77639. import { Observable } from "babylonjs/Misc/observable";
  77640. /**
  77641. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77642. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77643. */
  77644. export class SceneOptimization {
  77645. /**
  77646. * Defines the priority of this optimization (0 by default which means first in the list)
  77647. */
  77648. priority: number;
  77649. /**
  77650. * Gets a string describing the action executed by the current optimization
  77651. * @returns description string
  77652. */
  77653. getDescription(): string;
  77654. /**
  77655. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77656. * @param scene defines the current scene where to apply this optimization
  77657. * @param optimizer defines the current optimizer
  77658. * @returns true if everything that can be done was applied
  77659. */
  77660. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77661. /**
  77662. * Creates the SceneOptimization object
  77663. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77664. * @param desc defines the description associated with the optimization
  77665. */
  77666. constructor(
  77667. /**
  77668. * Defines the priority of this optimization (0 by default which means first in the list)
  77669. */
  77670. priority?: number);
  77671. }
  77672. /**
  77673. * Defines an optimization used to reduce the size of render target textures
  77674. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77675. */
  77676. export class TextureOptimization extends SceneOptimization {
  77677. /**
  77678. * Defines the priority of this optimization (0 by default which means first in the list)
  77679. */
  77680. priority: number;
  77681. /**
  77682. * 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
  77683. */
  77684. maximumSize: number;
  77685. /**
  77686. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77687. */
  77688. step: number;
  77689. /**
  77690. * Gets a string describing the action executed by the current optimization
  77691. * @returns description string
  77692. */
  77693. getDescription(): string;
  77694. /**
  77695. * Creates the TextureOptimization object
  77696. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77697. * @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
  77698. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77699. */
  77700. constructor(
  77701. /**
  77702. * Defines the priority of this optimization (0 by default which means first in the list)
  77703. */
  77704. priority?: number,
  77705. /**
  77706. * 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
  77707. */
  77708. maximumSize?: number,
  77709. /**
  77710. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77711. */
  77712. step?: number);
  77713. /**
  77714. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77715. * @param scene defines the current scene where to apply this optimization
  77716. * @param optimizer defines the current optimizer
  77717. * @returns true if everything that can be done was applied
  77718. */
  77719. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77720. }
  77721. /**
  77722. * Defines an optimization used to increase or decrease the rendering resolution
  77723. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77724. */
  77725. export class HardwareScalingOptimization extends SceneOptimization {
  77726. /**
  77727. * Defines the priority of this optimization (0 by default which means first in the list)
  77728. */
  77729. priority: number;
  77730. /**
  77731. * Defines the maximum scale to use (2 by default)
  77732. */
  77733. maximumScale: number;
  77734. /**
  77735. * Defines the step to use between two passes (0.5 by default)
  77736. */
  77737. step: number;
  77738. private _currentScale;
  77739. private _directionOffset;
  77740. /**
  77741. * Gets a string describing the action executed by the current optimization
  77742. * @return description string
  77743. */
  77744. getDescription(): string;
  77745. /**
  77746. * Creates the HardwareScalingOptimization object
  77747. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77748. * @param maximumScale defines the maximum scale to use (2 by default)
  77749. * @param step defines the step to use between two passes (0.5 by default)
  77750. */
  77751. constructor(
  77752. /**
  77753. * Defines the priority of this optimization (0 by default which means first in the list)
  77754. */
  77755. priority?: number,
  77756. /**
  77757. * Defines the maximum scale to use (2 by default)
  77758. */
  77759. maximumScale?: number,
  77760. /**
  77761. * Defines the step to use between two passes (0.5 by default)
  77762. */
  77763. step?: number);
  77764. /**
  77765. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77766. * @param scene defines the current scene where to apply this optimization
  77767. * @param optimizer defines the current optimizer
  77768. * @returns true if everything that can be done was applied
  77769. */
  77770. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77771. }
  77772. /**
  77773. * Defines an optimization used to remove shadows
  77774. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77775. */
  77776. export class ShadowsOptimization extends SceneOptimization {
  77777. /**
  77778. * Gets a string describing the action executed by the current optimization
  77779. * @return description string
  77780. */
  77781. getDescription(): string;
  77782. /**
  77783. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77784. * @param scene defines the current scene where to apply this optimization
  77785. * @param optimizer defines the current optimizer
  77786. * @returns true if everything that can be done was applied
  77787. */
  77788. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77789. }
  77790. /**
  77791. * Defines an optimization used to turn post-processes off
  77792. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77793. */
  77794. export class PostProcessesOptimization extends SceneOptimization {
  77795. /**
  77796. * Gets a string describing the action executed by the current optimization
  77797. * @return description string
  77798. */
  77799. getDescription(): string;
  77800. /**
  77801. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77802. * @param scene defines the current scene where to apply this optimization
  77803. * @param optimizer defines the current optimizer
  77804. * @returns true if everything that can be done was applied
  77805. */
  77806. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77807. }
  77808. /**
  77809. * Defines an optimization used to turn lens flares off
  77810. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77811. */
  77812. export class LensFlaresOptimization extends SceneOptimization {
  77813. /**
  77814. * Gets a string describing the action executed by the current optimization
  77815. * @return description string
  77816. */
  77817. getDescription(): string;
  77818. /**
  77819. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77820. * @param scene defines the current scene where to apply this optimization
  77821. * @param optimizer defines the current optimizer
  77822. * @returns true if everything that can be done was applied
  77823. */
  77824. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77825. }
  77826. /**
  77827. * Defines an optimization based on user defined callback.
  77828. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77829. */
  77830. export class CustomOptimization extends SceneOptimization {
  77831. /**
  77832. * Callback called to apply the custom optimization.
  77833. */
  77834. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  77835. /**
  77836. * Callback called to get custom description
  77837. */
  77838. onGetDescription: () => string;
  77839. /**
  77840. * Gets a string describing the action executed by the current optimization
  77841. * @returns description string
  77842. */
  77843. getDescription(): string;
  77844. /**
  77845. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77846. * @param scene defines the current scene where to apply this optimization
  77847. * @param optimizer defines the current optimizer
  77848. * @returns true if everything that can be done was applied
  77849. */
  77850. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77851. }
  77852. /**
  77853. * Defines an optimization used to turn particles off
  77854. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77855. */
  77856. export class ParticlesOptimization extends SceneOptimization {
  77857. /**
  77858. * Gets a string describing the action executed by the current optimization
  77859. * @return description string
  77860. */
  77861. getDescription(): string;
  77862. /**
  77863. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77864. * @param scene defines the current scene where to apply this optimization
  77865. * @param optimizer defines the current optimizer
  77866. * @returns true if everything that can be done was applied
  77867. */
  77868. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77869. }
  77870. /**
  77871. * Defines an optimization used to turn render targets off
  77872. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77873. */
  77874. export class RenderTargetsOptimization extends SceneOptimization {
  77875. /**
  77876. * Gets a string describing the action executed by the current optimization
  77877. * @return description string
  77878. */
  77879. getDescription(): string;
  77880. /**
  77881. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77882. * @param scene defines the current scene where to apply this optimization
  77883. * @param optimizer defines the current optimizer
  77884. * @returns true if everything that can be done was applied
  77885. */
  77886. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77887. }
  77888. /**
  77889. * Defines an optimization used to merge meshes with compatible materials
  77890. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77891. */
  77892. export class MergeMeshesOptimization extends SceneOptimization {
  77893. private static _UpdateSelectionTree;
  77894. /**
  77895. * Gets or sets a boolean which defines if optimization octree has to be updated
  77896. */
  77897. static get UpdateSelectionTree(): boolean;
  77898. /**
  77899. * Gets or sets a boolean which defines if optimization octree has to be updated
  77900. */
  77901. static set UpdateSelectionTree(value: boolean);
  77902. /**
  77903. * Gets a string describing the action executed by the current optimization
  77904. * @return description string
  77905. */
  77906. getDescription(): string;
  77907. private _canBeMerged;
  77908. /**
  77909. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77910. * @param scene defines the current scene where to apply this optimization
  77911. * @param optimizer defines the current optimizer
  77912. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  77913. * @returns true if everything that can be done was applied
  77914. */
  77915. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  77916. }
  77917. /**
  77918. * Defines a list of options used by SceneOptimizer
  77919. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77920. */
  77921. export class SceneOptimizerOptions {
  77922. /**
  77923. * Defines the target frame rate to reach (60 by default)
  77924. */
  77925. targetFrameRate: number;
  77926. /**
  77927. * Defines the interval between two checkes (2000ms by default)
  77928. */
  77929. trackerDuration: number;
  77930. /**
  77931. * Gets the list of optimizations to apply
  77932. */
  77933. optimizations: SceneOptimization[];
  77934. /**
  77935. * Creates a new list of options used by SceneOptimizer
  77936. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  77937. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  77938. */
  77939. constructor(
  77940. /**
  77941. * Defines the target frame rate to reach (60 by default)
  77942. */
  77943. targetFrameRate?: number,
  77944. /**
  77945. * Defines the interval between two checkes (2000ms by default)
  77946. */
  77947. trackerDuration?: number);
  77948. /**
  77949. * Add a new optimization
  77950. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  77951. * @returns the current SceneOptimizerOptions
  77952. */
  77953. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  77954. /**
  77955. * Add a new custom optimization
  77956. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  77957. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  77958. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77959. * @returns the current SceneOptimizerOptions
  77960. */
  77961. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  77962. /**
  77963. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  77964. * @param targetFrameRate defines the target frame rate (60 by default)
  77965. * @returns a SceneOptimizerOptions object
  77966. */
  77967. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77968. /**
  77969. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  77970. * @param targetFrameRate defines the target frame rate (60 by default)
  77971. * @returns a SceneOptimizerOptions object
  77972. */
  77973. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77974. /**
  77975. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  77976. * @param targetFrameRate defines the target frame rate (60 by default)
  77977. * @returns a SceneOptimizerOptions object
  77978. */
  77979. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77980. }
  77981. /**
  77982. * Class used to run optimizations in order to reach a target frame rate
  77983. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77984. */
  77985. export class SceneOptimizer implements IDisposable {
  77986. private _isRunning;
  77987. private _options;
  77988. private _scene;
  77989. private _currentPriorityLevel;
  77990. private _targetFrameRate;
  77991. private _trackerDuration;
  77992. private _currentFrameRate;
  77993. private _sceneDisposeObserver;
  77994. private _improvementMode;
  77995. /**
  77996. * Defines an observable called when the optimizer reaches the target frame rate
  77997. */
  77998. onSuccessObservable: Observable<SceneOptimizer>;
  77999. /**
  78000. * Defines an observable called when the optimizer enables an optimization
  78001. */
  78002. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78003. /**
  78004. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78005. */
  78006. onFailureObservable: Observable<SceneOptimizer>;
  78007. /**
  78008. * Gets a boolean indicating if the optimizer is in improvement mode
  78009. */
  78010. get isInImprovementMode(): boolean;
  78011. /**
  78012. * Gets the current priority level (0 at start)
  78013. */
  78014. get currentPriorityLevel(): number;
  78015. /**
  78016. * Gets the current frame rate checked by the SceneOptimizer
  78017. */
  78018. get currentFrameRate(): number;
  78019. /**
  78020. * Gets or sets the current target frame rate (60 by default)
  78021. */
  78022. get targetFrameRate(): number;
  78023. /**
  78024. * Gets or sets the current target frame rate (60 by default)
  78025. */
  78026. set targetFrameRate(value: number);
  78027. /**
  78028. * Gets or sets the current interval between two checks (every 2000ms by default)
  78029. */
  78030. get trackerDuration(): number;
  78031. /**
  78032. * Gets or sets the current interval between two checks (every 2000ms by default)
  78033. */
  78034. set trackerDuration(value: number);
  78035. /**
  78036. * Gets the list of active optimizations
  78037. */
  78038. get optimizations(): SceneOptimization[];
  78039. /**
  78040. * Creates a new SceneOptimizer
  78041. * @param scene defines the scene to work on
  78042. * @param options defines the options to use with the SceneOptimizer
  78043. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78044. * @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)
  78045. */
  78046. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78047. /**
  78048. * Stops the current optimizer
  78049. */
  78050. stop(): void;
  78051. /**
  78052. * Reset the optimizer to initial step (current priority level = 0)
  78053. */
  78054. reset(): void;
  78055. /**
  78056. * Start the optimizer. By default it will try to reach a specific framerate
  78057. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78058. */
  78059. start(): void;
  78060. private _checkCurrentState;
  78061. /**
  78062. * Release all resources
  78063. */
  78064. dispose(): void;
  78065. /**
  78066. * Helper function to create a SceneOptimizer with one single line of code
  78067. * @param scene defines the scene to work on
  78068. * @param options defines the options to use with the SceneOptimizer
  78069. * @param onSuccess defines a callback to call on success
  78070. * @param onFailure defines a callback to call on failure
  78071. * @returns the new SceneOptimizer object
  78072. */
  78073. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78074. }
  78075. }
  78076. declare module "babylonjs/Misc/sceneSerializer" {
  78077. import { Scene } from "babylonjs/scene";
  78078. /**
  78079. * Class used to serialize a scene into a string
  78080. */
  78081. export class SceneSerializer {
  78082. /**
  78083. * Clear cache used by a previous serialization
  78084. */
  78085. static ClearCache(): void;
  78086. /**
  78087. * Serialize a scene into a JSON compatible object
  78088. * @param scene defines the scene to serialize
  78089. * @returns a JSON compatible object
  78090. */
  78091. static Serialize(scene: Scene): any;
  78092. /**
  78093. * Serialize a mesh into a JSON compatible object
  78094. * @param toSerialize defines the mesh to serialize
  78095. * @param withParents defines if parents must be serialized as well
  78096. * @param withChildren defines if children must be serialized as well
  78097. * @returns a JSON compatible object
  78098. */
  78099. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78100. }
  78101. }
  78102. declare module "babylonjs/Misc/textureTools" {
  78103. import { Texture } from "babylonjs/Materials/Textures/texture";
  78104. /**
  78105. * Class used to host texture specific utilities
  78106. */
  78107. export class TextureTools {
  78108. /**
  78109. * Uses the GPU to create a copy texture rescaled at a given size
  78110. * @param texture Texture to copy from
  78111. * @param width defines the desired width
  78112. * @param height defines the desired height
  78113. * @param useBilinearMode defines if bilinear mode has to be used
  78114. * @return the generated texture
  78115. */
  78116. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78117. }
  78118. }
  78119. declare module "babylonjs/Misc/videoRecorder" {
  78120. import { Nullable } from "babylonjs/types";
  78121. import { Engine } from "babylonjs/Engines/engine";
  78122. /**
  78123. * This represents the different options available for the video capture.
  78124. */
  78125. export interface VideoRecorderOptions {
  78126. /** Defines the mime type of the video. */
  78127. mimeType: string;
  78128. /** Defines the FPS the video should be recorded at. */
  78129. fps: number;
  78130. /** Defines the chunk size for the recording data. */
  78131. recordChunckSize: number;
  78132. /** The audio tracks to attach to the recording. */
  78133. audioTracks?: MediaStreamTrack[];
  78134. }
  78135. /**
  78136. * This can help with recording videos from BabylonJS.
  78137. * This is based on the available WebRTC functionalities of the browser.
  78138. *
  78139. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78140. */
  78141. export class VideoRecorder {
  78142. private static readonly _defaultOptions;
  78143. /**
  78144. * Returns whether or not the VideoRecorder is available in your browser.
  78145. * @param engine Defines the Babylon Engine.
  78146. * @returns true if supported otherwise false.
  78147. */
  78148. static IsSupported(engine: Engine): boolean;
  78149. private readonly _options;
  78150. private _canvas;
  78151. private _mediaRecorder;
  78152. private _recordedChunks;
  78153. private _fileName;
  78154. private _resolve;
  78155. private _reject;
  78156. /**
  78157. * True when a recording is already in progress.
  78158. */
  78159. get isRecording(): boolean;
  78160. /**
  78161. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78162. * @param engine Defines the BabylonJS Engine you wish to record.
  78163. * @param options Defines options that can be used to customize the capture.
  78164. */
  78165. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78166. /**
  78167. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78168. */
  78169. stopRecording(): void;
  78170. /**
  78171. * Starts recording the canvas for a max duration specified in parameters.
  78172. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78173. * If null no automatic download will start and you can rely on the promise to get the data back.
  78174. * @param maxDuration Defines the maximum recording time in seconds.
  78175. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78176. * @return A promise callback at the end of the recording with the video data in Blob.
  78177. */
  78178. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78179. /**
  78180. * Releases internal resources used during the recording.
  78181. */
  78182. dispose(): void;
  78183. private _handleDataAvailable;
  78184. private _handleError;
  78185. private _handleStop;
  78186. }
  78187. }
  78188. declare module "babylonjs/Misc/screenshotTools" {
  78189. import { Camera } from "babylonjs/Cameras/camera";
  78190. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78191. import { Engine } from "babylonjs/Engines/engine";
  78192. /**
  78193. * Class containing a set of static utilities functions for screenshots
  78194. */
  78195. export class ScreenshotTools {
  78196. /**
  78197. * Captures a screenshot of the current rendering
  78198. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78199. * @param engine defines the rendering engine
  78200. * @param camera defines the source camera
  78201. * @param size This parameter can be set to a single number or to an object with the
  78202. * following (optional) properties: precision, width, height. If a single number is passed,
  78203. * it will be used for both width and height. If an object is passed, the screenshot size
  78204. * will be derived from the parameters. The precision property is a multiplier allowing
  78205. * rendering at a higher or lower resolution
  78206. * @param successCallback defines the callback receives a single parameter which contains the
  78207. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78208. * src parameter of an <img> to display it
  78209. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78210. * Check your browser for supported MIME types
  78211. */
  78212. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78213. /**
  78214. * Captures a screenshot of the current rendering
  78215. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78216. * @param engine defines the rendering engine
  78217. * @param camera defines the source camera
  78218. * @param size This parameter can be set to a single number or to an object with the
  78219. * following (optional) properties: precision, width, height. If a single number is passed,
  78220. * it will be used for both width and height. If an object is passed, the screenshot size
  78221. * will be derived from the parameters. The precision property is a multiplier allowing
  78222. * rendering at a higher or lower resolution
  78223. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78224. * Check your browser for supported MIME types
  78225. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78226. * to the src parameter of an <img> to display it
  78227. */
  78228. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78229. /**
  78230. * Generates an image screenshot from the specified camera.
  78231. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78232. * @param engine The engine to use for rendering
  78233. * @param camera The camera to use for rendering
  78234. * @param size This parameter can be set to a single number or to an object with the
  78235. * following (optional) properties: precision, width, height. If a single number is passed,
  78236. * it will be used for both width and height. If an object is passed, the screenshot size
  78237. * will be derived from the parameters. The precision property is a multiplier allowing
  78238. * rendering at a higher or lower resolution
  78239. * @param successCallback The callback receives a single parameter which contains the
  78240. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78241. * src parameter of an <img> to display it
  78242. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78243. * Check your browser for supported MIME types
  78244. * @param samples Texture samples (default: 1)
  78245. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78246. * @param fileName A name for for the downloaded file.
  78247. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78248. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78249. */
  78250. 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;
  78251. /**
  78252. * Generates an image screenshot from the specified camera.
  78253. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78254. * @param engine The engine to use for rendering
  78255. * @param camera The camera to use for rendering
  78256. * @param size This parameter can be set to a single number or to an object with the
  78257. * following (optional) properties: precision, width, height. If a single number is passed,
  78258. * it will be used for both width and height. If an object is passed, the screenshot size
  78259. * will be derived from the parameters. The precision property is a multiplier allowing
  78260. * rendering at a higher or lower resolution
  78261. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78262. * Check your browser for supported MIME types
  78263. * @param samples Texture samples (default: 1)
  78264. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78265. * @param fileName A name for for the downloaded file.
  78266. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78267. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78268. * to the src parameter of an <img> to display it
  78269. */
  78270. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78271. /**
  78272. * Gets height and width for screenshot size
  78273. * @private
  78274. */
  78275. private static _getScreenshotSize;
  78276. }
  78277. }
  78278. declare module "babylonjs/Misc/dataReader" {
  78279. /**
  78280. * Interface for a data buffer
  78281. */
  78282. export interface IDataBuffer {
  78283. /**
  78284. * Reads bytes from the data buffer.
  78285. * @param byteOffset The byte offset to read
  78286. * @param byteLength The byte length to read
  78287. * @returns A promise that resolves when the bytes are read
  78288. */
  78289. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78290. /**
  78291. * The byte length of the buffer.
  78292. */
  78293. readonly byteLength: number;
  78294. }
  78295. /**
  78296. * Utility class for reading from a data buffer
  78297. */
  78298. export class DataReader {
  78299. /**
  78300. * The data buffer associated with this data reader.
  78301. */
  78302. readonly buffer: IDataBuffer;
  78303. /**
  78304. * The current byte offset from the beginning of the data buffer.
  78305. */
  78306. byteOffset: number;
  78307. private _dataView;
  78308. private _dataByteOffset;
  78309. /**
  78310. * Constructor
  78311. * @param buffer The buffer to read
  78312. */
  78313. constructor(buffer: IDataBuffer);
  78314. /**
  78315. * Loads the given byte length.
  78316. * @param byteLength The byte length to load
  78317. * @returns A promise that resolves when the load is complete
  78318. */
  78319. loadAsync(byteLength: number): Promise<void>;
  78320. /**
  78321. * Read a unsigned 32-bit integer from the currently loaded data range.
  78322. * @returns The 32-bit integer read
  78323. */
  78324. readUint32(): number;
  78325. /**
  78326. * Read a byte array from the currently loaded data range.
  78327. * @param byteLength The byte length to read
  78328. * @returns The byte array read
  78329. */
  78330. readUint8Array(byteLength: number): Uint8Array;
  78331. /**
  78332. * Read a string from the currently loaded data range.
  78333. * @param byteLength The byte length to read
  78334. * @returns The string read
  78335. */
  78336. readString(byteLength: number): string;
  78337. /**
  78338. * Skips the given byte length the currently loaded data range.
  78339. * @param byteLength The byte length to skip
  78340. */
  78341. skipBytes(byteLength: number): void;
  78342. }
  78343. }
  78344. declare module "babylonjs/Misc/dataStorage" {
  78345. /**
  78346. * Class for storing data to local storage if available or in-memory storage otherwise
  78347. */
  78348. export class DataStorage {
  78349. private static _Storage;
  78350. private static _GetStorage;
  78351. /**
  78352. * Reads a string from the data storage
  78353. * @param key The key to read
  78354. * @param defaultValue The value if the key doesn't exist
  78355. * @returns The string value
  78356. */
  78357. static ReadString(key: string, defaultValue: string): string;
  78358. /**
  78359. * Writes a string to the data storage
  78360. * @param key The key to write
  78361. * @param value The value to write
  78362. */
  78363. static WriteString(key: string, value: string): void;
  78364. /**
  78365. * Reads a boolean from the data storage
  78366. * @param key The key to read
  78367. * @param defaultValue The value if the key doesn't exist
  78368. * @returns The boolean value
  78369. */
  78370. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78371. /**
  78372. * Writes a boolean to the data storage
  78373. * @param key The key to write
  78374. * @param value The value to write
  78375. */
  78376. static WriteBoolean(key: string, value: boolean): void;
  78377. /**
  78378. * Reads a number from the data storage
  78379. * @param key The key to read
  78380. * @param defaultValue The value if the key doesn't exist
  78381. * @returns The number value
  78382. */
  78383. static ReadNumber(key: string, defaultValue: number): number;
  78384. /**
  78385. * Writes a number to the data storage
  78386. * @param key The key to write
  78387. * @param value The value to write
  78388. */
  78389. static WriteNumber(key: string, value: number): void;
  78390. }
  78391. }
  78392. declare module "babylonjs/Misc/sceneRecorder" {
  78393. import { Scene } from "babylonjs/scene";
  78394. /**
  78395. * Class used to record delta files between 2 scene states
  78396. */
  78397. export class SceneRecorder {
  78398. private _trackedScene;
  78399. private _savedJSON;
  78400. /**
  78401. * Track a given scene. This means the current scene state will be considered the original state
  78402. * @param scene defines the scene to track
  78403. */
  78404. track(scene: Scene): void;
  78405. /**
  78406. * Get the delta between current state and original state
  78407. * @returns a string containing the delta
  78408. */
  78409. getDelta(): any;
  78410. private _compareArray;
  78411. private _compareObjects;
  78412. private _compareCollections;
  78413. private static GetShadowGeneratorById;
  78414. /**
  78415. * Apply a given delta to a given scene
  78416. * @param deltaJSON defines the JSON containing the delta
  78417. * @param scene defines the scene to apply the delta to
  78418. */
  78419. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78420. private static _ApplyPropertiesToEntity;
  78421. private static _ApplyDeltaForEntity;
  78422. }
  78423. }
  78424. declare module "babylonjs/Misc/index" {
  78425. export * from "babylonjs/Misc/andOrNotEvaluator";
  78426. export * from "babylonjs/Misc/assetsManager";
  78427. export * from "babylonjs/Misc/basis";
  78428. export * from "babylonjs/Misc/dds";
  78429. export * from "babylonjs/Misc/decorators";
  78430. export * from "babylonjs/Misc/deferred";
  78431. export * from "babylonjs/Misc/environmentTextureTools";
  78432. export * from "babylonjs/Misc/meshExploder";
  78433. export * from "babylonjs/Misc/filesInput";
  78434. export * from "babylonjs/Misc/HighDynamicRange/index";
  78435. export * from "babylonjs/Misc/khronosTextureContainer";
  78436. export * from "babylonjs/Misc/observable";
  78437. export * from "babylonjs/Misc/performanceMonitor";
  78438. export * from "babylonjs/Misc/promise";
  78439. export * from "babylonjs/Misc/sceneOptimizer";
  78440. export * from "babylonjs/Misc/sceneSerializer";
  78441. export * from "babylonjs/Misc/smartArray";
  78442. export * from "babylonjs/Misc/stringDictionary";
  78443. export * from "babylonjs/Misc/tags";
  78444. export * from "babylonjs/Misc/textureTools";
  78445. export * from "babylonjs/Misc/tga";
  78446. export * from "babylonjs/Misc/tools";
  78447. export * from "babylonjs/Misc/videoRecorder";
  78448. export * from "babylonjs/Misc/virtualJoystick";
  78449. export * from "babylonjs/Misc/workerPool";
  78450. export * from "babylonjs/Misc/logger";
  78451. export * from "babylonjs/Misc/typeStore";
  78452. export * from "babylonjs/Misc/filesInputStore";
  78453. export * from "babylonjs/Misc/deepCopier";
  78454. export * from "babylonjs/Misc/pivotTools";
  78455. export * from "babylonjs/Misc/precisionDate";
  78456. export * from "babylonjs/Misc/screenshotTools";
  78457. export * from "babylonjs/Misc/typeStore";
  78458. export * from "babylonjs/Misc/webRequest";
  78459. export * from "babylonjs/Misc/iInspectable";
  78460. export * from "babylonjs/Misc/brdfTextureTools";
  78461. export * from "babylonjs/Misc/rgbdTextureTools";
  78462. export * from "babylonjs/Misc/gradients";
  78463. export * from "babylonjs/Misc/perfCounter";
  78464. export * from "babylonjs/Misc/fileRequest";
  78465. export * from "babylonjs/Misc/customAnimationFrameRequester";
  78466. export * from "babylonjs/Misc/retryStrategy";
  78467. export * from "babylonjs/Misc/interfaces/screenshotSize";
  78468. export * from "babylonjs/Misc/canvasGenerator";
  78469. export * from "babylonjs/Misc/fileTools";
  78470. export * from "babylonjs/Misc/stringTools";
  78471. export * from "babylonjs/Misc/dataReader";
  78472. export * from "babylonjs/Misc/minMaxReducer";
  78473. export * from "babylonjs/Misc/depthReducer";
  78474. export * from "babylonjs/Misc/dataStorage";
  78475. export * from "babylonjs/Misc/sceneRecorder";
  78476. export * from "babylonjs/Misc/khronosTextureContainer2";
  78477. }
  78478. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  78479. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  78480. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78481. import { Observable } from "babylonjs/Misc/observable";
  78482. import { Matrix } from "babylonjs/Maths/math.vector";
  78483. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78484. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78485. /**
  78486. * An interface for all Hit test features
  78487. */
  78488. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78489. /**
  78490. * Triggered when new babylon (transformed) hit test results are available
  78491. */
  78492. onHitTestResultObservable: Observable<T[]>;
  78493. }
  78494. /**
  78495. * Options used for hit testing
  78496. */
  78497. export interface IWebXRLegacyHitTestOptions {
  78498. /**
  78499. * Only test when user interacted with the scene. Default - hit test every frame
  78500. */
  78501. testOnPointerDownOnly?: boolean;
  78502. /**
  78503. * The node to use to transform the local results to world coordinates
  78504. */
  78505. worldParentNode?: TransformNode;
  78506. }
  78507. /**
  78508. * Interface defining the babylon result of raycasting/hit-test
  78509. */
  78510. export interface IWebXRLegacyHitResult {
  78511. /**
  78512. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78513. */
  78514. transformationMatrix: Matrix;
  78515. /**
  78516. * The native hit test result
  78517. */
  78518. xrHitResult: XRHitResult | XRHitTestResult;
  78519. }
  78520. /**
  78521. * The currently-working hit-test module.
  78522. * Hit test (or Ray-casting) is used to interact with the real world.
  78523. * For further information read here - https://github.com/immersive-web/hit-test
  78524. */
  78525. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78526. /**
  78527. * options to use when constructing this feature
  78528. */
  78529. readonly options: IWebXRLegacyHitTestOptions;
  78530. private _direction;
  78531. private _mat;
  78532. private _onSelectEnabled;
  78533. private _origin;
  78534. /**
  78535. * The module's name
  78536. */
  78537. static readonly Name: string;
  78538. /**
  78539. * The (Babylon) version of this module.
  78540. * This is an integer representing the implementation version.
  78541. * This number does not correspond to the WebXR specs version
  78542. */
  78543. static readonly Version: number;
  78544. /**
  78545. * Populated with the last native XR Hit Results
  78546. */
  78547. lastNativeXRHitResults: XRHitResult[];
  78548. /**
  78549. * Triggered when new babylon (transformed) hit test results are available
  78550. */
  78551. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78552. /**
  78553. * Creates a new instance of the (legacy version) hit test feature
  78554. * @param _xrSessionManager an instance of WebXRSessionManager
  78555. * @param options options to use when constructing this feature
  78556. */
  78557. constructor(_xrSessionManager: WebXRSessionManager,
  78558. /**
  78559. * options to use when constructing this feature
  78560. */
  78561. options?: IWebXRLegacyHitTestOptions);
  78562. /**
  78563. * execute a hit test with an XR Ray
  78564. *
  78565. * @param xrSession a native xrSession that will execute this hit test
  78566. * @param xrRay the ray (position and direction) to use for ray-casting
  78567. * @param referenceSpace native XR reference space to use for the hit-test
  78568. * @param filter filter function that will filter the results
  78569. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78570. */
  78571. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78572. /**
  78573. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78574. * @param event the (select) event to use to select with
  78575. * @param referenceSpace the reference space to use for this hit test
  78576. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78577. */
  78578. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78579. /**
  78580. * attach this feature
  78581. * Will usually be called by the features manager
  78582. *
  78583. * @returns true if successful.
  78584. */
  78585. attach(): boolean;
  78586. /**
  78587. * detach this feature.
  78588. * Will usually be called by the features manager
  78589. *
  78590. * @returns true if successful.
  78591. */
  78592. detach(): boolean;
  78593. /**
  78594. * Dispose this feature and all of the resources attached
  78595. */
  78596. dispose(): void;
  78597. protected _onXRFrame(frame: XRFrame): void;
  78598. private _onHitTestResults;
  78599. private _onSelect;
  78600. }
  78601. }
  78602. declare module "babylonjs/XR/features/WebXRHitTest" {
  78603. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78604. import { Observable } from "babylonjs/Misc/observable";
  78605. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78606. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78607. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  78608. /**
  78609. * Options used for hit testing (version 2)
  78610. */
  78611. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  78612. /**
  78613. * Do not create a permanent hit test. Will usually be used when only
  78614. * transient inputs are needed.
  78615. */
  78616. disablePermanentHitTest?: boolean;
  78617. /**
  78618. * Enable transient (for example touch-based) hit test inspections
  78619. */
  78620. enableTransientHitTest?: boolean;
  78621. /**
  78622. * Offset ray for the permanent hit test
  78623. */
  78624. offsetRay?: Vector3;
  78625. /**
  78626. * Offset ray for the transient hit test
  78627. */
  78628. transientOffsetRay?: Vector3;
  78629. /**
  78630. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  78631. */
  78632. useReferenceSpace?: boolean;
  78633. /**
  78634. * Override the default entity type(s) of the hit-test result
  78635. */
  78636. entityTypes?: XRHitTestTrackableType[];
  78637. }
  78638. /**
  78639. * Interface defining the babylon result of hit-test
  78640. */
  78641. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  78642. /**
  78643. * The input source that generated this hit test (if transient)
  78644. */
  78645. inputSource?: XRInputSource;
  78646. /**
  78647. * Is this a transient hit test
  78648. */
  78649. isTransient?: boolean;
  78650. /**
  78651. * Position of the hit test result
  78652. */
  78653. position: Vector3;
  78654. /**
  78655. * Rotation of the hit test result
  78656. */
  78657. rotationQuaternion: Quaternion;
  78658. /**
  78659. * The native hit test result
  78660. */
  78661. xrHitResult: XRHitTestResult;
  78662. }
  78663. /**
  78664. * The currently-working hit-test module.
  78665. * Hit test (or Ray-casting) is used to interact with the real world.
  78666. * For further information read here - https://github.com/immersive-web/hit-test
  78667. *
  78668. * Tested on chrome (mobile) 80.
  78669. */
  78670. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  78671. /**
  78672. * options to use when constructing this feature
  78673. */
  78674. readonly options: IWebXRHitTestOptions;
  78675. private _tmpMat;
  78676. private _tmpPos;
  78677. private _tmpQuat;
  78678. private _transientXrHitTestSource;
  78679. private _xrHitTestSource;
  78680. private initHitTestSource;
  78681. /**
  78682. * The module's name
  78683. */
  78684. static readonly Name: string;
  78685. /**
  78686. * The (Babylon) version of this module.
  78687. * This is an integer representing the implementation version.
  78688. * This number does not correspond to the WebXR specs version
  78689. */
  78690. static readonly Version: number;
  78691. /**
  78692. * When set to true, each hit test will have its own position/rotation objects
  78693. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  78694. * the developers will clone them or copy them as they see fit.
  78695. */
  78696. autoCloneTransformation: boolean;
  78697. /**
  78698. * Triggered when new babylon (transformed) hit test results are available
  78699. * Note - this will be called when results come back from the device. It can be an empty array!!
  78700. */
  78701. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  78702. /**
  78703. * Use this to temporarily pause hit test checks.
  78704. */
  78705. paused: boolean;
  78706. /**
  78707. * Creates a new instance of the hit test feature
  78708. * @param _xrSessionManager an instance of WebXRSessionManager
  78709. * @param options options to use when constructing this feature
  78710. */
  78711. constructor(_xrSessionManager: WebXRSessionManager,
  78712. /**
  78713. * options to use when constructing this feature
  78714. */
  78715. options?: IWebXRHitTestOptions);
  78716. /**
  78717. * attach this feature
  78718. * Will usually be called by the features manager
  78719. *
  78720. * @returns true if successful.
  78721. */
  78722. attach(): boolean;
  78723. /**
  78724. * detach this feature.
  78725. * Will usually be called by the features manager
  78726. *
  78727. * @returns true if successful.
  78728. */
  78729. detach(): boolean;
  78730. /**
  78731. * Dispose this feature and all of the resources attached
  78732. */
  78733. dispose(): void;
  78734. protected _onXRFrame(frame: XRFrame): void;
  78735. private _processWebXRHitTestResult;
  78736. }
  78737. }
  78738. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  78739. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78740. import { Observable } from "babylonjs/Misc/observable";
  78741. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78742. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78743. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78744. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  78745. /**
  78746. * Configuration options of the anchor system
  78747. */
  78748. export interface IWebXRAnchorSystemOptions {
  78749. /**
  78750. * a node that will be used to convert local to world coordinates
  78751. */
  78752. worldParentNode?: TransformNode;
  78753. /**
  78754. * If set to true a reference of the created anchors will be kept until the next session starts
  78755. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78756. */
  78757. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78758. }
  78759. /**
  78760. * A babylon container for an XR Anchor
  78761. */
  78762. export interface IWebXRAnchor {
  78763. /**
  78764. * A babylon-assigned ID for this anchor
  78765. */
  78766. id: number;
  78767. /**
  78768. * Transformation matrix to apply to an object attached to this anchor
  78769. */
  78770. transformationMatrix: Matrix;
  78771. /**
  78772. * The native anchor object
  78773. */
  78774. xrAnchor: XRAnchor;
  78775. /**
  78776. * if defined, this object will be constantly updated by the anchor's position and rotation
  78777. */
  78778. attachedNode?: TransformNode;
  78779. }
  78780. /**
  78781. * An implementation of the anchor system for WebXR.
  78782. * For further information see https://github.com/immersive-web/anchors/
  78783. */
  78784. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  78785. private _options;
  78786. private _lastFrameDetected;
  78787. private _trackedAnchors;
  78788. private _referenceSpaceForFrameAnchors;
  78789. private _futureAnchors;
  78790. /**
  78791. * The module's name
  78792. */
  78793. static readonly Name: string;
  78794. /**
  78795. * The (Babylon) version of this module.
  78796. * This is an integer representing the implementation version.
  78797. * This number does not correspond to the WebXR specs version
  78798. */
  78799. static readonly Version: number;
  78800. /**
  78801. * Observers registered here will be executed when a new anchor was added to the session
  78802. */
  78803. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  78804. /**
  78805. * Observers registered here will be executed when an anchor was removed from the session
  78806. */
  78807. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  78808. /**
  78809. * Observers registered here will be executed when an existing anchor updates
  78810. * This can execute N times every frame
  78811. */
  78812. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  78813. /**
  78814. * Set the reference space to use for anchor creation, when not using a hit test.
  78815. * Will default to the session's reference space if not defined
  78816. */
  78817. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  78818. /**
  78819. * constructs a new anchor system
  78820. * @param _xrSessionManager an instance of WebXRSessionManager
  78821. * @param _options configuration object for this feature
  78822. */
  78823. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  78824. private _tmpVector;
  78825. private _tmpQuaternion;
  78826. private _populateTmpTransformation;
  78827. /**
  78828. * Create a new anchor point using a hit test result at a specific point in the scene
  78829. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78830. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78831. *
  78832. * @param hitTestResult The hit test result to use for this anchor creation
  78833. * @param position an optional position offset for this anchor
  78834. * @param rotationQuaternion an optional rotation offset for this anchor
  78835. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78836. */
  78837. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  78838. /**
  78839. * Add a new anchor at a specific position and rotation
  78840. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  78841. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  78842. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78843. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78844. *
  78845. * @param position the position in which to add an anchor
  78846. * @param rotationQuaternion an optional rotation for the anchor transformation
  78847. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  78848. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78849. */
  78850. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  78851. /**
  78852. * detach this feature.
  78853. * Will usually be called by the features manager
  78854. *
  78855. * @returns true if successful.
  78856. */
  78857. detach(): boolean;
  78858. /**
  78859. * Dispose this feature and all of the resources attached
  78860. */
  78861. dispose(): void;
  78862. protected _onXRFrame(frame: XRFrame): void;
  78863. /**
  78864. * avoiding using Array.find for global support.
  78865. * @param xrAnchor the plane to find in the array
  78866. */
  78867. private _findIndexInAnchorArray;
  78868. private _updateAnchorWithXRFrame;
  78869. private _createAnchorAtTransformation;
  78870. }
  78871. }
  78872. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  78873. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78874. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78875. import { Observable } from "babylonjs/Misc/observable";
  78876. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  78877. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78878. /**
  78879. * Options used in the plane detector module
  78880. */
  78881. export interface IWebXRPlaneDetectorOptions {
  78882. /**
  78883. * The node to use to transform the local results to world coordinates
  78884. */
  78885. worldParentNode?: TransformNode;
  78886. /**
  78887. * If set to true a reference of the created planes will be kept until the next session starts
  78888. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  78889. */
  78890. doNotRemovePlanesOnSessionEnded?: boolean;
  78891. }
  78892. /**
  78893. * A babylon interface for a WebXR plane.
  78894. * A Plane is actually a polygon, built from N points in space
  78895. *
  78896. * Supported in chrome 79, not supported in canary 81 ATM
  78897. */
  78898. export interface IWebXRPlane {
  78899. /**
  78900. * a babylon-assigned ID for this polygon
  78901. */
  78902. id: number;
  78903. /**
  78904. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  78905. */
  78906. polygonDefinition: Array<Vector3>;
  78907. /**
  78908. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  78909. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  78910. */
  78911. transformationMatrix: Matrix;
  78912. /**
  78913. * the native xr-plane object
  78914. */
  78915. xrPlane: XRPlane;
  78916. }
  78917. /**
  78918. * The plane detector is used to detect planes in the real world when in AR
  78919. * For more information see https://github.com/immersive-web/real-world-geometry/
  78920. */
  78921. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  78922. private _options;
  78923. private _detectedPlanes;
  78924. private _enabled;
  78925. private _lastFrameDetected;
  78926. /**
  78927. * The module's name
  78928. */
  78929. static readonly Name: string;
  78930. /**
  78931. * The (Babylon) version of this module.
  78932. * This is an integer representing the implementation version.
  78933. * This number does not correspond to the WebXR specs version
  78934. */
  78935. static readonly Version: number;
  78936. /**
  78937. * Observers registered here will be executed when a new plane was added to the session
  78938. */
  78939. onPlaneAddedObservable: Observable<IWebXRPlane>;
  78940. /**
  78941. * Observers registered here will be executed when a plane is no longer detected in the session
  78942. */
  78943. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  78944. /**
  78945. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  78946. * This can execute N times every frame
  78947. */
  78948. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  78949. /**
  78950. * construct a new Plane Detector
  78951. * @param _xrSessionManager an instance of xr Session manager
  78952. * @param _options configuration to use when constructing this feature
  78953. */
  78954. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  78955. /**
  78956. * detach this feature.
  78957. * Will usually be called by the features manager
  78958. *
  78959. * @returns true if successful.
  78960. */
  78961. detach(): boolean;
  78962. /**
  78963. * Dispose this feature and all of the resources attached
  78964. */
  78965. dispose(): void;
  78966. protected _onXRFrame(frame: XRFrame): void;
  78967. private _init;
  78968. private _updatePlaneWithXRPlane;
  78969. /**
  78970. * avoiding using Array.find for global support.
  78971. * @param xrPlane the plane to find in the array
  78972. */
  78973. private findIndexInPlaneArray;
  78974. }
  78975. }
  78976. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  78977. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78979. import { Observable } from "babylonjs/Misc/observable";
  78980. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78981. /**
  78982. * Options interface for the background remover plugin
  78983. */
  78984. export interface IWebXRBackgroundRemoverOptions {
  78985. /**
  78986. * Further background meshes to disable when entering AR
  78987. */
  78988. backgroundMeshes?: AbstractMesh[];
  78989. /**
  78990. * flags to configure the removal of the environment helper.
  78991. * If not set, the entire background will be removed. If set, flags should be set as well.
  78992. */
  78993. environmentHelperRemovalFlags?: {
  78994. /**
  78995. * Should the skybox be removed (default false)
  78996. */
  78997. skyBox?: boolean;
  78998. /**
  78999. * Should the ground be removed (default false)
  79000. */
  79001. ground?: boolean;
  79002. };
  79003. /**
  79004. * don't disable the environment helper
  79005. */
  79006. ignoreEnvironmentHelper?: boolean;
  79007. }
  79008. /**
  79009. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79010. */
  79011. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79012. /**
  79013. * read-only options to be used in this module
  79014. */
  79015. readonly options: IWebXRBackgroundRemoverOptions;
  79016. /**
  79017. * The module's name
  79018. */
  79019. static readonly Name: string;
  79020. /**
  79021. * The (Babylon) version of this module.
  79022. * This is an integer representing the implementation version.
  79023. * This number does not correspond to the WebXR specs version
  79024. */
  79025. static readonly Version: number;
  79026. /**
  79027. * registered observers will be triggered when the background state changes
  79028. */
  79029. onBackgroundStateChangedObservable: Observable<boolean>;
  79030. /**
  79031. * constructs a new background remover module
  79032. * @param _xrSessionManager the session manager for this module
  79033. * @param options read-only options to be used in this module
  79034. */
  79035. constructor(_xrSessionManager: WebXRSessionManager,
  79036. /**
  79037. * read-only options to be used in this module
  79038. */
  79039. options?: IWebXRBackgroundRemoverOptions);
  79040. /**
  79041. * attach this feature
  79042. * Will usually be called by the features manager
  79043. *
  79044. * @returns true if successful.
  79045. */
  79046. attach(): boolean;
  79047. /**
  79048. * detach this feature.
  79049. * Will usually be called by the features manager
  79050. *
  79051. * @returns true if successful.
  79052. */
  79053. detach(): boolean;
  79054. /**
  79055. * Dispose this feature and all of the resources attached
  79056. */
  79057. dispose(): void;
  79058. protected _onXRFrame(_xrFrame: XRFrame): void;
  79059. private _setBackgroundState;
  79060. }
  79061. }
  79062. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79063. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79064. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79065. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79066. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79067. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79068. import { Nullable } from "babylonjs/types";
  79069. /**
  79070. * Options for the controller physics feature
  79071. */
  79072. export class IWebXRControllerPhysicsOptions {
  79073. /**
  79074. * Should the headset get its own impostor
  79075. */
  79076. enableHeadsetImpostor?: boolean;
  79077. /**
  79078. * Optional parameters for the headset impostor
  79079. */
  79080. headsetImpostorParams?: {
  79081. /**
  79082. * The type of impostor to create. Default is sphere
  79083. */
  79084. impostorType: number;
  79085. /**
  79086. * the size of the impostor. Defaults to 10cm
  79087. */
  79088. impostorSize?: number | {
  79089. width: number;
  79090. height: number;
  79091. depth: number;
  79092. };
  79093. /**
  79094. * Friction definitions
  79095. */
  79096. friction?: number;
  79097. /**
  79098. * Restitution
  79099. */
  79100. restitution?: number;
  79101. };
  79102. /**
  79103. * The physics properties of the future impostors
  79104. */
  79105. physicsProperties?: {
  79106. /**
  79107. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79108. * Note that this requires a physics engine that supports mesh impostors!
  79109. */
  79110. useControllerMesh?: boolean;
  79111. /**
  79112. * The type of impostor to create. Default is sphere
  79113. */
  79114. impostorType?: number;
  79115. /**
  79116. * the size of the impostor. Defaults to 10cm
  79117. */
  79118. impostorSize?: number | {
  79119. width: number;
  79120. height: number;
  79121. depth: number;
  79122. };
  79123. /**
  79124. * Friction definitions
  79125. */
  79126. friction?: number;
  79127. /**
  79128. * Restitution
  79129. */
  79130. restitution?: number;
  79131. };
  79132. /**
  79133. * the xr input to use with this pointer selection
  79134. */
  79135. xrInput: WebXRInput;
  79136. }
  79137. /**
  79138. * Add physics impostor to your webxr controllers,
  79139. * including naive calculation of their linear and angular velocity
  79140. */
  79141. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79142. private readonly _options;
  79143. private _attachController;
  79144. private _controllers;
  79145. private _debugMode;
  79146. private _delta;
  79147. private _headsetImpostor?;
  79148. private _headsetMesh?;
  79149. private _lastTimestamp;
  79150. private _tmpQuaternion;
  79151. private _tmpVector;
  79152. /**
  79153. * The module's name
  79154. */
  79155. static readonly Name: string;
  79156. /**
  79157. * The (Babylon) version of this module.
  79158. * This is an integer representing the implementation version.
  79159. * This number does not correspond to the webxr specs version
  79160. */
  79161. static readonly Version: number;
  79162. /**
  79163. * Construct a new Controller Physics Feature
  79164. * @param _xrSessionManager the corresponding xr session manager
  79165. * @param _options options to create this feature with
  79166. */
  79167. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79168. /**
  79169. * @hidden
  79170. * enable debugging - will show console outputs and the impostor mesh
  79171. */
  79172. _enablePhysicsDebug(): void;
  79173. /**
  79174. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79175. * @param xrController the controller to add
  79176. */
  79177. addController(xrController: WebXRInputSource): void;
  79178. /**
  79179. * attach this feature
  79180. * Will usually be called by the features manager
  79181. *
  79182. * @returns true if successful.
  79183. */
  79184. attach(): boolean;
  79185. /**
  79186. * detach this feature.
  79187. * Will usually be called by the features manager
  79188. *
  79189. * @returns true if successful.
  79190. */
  79191. detach(): boolean;
  79192. /**
  79193. * Get the headset impostor, if enabled
  79194. * @returns the impostor
  79195. */
  79196. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79197. /**
  79198. * Get the physics impostor of a specific controller.
  79199. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79200. * @param controller the controller or the controller id of which to get the impostor
  79201. * @returns the impostor or null
  79202. */
  79203. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79204. /**
  79205. * Update the physics properties provided in the constructor
  79206. * @param newProperties the new properties object
  79207. */
  79208. setPhysicsProperties(newProperties: {
  79209. impostorType?: number;
  79210. impostorSize?: number | {
  79211. width: number;
  79212. height: number;
  79213. depth: number;
  79214. };
  79215. friction?: number;
  79216. restitution?: number;
  79217. }): void;
  79218. protected _onXRFrame(_xrFrame: any): void;
  79219. private _detachController;
  79220. }
  79221. }
  79222. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79223. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79224. import { Observable } from "babylonjs/Misc/observable";
  79225. import { Vector3 } from "babylonjs/Maths/math.vector";
  79226. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79227. /**
  79228. * A babylon interface for a "WebXR" feature point.
  79229. * Represents the position and confidence value of a given feature point.
  79230. */
  79231. export interface IWebXRFeaturePoint {
  79232. /**
  79233. * Represents the position of the feature point in world space.
  79234. */
  79235. position: Vector3;
  79236. /**
  79237. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79238. */
  79239. confidenceValue: number;
  79240. }
  79241. /**
  79242. * The feature point system is used to detect feature points from real world geometry.
  79243. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79244. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79245. */
  79246. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79247. private _enabled;
  79248. private _featurePointCloud;
  79249. /**
  79250. * The module's name
  79251. */
  79252. static readonly Name: string;
  79253. /**
  79254. * The (Babylon) version of this module.
  79255. * This is an integer representing the implementation version.
  79256. * This number does not correspond to the WebXR specs version
  79257. */
  79258. static readonly Version: number;
  79259. /**
  79260. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79261. * Will notify the observers about which feature points have been added.
  79262. */
  79263. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79264. /**
  79265. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79266. * Will notify the observers about which feature points have been updated.
  79267. */
  79268. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79269. /**
  79270. * The current feature point cloud maintained across frames.
  79271. */
  79272. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79273. /**
  79274. * construct the feature point system
  79275. * @param _xrSessionManager an instance of xr Session manager
  79276. */
  79277. constructor(_xrSessionManager: WebXRSessionManager);
  79278. /**
  79279. * Detach this feature.
  79280. * Will usually be called by the features manager
  79281. *
  79282. * @returns true if successful.
  79283. */
  79284. detach(): boolean;
  79285. /**
  79286. * Dispose this feature and all of the resources attached
  79287. */
  79288. dispose(): void;
  79289. /**
  79290. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79291. */
  79292. protected _onXRFrame(frame: XRFrame): void;
  79293. /**
  79294. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79295. */
  79296. private _init;
  79297. }
  79298. }
  79299. declare module "babylonjs/XR/features/WebXRHandTracking" {
  79300. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79301. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79303. import { Mesh } from "babylonjs/Meshes/mesh";
  79304. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79305. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79306. import { Nullable } from "babylonjs/types";
  79307. import { IDisposable } from "babylonjs/scene";
  79308. import { Observable } from "babylonjs/Misc/observable";
  79309. /**
  79310. * Configuration interface for the hand tracking feature
  79311. */
  79312. export interface IWebXRHandTrackingOptions {
  79313. /**
  79314. * The xrInput that will be used as source for new hands
  79315. */
  79316. xrInput: WebXRInput;
  79317. /**
  79318. * Configuration object for the joint meshes
  79319. */
  79320. jointMeshes?: {
  79321. /**
  79322. * Should the meshes created be invisible (defaults to false)
  79323. */
  79324. invisible?: boolean;
  79325. /**
  79326. * A source mesh to be used to create instances. Defaults to a sphere.
  79327. * This mesh will be the source for all other (25) meshes.
  79328. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79329. */
  79330. sourceMesh?: Mesh;
  79331. /**
  79332. * Should the source mesh stay visible. Defaults to false
  79333. */
  79334. keepOriginalVisible?: boolean;
  79335. /**
  79336. * Scale factor for all instances (defaults to 2)
  79337. */
  79338. scaleFactor?: number;
  79339. /**
  79340. * Should each instance have its own physics impostor
  79341. */
  79342. enablePhysics?: boolean;
  79343. /**
  79344. * If enabled, override default physics properties
  79345. */
  79346. physicsProps?: {
  79347. friction?: number;
  79348. restitution?: number;
  79349. impostorType?: number;
  79350. };
  79351. /**
  79352. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  79353. */
  79354. handMesh?: AbstractMesh;
  79355. };
  79356. }
  79357. /**
  79358. * Parts of the hands divided to writs and finger names
  79359. */
  79360. export const enum HandPart {
  79361. /**
  79362. * HandPart - Wrist
  79363. */
  79364. WRIST = "wrist",
  79365. /**
  79366. * HandPart - The THumb
  79367. */
  79368. THUMB = "thumb",
  79369. /**
  79370. * HandPart - Index finger
  79371. */
  79372. INDEX = "index",
  79373. /**
  79374. * HandPart - Middle finger
  79375. */
  79376. MIDDLE = "middle",
  79377. /**
  79378. * HandPart - Ring finger
  79379. */
  79380. RING = "ring",
  79381. /**
  79382. * HandPart - Little finger
  79383. */
  79384. LITTLE = "little"
  79385. }
  79386. /**
  79387. * Representing a single hand (with its corresponding native XRHand object)
  79388. */
  79389. export class WebXRHand implements IDisposable {
  79390. /** the controller to which the hand correlates */
  79391. readonly xrController: WebXRInputSource;
  79392. /** the meshes to be used to track the hand joints */
  79393. readonly trackedMeshes: AbstractMesh[];
  79394. /**
  79395. * Hand-parts definition (key is HandPart)
  79396. */
  79397. handPartsDefinition: {
  79398. [key: string]: number[];
  79399. };
  79400. /**
  79401. * Populate the HandPartsDefinition object.
  79402. * This is called as a side effect since certain browsers don't have XRHand defined.
  79403. */
  79404. private generateHandPartsDefinition;
  79405. /**
  79406. * Construct a new hand object
  79407. * @param xrController the controller to which the hand correlates
  79408. * @param trackedMeshes the meshes to be used to track the hand joints
  79409. */
  79410. constructor(
  79411. /** the controller to which the hand correlates */
  79412. xrController: WebXRInputSource,
  79413. /** the meshes to be used to track the hand joints */
  79414. trackedMeshes: AbstractMesh[]);
  79415. /**
  79416. * Update this hand from the latest xr frame
  79417. * @param xrFrame xrFrame to update from
  79418. * @param referenceSpace The current viewer reference space
  79419. * @param scaleFactor optional scale factor for the meshes
  79420. */
  79421. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79422. /**
  79423. * Get meshes of part of the hand
  79424. * @param part the part of hand to get
  79425. * @returns An array of meshes that correlate to the hand part requested
  79426. */
  79427. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79428. /**
  79429. * Dispose this Hand object
  79430. */
  79431. dispose(): void;
  79432. }
  79433. /**
  79434. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79435. */
  79436. export class WebXRHandTracking extends WebXRAbstractFeature {
  79437. /**
  79438. * options to use when constructing this feature
  79439. */
  79440. readonly options: IWebXRHandTrackingOptions;
  79441. private static _idCounter;
  79442. /**
  79443. * The module's name
  79444. */
  79445. static readonly Name: string;
  79446. /**
  79447. * The (Babylon) version of this module.
  79448. * This is an integer representing the implementation version.
  79449. * This number does not correspond to the WebXR specs version
  79450. */
  79451. static readonly Version: number;
  79452. /**
  79453. * This observable will notify registered observers when a new hand object was added and initialized
  79454. */
  79455. onHandAddedObservable: Observable<WebXRHand>;
  79456. /**
  79457. * This observable will notify its observers right before the hand object is disposed
  79458. */
  79459. onHandRemovedObservable: Observable<WebXRHand>;
  79460. private _hands;
  79461. /**
  79462. * Creates a new instance of the hit test feature
  79463. * @param _xrSessionManager an instance of WebXRSessionManager
  79464. * @param options options to use when constructing this feature
  79465. */
  79466. constructor(_xrSessionManager: WebXRSessionManager,
  79467. /**
  79468. * options to use when constructing this feature
  79469. */
  79470. options: IWebXRHandTrackingOptions);
  79471. /**
  79472. * Check if the needed objects are defined.
  79473. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79474. */
  79475. isCompatible(): boolean;
  79476. /**
  79477. * attach this feature
  79478. * Will usually be called by the features manager
  79479. *
  79480. * @returns true if successful.
  79481. */
  79482. attach(): boolean;
  79483. /**
  79484. * detach this feature.
  79485. * Will usually be called by the features manager
  79486. *
  79487. * @returns true if successful.
  79488. */
  79489. detach(): boolean;
  79490. /**
  79491. * Dispose this feature and all of the resources attached
  79492. */
  79493. dispose(): void;
  79494. /**
  79495. * Get the hand object according to the controller id
  79496. * @param controllerId the controller id to which we want to get the hand
  79497. * @returns null if not found or the WebXRHand object if found
  79498. */
  79499. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79500. /**
  79501. * Get a hand object according to the requested handedness
  79502. * @param handedness the handedness to request
  79503. * @returns null if not found or the WebXRHand object if found
  79504. */
  79505. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79506. protected _onXRFrame(_xrFrame: XRFrame): void;
  79507. private _attachHand;
  79508. private _detachHand;
  79509. }
  79510. }
  79511. declare module "babylonjs/XR/features/index" {
  79512. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  79513. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  79514. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  79515. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  79516. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  79517. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  79518. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  79519. export * from "babylonjs/XR/features/WebXRHitTest";
  79520. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  79521. export * from "babylonjs/XR/features/WebXRHandTracking";
  79522. }
  79523. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  79524. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79526. import { Scene } from "babylonjs/scene";
  79527. /**
  79528. * The motion controller class for all microsoft mixed reality controllers
  79529. */
  79530. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  79531. protected readonly _mapping: {
  79532. defaultButton: {
  79533. valueNodeName: string;
  79534. unpressedNodeName: string;
  79535. pressedNodeName: string;
  79536. };
  79537. defaultAxis: {
  79538. valueNodeName: string;
  79539. minNodeName: string;
  79540. maxNodeName: string;
  79541. };
  79542. buttons: {
  79543. "xr-standard-trigger": {
  79544. rootNodeName: string;
  79545. componentProperty: string;
  79546. states: string[];
  79547. };
  79548. "xr-standard-squeeze": {
  79549. rootNodeName: string;
  79550. componentProperty: string;
  79551. states: string[];
  79552. };
  79553. "xr-standard-touchpad": {
  79554. rootNodeName: string;
  79555. labelAnchorNodeName: string;
  79556. touchPointNodeName: string;
  79557. };
  79558. "xr-standard-thumbstick": {
  79559. rootNodeName: string;
  79560. componentProperty: string;
  79561. states: string[];
  79562. };
  79563. };
  79564. axes: {
  79565. "xr-standard-touchpad": {
  79566. "x-axis": {
  79567. rootNodeName: string;
  79568. };
  79569. "y-axis": {
  79570. rootNodeName: string;
  79571. };
  79572. };
  79573. "xr-standard-thumbstick": {
  79574. "x-axis": {
  79575. rootNodeName: string;
  79576. };
  79577. "y-axis": {
  79578. rootNodeName: string;
  79579. };
  79580. };
  79581. };
  79582. };
  79583. /**
  79584. * The base url used to load the left and right controller models
  79585. */
  79586. static MODEL_BASE_URL: string;
  79587. /**
  79588. * The name of the left controller model file
  79589. */
  79590. static MODEL_LEFT_FILENAME: string;
  79591. /**
  79592. * The name of the right controller model file
  79593. */
  79594. static MODEL_RIGHT_FILENAME: string;
  79595. profileId: string;
  79596. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79597. protected _getFilenameAndPath(): {
  79598. filename: string;
  79599. path: string;
  79600. };
  79601. protected _getModelLoadingConstraints(): boolean;
  79602. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79603. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79604. protected _updateModel(): void;
  79605. }
  79606. }
  79607. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  79608. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79610. import { Scene } from "babylonjs/scene";
  79611. /**
  79612. * The motion controller class for oculus touch (quest, rift).
  79613. * This class supports legacy mapping as well the standard xr mapping
  79614. */
  79615. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  79616. private _forceLegacyControllers;
  79617. private _modelRootNode;
  79618. /**
  79619. * The base url used to load the left and right controller models
  79620. */
  79621. static MODEL_BASE_URL: string;
  79622. /**
  79623. * The name of the left controller model file
  79624. */
  79625. static MODEL_LEFT_FILENAME: string;
  79626. /**
  79627. * The name of the right controller model file
  79628. */
  79629. static MODEL_RIGHT_FILENAME: string;
  79630. /**
  79631. * Base Url for the Quest controller model.
  79632. */
  79633. static QUEST_MODEL_BASE_URL: string;
  79634. profileId: string;
  79635. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  79636. protected _getFilenameAndPath(): {
  79637. filename: string;
  79638. path: string;
  79639. };
  79640. protected _getModelLoadingConstraints(): boolean;
  79641. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79642. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79643. protected _updateModel(): void;
  79644. /**
  79645. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  79646. * between the touch and touch 2.
  79647. */
  79648. private _isQuest;
  79649. }
  79650. }
  79651. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  79652. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79653. import { Scene } from "babylonjs/scene";
  79654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79655. /**
  79656. * The motion controller class for the standard HTC-Vive controllers
  79657. */
  79658. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  79659. private _modelRootNode;
  79660. /**
  79661. * The base url used to load the left and right controller models
  79662. */
  79663. static MODEL_BASE_URL: string;
  79664. /**
  79665. * File name for the controller model.
  79666. */
  79667. static MODEL_FILENAME: string;
  79668. profileId: string;
  79669. /**
  79670. * Create a new Vive motion controller object
  79671. * @param scene the scene to use to create this controller
  79672. * @param gamepadObject the corresponding gamepad object
  79673. * @param handedness the handedness of the controller
  79674. */
  79675. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79676. protected _getFilenameAndPath(): {
  79677. filename: string;
  79678. path: string;
  79679. };
  79680. protected _getModelLoadingConstraints(): boolean;
  79681. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79682. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79683. protected _updateModel(): void;
  79684. }
  79685. }
  79686. declare module "babylonjs/XR/motionController/index" {
  79687. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79688. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  79689. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  79690. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  79691. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  79692. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  79693. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  79694. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  79695. }
  79696. declare module "babylonjs/XR/index" {
  79697. export * from "babylonjs/XR/webXRCamera";
  79698. export * from "babylonjs/XR/webXREnterExitUI";
  79699. export * from "babylonjs/XR/webXRExperienceHelper";
  79700. export * from "babylonjs/XR/webXRInput";
  79701. export * from "babylonjs/XR/webXRInputSource";
  79702. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  79703. export * from "babylonjs/XR/webXRTypes";
  79704. export * from "babylonjs/XR/webXRSessionManager";
  79705. export * from "babylonjs/XR/webXRDefaultExperience";
  79706. export * from "babylonjs/XR/webXRFeaturesManager";
  79707. export * from "babylonjs/XR/features/index";
  79708. export * from "babylonjs/XR/motionController/index";
  79709. }
  79710. declare module "babylonjs/index" {
  79711. export * from "babylonjs/abstractScene";
  79712. export * from "babylonjs/Actions/index";
  79713. export * from "babylonjs/Animations/index";
  79714. export * from "babylonjs/assetContainer";
  79715. export * from "babylonjs/Audio/index";
  79716. export * from "babylonjs/Behaviors/index";
  79717. export * from "babylonjs/Bones/index";
  79718. export * from "babylonjs/Cameras/index";
  79719. export * from "babylonjs/Collisions/index";
  79720. export * from "babylonjs/Culling/index";
  79721. export * from "babylonjs/Debug/index";
  79722. export * from "babylonjs/DeviceInput/index";
  79723. export * from "babylonjs/Engines/index";
  79724. export * from "babylonjs/Events/index";
  79725. export * from "babylonjs/Gamepads/index";
  79726. export * from "babylonjs/Gizmos/index";
  79727. export * from "babylonjs/Helpers/index";
  79728. export * from "babylonjs/Instrumentation/index";
  79729. export * from "babylonjs/Layers/index";
  79730. export * from "babylonjs/LensFlares/index";
  79731. export * from "babylonjs/Lights/index";
  79732. export * from "babylonjs/Loading/index";
  79733. export * from "babylonjs/Materials/index";
  79734. export * from "babylonjs/Maths/index";
  79735. export * from "babylonjs/Meshes/index";
  79736. export * from "babylonjs/Morph/index";
  79737. export * from "babylonjs/Navigation/index";
  79738. export * from "babylonjs/node";
  79739. export * from "babylonjs/Offline/index";
  79740. export * from "babylonjs/Particles/index";
  79741. export * from "babylonjs/Physics/index";
  79742. export * from "babylonjs/PostProcesses/index";
  79743. export * from "babylonjs/Probes/index";
  79744. export * from "babylonjs/Rendering/index";
  79745. export * from "babylonjs/scene";
  79746. export * from "babylonjs/sceneComponent";
  79747. export * from "babylonjs/Sprites/index";
  79748. export * from "babylonjs/States/index";
  79749. export * from "babylonjs/Misc/index";
  79750. export * from "babylonjs/XR/index";
  79751. export * from "babylonjs/types";
  79752. }
  79753. declare module "babylonjs/Animations/pathCursor" {
  79754. import { Vector3 } from "babylonjs/Maths/math.vector";
  79755. import { Path2 } from "babylonjs/Maths/math.path";
  79756. /**
  79757. * A cursor which tracks a point on a path
  79758. */
  79759. export class PathCursor {
  79760. private path;
  79761. /**
  79762. * Stores path cursor callbacks for when an onchange event is triggered
  79763. */
  79764. private _onchange;
  79765. /**
  79766. * The value of the path cursor
  79767. */
  79768. value: number;
  79769. /**
  79770. * The animation array of the path cursor
  79771. */
  79772. animations: Animation[];
  79773. /**
  79774. * Initializes the path cursor
  79775. * @param path The path to track
  79776. */
  79777. constructor(path: Path2);
  79778. /**
  79779. * Gets the cursor point on the path
  79780. * @returns A point on the path cursor at the cursor location
  79781. */
  79782. getPoint(): Vector3;
  79783. /**
  79784. * Moves the cursor ahead by the step amount
  79785. * @param step The amount to move the cursor forward
  79786. * @returns This path cursor
  79787. */
  79788. moveAhead(step?: number): PathCursor;
  79789. /**
  79790. * Moves the cursor behind by the step amount
  79791. * @param step The amount to move the cursor back
  79792. * @returns This path cursor
  79793. */
  79794. moveBack(step?: number): PathCursor;
  79795. /**
  79796. * Moves the cursor by the step amount
  79797. * If the step amount is greater than one, an exception is thrown
  79798. * @param step The amount to move the cursor
  79799. * @returns This path cursor
  79800. */
  79801. move(step: number): PathCursor;
  79802. /**
  79803. * Ensures that the value is limited between zero and one
  79804. * @returns This path cursor
  79805. */
  79806. private ensureLimits;
  79807. /**
  79808. * Runs onchange callbacks on change (used by the animation engine)
  79809. * @returns This path cursor
  79810. */
  79811. private raiseOnChange;
  79812. /**
  79813. * Executes a function on change
  79814. * @param f A path cursor onchange callback
  79815. * @returns This path cursor
  79816. */
  79817. onchange(f: (cursor: PathCursor) => void): PathCursor;
  79818. }
  79819. }
  79820. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  79821. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  79822. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  79823. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  79824. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  79825. }
  79826. declare module "babylonjs/Engines/Processors/Expressions/index" {
  79827. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  79828. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  79829. }
  79830. declare module "babylonjs/Engines/Processors/index" {
  79831. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  79832. export * from "babylonjs/Engines/Processors/Expressions/index";
  79833. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  79834. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  79835. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  79836. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  79837. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  79838. export * from "babylonjs/Engines/Processors/shaderProcessor";
  79839. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  79840. }
  79841. declare module "babylonjs/Legacy/legacy" {
  79842. import * as Babylon from "babylonjs/index";
  79843. export * from "babylonjs/index";
  79844. }
  79845. declare module "babylonjs/Shaders/blur.fragment" {
  79846. /** @hidden */
  79847. export var blurPixelShader: {
  79848. name: string;
  79849. shader: string;
  79850. };
  79851. }
  79852. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  79853. /** @hidden */
  79854. export var pointCloudVertexDeclaration: {
  79855. name: string;
  79856. shader: string;
  79857. };
  79858. }
  79859. declare module "babylonjs" {
  79860. export * from "babylonjs/Legacy/legacy";
  79861. }
  79862. declare module BABYLON {
  79863. /** Alias type for value that can be null */
  79864. export type Nullable<T> = T | null;
  79865. /**
  79866. * Alias type for number that are floats
  79867. * @ignorenaming
  79868. */
  79869. export type float = number;
  79870. /**
  79871. * Alias type for number that are doubles.
  79872. * @ignorenaming
  79873. */
  79874. export type double = number;
  79875. /**
  79876. * Alias type for number that are integer
  79877. * @ignorenaming
  79878. */
  79879. export type int = number;
  79880. /** Alias type for number array or Float32Array */
  79881. export type FloatArray = number[] | Float32Array;
  79882. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  79883. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  79884. /**
  79885. * Alias for types that can be used by a Buffer or VertexBuffer.
  79886. */
  79887. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  79888. /**
  79889. * Alias type for primitive types
  79890. * @ignorenaming
  79891. */
  79892. type Primitive = undefined | null | boolean | string | number | Function;
  79893. /**
  79894. * Type modifier to make all the properties of an object Readonly
  79895. */
  79896. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  79897. /**
  79898. * Type modifier to make all the properties of an object Readonly recursively
  79899. */
  79900. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  79901. /**
  79902. * Type modifier to make object properties readonly.
  79903. */
  79904. export type DeepImmutableObject<T> = {
  79905. readonly [K in keyof T]: DeepImmutable<T[K]>;
  79906. };
  79907. /** @hidden */
  79908. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  79909. }
  79910. }
  79911. declare module BABYLON {
  79912. /**
  79913. * A class serves as a medium between the observable and its observers
  79914. */
  79915. export class EventState {
  79916. /**
  79917. * Create a new EventState
  79918. * @param mask defines the mask associated with this state
  79919. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79920. * @param target defines the original target of the state
  79921. * @param currentTarget defines the current target of the state
  79922. */
  79923. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  79924. /**
  79925. * Initialize the current event state
  79926. * @param mask defines the mask associated with this state
  79927. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79928. * @param target defines the original target of the state
  79929. * @param currentTarget defines the current target of the state
  79930. * @returns the current event state
  79931. */
  79932. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  79933. /**
  79934. * An Observer can set this property to true to prevent subsequent observers of being notified
  79935. */
  79936. skipNextObservers: boolean;
  79937. /**
  79938. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79939. */
  79940. mask: number;
  79941. /**
  79942. * The object that originally notified the event
  79943. */
  79944. target?: any;
  79945. /**
  79946. * The current object in the bubbling phase
  79947. */
  79948. currentTarget?: any;
  79949. /**
  79950. * This will be populated with the return value of the last function that was executed.
  79951. * If it is the first function in the callback chain it will be the event data.
  79952. */
  79953. lastReturnValue?: any;
  79954. }
  79955. /**
  79956. * Represent an Observer registered to a given Observable object.
  79957. */
  79958. export class Observer<T> {
  79959. /**
  79960. * Defines the callback to call when the observer is notified
  79961. */
  79962. callback: (eventData: T, eventState: EventState) => void;
  79963. /**
  79964. * Defines the mask of the observer (used to filter notifications)
  79965. */
  79966. mask: number;
  79967. /**
  79968. * Defines the current scope used to restore the JS context
  79969. */
  79970. scope: any;
  79971. /** @hidden */
  79972. _willBeUnregistered: boolean;
  79973. /**
  79974. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  79975. */
  79976. unregisterOnNextCall: boolean;
  79977. /**
  79978. * Creates a new observer
  79979. * @param callback defines the callback to call when the observer is notified
  79980. * @param mask defines the mask of the observer (used to filter notifications)
  79981. * @param scope defines the current scope used to restore the JS context
  79982. */
  79983. constructor(
  79984. /**
  79985. * Defines the callback to call when the observer is notified
  79986. */
  79987. callback: (eventData: T, eventState: EventState) => void,
  79988. /**
  79989. * Defines the mask of the observer (used to filter notifications)
  79990. */
  79991. mask: number,
  79992. /**
  79993. * Defines the current scope used to restore the JS context
  79994. */
  79995. scope?: any);
  79996. }
  79997. /**
  79998. * Represent a list of observers registered to multiple Observables object.
  79999. */
  80000. export class MultiObserver<T> {
  80001. private _observers;
  80002. private _observables;
  80003. /**
  80004. * Release associated resources
  80005. */
  80006. dispose(): void;
  80007. /**
  80008. * Raise a callback when one of the observable will notify
  80009. * @param observables defines a list of observables to watch
  80010. * @param callback defines the callback to call on notification
  80011. * @param mask defines the mask used to filter notifications
  80012. * @param scope defines the current scope used to restore the JS context
  80013. * @returns the new MultiObserver
  80014. */
  80015. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80016. }
  80017. /**
  80018. * The Observable class is a simple implementation of the Observable pattern.
  80019. *
  80020. * 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.
  80021. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80022. * 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).
  80023. * 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.
  80024. */
  80025. export class Observable<T> {
  80026. private _observers;
  80027. private _eventState;
  80028. private _onObserverAdded;
  80029. /**
  80030. * Gets the list of observers
  80031. */
  80032. get observers(): Array<Observer<T>>;
  80033. /**
  80034. * Creates a new observable
  80035. * @param onObserverAdded defines a callback to call when a new observer is added
  80036. */
  80037. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80038. /**
  80039. * Create a new Observer with the specified callback
  80040. * @param callback the callback that will be executed for that Observer
  80041. * @param mask the mask used to filter observers
  80042. * @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.
  80043. * @param scope optional scope for the callback to be called from
  80044. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80045. * @returns the new observer created for the callback
  80046. */
  80047. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80048. /**
  80049. * Create a new Observer with the specified callback and unregisters after the next notification
  80050. * @param callback the callback that will be executed for that Observer
  80051. * @returns the new observer created for the callback
  80052. */
  80053. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80054. /**
  80055. * Remove an Observer from the Observable object
  80056. * @param observer the instance of the Observer to remove
  80057. * @returns false if it doesn't belong to this Observable
  80058. */
  80059. remove(observer: Nullable<Observer<T>>): boolean;
  80060. /**
  80061. * Remove a callback from the Observable object
  80062. * @param callback the callback to remove
  80063. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80064. * @returns false if it doesn't belong to this Observable
  80065. */
  80066. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80067. private _deferUnregister;
  80068. private _remove;
  80069. /**
  80070. * Moves the observable to the top of the observer list making it get called first when notified
  80071. * @param observer the observer to move
  80072. */
  80073. makeObserverTopPriority(observer: Observer<T>): void;
  80074. /**
  80075. * Moves the observable to the bottom of the observer list making it get called last when notified
  80076. * @param observer the observer to move
  80077. */
  80078. makeObserverBottomPriority(observer: Observer<T>): void;
  80079. /**
  80080. * Notify all Observers by calling their respective callback with the given data
  80081. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80082. * @param eventData defines the data to send to all observers
  80083. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80084. * @param target defines the original target of the state
  80085. * @param currentTarget defines the current target of the state
  80086. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80087. */
  80088. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  80089. /**
  80090. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80091. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80092. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80093. * and it is crucial that all callbacks will be executed.
  80094. * The order of the callbacks is kept, callbacks are not executed parallel.
  80095. *
  80096. * @param eventData The data to be sent to each callback
  80097. * @param mask is used to filter observers defaults to -1
  80098. * @param target defines the callback target (see EventState)
  80099. * @param currentTarget defines he current object in the bubbling phase
  80100. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80101. */
  80102. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  80103. /**
  80104. * Notify a specific observer
  80105. * @param observer defines the observer to notify
  80106. * @param eventData defines the data to be sent to each callback
  80107. * @param mask is used to filter observers defaults to -1
  80108. */
  80109. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80110. /**
  80111. * Gets a boolean indicating if the observable has at least one observer
  80112. * @returns true is the Observable has at least one Observer registered
  80113. */
  80114. hasObservers(): boolean;
  80115. /**
  80116. * Clear the list of observers
  80117. */
  80118. clear(): void;
  80119. /**
  80120. * Clone the current observable
  80121. * @returns a new observable
  80122. */
  80123. clone(): Observable<T>;
  80124. /**
  80125. * Does this observable handles observer registered with a given mask
  80126. * @param mask defines the mask to be tested
  80127. * @return whether or not one observer registered with the given mask is handeled
  80128. **/
  80129. hasSpecificMask(mask?: number): boolean;
  80130. }
  80131. }
  80132. declare module BABYLON {
  80133. /**
  80134. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80135. * Babylon.js
  80136. */
  80137. export class DomManagement {
  80138. /**
  80139. * Checks if the window object exists
  80140. * @returns true if the window object exists
  80141. */
  80142. static IsWindowObjectExist(): boolean;
  80143. /**
  80144. * Checks if the navigator object exists
  80145. * @returns true if the navigator object exists
  80146. */
  80147. static IsNavigatorAvailable(): boolean;
  80148. /**
  80149. * Check if the document object exists
  80150. * @returns true if the document object exists
  80151. */
  80152. static IsDocumentAvailable(): boolean;
  80153. /**
  80154. * Extracts text content from a DOM element hierarchy
  80155. * @param element defines the root element
  80156. * @returns a string
  80157. */
  80158. static GetDOMTextContent(element: HTMLElement): string;
  80159. }
  80160. }
  80161. declare module BABYLON {
  80162. /**
  80163. * Logger used througouht the application to allow configuration of
  80164. * the log level required for the messages.
  80165. */
  80166. export class Logger {
  80167. /**
  80168. * No log
  80169. */
  80170. static readonly NoneLogLevel: number;
  80171. /**
  80172. * Only message logs
  80173. */
  80174. static readonly MessageLogLevel: number;
  80175. /**
  80176. * Only warning logs
  80177. */
  80178. static readonly WarningLogLevel: number;
  80179. /**
  80180. * Only error logs
  80181. */
  80182. static readonly ErrorLogLevel: number;
  80183. /**
  80184. * All logs
  80185. */
  80186. static readonly AllLogLevel: number;
  80187. private static _LogCache;
  80188. /**
  80189. * Gets a value indicating the number of loading errors
  80190. * @ignorenaming
  80191. */
  80192. static errorsCount: number;
  80193. /**
  80194. * Callback called when a new log is added
  80195. */
  80196. static OnNewCacheEntry: (entry: string) => void;
  80197. private static _AddLogEntry;
  80198. private static _FormatMessage;
  80199. private static _LogDisabled;
  80200. private static _LogEnabled;
  80201. private static _WarnDisabled;
  80202. private static _WarnEnabled;
  80203. private static _ErrorDisabled;
  80204. private static _ErrorEnabled;
  80205. /**
  80206. * Log a message to the console
  80207. */
  80208. static Log: (message: string) => void;
  80209. /**
  80210. * Write a warning message to the console
  80211. */
  80212. static Warn: (message: string) => void;
  80213. /**
  80214. * Write an error message to the console
  80215. */
  80216. static Error: (message: string) => void;
  80217. /**
  80218. * Gets current log cache (list of logs)
  80219. */
  80220. static get LogCache(): string;
  80221. /**
  80222. * Clears the log cache
  80223. */
  80224. static ClearLogCache(): void;
  80225. /**
  80226. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  80227. */
  80228. static set LogLevels(level: number);
  80229. }
  80230. }
  80231. declare module BABYLON {
  80232. /** @hidden */
  80233. export class _TypeStore {
  80234. /** @hidden */
  80235. static RegisteredTypes: {
  80236. [key: string]: Object;
  80237. };
  80238. /** @hidden */
  80239. static GetClass(fqdn: string): any;
  80240. }
  80241. }
  80242. declare module BABYLON {
  80243. /**
  80244. * Helper to manipulate strings
  80245. */
  80246. export class StringTools {
  80247. /**
  80248. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  80249. * @param str Source string
  80250. * @param suffix Suffix to search for in the source string
  80251. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80252. */
  80253. static EndsWith(str: string, suffix: string): boolean;
  80254. /**
  80255. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  80256. * @param str Source string
  80257. * @param suffix Suffix to search for in the source string
  80258. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80259. */
  80260. static StartsWith(str: string, suffix: string): boolean;
  80261. /**
  80262. * Decodes a buffer into a string
  80263. * @param buffer The buffer to decode
  80264. * @returns The decoded string
  80265. */
  80266. static Decode(buffer: Uint8Array | Uint16Array): string;
  80267. /**
  80268. * Encode a buffer to a base64 string
  80269. * @param buffer defines the buffer to encode
  80270. * @returns the encoded string
  80271. */
  80272. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  80273. /**
  80274. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  80275. * @param num the number to convert and pad
  80276. * @param length the expected length of the string
  80277. * @returns the padded string
  80278. */
  80279. static PadNumber(num: number, length: number): string;
  80280. }
  80281. }
  80282. declare module BABYLON {
  80283. /**
  80284. * Class containing a set of static utilities functions for deep copy.
  80285. */
  80286. export class DeepCopier {
  80287. /**
  80288. * Tries to copy an object by duplicating every property
  80289. * @param source defines the source object
  80290. * @param destination defines the target object
  80291. * @param doNotCopyList defines a list of properties to avoid
  80292. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  80293. */
  80294. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  80295. }
  80296. }
  80297. declare module BABYLON {
  80298. /**
  80299. * Class containing a set of static utilities functions for precision date
  80300. */
  80301. export class PrecisionDate {
  80302. /**
  80303. * Gets either window.performance.now() if supported or Date.now() else
  80304. */
  80305. static get Now(): number;
  80306. }
  80307. }
  80308. declare module BABYLON {
  80309. /** @hidden */
  80310. export class _DevTools {
  80311. static WarnImport(name: string): string;
  80312. }
  80313. }
  80314. declare module BABYLON {
  80315. /**
  80316. * Interface used to define the mechanism to get data from the network
  80317. */
  80318. export interface IWebRequest {
  80319. /**
  80320. * Returns client's response url
  80321. */
  80322. responseURL: string;
  80323. /**
  80324. * Returns client's status
  80325. */
  80326. status: number;
  80327. /**
  80328. * Returns client's status as a text
  80329. */
  80330. statusText: string;
  80331. }
  80332. }
  80333. declare module BABYLON {
  80334. /**
  80335. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  80336. */
  80337. export class WebRequest implements IWebRequest {
  80338. private _xhr;
  80339. /**
  80340. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  80341. * i.e. when loading files, where the server/service expects an Authorization header
  80342. */
  80343. static CustomRequestHeaders: {
  80344. [key: string]: string;
  80345. };
  80346. /**
  80347. * Add callback functions in this array to update all the requests before they get sent to the network
  80348. */
  80349. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  80350. private _injectCustomRequestHeaders;
  80351. /**
  80352. * Gets or sets a function to be called when loading progress changes
  80353. */
  80354. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  80355. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  80356. /**
  80357. * Returns client's state
  80358. */
  80359. get readyState(): number;
  80360. /**
  80361. * Returns client's status
  80362. */
  80363. get status(): number;
  80364. /**
  80365. * Returns client's status as a text
  80366. */
  80367. get statusText(): string;
  80368. /**
  80369. * Returns client's response
  80370. */
  80371. get response(): any;
  80372. /**
  80373. * Returns client's response url
  80374. */
  80375. get responseURL(): string;
  80376. /**
  80377. * Returns client's response as text
  80378. */
  80379. get responseText(): string;
  80380. /**
  80381. * Gets or sets the expected response type
  80382. */
  80383. get responseType(): XMLHttpRequestResponseType;
  80384. set responseType(value: XMLHttpRequestResponseType);
  80385. /** @hidden */
  80386. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  80387. /** @hidden */
  80388. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  80389. /**
  80390. * Cancels any network activity
  80391. */
  80392. abort(): void;
  80393. /**
  80394. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  80395. * @param body defines an optional request body
  80396. */
  80397. send(body?: Document | BodyInit | null): void;
  80398. /**
  80399. * Sets the request method, request URL
  80400. * @param method defines the method to use (GET, POST, etc..)
  80401. * @param url defines the url to connect with
  80402. */
  80403. open(method: string, url: string): void;
  80404. /**
  80405. * Sets the value of a request header.
  80406. * @param name The name of the header whose value is to be set
  80407. * @param value The value to set as the body of the header
  80408. */
  80409. setRequestHeader(name: string, value: string): void;
  80410. /**
  80411. * Get the string containing the text of a particular header's value.
  80412. * @param name The name of the header
  80413. * @returns The string containing the text of the given header name
  80414. */
  80415. getResponseHeader(name: string): Nullable<string>;
  80416. }
  80417. }
  80418. declare module BABYLON {
  80419. /**
  80420. * File request interface
  80421. */
  80422. export interface IFileRequest {
  80423. /**
  80424. * Raised when the request is complete (success or error).
  80425. */
  80426. onCompleteObservable: Observable<IFileRequest>;
  80427. /**
  80428. * Aborts the request for a file.
  80429. */
  80430. abort: () => void;
  80431. }
  80432. }
  80433. declare module BABYLON {
  80434. /**
  80435. * Define options used to create a render target texture
  80436. */
  80437. export class RenderTargetCreationOptions {
  80438. /**
  80439. * Specifies is mipmaps must be generated
  80440. */
  80441. generateMipMaps?: boolean;
  80442. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  80443. generateDepthBuffer?: boolean;
  80444. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  80445. generateStencilBuffer?: boolean;
  80446. /** Defines texture type (int by default) */
  80447. type?: number;
  80448. /** Defines sampling mode (trilinear by default) */
  80449. samplingMode?: number;
  80450. /** Defines format (RGBA by default) */
  80451. format?: number;
  80452. }
  80453. }
  80454. declare module BABYLON {
  80455. /** Defines the cross module used constants to avoid circular dependncies */
  80456. export class Constants {
  80457. /** Defines that alpha blending is disabled */
  80458. static readonly ALPHA_DISABLE: number;
  80459. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  80460. static readonly ALPHA_ADD: number;
  80461. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  80462. static readonly ALPHA_COMBINE: number;
  80463. /** Defines that alpha blending is DEST - SRC * DEST */
  80464. static readonly ALPHA_SUBTRACT: number;
  80465. /** Defines that alpha blending is SRC * DEST */
  80466. static readonly ALPHA_MULTIPLY: number;
  80467. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  80468. static readonly ALPHA_MAXIMIZED: number;
  80469. /** Defines that alpha blending is SRC + DEST */
  80470. static readonly ALPHA_ONEONE: number;
  80471. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  80472. static readonly ALPHA_PREMULTIPLIED: number;
  80473. /**
  80474. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  80475. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  80476. */
  80477. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  80478. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  80479. static readonly ALPHA_INTERPOLATE: number;
  80480. /**
  80481. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  80482. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  80483. */
  80484. static readonly ALPHA_SCREENMODE: number;
  80485. /**
  80486. * Defines that alpha blending is SRC + DST
  80487. * Alpha will be set to SRC ALPHA + DST ALPHA
  80488. */
  80489. static readonly ALPHA_ONEONE_ONEONE: number;
  80490. /**
  80491. * Defines that alpha blending is SRC * DST ALPHA + DST
  80492. * Alpha will be set to 0
  80493. */
  80494. static readonly ALPHA_ALPHATOCOLOR: number;
  80495. /**
  80496. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80497. */
  80498. static readonly ALPHA_REVERSEONEMINUS: number;
  80499. /**
  80500. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  80501. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  80502. */
  80503. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  80504. /**
  80505. * Defines that alpha blending is SRC + DST
  80506. * Alpha will be set to SRC ALPHA
  80507. */
  80508. static readonly ALPHA_ONEONE_ONEZERO: number;
  80509. /**
  80510. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80511. * Alpha will be set to DST ALPHA
  80512. */
  80513. static readonly ALPHA_EXCLUSION: number;
  80514. /** Defines that alpha blending equation a SUM */
  80515. static readonly ALPHA_EQUATION_ADD: number;
  80516. /** Defines that alpha blending equation a SUBSTRACTION */
  80517. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  80518. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  80519. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  80520. /** Defines that alpha blending equation a MAX operation */
  80521. static readonly ALPHA_EQUATION_MAX: number;
  80522. /** Defines that alpha blending equation a MIN operation */
  80523. static readonly ALPHA_EQUATION_MIN: number;
  80524. /**
  80525. * Defines that alpha blending equation a DARKEN operation:
  80526. * It takes the min of the src and sums the alpha channels.
  80527. */
  80528. static readonly ALPHA_EQUATION_DARKEN: number;
  80529. /** Defines that the ressource is not delayed*/
  80530. static readonly DELAYLOADSTATE_NONE: number;
  80531. /** Defines that the ressource was successfully delay loaded */
  80532. static readonly DELAYLOADSTATE_LOADED: number;
  80533. /** Defines that the ressource is currently delay loading */
  80534. static readonly DELAYLOADSTATE_LOADING: number;
  80535. /** Defines that the ressource is delayed and has not started loading */
  80536. static readonly DELAYLOADSTATE_NOTLOADED: number;
  80537. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  80538. static readonly NEVER: number;
  80539. /** 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 */
  80540. static readonly ALWAYS: number;
  80541. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  80542. static readonly LESS: number;
  80543. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  80544. static readonly EQUAL: number;
  80545. /** 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 */
  80546. static readonly LEQUAL: number;
  80547. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  80548. static readonly GREATER: number;
  80549. /** 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 */
  80550. static readonly GEQUAL: number;
  80551. /** 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 */
  80552. static readonly NOTEQUAL: number;
  80553. /** Passed to stencilOperation to specify that stencil value must be kept */
  80554. static readonly KEEP: number;
  80555. /** Passed to stencilOperation to specify that stencil value must be replaced */
  80556. static readonly REPLACE: number;
  80557. /** Passed to stencilOperation to specify that stencil value must be incremented */
  80558. static readonly INCR: number;
  80559. /** Passed to stencilOperation to specify that stencil value must be decremented */
  80560. static readonly DECR: number;
  80561. /** Passed to stencilOperation to specify that stencil value must be inverted */
  80562. static readonly INVERT: number;
  80563. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  80564. static readonly INCR_WRAP: number;
  80565. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  80566. static readonly DECR_WRAP: number;
  80567. /** Texture is not repeating outside of 0..1 UVs */
  80568. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  80569. /** Texture is repeating outside of 0..1 UVs */
  80570. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  80571. /** Texture is repeating and mirrored */
  80572. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  80573. /** ALPHA */
  80574. static readonly TEXTUREFORMAT_ALPHA: number;
  80575. /** LUMINANCE */
  80576. static readonly TEXTUREFORMAT_LUMINANCE: number;
  80577. /** LUMINANCE_ALPHA */
  80578. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  80579. /** RGB */
  80580. static readonly TEXTUREFORMAT_RGB: number;
  80581. /** RGBA */
  80582. static readonly TEXTUREFORMAT_RGBA: number;
  80583. /** RED */
  80584. static readonly TEXTUREFORMAT_RED: number;
  80585. /** RED (2nd reference) */
  80586. static readonly TEXTUREFORMAT_R: number;
  80587. /** RG */
  80588. static readonly TEXTUREFORMAT_RG: number;
  80589. /** RED_INTEGER */
  80590. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  80591. /** RED_INTEGER (2nd reference) */
  80592. static readonly TEXTUREFORMAT_R_INTEGER: number;
  80593. /** RG_INTEGER */
  80594. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  80595. /** RGB_INTEGER */
  80596. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  80597. /** RGBA_INTEGER */
  80598. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  80599. /** UNSIGNED_BYTE */
  80600. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  80601. /** UNSIGNED_BYTE (2nd reference) */
  80602. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  80603. /** FLOAT */
  80604. static readonly TEXTURETYPE_FLOAT: number;
  80605. /** HALF_FLOAT */
  80606. static readonly TEXTURETYPE_HALF_FLOAT: number;
  80607. /** BYTE */
  80608. static readonly TEXTURETYPE_BYTE: number;
  80609. /** SHORT */
  80610. static readonly TEXTURETYPE_SHORT: number;
  80611. /** UNSIGNED_SHORT */
  80612. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  80613. /** INT */
  80614. static readonly TEXTURETYPE_INT: number;
  80615. /** UNSIGNED_INT */
  80616. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  80617. /** UNSIGNED_SHORT_4_4_4_4 */
  80618. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  80619. /** UNSIGNED_SHORT_5_5_5_1 */
  80620. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  80621. /** UNSIGNED_SHORT_5_6_5 */
  80622. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  80623. /** UNSIGNED_INT_2_10_10_10_REV */
  80624. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  80625. /** UNSIGNED_INT_24_8 */
  80626. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  80627. /** UNSIGNED_INT_10F_11F_11F_REV */
  80628. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  80629. /** UNSIGNED_INT_5_9_9_9_REV */
  80630. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  80631. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  80632. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80633. /** nearest is mag = nearest and min = nearest and no mip */
  80634. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  80635. /** mag = nearest and min = nearest and mip = none */
  80636. static readonly TEXTURE_NEAREST_NEAREST: number;
  80637. /** Bilinear is mag = linear and min = linear and no mip */
  80638. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  80639. /** mag = linear and min = linear and mip = none */
  80640. static readonly TEXTURE_LINEAR_LINEAR: number;
  80641. /** Trilinear is mag = linear and min = linear and mip = linear */
  80642. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  80643. /** Trilinear is mag = linear and min = linear and mip = linear */
  80644. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  80645. /** mag = nearest and min = nearest and mip = nearest */
  80646. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  80647. /** mag = nearest and min = linear and mip = nearest */
  80648. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  80649. /** mag = nearest and min = linear and mip = linear */
  80650. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  80651. /** mag = nearest and min = linear and mip = none */
  80652. static readonly TEXTURE_NEAREST_LINEAR: number;
  80653. /** nearest is mag = nearest and min = nearest and mip = linear */
  80654. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  80655. /** mag = linear and min = nearest and mip = nearest */
  80656. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  80657. /** mag = linear and min = nearest and mip = linear */
  80658. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  80659. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80660. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  80661. /** mag = linear and min = nearest and mip = none */
  80662. static readonly TEXTURE_LINEAR_NEAREST: number;
  80663. /** Explicit coordinates mode */
  80664. static readonly TEXTURE_EXPLICIT_MODE: number;
  80665. /** Spherical coordinates mode */
  80666. static readonly TEXTURE_SPHERICAL_MODE: number;
  80667. /** Planar coordinates mode */
  80668. static readonly TEXTURE_PLANAR_MODE: number;
  80669. /** Cubic coordinates mode */
  80670. static readonly TEXTURE_CUBIC_MODE: number;
  80671. /** Projection coordinates mode */
  80672. static readonly TEXTURE_PROJECTION_MODE: number;
  80673. /** Skybox coordinates mode */
  80674. static readonly TEXTURE_SKYBOX_MODE: number;
  80675. /** Inverse Cubic coordinates mode */
  80676. static readonly TEXTURE_INVCUBIC_MODE: number;
  80677. /** Equirectangular coordinates mode */
  80678. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  80679. /** Equirectangular Fixed coordinates mode */
  80680. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  80681. /** Equirectangular Fixed Mirrored coordinates mode */
  80682. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80683. /** Offline (baking) quality for texture filtering */
  80684. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  80685. /** High quality for texture filtering */
  80686. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  80687. /** Medium quality for texture filtering */
  80688. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  80689. /** Low quality for texture filtering */
  80690. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  80691. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  80692. static readonly SCALEMODE_FLOOR: number;
  80693. /** Defines that texture rescaling will look for the nearest power of 2 size */
  80694. static readonly SCALEMODE_NEAREST: number;
  80695. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  80696. static readonly SCALEMODE_CEILING: number;
  80697. /**
  80698. * The dirty texture flag value
  80699. */
  80700. static readonly MATERIAL_TextureDirtyFlag: number;
  80701. /**
  80702. * The dirty light flag value
  80703. */
  80704. static readonly MATERIAL_LightDirtyFlag: number;
  80705. /**
  80706. * The dirty fresnel flag value
  80707. */
  80708. static readonly MATERIAL_FresnelDirtyFlag: number;
  80709. /**
  80710. * The dirty attribute flag value
  80711. */
  80712. static readonly MATERIAL_AttributesDirtyFlag: number;
  80713. /**
  80714. * The dirty misc flag value
  80715. */
  80716. static readonly MATERIAL_MiscDirtyFlag: number;
  80717. /**
  80718. * The all dirty flag value
  80719. */
  80720. static readonly MATERIAL_AllDirtyFlag: number;
  80721. /**
  80722. * Returns the triangle fill mode
  80723. */
  80724. static readonly MATERIAL_TriangleFillMode: number;
  80725. /**
  80726. * Returns the wireframe mode
  80727. */
  80728. static readonly MATERIAL_WireFrameFillMode: number;
  80729. /**
  80730. * Returns the point fill mode
  80731. */
  80732. static readonly MATERIAL_PointFillMode: number;
  80733. /**
  80734. * Returns the point list draw mode
  80735. */
  80736. static readonly MATERIAL_PointListDrawMode: number;
  80737. /**
  80738. * Returns the line list draw mode
  80739. */
  80740. static readonly MATERIAL_LineListDrawMode: number;
  80741. /**
  80742. * Returns the line loop draw mode
  80743. */
  80744. static readonly MATERIAL_LineLoopDrawMode: number;
  80745. /**
  80746. * Returns the line strip draw mode
  80747. */
  80748. static readonly MATERIAL_LineStripDrawMode: number;
  80749. /**
  80750. * Returns the triangle strip draw mode
  80751. */
  80752. static readonly MATERIAL_TriangleStripDrawMode: number;
  80753. /**
  80754. * Returns the triangle fan draw mode
  80755. */
  80756. static readonly MATERIAL_TriangleFanDrawMode: number;
  80757. /**
  80758. * Stores the clock-wise side orientation
  80759. */
  80760. static readonly MATERIAL_ClockWiseSideOrientation: number;
  80761. /**
  80762. * Stores the counter clock-wise side orientation
  80763. */
  80764. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  80765. /**
  80766. * Nothing
  80767. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80768. */
  80769. static readonly ACTION_NothingTrigger: number;
  80770. /**
  80771. * On pick
  80772. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80773. */
  80774. static readonly ACTION_OnPickTrigger: number;
  80775. /**
  80776. * On left pick
  80777. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80778. */
  80779. static readonly ACTION_OnLeftPickTrigger: number;
  80780. /**
  80781. * On right pick
  80782. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80783. */
  80784. static readonly ACTION_OnRightPickTrigger: number;
  80785. /**
  80786. * On center pick
  80787. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80788. */
  80789. static readonly ACTION_OnCenterPickTrigger: number;
  80790. /**
  80791. * On pick down
  80792. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80793. */
  80794. static readonly ACTION_OnPickDownTrigger: number;
  80795. /**
  80796. * On double pick
  80797. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80798. */
  80799. static readonly ACTION_OnDoublePickTrigger: number;
  80800. /**
  80801. * On pick up
  80802. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80803. */
  80804. static readonly ACTION_OnPickUpTrigger: number;
  80805. /**
  80806. * On pick out.
  80807. * This trigger will only be raised if you also declared a OnPickDown
  80808. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80809. */
  80810. static readonly ACTION_OnPickOutTrigger: number;
  80811. /**
  80812. * On long press
  80813. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80814. */
  80815. static readonly ACTION_OnLongPressTrigger: number;
  80816. /**
  80817. * On pointer over
  80818. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80819. */
  80820. static readonly ACTION_OnPointerOverTrigger: number;
  80821. /**
  80822. * On pointer out
  80823. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80824. */
  80825. static readonly ACTION_OnPointerOutTrigger: number;
  80826. /**
  80827. * On every frame
  80828. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80829. */
  80830. static readonly ACTION_OnEveryFrameTrigger: number;
  80831. /**
  80832. * On intersection enter
  80833. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80834. */
  80835. static readonly ACTION_OnIntersectionEnterTrigger: number;
  80836. /**
  80837. * On intersection exit
  80838. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80839. */
  80840. static readonly ACTION_OnIntersectionExitTrigger: number;
  80841. /**
  80842. * On key down
  80843. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80844. */
  80845. static readonly ACTION_OnKeyDownTrigger: number;
  80846. /**
  80847. * On key up
  80848. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80849. */
  80850. static readonly ACTION_OnKeyUpTrigger: number;
  80851. /**
  80852. * Billboard mode will only apply to Y axis
  80853. */
  80854. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  80855. /**
  80856. * Billboard mode will apply to all axes
  80857. */
  80858. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  80859. /**
  80860. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  80861. */
  80862. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  80863. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80864. * Test order :
  80865. * Is the bounding sphere outside the frustum ?
  80866. * If not, are the bounding box vertices outside the frustum ?
  80867. * It not, then the cullable object is in the frustum.
  80868. */
  80869. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  80870. /** Culling strategy : Bounding Sphere Only.
  80871. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80872. * It's also less accurate than the standard because some not visible objects can still be selected.
  80873. * Test : is the bounding sphere outside the frustum ?
  80874. * If not, then the cullable object is in the frustum.
  80875. */
  80876. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80877. /** Culling strategy : Optimistic Inclusion.
  80878. * This in an inclusion test first, then the standard exclusion test.
  80879. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80880. * 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.
  80881. * Anyway, it's as accurate as the standard strategy.
  80882. * Test :
  80883. * Is the cullable object bounding sphere center in the frustum ?
  80884. * If not, apply the default culling strategy.
  80885. */
  80886. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80887. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80888. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80889. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80890. * 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.
  80891. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80892. * Test :
  80893. * Is the cullable object bounding sphere center in the frustum ?
  80894. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80895. */
  80896. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80897. /**
  80898. * No logging while loading
  80899. */
  80900. static readonly SCENELOADER_NO_LOGGING: number;
  80901. /**
  80902. * Minimal logging while loading
  80903. */
  80904. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  80905. /**
  80906. * Summary logging while loading
  80907. */
  80908. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  80909. /**
  80910. * Detailled logging while loading
  80911. */
  80912. static readonly SCENELOADER_DETAILED_LOGGING: number;
  80913. /**
  80914. * Prepass texture index for color
  80915. */
  80916. static readonly PREPASS_COLOR_INDEX: number;
  80917. /**
  80918. * Prepass texture index for irradiance
  80919. */
  80920. static readonly PREPASS_IRRADIANCE_INDEX: number;
  80921. /**
  80922. * Prepass texture index for depth + normal
  80923. */
  80924. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  80925. /**
  80926. * Prepass texture index for albedo
  80927. */
  80928. static readonly PREPASS_ALBEDO_INDEX: number;
  80929. }
  80930. }
  80931. declare module BABYLON {
  80932. /**
  80933. * This represents the required contract to create a new type of texture loader.
  80934. */
  80935. export interface IInternalTextureLoader {
  80936. /**
  80937. * Defines wether the loader supports cascade loading the different faces.
  80938. */
  80939. supportCascades: boolean;
  80940. /**
  80941. * This returns if the loader support the current file information.
  80942. * @param extension defines the file extension of the file being loaded
  80943. * @param mimeType defines the optional mime type of the file being loaded
  80944. * @returns true if the loader can load the specified file
  80945. */
  80946. canLoad(extension: string, mimeType?: string): boolean;
  80947. /**
  80948. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  80949. * @param data contains the texture data
  80950. * @param texture defines the BabylonJS internal texture
  80951. * @param createPolynomials will be true if polynomials have been requested
  80952. * @param onLoad defines the callback to trigger once the texture is ready
  80953. * @param onError defines the callback to trigger in case of error
  80954. */
  80955. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  80956. /**
  80957. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  80958. * @param data contains the texture data
  80959. * @param texture defines the BabylonJS internal texture
  80960. * @param callback defines the method to call once ready to upload
  80961. */
  80962. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  80963. }
  80964. }
  80965. declare module BABYLON {
  80966. /**
  80967. * Class used to store and describe the pipeline context associated with an effect
  80968. */
  80969. export interface IPipelineContext {
  80970. /**
  80971. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  80972. */
  80973. isAsync: boolean;
  80974. /**
  80975. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  80976. */
  80977. isReady: boolean;
  80978. /** @hidden */
  80979. _getVertexShaderCode(): string | null;
  80980. /** @hidden */
  80981. _getFragmentShaderCode(): string | null;
  80982. /** @hidden */
  80983. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  80984. }
  80985. }
  80986. declare module BABYLON {
  80987. /**
  80988. * Class used to store gfx data (like WebGLBuffer)
  80989. */
  80990. export class DataBuffer {
  80991. /**
  80992. * Gets or sets the number of objects referencing this buffer
  80993. */
  80994. references: number;
  80995. /** Gets or sets the size of the underlying buffer */
  80996. capacity: number;
  80997. /**
  80998. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  80999. */
  81000. is32Bits: boolean;
  81001. /**
  81002. * Gets the underlying buffer
  81003. */
  81004. get underlyingResource(): any;
  81005. }
  81006. }
  81007. declare module BABYLON {
  81008. /** @hidden */
  81009. export interface IShaderProcessor {
  81010. attributeProcessor?: (attribute: string) => string;
  81011. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81012. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81013. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81014. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81015. lineProcessor?: (line: string, isFragment: boolean) => string;
  81016. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81017. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81018. }
  81019. }
  81020. declare module BABYLON {
  81021. /** @hidden */
  81022. export interface ProcessingOptions {
  81023. defines: string[];
  81024. indexParameters: any;
  81025. isFragment: boolean;
  81026. shouldUseHighPrecisionShader: boolean;
  81027. supportsUniformBuffers: boolean;
  81028. shadersRepository: string;
  81029. includesShadersStore: {
  81030. [key: string]: string;
  81031. };
  81032. processor?: IShaderProcessor;
  81033. version: string;
  81034. platformName: string;
  81035. lookForClosingBracketForUniformBuffer?: boolean;
  81036. }
  81037. }
  81038. declare module BABYLON {
  81039. /** @hidden */
  81040. export class ShaderCodeNode {
  81041. line: string;
  81042. children: ShaderCodeNode[];
  81043. additionalDefineKey?: string;
  81044. additionalDefineValue?: string;
  81045. isValid(preprocessors: {
  81046. [key: string]: string;
  81047. }): boolean;
  81048. process(preprocessors: {
  81049. [key: string]: string;
  81050. }, options: ProcessingOptions): string;
  81051. }
  81052. }
  81053. declare module BABYLON {
  81054. /** @hidden */
  81055. export class ShaderCodeCursor {
  81056. private _lines;
  81057. lineIndex: number;
  81058. get currentLine(): string;
  81059. get canRead(): boolean;
  81060. set lines(value: string[]);
  81061. }
  81062. }
  81063. declare module BABYLON {
  81064. /** @hidden */
  81065. export class ShaderCodeConditionNode extends ShaderCodeNode {
  81066. process(preprocessors: {
  81067. [key: string]: string;
  81068. }, options: ProcessingOptions): string;
  81069. }
  81070. }
  81071. declare module BABYLON {
  81072. /** @hidden */
  81073. export class ShaderDefineExpression {
  81074. isTrue(preprocessors: {
  81075. [key: string]: string;
  81076. }): boolean;
  81077. private static _OperatorPriority;
  81078. private static _Stack;
  81079. static postfixToInfix(postfix: string[]): string;
  81080. static infixToPostfix(infix: string): string[];
  81081. }
  81082. }
  81083. declare module BABYLON {
  81084. /** @hidden */
  81085. export class ShaderCodeTestNode extends ShaderCodeNode {
  81086. testExpression: ShaderDefineExpression;
  81087. isValid(preprocessors: {
  81088. [key: string]: string;
  81089. }): boolean;
  81090. }
  81091. }
  81092. declare module BABYLON {
  81093. /** @hidden */
  81094. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81095. define: string;
  81096. not: boolean;
  81097. constructor(define: string, not?: boolean);
  81098. isTrue(preprocessors: {
  81099. [key: string]: string;
  81100. }): boolean;
  81101. }
  81102. }
  81103. declare module BABYLON {
  81104. /** @hidden */
  81105. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81106. leftOperand: ShaderDefineExpression;
  81107. rightOperand: ShaderDefineExpression;
  81108. isTrue(preprocessors: {
  81109. [key: string]: string;
  81110. }): boolean;
  81111. }
  81112. }
  81113. declare module BABYLON {
  81114. /** @hidden */
  81115. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81116. leftOperand: ShaderDefineExpression;
  81117. rightOperand: ShaderDefineExpression;
  81118. isTrue(preprocessors: {
  81119. [key: string]: string;
  81120. }): boolean;
  81121. }
  81122. }
  81123. declare module BABYLON {
  81124. /** @hidden */
  81125. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81126. define: string;
  81127. operand: string;
  81128. testValue: string;
  81129. constructor(define: string, operand: string, testValue: string);
  81130. isTrue(preprocessors: {
  81131. [key: string]: string;
  81132. }): boolean;
  81133. }
  81134. }
  81135. declare module BABYLON {
  81136. /**
  81137. * Class used to enable access to offline support
  81138. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  81139. */
  81140. export interface IOfflineProvider {
  81141. /**
  81142. * Gets a boolean indicating if scene must be saved in the database
  81143. */
  81144. enableSceneOffline: boolean;
  81145. /**
  81146. * Gets a boolean indicating if textures must be saved in the database
  81147. */
  81148. enableTexturesOffline: boolean;
  81149. /**
  81150. * Open the offline support and make it available
  81151. * @param successCallback defines the callback to call on success
  81152. * @param errorCallback defines the callback to call on error
  81153. */
  81154. open(successCallback: () => void, errorCallback: () => void): void;
  81155. /**
  81156. * Loads an image from the offline support
  81157. * @param url defines the url to load from
  81158. * @param image defines the target DOM image
  81159. */
  81160. loadImage(url: string, image: HTMLImageElement): void;
  81161. /**
  81162. * Loads a file from offline support
  81163. * @param url defines the URL to load from
  81164. * @param sceneLoaded defines a callback to call on success
  81165. * @param progressCallBack defines a callback to call when progress changed
  81166. * @param errorCallback defines a callback to call on error
  81167. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  81168. */
  81169. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  81170. }
  81171. }
  81172. declare module BABYLON {
  81173. /**
  81174. * Class used to help managing file picking and drag'n'drop
  81175. * File Storage
  81176. */
  81177. export class FilesInputStore {
  81178. /**
  81179. * List of files ready to be loaded
  81180. */
  81181. static FilesToLoad: {
  81182. [key: string]: File;
  81183. };
  81184. }
  81185. }
  81186. declare module BABYLON {
  81187. /**
  81188. * Class used to define a retry strategy when error happens while loading assets
  81189. */
  81190. export class RetryStrategy {
  81191. /**
  81192. * Function used to defines an exponential back off strategy
  81193. * @param maxRetries defines the maximum number of retries (3 by default)
  81194. * @param baseInterval defines the interval between retries
  81195. * @returns the strategy function to use
  81196. */
  81197. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  81198. }
  81199. }
  81200. declare module BABYLON {
  81201. /**
  81202. * @ignore
  81203. * Application error to support additional information when loading a file
  81204. */
  81205. export abstract class BaseError extends Error {
  81206. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  81207. }
  81208. }
  81209. declare module BABYLON {
  81210. /** @ignore */
  81211. export class LoadFileError extends BaseError {
  81212. request?: WebRequest;
  81213. file?: File;
  81214. /**
  81215. * Creates a new LoadFileError
  81216. * @param message defines the message of the error
  81217. * @param request defines the optional web request
  81218. * @param file defines the optional file
  81219. */
  81220. constructor(message: string, object?: WebRequest | File);
  81221. }
  81222. /** @ignore */
  81223. export class RequestFileError extends BaseError {
  81224. request: WebRequest;
  81225. /**
  81226. * Creates a new LoadFileError
  81227. * @param message defines the message of the error
  81228. * @param request defines the optional web request
  81229. */
  81230. constructor(message: string, request: WebRequest);
  81231. }
  81232. /** @ignore */
  81233. export class ReadFileError extends BaseError {
  81234. file: File;
  81235. /**
  81236. * Creates a new ReadFileError
  81237. * @param message defines the message of the error
  81238. * @param file defines the optional file
  81239. */
  81240. constructor(message: string, file: File);
  81241. }
  81242. /**
  81243. * @hidden
  81244. */
  81245. export class FileTools {
  81246. /**
  81247. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  81248. */
  81249. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  81250. /**
  81251. * Gets or sets the base URL to use to load assets
  81252. */
  81253. static BaseUrl: string;
  81254. /**
  81255. * Default behaviour for cors in the application.
  81256. * It can be a string if the expected behavior is identical in the entire app.
  81257. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  81258. */
  81259. static CorsBehavior: string | ((url: string | string[]) => string);
  81260. /**
  81261. * Gets or sets a function used to pre-process url before using them to load assets
  81262. */
  81263. static PreprocessUrl: (url: string) => string;
  81264. /**
  81265. * Removes unwanted characters from an url
  81266. * @param url defines the url to clean
  81267. * @returns the cleaned url
  81268. */
  81269. private static _CleanUrl;
  81270. /**
  81271. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  81272. * @param url define the url we are trying
  81273. * @param element define the dom element where to configure the cors policy
  81274. */
  81275. static SetCorsBehavior(url: string | string[], element: {
  81276. crossOrigin: string | null;
  81277. }): void;
  81278. /**
  81279. * Loads an image as an HTMLImageElement.
  81280. * @param input url string, ArrayBuffer, or Blob to load
  81281. * @param onLoad callback called when the image successfully loads
  81282. * @param onError callback called when the image fails to load
  81283. * @param offlineProvider offline provider for caching
  81284. * @param mimeType optional mime type
  81285. * @returns the HTMLImageElement of the loaded image
  81286. */
  81287. 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>;
  81288. /**
  81289. * Reads a file from a File object
  81290. * @param file defines the file to load
  81291. * @param onSuccess defines the callback to call when data is loaded
  81292. * @param onProgress defines the callback to call during loading process
  81293. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  81294. * @param onError defines the callback to call when an error occurs
  81295. * @returns a file request object
  81296. */
  81297. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  81298. /**
  81299. * Loads a file from a url
  81300. * @param url url to load
  81301. * @param onSuccess callback called when the file successfully loads
  81302. * @param onProgress callback called while file is loading (if the server supports this mode)
  81303. * @param offlineProvider defines the offline provider for caching
  81304. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81305. * @param onError callback called when the file fails to load
  81306. * @returns a file request object
  81307. */
  81308. 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;
  81309. /**
  81310. * Loads a file
  81311. * @param url url to load
  81312. * @param onSuccess callback called when the file successfully loads
  81313. * @param onProgress callback called while file is loading (if the server supports this mode)
  81314. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81315. * @param onError callback called when the file fails to load
  81316. * @param onOpened callback called when the web request is opened
  81317. * @returns a file request object
  81318. */
  81319. 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;
  81320. /**
  81321. * Checks if the loaded document was accessed via `file:`-Protocol.
  81322. * @returns boolean
  81323. */
  81324. static IsFileURL(): boolean;
  81325. }
  81326. }
  81327. declare module BABYLON {
  81328. /** @hidden */
  81329. export class ShaderProcessor {
  81330. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  81331. private static _ProcessPrecision;
  81332. private static _ExtractOperation;
  81333. private static _BuildSubExpression;
  81334. private static _BuildExpression;
  81335. private static _MoveCursorWithinIf;
  81336. private static _MoveCursor;
  81337. private static _EvaluatePreProcessors;
  81338. private static _PreparePreProcessors;
  81339. private static _ProcessShaderConversion;
  81340. private static _ProcessIncludes;
  81341. /**
  81342. * Loads a file from a url
  81343. * @param url url to load
  81344. * @param onSuccess callback called when the file successfully loads
  81345. * @param onProgress callback called while file is loading (if the server supports this mode)
  81346. * @param offlineProvider defines the offline provider for caching
  81347. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81348. * @param onError callback called when the file fails to load
  81349. * @returns a file request object
  81350. * @hidden
  81351. */
  81352. 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;
  81353. }
  81354. }
  81355. declare module BABYLON {
  81356. /**
  81357. * @hidden
  81358. */
  81359. export interface IColor4Like {
  81360. r: float;
  81361. g: float;
  81362. b: float;
  81363. a: float;
  81364. }
  81365. /**
  81366. * @hidden
  81367. */
  81368. export interface IColor3Like {
  81369. r: float;
  81370. g: float;
  81371. b: float;
  81372. }
  81373. /**
  81374. * @hidden
  81375. */
  81376. export interface IVector4Like {
  81377. x: float;
  81378. y: float;
  81379. z: float;
  81380. w: float;
  81381. }
  81382. /**
  81383. * @hidden
  81384. */
  81385. export interface IVector3Like {
  81386. x: float;
  81387. y: float;
  81388. z: float;
  81389. }
  81390. /**
  81391. * @hidden
  81392. */
  81393. export interface IVector2Like {
  81394. x: float;
  81395. y: float;
  81396. }
  81397. /**
  81398. * @hidden
  81399. */
  81400. export interface IMatrixLike {
  81401. toArray(): DeepImmutable<Float32Array | Array<number>>;
  81402. updateFlag: int;
  81403. }
  81404. /**
  81405. * @hidden
  81406. */
  81407. export interface IViewportLike {
  81408. x: float;
  81409. y: float;
  81410. width: float;
  81411. height: float;
  81412. }
  81413. /**
  81414. * @hidden
  81415. */
  81416. export interface IPlaneLike {
  81417. normal: IVector3Like;
  81418. d: float;
  81419. normalize(): void;
  81420. }
  81421. }
  81422. declare module BABYLON {
  81423. /**
  81424. * Interface used to define common properties for effect fallbacks
  81425. */
  81426. export interface IEffectFallbacks {
  81427. /**
  81428. * Removes the defines that should be removed when falling back.
  81429. * @param currentDefines defines the current define statements for the shader.
  81430. * @param effect defines the current effect we try to compile
  81431. * @returns The resulting defines with defines of the current rank removed.
  81432. */
  81433. reduce(currentDefines: string, effect: Effect): string;
  81434. /**
  81435. * Removes the fallback from the bound mesh.
  81436. */
  81437. unBindMesh(): void;
  81438. /**
  81439. * Checks to see if more fallbacks are still availible.
  81440. */
  81441. hasMoreFallbacks: boolean;
  81442. }
  81443. }
  81444. declare module BABYLON {
  81445. /**
  81446. * Class used to evalaute queries containing `and` and `or` operators
  81447. */
  81448. export class AndOrNotEvaluator {
  81449. /**
  81450. * Evaluate a query
  81451. * @param query defines the query to evaluate
  81452. * @param evaluateCallback defines the callback used to filter result
  81453. * @returns true if the query matches
  81454. */
  81455. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  81456. private static _HandleParenthesisContent;
  81457. private static _SimplifyNegation;
  81458. }
  81459. }
  81460. declare module BABYLON {
  81461. /**
  81462. * Class used to store custom tags
  81463. */
  81464. export class Tags {
  81465. /**
  81466. * Adds support for tags on the given object
  81467. * @param obj defines the object to use
  81468. */
  81469. static EnableFor(obj: any): void;
  81470. /**
  81471. * Removes tags support
  81472. * @param obj defines the object to use
  81473. */
  81474. static DisableFor(obj: any): void;
  81475. /**
  81476. * Gets a boolean indicating if the given object has tags
  81477. * @param obj defines the object to use
  81478. * @returns a boolean
  81479. */
  81480. static HasTags(obj: any): boolean;
  81481. /**
  81482. * Gets the tags available on a given object
  81483. * @param obj defines the object to use
  81484. * @param asString defines if the tags must be returned as a string instead of an array of strings
  81485. * @returns the tags
  81486. */
  81487. static GetTags(obj: any, asString?: boolean): any;
  81488. /**
  81489. * Adds tags to an object
  81490. * @param obj defines the object to use
  81491. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  81492. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  81493. */
  81494. static AddTagsTo(obj: any, tagsString: string): void;
  81495. /**
  81496. * @hidden
  81497. */
  81498. static _AddTagTo(obj: any, tag: string): void;
  81499. /**
  81500. * Removes specific tags from a specific object
  81501. * @param obj defines the object to use
  81502. * @param tagsString defines the tags to remove
  81503. */
  81504. static RemoveTagsFrom(obj: any, tagsString: string): void;
  81505. /**
  81506. * @hidden
  81507. */
  81508. static _RemoveTagFrom(obj: any, tag: string): void;
  81509. /**
  81510. * Defines if tags hosted on an object match a given query
  81511. * @param obj defines the object to use
  81512. * @param tagsQuery defines the tag query
  81513. * @returns a boolean
  81514. */
  81515. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  81516. }
  81517. }
  81518. declare module BABYLON {
  81519. /**
  81520. * Scalar computation library
  81521. */
  81522. export class Scalar {
  81523. /**
  81524. * Two pi constants convenient for computation.
  81525. */
  81526. static TwoPi: number;
  81527. /**
  81528. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81529. * @param a number
  81530. * @param b number
  81531. * @param epsilon (default = 1.401298E-45)
  81532. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81533. */
  81534. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  81535. /**
  81536. * Returns a string : the upper case translation of the number i to hexadecimal.
  81537. * @param i number
  81538. * @returns the upper case translation of the number i to hexadecimal.
  81539. */
  81540. static ToHex(i: number): string;
  81541. /**
  81542. * Returns -1 if value is negative and +1 is value is positive.
  81543. * @param value the value
  81544. * @returns the value itself if it's equal to zero.
  81545. */
  81546. static Sign(value: number): number;
  81547. /**
  81548. * Returns the value itself if it's between min and max.
  81549. * Returns min if the value is lower than min.
  81550. * Returns max if the value is greater than max.
  81551. * @param value the value to clmap
  81552. * @param min the min value to clamp to (default: 0)
  81553. * @param max the max value to clamp to (default: 1)
  81554. * @returns the clamped value
  81555. */
  81556. static Clamp(value: number, min?: number, max?: number): number;
  81557. /**
  81558. * the log2 of value.
  81559. * @param value the value to compute log2 of
  81560. * @returns the log2 of value.
  81561. */
  81562. static Log2(value: number): number;
  81563. /**
  81564. * Loops the value, so that it is never larger than length and never smaller than 0.
  81565. *
  81566. * This is similar to the modulo operator but it works with floating point numbers.
  81567. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  81568. * With t = 5 and length = 2.5, the result would be 0.0.
  81569. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  81570. * @param value the value
  81571. * @param length the length
  81572. * @returns the looped value
  81573. */
  81574. static Repeat(value: number, length: number): number;
  81575. /**
  81576. * Normalize the value between 0.0 and 1.0 using min and max values
  81577. * @param value value to normalize
  81578. * @param min max to normalize between
  81579. * @param max min to normalize between
  81580. * @returns the normalized value
  81581. */
  81582. static Normalize(value: number, min: number, max: number): number;
  81583. /**
  81584. * Denormalize the value from 0.0 and 1.0 using min and max values
  81585. * @param normalized value to denormalize
  81586. * @param min max to denormalize between
  81587. * @param max min to denormalize between
  81588. * @returns the denormalized value
  81589. */
  81590. static Denormalize(normalized: number, min: number, max: number): number;
  81591. /**
  81592. * Calculates the shortest difference between two given angles given in degrees.
  81593. * @param current current angle in degrees
  81594. * @param target target angle in degrees
  81595. * @returns the delta
  81596. */
  81597. static DeltaAngle(current: number, target: number): number;
  81598. /**
  81599. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  81600. * @param tx value
  81601. * @param length length
  81602. * @returns The returned value will move back and forth between 0 and length
  81603. */
  81604. static PingPong(tx: number, length: number): number;
  81605. /**
  81606. * Interpolates between min and max with smoothing at the limits.
  81607. *
  81608. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  81609. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  81610. * @param from from
  81611. * @param to to
  81612. * @param tx value
  81613. * @returns the smooth stepped value
  81614. */
  81615. static SmoothStep(from: number, to: number, tx: number): number;
  81616. /**
  81617. * Moves a value current towards target.
  81618. *
  81619. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  81620. * Negative values of maxDelta pushes the value away from target.
  81621. * @param current current value
  81622. * @param target target value
  81623. * @param maxDelta max distance to move
  81624. * @returns resulting value
  81625. */
  81626. static MoveTowards(current: number, target: number, maxDelta: number): number;
  81627. /**
  81628. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  81629. *
  81630. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  81631. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  81632. * @param current current value
  81633. * @param target target value
  81634. * @param maxDelta max distance to move
  81635. * @returns resulting angle
  81636. */
  81637. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  81638. /**
  81639. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  81640. * @param start start value
  81641. * @param end target value
  81642. * @param amount amount to lerp between
  81643. * @returns the lerped value
  81644. */
  81645. static Lerp(start: number, end: number, amount: number): number;
  81646. /**
  81647. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  81648. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  81649. * @param start start value
  81650. * @param end target value
  81651. * @param amount amount to lerp between
  81652. * @returns the lerped value
  81653. */
  81654. static LerpAngle(start: number, end: number, amount: number): number;
  81655. /**
  81656. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  81657. * @param a start value
  81658. * @param b target value
  81659. * @param value value between a and b
  81660. * @returns the inverseLerp value
  81661. */
  81662. static InverseLerp(a: number, b: number, value: number): number;
  81663. /**
  81664. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  81665. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  81666. * @param value1 spline value
  81667. * @param tangent1 spline value
  81668. * @param value2 spline value
  81669. * @param tangent2 spline value
  81670. * @param amount input value
  81671. * @returns hermite result
  81672. */
  81673. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  81674. /**
  81675. * Returns a random float number between and min and max values
  81676. * @param min min value of random
  81677. * @param max max value of random
  81678. * @returns random value
  81679. */
  81680. static RandomRange(min: number, max: number): number;
  81681. /**
  81682. * This function returns percentage of a number in a given range.
  81683. *
  81684. * RangeToPercent(40,20,60) will return 0.5 (50%)
  81685. * RangeToPercent(34,0,100) will return 0.34 (34%)
  81686. * @param number to convert to percentage
  81687. * @param min min range
  81688. * @param max max range
  81689. * @returns the percentage
  81690. */
  81691. static RangeToPercent(number: number, min: number, max: number): number;
  81692. /**
  81693. * This function returns number that corresponds to the percentage in a given range.
  81694. *
  81695. * PercentToRange(0.34,0,100) will return 34.
  81696. * @param percent to convert to number
  81697. * @param min min range
  81698. * @param max max range
  81699. * @returns the number
  81700. */
  81701. static PercentToRange(percent: number, min: number, max: number): number;
  81702. /**
  81703. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  81704. * @param angle The angle to normalize in radian.
  81705. * @return The converted angle.
  81706. */
  81707. static NormalizeRadians(angle: number): number;
  81708. }
  81709. }
  81710. declare module BABYLON {
  81711. /**
  81712. * Constant used to convert a value to gamma space
  81713. * @ignorenaming
  81714. */
  81715. export const ToGammaSpace: number;
  81716. /**
  81717. * Constant used to convert a value to linear space
  81718. * @ignorenaming
  81719. */
  81720. export const ToLinearSpace = 2.2;
  81721. /**
  81722. * Constant used to define the minimal number value in Babylon.js
  81723. * @ignorenaming
  81724. */
  81725. let Epsilon: number;
  81726. }
  81727. declare module BABYLON {
  81728. /**
  81729. * Class used to represent a viewport on screen
  81730. */
  81731. export class Viewport {
  81732. /** viewport left coordinate */
  81733. x: number;
  81734. /** viewport top coordinate */
  81735. y: number;
  81736. /**viewport width */
  81737. width: number;
  81738. /** viewport height */
  81739. height: number;
  81740. /**
  81741. * Creates a Viewport object located at (x, y) and sized (width, height)
  81742. * @param x defines viewport left coordinate
  81743. * @param y defines viewport top coordinate
  81744. * @param width defines the viewport width
  81745. * @param height defines the viewport height
  81746. */
  81747. constructor(
  81748. /** viewport left coordinate */
  81749. x: number,
  81750. /** viewport top coordinate */
  81751. y: number,
  81752. /**viewport width */
  81753. width: number,
  81754. /** viewport height */
  81755. height: number);
  81756. /**
  81757. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  81758. * @param renderWidth defines the rendering width
  81759. * @param renderHeight defines the rendering height
  81760. * @returns a new Viewport
  81761. */
  81762. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  81763. /**
  81764. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  81765. * @param renderWidth defines the rendering width
  81766. * @param renderHeight defines the rendering height
  81767. * @param ref defines the target viewport
  81768. * @returns the current viewport
  81769. */
  81770. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  81771. /**
  81772. * Returns a new Viewport copied from the current one
  81773. * @returns a new Viewport
  81774. */
  81775. clone(): Viewport;
  81776. }
  81777. }
  81778. declare module BABYLON {
  81779. /**
  81780. * Class containing a set of static utilities functions for arrays.
  81781. */
  81782. export class ArrayTools {
  81783. /**
  81784. * Returns an array of the given size filled with element built from the given constructor and the paramters
  81785. * @param size the number of element to construct and put in the array
  81786. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  81787. * @returns a new array filled with new objects
  81788. */
  81789. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  81790. }
  81791. }
  81792. declare module BABYLON {
  81793. /**
  81794. * Represents a plane by the equation ax + by + cz + d = 0
  81795. */
  81796. export class Plane {
  81797. private static _TmpMatrix;
  81798. /**
  81799. * Normal of the plane (a,b,c)
  81800. */
  81801. normal: Vector3;
  81802. /**
  81803. * d component of the plane
  81804. */
  81805. d: number;
  81806. /**
  81807. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  81808. * @param a a component of the plane
  81809. * @param b b component of the plane
  81810. * @param c c component of the plane
  81811. * @param d d component of the plane
  81812. */
  81813. constructor(a: number, b: number, c: number, d: number);
  81814. /**
  81815. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  81816. */
  81817. asArray(): number[];
  81818. /**
  81819. * @returns a new plane copied from the current Plane.
  81820. */
  81821. clone(): Plane;
  81822. /**
  81823. * @returns the string "Plane".
  81824. */
  81825. getClassName(): string;
  81826. /**
  81827. * @returns the Plane hash code.
  81828. */
  81829. getHashCode(): number;
  81830. /**
  81831. * Normalize the current Plane in place.
  81832. * @returns the updated Plane.
  81833. */
  81834. normalize(): Plane;
  81835. /**
  81836. * Applies a transformation the plane and returns the result
  81837. * @param transformation the transformation matrix to be applied to the plane
  81838. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  81839. */
  81840. transform(transformation: DeepImmutable<Matrix>): Plane;
  81841. /**
  81842. * Compute the dot product between the point and the plane normal
  81843. * @param point point to calculate the dot product with
  81844. * @returns the dot product (float) of the point coordinates and the plane normal.
  81845. */
  81846. dotCoordinate(point: DeepImmutable<Vector3>): number;
  81847. /**
  81848. * Updates the current Plane from the plane defined by the three given points.
  81849. * @param point1 one of the points used to contruct the plane
  81850. * @param point2 one of the points used to contruct the plane
  81851. * @param point3 one of the points used to contruct the plane
  81852. * @returns the updated Plane.
  81853. */
  81854. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81855. /**
  81856. * Checks if the plane is facing a given direction
  81857. * @param direction the direction to check if the plane is facing
  81858. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  81859. * @returns True is the vector "direction" is the same side than the plane normal.
  81860. */
  81861. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  81862. /**
  81863. * Calculates the distance to a point
  81864. * @param point point to calculate distance to
  81865. * @returns the signed distance (float) from the given point to the Plane.
  81866. */
  81867. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  81868. /**
  81869. * Creates a plane from an array
  81870. * @param array the array to create a plane from
  81871. * @returns a new Plane from the given array.
  81872. */
  81873. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  81874. /**
  81875. * Creates a plane from three points
  81876. * @param point1 point used to create the plane
  81877. * @param point2 point used to create the plane
  81878. * @param point3 point used to create the plane
  81879. * @returns a new Plane defined by the three given points.
  81880. */
  81881. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81882. /**
  81883. * Creates a plane from an origin point and a normal
  81884. * @param origin origin of the plane to be constructed
  81885. * @param normal normal of the plane to be constructed
  81886. * @returns a new Plane the normal vector to this plane at the given origin point.
  81887. * Note : the vector "normal" is updated because normalized.
  81888. */
  81889. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  81890. /**
  81891. * Calculates the distance from a plane and a point
  81892. * @param origin origin of the plane to be constructed
  81893. * @param normal normal of the plane to be constructed
  81894. * @param point point to calculate distance to
  81895. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  81896. */
  81897. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  81898. }
  81899. }
  81900. declare module BABYLON {
  81901. /** @hidden */
  81902. export class PerformanceConfigurator {
  81903. /** @hidden */
  81904. static MatrixUse64Bits: boolean;
  81905. /** @hidden */
  81906. static MatrixTrackPrecisionChange: boolean;
  81907. /** @hidden */
  81908. static MatrixCurrentType: any;
  81909. /** @hidden */
  81910. static MatrixTrackedMatrices: Array<any> | null;
  81911. /** @hidden */
  81912. static SetMatrixPrecision(use64bits: boolean): void;
  81913. }
  81914. }
  81915. declare module BABYLON {
  81916. /**
  81917. * Class representing a vector containing 2 coordinates
  81918. */
  81919. export class Vector2 {
  81920. /** defines the first coordinate */
  81921. x: number;
  81922. /** defines the second coordinate */
  81923. y: number;
  81924. /**
  81925. * Creates a new Vector2 from the given x and y coordinates
  81926. * @param x defines the first coordinate
  81927. * @param y defines the second coordinate
  81928. */
  81929. constructor(
  81930. /** defines the first coordinate */
  81931. x?: number,
  81932. /** defines the second coordinate */
  81933. y?: number);
  81934. /**
  81935. * Gets a string with the Vector2 coordinates
  81936. * @returns a string with the Vector2 coordinates
  81937. */
  81938. toString(): string;
  81939. /**
  81940. * Gets class name
  81941. * @returns the string "Vector2"
  81942. */
  81943. getClassName(): string;
  81944. /**
  81945. * Gets current vector hash code
  81946. * @returns the Vector2 hash code as a number
  81947. */
  81948. getHashCode(): number;
  81949. /**
  81950. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  81951. * @param array defines the source array
  81952. * @param index defines the offset in source array
  81953. * @returns the current Vector2
  81954. */
  81955. toArray(array: FloatArray, index?: number): Vector2;
  81956. /**
  81957. * Update the current vector from an array
  81958. * @param array defines the destination array
  81959. * @param index defines the offset in the destination array
  81960. * @returns the current Vector3
  81961. */
  81962. fromArray(array: FloatArray, index?: number): Vector2;
  81963. /**
  81964. * Copy the current vector to an array
  81965. * @returns a new array with 2 elements: the Vector2 coordinates.
  81966. */
  81967. asArray(): number[];
  81968. /**
  81969. * Sets the Vector2 coordinates with the given Vector2 coordinates
  81970. * @param source defines the source Vector2
  81971. * @returns the current updated Vector2
  81972. */
  81973. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  81974. /**
  81975. * Sets the Vector2 coordinates with the given floats
  81976. * @param x defines the first coordinate
  81977. * @param y defines the second coordinate
  81978. * @returns the current updated Vector2
  81979. */
  81980. copyFromFloats(x: number, y: number): Vector2;
  81981. /**
  81982. * Sets the Vector2 coordinates with the given floats
  81983. * @param x defines the first coordinate
  81984. * @param y defines the second coordinate
  81985. * @returns the current updated Vector2
  81986. */
  81987. set(x: number, y: number): Vector2;
  81988. /**
  81989. * Add another vector with the current one
  81990. * @param otherVector defines the other vector
  81991. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  81992. */
  81993. add(otherVector: DeepImmutable<Vector2>): Vector2;
  81994. /**
  81995. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  81996. * @param otherVector defines the other vector
  81997. * @param result defines the target vector
  81998. * @returns the unmodified current Vector2
  81999. */
  82000. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82001. /**
  82002. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82003. * @param otherVector defines the other vector
  82004. * @returns the current updated Vector2
  82005. */
  82006. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82007. /**
  82008. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82009. * @param otherVector defines the other vector
  82010. * @returns a new Vector2
  82011. */
  82012. addVector3(otherVector: Vector3): Vector2;
  82013. /**
  82014. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82015. * @param otherVector defines the other vector
  82016. * @returns a new Vector2
  82017. */
  82018. subtract(otherVector: Vector2): Vector2;
  82019. /**
  82020. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82021. * @param otherVector defines the other vector
  82022. * @param result defines the target vector
  82023. * @returns the unmodified current Vector2
  82024. */
  82025. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82026. /**
  82027. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82028. * @param otherVector defines the other vector
  82029. * @returns the current updated Vector2
  82030. */
  82031. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82032. /**
  82033. * Multiplies in place the current Vector2 coordinates by the given ones
  82034. * @param otherVector defines the other vector
  82035. * @returns the current updated Vector2
  82036. */
  82037. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82038. /**
  82039. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82040. * @param otherVector defines the other vector
  82041. * @returns a new Vector2
  82042. */
  82043. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82044. /**
  82045. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82046. * @param otherVector defines the other vector
  82047. * @param result defines the target vector
  82048. * @returns the unmodified current Vector2
  82049. */
  82050. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82051. /**
  82052. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82053. * @param x defines the first coordinate
  82054. * @param y defines the second coordinate
  82055. * @returns a new Vector2
  82056. */
  82057. multiplyByFloats(x: number, y: number): Vector2;
  82058. /**
  82059. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82060. * @param otherVector defines the other vector
  82061. * @returns a new Vector2
  82062. */
  82063. divide(otherVector: Vector2): Vector2;
  82064. /**
  82065. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  82066. * @param otherVector defines the other vector
  82067. * @param result defines the target vector
  82068. * @returns the unmodified current Vector2
  82069. */
  82070. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82071. /**
  82072. * Divides the current Vector2 coordinates by the given ones
  82073. * @param otherVector defines the other vector
  82074. * @returns the current updated Vector2
  82075. */
  82076. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82077. /**
  82078. * Gets a new Vector2 with current Vector2 negated coordinates
  82079. * @returns a new Vector2
  82080. */
  82081. negate(): Vector2;
  82082. /**
  82083. * Negate this vector in place
  82084. * @returns this
  82085. */
  82086. negateInPlace(): Vector2;
  82087. /**
  82088. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82089. * @param result defines the Vector3 object where to store the result
  82090. * @returns the current Vector2
  82091. */
  82092. negateToRef(result: Vector2): Vector2;
  82093. /**
  82094. * Multiply the Vector2 coordinates by scale
  82095. * @param scale defines the scaling factor
  82096. * @returns the current updated Vector2
  82097. */
  82098. scaleInPlace(scale: number): Vector2;
  82099. /**
  82100. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82101. * @param scale defines the scaling factor
  82102. * @returns a new Vector2
  82103. */
  82104. scale(scale: number): Vector2;
  82105. /**
  82106. * Scale the current Vector2 values by a factor to a given Vector2
  82107. * @param scale defines the scale factor
  82108. * @param result defines the Vector2 object where to store the result
  82109. * @returns the unmodified current Vector2
  82110. */
  82111. scaleToRef(scale: number, result: Vector2): Vector2;
  82112. /**
  82113. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82114. * @param scale defines the scale factor
  82115. * @param result defines the Vector2 object where to store the result
  82116. * @returns the unmodified current Vector2
  82117. */
  82118. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82119. /**
  82120. * Gets a boolean if two vectors are equals
  82121. * @param otherVector defines the other vector
  82122. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82123. */
  82124. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82125. /**
  82126. * Gets a boolean if two vectors are equals (using an epsilon value)
  82127. * @param otherVector defines the other vector
  82128. * @param epsilon defines the minimal distance to consider equality
  82129. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  82130. */
  82131. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  82132. /**
  82133. * Gets a new Vector2 from current Vector2 floored values
  82134. * @returns a new Vector2
  82135. */
  82136. floor(): Vector2;
  82137. /**
  82138. * Gets a new Vector2 from current Vector2 floored values
  82139. * @returns a new Vector2
  82140. */
  82141. fract(): Vector2;
  82142. /**
  82143. * Gets the length of the vector
  82144. * @returns the vector length (float)
  82145. */
  82146. length(): number;
  82147. /**
  82148. * Gets the vector squared length
  82149. * @returns the vector squared length (float)
  82150. */
  82151. lengthSquared(): number;
  82152. /**
  82153. * Normalize the vector
  82154. * @returns the current updated Vector2
  82155. */
  82156. normalize(): Vector2;
  82157. /**
  82158. * Gets a new Vector2 copied from the Vector2
  82159. * @returns a new Vector2
  82160. */
  82161. clone(): Vector2;
  82162. /**
  82163. * Gets a new Vector2(0, 0)
  82164. * @returns a new Vector2
  82165. */
  82166. static Zero(): Vector2;
  82167. /**
  82168. * Gets a new Vector2(1, 1)
  82169. * @returns a new Vector2
  82170. */
  82171. static One(): Vector2;
  82172. /**
  82173. * Gets a new Vector2 set from the given index element of the given array
  82174. * @param array defines the data source
  82175. * @param offset defines the offset in the data source
  82176. * @returns a new Vector2
  82177. */
  82178. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  82179. /**
  82180. * Sets "result" from the given index element of the given array
  82181. * @param array defines the data source
  82182. * @param offset defines the offset in the data source
  82183. * @param result defines the target vector
  82184. */
  82185. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82186. /**
  82187. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  82188. * @param value1 defines 1st point of control
  82189. * @param value2 defines 2nd point of control
  82190. * @param value3 defines 3rd point of control
  82191. * @param value4 defines 4th point of control
  82192. * @param amount defines the interpolation factor
  82193. * @returns a new Vector2
  82194. */
  82195. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  82196. /**
  82197. * 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".
  82198. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  82199. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  82200. * @param value defines the value to clamp
  82201. * @param min defines the lower limit
  82202. * @param max defines the upper limit
  82203. * @returns a new Vector2
  82204. */
  82205. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  82206. /**
  82207. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  82208. * @param value1 defines the 1st control point
  82209. * @param tangent1 defines the outgoing tangent
  82210. * @param value2 defines the 2nd control point
  82211. * @param tangent2 defines the incoming tangent
  82212. * @param amount defines the interpolation factor
  82213. * @returns a new Vector2
  82214. */
  82215. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  82216. /**
  82217. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  82218. * @param start defines the start vector
  82219. * @param end defines the end vector
  82220. * @param amount defines the interpolation factor
  82221. * @returns a new Vector2
  82222. */
  82223. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  82224. /**
  82225. * Gets the dot product of the vector "left" and the vector "right"
  82226. * @param left defines first vector
  82227. * @param right defines second vector
  82228. * @returns the dot product (float)
  82229. */
  82230. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  82231. /**
  82232. * Returns a new Vector2 equal to the normalized given vector
  82233. * @param vector defines the vector to normalize
  82234. * @returns a new Vector2
  82235. */
  82236. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  82237. /**
  82238. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  82239. * @param left defines 1st vector
  82240. * @param right defines 2nd vector
  82241. * @returns a new Vector2
  82242. */
  82243. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82244. /**
  82245. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  82246. * @param left defines 1st vector
  82247. * @param right defines 2nd vector
  82248. * @returns a new Vector2
  82249. */
  82250. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82251. /**
  82252. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  82253. * @param vector defines the vector to transform
  82254. * @param transformation defines the matrix to apply
  82255. * @returns a new Vector2
  82256. */
  82257. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  82258. /**
  82259. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  82260. * @param vector defines the vector to transform
  82261. * @param transformation defines the matrix to apply
  82262. * @param result defines the target vector
  82263. */
  82264. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  82265. /**
  82266. * Determines if a given vector is included in a triangle
  82267. * @param p defines the vector to test
  82268. * @param p0 defines 1st triangle point
  82269. * @param p1 defines 2nd triangle point
  82270. * @param p2 defines 3rd triangle point
  82271. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  82272. */
  82273. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  82274. /**
  82275. * Gets the distance between the vectors "value1" and "value2"
  82276. * @param value1 defines first vector
  82277. * @param value2 defines second vector
  82278. * @returns the distance between vectors
  82279. */
  82280. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82281. /**
  82282. * Returns the squared distance between the vectors "value1" and "value2"
  82283. * @param value1 defines first vector
  82284. * @param value2 defines second vector
  82285. * @returns the squared distance between vectors
  82286. */
  82287. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82288. /**
  82289. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  82290. * @param value1 defines first vector
  82291. * @param value2 defines second vector
  82292. * @returns a new Vector2
  82293. */
  82294. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  82295. /**
  82296. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  82297. * @param p defines the middle point
  82298. * @param segA defines one point of the segment
  82299. * @param segB defines the other point of the segment
  82300. * @returns the shortest distance
  82301. */
  82302. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  82303. }
  82304. /**
  82305. * Class used to store (x,y,z) vector representation
  82306. * A Vector3 is the main object used in 3D geometry
  82307. * It can represent etiher the coordinates of a point the space, either a direction
  82308. * Reminder: js uses a left handed forward facing system
  82309. */
  82310. export class Vector3 {
  82311. private static _UpReadOnly;
  82312. private static _ZeroReadOnly;
  82313. /** @hidden */
  82314. _x: number;
  82315. /** @hidden */
  82316. _y: number;
  82317. /** @hidden */
  82318. _z: number;
  82319. /** @hidden */
  82320. _isDirty: boolean;
  82321. /** Gets or sets the x coordinate */
  82322. get x(): number;
  82323. set x(value: number);
  82324. /** Gets or sets the y coordinate */
  82325. get y(): number;
  82326. set y(value: number);
  82327. /** Gets or sets the z coordinate */
  82328. get z(): number;
  82329. set z(value: number);
  82330. /**
  82331. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  82332. * @param x defines the first coordinates (on X axis)
  82333. * @param y defines the second coordinates (on Y axis)
  82334. * @param z defines the third coordinates (on Z axis)
  82335. */
  82336. constructor(x?: number, y?: number, z?: number);
  82337. /**
  82338. * Creates a string representation of the Vector3
  82339. * @returns a string with the Vector3 coordinates.
  82340. */
  82341. toString(): string;
  82342. /**
  82343. * Gets the class name
  82344. * @returns the string "Vector3"
  82345. */
  82346. getClassName(): string;
  82347. /**
  82348. * Creates the Vector3 hash code
  82349. * @returns a number which tends to be unique between Vector3 instances
  82350. */
  82351. getHashCode(): number;
  82352. /**
  82353. * Creates an array containing three elements : the coordinates of the Vector3
  82354. * @returns a new array of numbers
  82355. */
  82356. asArray(): number[];
  82357. /**
  82358. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  82359. * @param array defines the destination array
  82360. * @param index defines the offset in the destination array
  82361. * @returns the current Vector3
  82362. */
  82363. toArray(array: FloatArray, index?: number): Vector3;
  82364. /**
  82365. * Update the current vector from an array
  82366. * @param array defines the destination array
  82367. * @param index defines the offset in the destination array
  82368. * @returns the current Vector3
  82369. */
  82370. fromArray(array: FloatArray, index?: number): Vector3;
  82371. /**
  82372. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  82373. * @returns a new Quaternion object, computed from the Vector3 coordinates
  82374. */
  82375. toQuaternion(): Quaternion;
  82376. /**
  82377. * Adds the given vector to the current Vector3
  82378. * @param otherVector defines the second operand
  82379. * @returns the current updated Vector3
  82380. */
  82381. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82382. /**
  82383. * Adds the given coordinates to the current Vector3
  82384. * @param x defines the x coordinate of the operand
  82385. * @param y defines the y coordinate of the operand
  82386. * @param z defines the z coordinate of the operand
  82387. * @returns the current updated Vector3
  82388. */
  82389. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82390. /**
  82391. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  82392. * @param otherVector defines the second operand
  82393. * @returns the resulting Vector3
  82394. */
  82395. add(otherVector: DeepImmutable<Vector3>): Vector3;
  82396. /**
  82397. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  82398. * @param otherVector defines the second operand
  82399. * @param result defines the Vector3 object where to store the result
  82400. * @returns the current Vector3
  82401. */
  82402. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82403. /**
  82404. * Subtract the given vector from the current Vector3
  82405. * @param otherVector defines the second operand
  82406. * @returns the current updated Vector3
  82407. */
  82408. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82409. /**
  82410. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  82411. * @param otherVector defines the second operand
  82412. * @returns the resulting Vector3
  82413. */
  82414. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  82415. /**
  82416. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  82417. * @param otherVector defines the second operand
  82418. * @param result defines the Vector3 object where to store the result
  82419. * @returns the current Vector3
  82420. */
  82421. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82422. /**
  82423. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  82424. * @param x defines the x coordinate of the operand
  82425. * @param y defines the y coordinate of the operand
  82426. * @param z defines the z coordinate of the operand
  82427. * @returns the resulting Vector3
  82428. */
  82429. subtractFromFloats(x: number, y: number, z: number): Vector3;
  82430. /**
  82431. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  82432. * @param x defines the x coordinate of the operand
  82433. * @param y defines the y coordinate of the operand
  82434. * @param z defines the z coordinate of the operand
  82435. * @param result defines the Vector3 object where to store the result
  82436. * @returns the current Vector3
  82437. */
  82438. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  82439. /**
  82440. * Gets a new Vector3 set with the current Vector3 negated coordinates
  82441. * @returns a new Vector3
  82442. */
  82443. negate(): Vector3;
  82444. /**
  82445. * Negate this vector in place
  82446. * @returns this
  82447. */
  82448. negateInPlace(): Vector3;
  82449. /**
  82450. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  82451. * @param result defines the Vector3 object where to store the result
  82452. * @returns the current Vector3
  82453. */
  82454. negateToRef(result: Vector3): Vector3;
  82455. /**
  82456. * Multiplies the Vector3 coordinates by the float "scale"
  82457. * @param scale defines the multiplier factor
  82458. * @returns the current updated Vector3
  82459. */
  82460. scaleInPlace(scale: number): Vector3;
  82461. /**
  82462. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  82463. * @param scale defines the multiplier factor
  82464. * @returns a new Vector3
  82465. */
  82466. scale(scale: number): Vector3;
  82467. /**
  82468. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  82469. * @param scale defines the multiplier factor
  82470. * @param result defines the Vector3 object where to store the result
  82471. * @returns the current Vector3
  82472. */
  82473. scaleToRef(scale: number, result: Vector3): Vector3;
  82474. /**
  82475. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  82476. * @param scale defines the scale factor
  82477. * @param result defines the Vector3 object where to store the result
  82478. * @returns the unmodified current Vector3
  82479. */
  82480. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  82481. /**
  82482. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82483. * @param origin defines the origin of the projection ray
  82484. * @param plane defines the plane to project to
  82485. * @returns the projected vector3
  82486. */
  82487. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  82488. /**
  82489. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82490. * @param origin defines the origin of the projection ray
  82491. * @param plane defines the plane to project to
  82492. * @param result defines the Vector3 where to store the result
  82493. */
  82494. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  82495. /**
  82496. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  82497. * @param otherVector defines the second operand
  82498. * @returns true if both vectors are equals
  82499. */
  82500. equals(otherVector: DeepImmutable<Vector3>): boolean;
  82501. /**
  82502. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  82503. * @param otherVector defines the second operand
  82504. * @param epsilon defines the minimal distance to define values as equals
  82505. * @returns true if both vectors are distant less than epsilon
  82506. */
  82507. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  82508. /**
  82509. * Returns true if the current Vector3 coordinates equals the given floats
  82510. * @param x defines the x coordinate of the operand
  82511. * @param y defines the y coordinate of the operand
  82512. * @param z defines the z coordinate of the operand
  82513. * @returns true if both vectors are equals
  82514. */
  82515. equalsToFloats(x: number, y: number, z: number): boolean;
  82516. /**
  82517. * Multiplies the current Vector3 coordinates by the given ones
  82518. * @param otherVector defines the second operand
  82519. * @returns the current updated Vector3
  82520. */
  82521. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82522. /**
  82523. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  82524. * @param otherVector defines the second operand
  82525. * @returns the new Vector3
  82526. */
  82527. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  82528. /**
  82529. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  82530. * @param otherVector defines the second operand
  82531. * @param result defines the Vector3 object where to store the result
  82532. * @returns the current Vector3
  82533. */
  82534. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82535. /**
  82536. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  82537. * @param x defines the x coordinate of the operand
  82538. * @param y defines the y coordinate of the operand
  82539. * @param z defines the z coordinate of the operand
  82540. * @returns the new Vector3
  82541. */
  82542. multiplyByFloats(x: number, y: number, z: number): Vector3;
  82543. /**
  82544. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  82545. * @param otherVector defines the second operand
  82546. * @returns the new Vector3
  82547. */
  82548. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  82549. /**
  82550. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  82551. * @param otherVector defines the second operand
  82552. * @param result defines the Vector3 object where to store the result
  82553. * @returns the current Vector3
  82554. */
  82555. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82556. /**
  82557. * Divides the current Vector3 coordinates by the given ones.
  82558. * @param otherVector defines the second operand
  82559. * @returns the current updated Vector3
  82560. */
  82561. divideInPlace(otherVector: Vector3): Vector3;
  82562. /**
  82563. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  82564. * @param other defines the second operand
  82565. * @returns the current updated Vector3
  82566. */
  82567. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  82568. /**
  82569. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  82570. * @param other defines the second operand
  82571. * @returns the current updated Vector3
  82572. */
  82573. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  82574. /**
  82575. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  82576. * @param x defines the x coordinate of the operand
  82577. * @param y defines the y coordinate of the operand
  82578. * @param z defines the z coordinate of the operand
  82579. * @returns the current updated Vector3
  82580. */
  82581. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82582. /**
  82583. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  82584. * @param x defines the x coordinate of the operand
  82585. * @param y defines the y coordinate of the operand
  82586. * @param z defines the z coordinate of the operand
  82587. * @returns the current updated Vector3
  82588. */
  82589. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82590. /**
  82591. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  82592. * Check if is non uniform within a certain amount of decimal places to account for this
  82593. * @param epsilon the amount the values can differ
  82594. * @returns if the the vector is non uniform to a certain number of decimal places
  82595. */
  82596. isNonUniformWithinEpsilon(epsilon: number): boolean;
  82597. /**
  82598. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  82599. */
  82600. get isNonUniform(): boolean;
  82601. /**
  82602. * Gets a new Vector3 from current Vector3 floored values
  82603. * @returns a new Vector3
  82604. */
  82605. floor(): Vector3;
  82606. /**
  82607. * Gets a new Vector3 from current Vector3 floored values
  82608. * @returns a new Vector3
  82609. */
  82610. fract(): Vector3;
  82611. /**
  82612. * Gets the length of the Vector3
  82613. * @returns the length of the Vector3
  82614. */
  82615. length(): number;
  82616. /**
  82617. * Gets the squared length of the Vector3
  82618. * @returns squared length of the Vector3
  82619. */
  82620. lengthSquared(): number;
  82621. /**
  82622. * Normalize the current Vector3.
  82623. * Please note that this is an in place operation.
  82624. * @returns the current updated Vector3
  82625. */
  82626. normalize(): Vector3;
  82627. /**
  82628. * Reorders the x y z properties of the vector in place
  82629. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  82630. * @returns the current updated vector
  82631. */
  82632. reorderInPlace(order: string): this;
  82633. /**
  82634. * Rotates the vector around 0,0,0 by a quaternion
  82635. * @param quaternion the rotation quaternion
  82636. * @param result vector to store the result
  82637. * @returns the resulting vector
  82638. */
  82639. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  82640. /**
  82641. * Rotates a vector around a given point
  82642. * @param quaternion the rotation quaternion
  82643. * @param point the point to rotate around
  82644. * @param result vector to store the result
  82645. * @returns the resulting vector
  82646. */
  82647. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  82648. /**
  82649. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  82650. * The cross product is then orthogonal to both current and "other"
  82651. * @param other defines the right operand
  82652. * @returns the cross product
  82653. */
  82654. cross(other: Vector3): Vector3;
  82655. /**
  82656. * Normalize the current Vector3 with the given input length.
  82657. * Please note that this is an in place operation.
  82658. * @param len the length of the vector
  82659. * @returns the current updated Vector3
  82660. */
  82661. normalizeFromLength(len: number): Vector3;
  82662. /**
  82663. * Normalize the current Vector3 to a new vector
  82664. * @returns the new Vector3
  82665. */
  82666. normalizeToNew(): Vector3;
  82667. /**
  82668. * Normalize the current Vector3 to the reference
  82669. * @param reference define the Vector3 to update
  82670. * @returns the updated Vector3
  82671. */
  82672. normalizeToRef(reference: Vector3): Vector3;
  82673. /**
  82674. * Creates a new Vector3 copied from the current Vector3
  82675. * @returns the new Vector3
  82676. */
  82677. clone(): Vector3;
  82678. /**
  82679. * Copies the given vector coordinates to the current Vector3 ones
  82680. * @param source defines the source Vector3
  82681. * @returns the current updated Vector3
  82682. */
  82683. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  82684. /**
  82685. * Copies the given floats to the current Vector3 coordinates
  82686. * @param x defines the x coordinate of the operand
  82687. * @param y defines the y coordinate of the operand
  82688. * @param z defines the z coordinate of the operand
  82689. * @returns the current updated Vector3
  82690. */
  82691. copyFromFloats(x: number, y: number, z: number): Vector3;
  82692. /**
  82693. * Copies the given floats to the current Vector3 coordinates
  82694. * @param x defines the x coordinate of the operand
  82695. * @param y defines the y coordinate of the operand
  82696. * @param z defines the z coordinate of the operand
  82697. * @returns the current updated Vector3
  82698. */
  82699. set(x: number, y: number, z: number): Vector3;
  82700. /**
  82701. * Copies the given float to the current Vector3 coordinates
  82702. * @param v defines the x, y and z coordinates of the operand
  82703. * @returns the current updated Vector3
  82704. */
  82705. setAll(v: number): Vector3;
  82706. /**
  82707. * Get the clip factor between two vectors
  82708. * @param vector0 defines the first operand
  82709. * @param vector1 defines the second operand
  82710. * @param axis defines the axis to use
  82711. * @param size defines the size along the axis
  82712. * @returns the clip factor
  82713. */
  82714. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  82715. /**
  82716. * Get angle between two vectors
  82717. * @param vector0 angle between vector0 and vector1
  82718. * @param vector1 angle between vector0 and vector1
  82719. * @param normal direction of the normal
  82720. * @return the angle between vector0 and vector1
  82721. */
  82722. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  82723. /**
  82724. * Returns a new Vector3 set from the index "offset" of the given array
  82725. * @param array defines the source array
  82726. * @param offset defines the offset in the source array
  82727. * @returns the new Vector3
  82728. */
  82729. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  82730. /**
  82731. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  82732. * @param array defines the source array
  82733. * @param offset defines the offset in the source array
  82734. * @returns the new Vector3
  82735. * @deprecated Please use FromArray instead.
  82736. */
  82737. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  82738. /**
  82739. * Sets the given vector "result" with the element values from the index "offset" of the given array
  82740. * @param array defines the source array
  82741. * @param offset defines the offset in the source array
  82742. * @param result defines the Vector3 where to store the result
  82743. */
  82744. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  82745. /**
  82746. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  82747. * @param array defines the source array
  82748. * @param offset defines the offset in the source array
  82749. * @param result defines the Vector3 where to store the result
  82750. * @deprecated Please use FromArrayToRef instead.
  82751. */
  82752. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  82753. /**
  82754. * Sets the given vector "result" with the given floats.
  82755. * @param x defines the x coordinate of the source
  82756. * @param y defines the y coordinate of the source
  82757. * @param z defines the z coordinate of the source
  82758. * @param result defines the Vector3 where to store the result
  82759. */
  82760. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  82761. /**
  82762. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  82763. * @returns a new empty Vector3
  82764. */
  82765. static Zero(): Vector3;
  82766. /**
  82767. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  82768. * @returns a new unit Vector3
  82769. */
  82770. static One(): Vector3;
  82771. /**
  82772. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  82773. * @returns a new up Vector3
  82774. */
  82775. static Up(): Vector3;
  82776. /**
  82777. * Gets a up Vector3 that must not be updated
  82778. */
  82779. static get UpReadOnly(): DeepImmutable<Vector3>;
  82780. /**
  82781. * Gets a zero Vector3 that must not be updated
  82782. */
  82783. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  82784. /**
  82785. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  82786. * @returns a new down Vector3
  82787. */
  82788. static Down(): Vector3;
  82789. /**
  82790. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  82791. * @param rightHandedSystem is the scene right-handed (negative z)
  82792. * @returns a new forward Vector3
  82793. */
  82794. static Forward(rightHandedSystem?: boolean): Vector3;
  82795. /**
  82796. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  82797. * @param rightHandedSystem is the scene right-handed (negative-z)
  82798. * @returns a new forward Vector3
  82799. */
  82800. static Backward(rightHandedSystem?: boolean): Vector3;
  82801. /**
  82802. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  82803. * @returns a new right Vector3
  82804. */
  82805. static Right(): Vector3;
  82806. /**
  82807. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  82808. * @returns a new left Vector3
  82809. */
  82810. static Left(): Vector3;
  82811. /**
  82812. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  82813. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82814. * @param vector defines the Vector3 to transform
  82815. * @param transformation defines the transformation matrix
  82816. * @returns the transformed Vector3
  82817. */
  82818. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82819. /**
  82820. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  82821. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82822. * @param vector defines the Vector3 to transform
  82823. * @param transformation defines the transformation matrix
  82824. * @param result defines the Vector3 where to store the result
  82825. */
  82826. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82827. /**
  82828. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  82829. * This method computes tranformed coordinates only, not transformed direction vectors
  82830. * @param x define the x coordinate of the source vector
  82831. * @param y define the y coordinate of the source vector
  82832. * @param z define the z coordinate of the source vector
  82833. * @param transformation defines the transformation matrix
  82834. * @param result defines the Vector3 where to store the result
  82835. */
  82836. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82837. /**
  82838. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  82839. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82840. * @param vector defines the Vector3 to transform
  82841. * @param transformation defines the transformation matrix
  82842. * @returns the new Vector3
  82843. */
  82844. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82845. /**
  82846. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  82847. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82848. * @param vector defines the Vector3 to transform
  82849. * @param transformation defines the transformation matrix
  82850. * @param result defines the Vector3 where to store the result
  82851. */
  82852. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82853. /**
  82854. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  82855. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82856. * @param x define the x coordinate of the source vector
  82857. * @param y define the y coordinate of the source vector
  82858. * @param z define the z coordinate of the source vector
  82859. * @param transformation defines the transformation matrix
  82860. * @param result defines the Vector3 where to store the result
  82861. */
  82862. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82863. /**
  82864. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  82865. * @param value1 defines the first control point
  82866. * @param value2 defines the second control point
  82867. * @param value3 defines the third control point
  82868. * @param value4 defines the fourth control point
  82869. * @param amount defines the amount on the spline to use
  82870. * @returns the new Vector3
  82871. */
  82872. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  82873. /**
  82874. * 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"
  82875. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82876. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82877. * @param value defines the current value
  82878. * @param min defines the lower range value
  82879. * @param max defines the upper range value
  82880. * @returns the new Vector3
  82881. */
  82882. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  82883. /**
  82884. * 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"
  82885. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82886. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82887. * @param value defines the current value
  82888. * @param min defines the lower range value
  82889. * @param max defines the upper range value
  82890. * @param result defines the Vector3 where to store the result
  82891. */
  82892. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  82893. /**
  82894. * Checks if a given vector is inside a specific range
  82895. * @param v defines the vector to test
  82896. * @param min defines the minimum range
  82897. * @param max defines the maximum range
  82898. */
  82899. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  82900. /**
  82901. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  82902. * @param value1 defines the first control point
  82903. * @param tangent1 defines the first tangent vector
  82904. * @param value2 defines the second control point
  82905. * @param tangent2 defines the second tangent vector
  82906. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  82907. * @returns the new Vector3
  82908. */
  82909. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  82910. /**
  82911. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  82912. * @param start defines the start value
  82913. * @param end defines the end value
  82914. * @param amount max defines amount between both (between 0 and 1)
  82915. * @returns the new Vector3
  82916. */
  82917. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  82918. /**
  82919. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  82920. * @param start defines the start value
  82921. * @param end defines the end value
  82922. * @param amount max defines amount between both (between 0 and 1)
  82923. * @param result defines the Vector3 where to store the result
  82924. */
  82925. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  82926. /**
  82927. * Returns the dot product (float) between the vectors "left" and "right"
  82928. * @param left defines the left operand
  82929. * @param right defines the right operand
  82930. * @returns the dot product
  82931. */
  82932. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  82933. /**
  82934. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  82935. * The cross product is then orthogonal to both "left" and "right"
  82936. * @param left defines the left operand
  82937. * @param right defines the right operand
  82938. * @returns the cross product
  82939. */
  82940. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82941. /**
  82942. * Sets the given vector "result" with the cross product of "left" and "right"
  82943. * The cross product is then orthogonal to both "left" and "right"
  82944. * @param left defines the left operand
  82945. * @param right defines the right operand
  82946. * @param result defines the Vector3 where to store the result
  82947. */
  82948. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  82949. /**
  82950. * Returns a new Vector3 as the normalization of the given vector
  82951. * @param vector defines the Vector3 to normalize
  82952. * @returns the new Vector3
  82953. */
  82954. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  82955. /**
  82956. * Sets the given vector "result" with the normalization of the given first vector
  82957. * @param vector defines the Vector3 to normalize
  82958. * @param result defines the Vector3 where to store the result
  82959. */
  82960. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  82961. /**
  82962. * Project a Vector3 onto screen space
  82963. * @param vector defines the Vector3 to project
  82964. * @param world defines the world matrix to use
  82965. * @param transform defines the transform (view x projection) matrix to use
  82966. * @param viewport defines the screen viewport to use
  82967. * @returns the new Vector3
  82968. */
  82969. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  82970. /** @hidden */
  82971. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  82972. /**
  82973. * Unproject from screen space to object space
  82974. * @param source defines the screen space Vector3 to use
  82975. * @param viewportWidth defines the current width of the viewport
  82976. * @param viewportHeight defines the current height of the viewport
  82977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82978. * @param transform defines the transform (view x projection) matrix to use
  82979. * @returns the new Vector3
  82980. */
  82981. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  82982. /**
  82983. * Unproject from screen space to object space
  82984. * @param source defines the screen space Vector3 to use
  82985. * @param viewportWidth defines the current width of the viewport
  82986. * @param viewportHeight defines the current height of the viewport
  82987. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82988. * @param view defines the view matrix to use
  82989. * @param projection defines the projection matrix to use
  82990. * @returns the new Vector3
  82991. */
  82992. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  82993. /**
  82994. * Unproject from screen space to object space
  82995. * @param source defines the screen space Vector3 to use
  82996. * @param viewportWidth defines the current width of the viewport
  82997. * @param viewportHeight defines the current height of the viewport
  82998. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82999. * @param view defines the view matrix to use
  83000. * @param projection defines the projection matrix to use
  83001. * @param result defines the Vector3 where to store the result
  83002. */
  83003. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83004. /**
  83005. * Unproject from screen space to object space
  83006. * @param sourceX defines the screen space x coordinate to use
  83007. * @param sourceY defines the screen space y coordinate to use
  83008. * @param sourceZ defines the screen space z coordinate to use
  83009. * @param viewportWidth defines the current width of the viewport
  83010. * @param viewportHeight defines the current height of the viewport
  83011. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83012. * @param view defines the view matrix to use
  83013. * @param projection defines the projection matrix to use
  83014. * @param result defines the Vector3 where to store the result
  83015. */
  83016. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83017. /**
  83018. * Gets the minimal coordinate values between two Vector3
  83019. * @param left defines the first operand
  83020. * @param right defines the second operand
  83021. * @returns the new Vector3
  83022. */
  83023. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83024. /**
  83025. * Gets the maximal coordinate values between two Vector3
  83026. * @param left defines the first operand
  83027. * @param right defines the second operand
  83028. * @returns the new Vector3
  83029. */
  83030. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83031. /**
  83032. * Returns the distance between the vectors "value1" and "value2"
  83033. * @param value1 defines the first operand
  83034. * @param value2 defines the second operand
  83035. * @returns the distance
  83036. */
  83037. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83038. /**
  83039. * Returns the squared distance between the vectors "value1" and "value2"
  83040. * @param value1 defines the first operand
  83041. * @param value2 defines the second operand
  83042. * @returns the squared distance
  83043. */
  83044. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83045. /**
  83046. * Returns a new Vector3 located at the center between "value1" and "value2"
  83047. * @param value1 defines the first operand
  83048. * @param value2 defines the second operand
  83049. * @returns the new Vector3
  83050. */
  83051. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  83052. /**
  83053. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  83054. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  83055. * to something in order to rotate it from its local system to the given target system
  83056. * Note: axis1, axis2 and axis3 are normalized during this operation
  83057. * @param axis1 defines the first axis
  83058. * @param axis2 defines the second axis
  83059. * @param axis3 defines the third axis
  83060. * @returns a new Vector3
  83061. */
  83062. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  83063. /**
  83064. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  83065. * @param axis1 defines the first axis
  83066. * @param axis2 defines the second axis
  83067. * @param axis3 defines the third axis
  83068. * @param ref defines the Vector3 where to store the result
  83069. */
  83070. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83071. }
  83072. /**
  83073. * Vector4 class created for EulerAngle class conversion to Quaternion
  83074. */
  83075. export class Vector4 {
  83076. /** x value of the vector */
  83077. x: number;
  83078. /** y value of the vector */
  83079. y: number;
  83080. /** z value of the vector */
  83081. z: number;
  83082. /** w value of the vector */
  83083. w: number;
  83084. /**
  83085. * Creates a Vector4 object from the given floats.
  83086. * @param x x value of the vector
  83087. * @param y y value of the vector
  83088. * @param z z value of the vector
  83089. * @param w w value of the vector
  83090. */
  83091. constructor(
  83092. /** x value of the vector */
  83093. x: number,
  83094. /** y value of the vector */
  83095. y: number,
  83096. /** z value of the vector */
  83097. z: number,
  83098. /** w value of the vector */
  83099. w: number);
  83100. /**
  83101. * Returns the string with the Vector4 coordinates.
  83102. * @returns a string containing all the vector values
  83103. */
  83104. toString(): string;
  83105. /**
  83106. * Returns the string "Vector4".
  83107. * @returns "Vector4"
  83108. */
  83109. getClassName(): string;
  83110. /**
  83111. * Returns the Vector4 hash code.
  83112. * @returns a unique hash code
  83113. */
  83114. getHashCode(): number;
  83115. /**
  83116. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83117. * @returns the resulting array
  83118. */
  83119. asArray(): number[];
  83120. /**
  83121. * Populates the given array from the given index with the Vector4 coordinates.
  83122. * @param array array to populate
  83123. * @param index index of the array to start at (default: 0)
  83124. * @returns the Vector4.
  83125. */
  83126. toArray(array: FloatArray, index?: number): Vector4;
  83127. /**
  83128. * Update the current vector from an array
  83129. * @param array defines the destination array
  83130. * @param index defines the offset in the destination array
  83131. * @returns the current Vector3
  83132. */
  83133. fromArray(array: FloatArray, index?: number): Vector4;
  83134. /**
  83135. * Adds the given vector to the current Vector4.
  83136. * @param otherVector the vector to add
  83137. * @returns the updated Vector4.
  83138. */
  83139. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83140. /**
  83141. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  83142. * @param otherVector the vector to add
  83143. * @returns the resulting vector
  83144. */
  83145. add(otherVector: DeepImmutable<Vector4>): Vector4;
  83146. /**
  83147. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  83148. * @param otherVector the vector to add
  83149. * @param result the vector to store the result
  83150. * @returns the current Vector4.
  83151. */
  83152. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83153. /**
  83154. * Subtract in place the given vector from the current Vector4.
  83155. * @param otherVector the vector to subtract
  83156. * @returns the updated Vector4.
  83157. */
  83158. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83159. /**
  83160. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  83161. * @param otherVector the vector to add
  83162. * @returns the new vector with the result
  83163. */
  83164. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  83165. /**
  83166. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  83167. * @param otherVector the vector to subtract
  83168. * @param result the vector to store the result
  83169. * @returns the current Vector4.
  83170. */
  83171. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83172. /**
  83173. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83174. */
  83175. /**
  83176. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83177. * @param x value to subtract
  83178. * @param y value to subtract
  83179. * @param z value to subtract
  83180. * @param w value to subtract
  83181. * @returns new vector containing the result
  83182. */
  83183. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83184. /**
  83185. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83186. * @param x value to subtract
  83187. * @param y value to subtract
  83188. * @param z value to subtract
  83189. * @param w value to subtract
  83190. * @param result the vector to store the result in
  83191. * @returns the current Vector4.
  83192. */
  83193. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  83194. /**
  83195. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  83196. * @returns a new vector with the negated values
  83197. */
  83198. negate(): Vector4;
  83199. /**
  83200. * Negate this vector in place
  83201. * @returns this
  83202. */
  83203. negateInPlace(): Vector4;
  83204. /**
  83205. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  83206. * @param result defines the Vector3 object where to store the result
  83207. * @returns the current Vector4
  83208. */
  83209. negateToRef(result: Vector4): Vector4;
  83210. /**
  83211. * Multiplies the current Vector4 coordinates by scale (float).
  83212. * @param scale the number to scale with
  83213. * @returns the updated Vector4.
  83214. */
  83215. scaleInPlace(scale: number): Vector4;
  83216. /**
  83217. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  83218. * @param scale the number to scale with
  83219. * @returns a new vector with the result
  83220. */
  83221. scale(scale: number): Vector4;
  83222. /**
  83223. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  83224. * @param scale the number to scale with
  83225. * @param result a vector to store the result in
  83226. * @returns the current Vector4.
  83227. */
  83228. scaleToRef(scale: number, result: Vector4): Vector4;
  83229. /**
  83230. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  83231. * @param scale defines the scale factor
  83232. * @param result defines the Vector4 object where to store the result
  83233. * @returns the unmodified current Vector4
  83234. */
  83235. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  83236. /**
  83237. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  83238. * @param otherVector the vector to compare against
  83239. * @returns true if they are equal
  83240. */
  83241. equals(otherVector: DeepImmutable<Vector4>): boolean;
  83242. /**
  83243. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  83244. * @param otherVector vector to compare against
  83245. * @param epsilon (Default: very small number)
  83246. * @returns true if they are equal
  83247. */
  83248. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  83249. /**
  83250. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  83251. * @param x x value to compare against
  83252. * @param y y value to compare against
  83253. * @param z z value to compare against
  83254. * @param w w value to compare against
  83255. * @returns true if equal
  83256. */
  83257. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  83258. /**
  83259. * Multiplies in place the current Vector4 by the given one.
  83260. * @param otherVector vector to multiple with
  83261. * @returns the updated Vector4.
  83262. */
  83263. multiplyInPlace(otherVector: Vector4): Vector4;
  83264. /**
  83265. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  83266. * @param otherVector vector to multiple with
  83267. * @returns resulting new vector
  83268. */
  83269. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  83270. /**
  83271. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  83272. * @param otherVector vector to multiple with
  83273. * @param result vector to store the result
  83274. * @returns the current Vector4.
  83275. */
  83276. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83277. /**
  83278. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  83279. * @param x x value multiply with
  83280. * @param y y value multiply with
  83281. * @param z z value multiply with
  83282. * @param w w value multiply with
  83283. * @returns resulting new vector
  83284. */
  83285. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  83286. /**
  83287. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  83288. * @param otherVector vector to devide with
  83289. * @returns resulting new vector
  83290. */
  83291. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  83292. /**
  83293. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  83294. * @param otherVector vector to devide with
  83295. * @param result vector to store the result
  83296. * @returns the current Vector4.
  83297. */
  83298. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83299. /**
  83300. * Divides the current Vector3 coordinates by the given ones.
  83301. * @param otherVector vector to devide with
  83302. * @returns the updated Vector3.
  83303. */
  83304. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83305. /**
  83306. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  83307. * @param other defines the second operand
  83308. * @returns the current updated Vector4
  83309. */
  83310. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83311. /**
  83312. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  83313. * @param other defines the second operand
  83314. * @returns the current updated Vector4
  83315. */
  83316. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83317. /**
  83318. * Gets a new Vector4 from current Vector4 floored values
  83319. * @returns a new Vector4
  83320. */
  83321. floor(): Vector4;
  83322. /**
  83323. * Gets a new Vector4 from current Vector3 floored values
  83324. * @returns a new Vector4
  83325. */
  83326. fract(): Vector4;
  83327. /**
  83328. * Returns the Vector4 length (float).
  83329. * @returns the length
  83330. */
  83331. length(): number;
  83332. /**
  83333. * Returns the Vector4 squared length (float).
  83334. * @returns the length squared
  83335. */
  83336. lengthSquared(): number;
  83337. /**
  83338. * Normalizes in place the Vector4.
  83339. * @returns the updated Vector4.
  83340. */
  83341. normalize(): Vector4;
  83342. /**
  83343. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  83344. * @returns this converted to a new vector3
  83345. */
  83346. toVector3(): Vector3;
  83347. /**
  83348. * Returns a new Vector4 copied from the current one.
  83349. * @returns the new cloned vector
  83350. */
  83351. clone(): Vector4;
  83352. /**
  83353. * Updates the current Vector4 with the given one coordinates.
  83354. * @param source the source vector to copy from
  83355. * @returns the updated Vector4.
  83356. */
  83357. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  83358. /**
  83359. * Updates the current Vector4 coordinates with the given floats.
  83360. * @param x float to copy from
  83361. * @param y float to copy from
  83362. * @param z float to copy from
  83363. * @param w float to copy from
  83364. * @returns the updated Vector4.
  83365. */
  83366. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83367. /**
  83368. * Updates the current Vector4 coordinates with the given floats.
  83369. * @param x float to set from
  83370. * @param y float to set from
  83371. * @param z float to set from
  83372. * @param w float to set from
  83373. * @returns the updated Vector4.
  83374. */
  83375. set(x: number, y: number, z: number, w: number): Vector4;
  83376. /**
  83377. * Copies the given float to the current Vector3 coordinates
  83378. * @param v defines the x, y, z and w coordinates of the operand
  83379. * @returns the current updated Vector3
  83380. */
  83381. setAll(v: number): Vector4;
  83382. /**
  83383. * Returns a new Vector4 set from the starting index of the given array.
  83384. * @param array the array to pull values from
  83385. * @param offset the offset into the array to start at
  83386. * @returns the new vector
  83387. */
  83388. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  83389. /**
  83390. * Updates the given vector "result" from the starting index of the given array.
  83391. * @param array the array to pull values from
  83392. * @param offset the offset into the array to start at
  83393. * @param result the vector to store the result in
  83394. */
  83395. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  83396. /**
  83397. * Updates the given vector "result" from the starting index of the given Float32Array.
  83398. * @param array the array to pull values from
  83399. * @param offset the offset into the array to start at
  83400. * @param result the vector to store the result in
  83401. */
  83402. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  83403. /**
  83404. * Updates the given vector "result" coordinates from the given floats.
  83405. * @param x float to set from
  83406. * @param y float to set from
  83407. * @param z float to set from
  83408. * @param w float to set from
  83409. * @param result the vector to the floats in
  83410. */
  83411. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  83412. /**
  83413. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  83414. * @returns the new vector
  83415. */
  83416. static Zero(): Vector4;
  83417. /**
  83418. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  83419. * @returns the new vector
  83420. */
  83421. static One(): Vector4;
  83422. /**
  83423. * Returns a new normalized Vector4 from the given one.
  83424. * @param vector the vector to normalize
  83425. * @returns the vector
  83426. */
  83427. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  83428. /**
  83429. * Updates the given vector "result" from the normalization of the given one.
  83430. * @param vector the vector to normalize
  83431. * @param result the vector to store the result in
  83432. */
  83433. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  83434. /**
  83435. * Returns a vector with the minimum values from the left and right vectors
  83436. * @param left left vector to minimize
  83437. * @param right right vector to minimize
  83438. * @returns a new vector with the minimum of the left and right vector values
  83439. */
  83440. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83441. /**
  83442. * Returns a vector with the maximum values from the left and right vectors
  83443. * @param left left vector to maximize
  83444. * @param right right vector to maximize
  83445. * @returns a new vector with the maximum of the left and right vector values
  83446. */
  83447. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83448. /**
  83449. * Returns the distance (float) between the vectors "value1" and "value2".
  83450. * @param value1 value to calulate the distance between
  83451. * @param value2 value to calulate the distance between
  83452. * @return the distance between the two vectors
  83453. */
  83454. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83455. /**
  83456. * Returns the squared distance (float) between the vectors "value1" and "value2".
  83457. * @param value1 value to calulate the distance between
  83458. * @param value2 value to calulate the distance between
  83459. * @return the distance between the two vectors squared
  83460. */
  83461. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83462. /**
  83463. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  83464. * @param value1 value to calulate the center between
  83465. * @param value2 value to calulate the center between
  83466. * @return the center between the two vectors
  83467. */
  83468. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  83469. /**
  83470. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  83471. * This methods computes transformed normalized direction vectors only.
  83472. * @param vector the vector to transform
  83473. * @param transformation the transformation matrix to apply
  83474. * @returns the new vector
  83475. */
  83476. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  83477. /**
  83478. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  83479. * This methods computes transformed normalized direction vectors only.
  83480. * @param vector the vector to transform
  83481. * @param transformation the transformation matrix to apply
  83482. * @param result the vector to store the result in
  83483. */
  83484. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83485. /**
  83486. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  83487. * This methods computes transformed normalized direction vectors only.
  83488. * @param x value to transform
  83489. * @param y value to transform
  83490. * @param z value to transform
  83491. * @param w value to transform
  83492. * @param transformation the transformation matrix to apply
  83493. * @param result the vector to store the results in
  83494. */
  83495. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83496. /**
  83497. * Creates a new Vector4 from a Vector3
  83498. * @param source defines the source data
  83499. * @param w defines the 4th component (default is 0)
  83500. * @returns a new Vector4
  83501. */
  83502. static FromVector3(source: Vector3, w?: number): Vector4;
  83503. }
  83504. /**
  83505. * Class used to store quaternion data
  83506. * @see https://en.wikipedia.org/wiki/Quaternion
  83507. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  83508. */
  83509. export class Quaternion {
  83510. /** @hidden */
  83511. _x: number;
  83512. /** @hidden */
  83513. _y: number;
  83514. /** @hidden */
  83515. _z: number;
  83516. /** @hidden */
  83517. _w: number;
  83518. /** @hidden */
  83519. _isDirty: boolean;
  83520. /** Gets or sets the x coordinate */
  83521. get x(): number;
  83522. set x(value: number);
  83523. /** Gets or sets the y coordinate */
  83524. get y(): number;
  83525. set y(value: number);
  83526. /** Gets or sets the z coordinate */
  83527. get z(): number;
  83528. set z(value: number);
  83529. /** Gets or sets the w coordinate */
  83530. get w(): number;
  83531. set w(value: number);
  83532. /**
  83533. * Creates a new Quaternion from the given floats
  83534. * @param x defines the first component (0 by default)
  83535. * @param y defines the second component (0 by default)
  83536. * @param z defines the third component (0 by default)
  83537. * @param w defines the fourth component (1.0 by default)
  83538. */
  83539. constructor(x?: number, y?: number, z?: number, w?: number);
  83540. /**
  83541. * Gets a string representation for the current quaternion
  83542. * @returns a string with the Quaternion coordinates
  83543. */
  83544. toString(): string;
  83545. /**
  83546. * Gets the class name of the quaternion
  83547. * @returns the string "Quaternion"
  83548. */
  83549. getClassName(): string;
  83550. /**
  83551. * Gets a hash code for this quaternion
  83552. * @returns the quaternion hash code
  83553. */
  83554. getHashCode(): number;
  83555. /**
  83556. * Copy the quaternion to an array
  83557. * @returns a new array populated with 4 elements from the quaternion coordinates
  83558. */
  83559. asArray(): number[];
  83560. /**
  83561. * Check if two quaternions are equals
  83562. * @param otherQuaternion defines the second operand
  83563. * @return true if the current quaternion and the given one coordinates are strictly equals
  83564. */
  83565. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  83566. /**
  83567. * Gets a boolean if two quaternions are equals (using an epsilon value)
  83568. * @param otherQuaternion defines the other quaternion
  83569. * @param epsilon defines the minimal distance to consider equality
  83570. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  83571. */
  83572. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  83573. /**
  83574. * Clone the current quaternion
  83575. * @returns a new quaternion copied from the current one
  83576. */
  83577. clone(): Quaternion;
  83578. /**
  83579. * Copy a quaternion to the current one
  83580. * @param other defines the other quaternion
  83581. * @returns the updated current quaternion
  83582. */
  83583. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  83584. /**
  83585. * Updates the current quaternion with the given float coordinates
  83586. * @param x defines the x coordinate
  83587. * @param y defines the y coordinate
  83588. * @param z defines the z coordinate
  83589. * @param w defines the w coordinate
  83590. * @returns the updated current quaternion
  83591. */
  83592. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  83593. /**
  83594. * Updates the current quaternion from the given float coordinates
  83595. * @param x defines the x coordinate
  83596. * @param y defines the y coordinate
  83597. * @param z defines the z coordinate
  83598. * @param w defines the w coordinate
  83599. * @returns the updated current quaternion
  83600. */
  83601. set(x: number, y: number, z: number, w: number): Quaternion;
  83602. /**
  83603. * Adds two quaternions
  83604. * @param other defines the second operand
  83605. * @returns a new quaternion as the addition result of the given one and the current quaternion
  83606. */
  83607. add(other: DeepImmutable<Quaternion>): Quaternion;
  83608. /**
  83609. * Add a quaternion to the current one
  83610. * @param other defines the quaternion to add
  83611. * @returns the current quaternion
  83612. */
  83613. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  83614. /**
  83615. * Subtract two quaternions
  83616. * @param other defines the second operand
  83617. * @returns a new quaternion as the subtraction result of the given one from the current one
  83618. */
  83619. subtract(other: Quaternion): Quaternion;
  83620. /**
  83621. * Multiplies the current quaternion by a scale factor
  83622. * @param value defines the scale factor
  83623. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  83624. */
  83625. scale(value: number): Quaternion;
  83626. /**
  83627. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  83628. * @param scale defines the scale factor
  83629. * @param result defines the Quaternion object where to store the result
  83630. * @returns the unmodified current quaternion
  83631. */
  83632. scaleToRef(scale: number, result: Quaternion): Quaternion;
  83633. /**
  83634. * Multiplies in place the current quaternion by a scale factor
  83635. * @param value defines the scale factor
  83636. * @returns the current modified quaternion
  83637. */
  83638. scaleInPlace(value: number): Quaternion;
  83639. /**
  83640. * Scale the current quaternion values by a factor and add the result to a given quaternion
  83641. * @param scale defines the scale factor
  83642. * @param result defines the Quaternion object where to store the result
  83643. * @returns the unmodified current quaternion
  83644. */
  83645. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  83646. /**
  83647. * Multiplies two quaternions
  83648. * @param q1 defines the second operand
  83649. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  83650. */
  83651. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  83652. /**
  83653. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  83654. * @param q1 defines the second operand
  83655. * @param result defines the target quaternion
  83656. * @returns the current quaternion
  83657. */
  83658. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  83659. /**
  83660. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  83661. * @param q1 defines the second operand
  83662. * @returns the currentupdated quaternion
  83663. */
  83664. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  83665. /**
  83666. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  83667. * @param ref defines the target quaternion
  83668. * @returns the current quaternion
  83669. */
  83670. conjugateToRef(ref: Quaternion): Quaternion;
  83671. /**
  83672. * Conjugates in place (1-q) the current quaternion
  83673. * @returns the current updated quaternion
  83674. */
  83675. conjugateInPlace(): Quaternion;
  83676. /**
  83677. * Conjugates in place (1-q) the current quaternion
  83678. * @returns a new quaternion
  83679. */
  83680. conjugate(): Quaternion;
  83681. /**
  83682. * Gets length of current quaternion
  83683. * @returns the quaternion length (float)
  83684. */
  83685. length(): number;
  83686. /**
  83687. * Normalize in place the current quaternion
  83688. * @returns the current updated quaternion
  83689. */
  83690. normalize(): Quaternion;
  83691. /**
  83692. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  83693. * @param order is a reserved parameter and is ignore for now
  83694. * @returns a new Vector3 containing the Euler angles
  83695. */
  83696. toEulerAngles(order?: string): Vector3;
  83697. /**
  83698. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  83699. * @param result defines the vector which will be filled with the Euler angles
  83700. * @param order is a reserved parameter and is ignore for now
  83701. * @returns the current unchanged quaternion
  83702. */
  83703. toEulerAnglesToRef(result: Vector3): Quaternion;
  83704. /**
  83705. * Updates the given rotation matrix with the current quaternion values
  83706. * @param result defines the target matrix
  83707. * @returns the current unchanged quaternion
  83708. */
  83709. toRotationMatrix(result: Matrix): Quaternion;
  83710. /**
  83711. * Updates the current quaternion from the given rotation matrix values
  83712. * @param matrix defines the source matrix
  83713. * @returns the current updated quaternion
  83714. */
  83715. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  83716. /**
  83717. * Creates a new quaternion from a rotation matrix
  83718. * @param matrix defines the source matrix
  83719. * @returns a new quaternion created from the given rotation matrix values
  83720. */
  83721. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  83722. /**
  83723. * Updates the given quaternion with the given rotation matrix values
  83724. * @param matrix defines the source matrix
  83725. * @param result defines the target quaternion
  83726. */
  83727. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  83728. /**
  83729. * Returns the dot product (float) between the quaternions "left" and "right"
  83730. * @param left defines the left operand
  83731. * @param right defines the right operand
  83732. * @returns the dot product
  83733. */
  83734. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  83735. /**
  83736. * Checks if the two quaternions are close to each other
  83737. * @param quat0 defines the first quaternion to check
  83738. * @param quat1 defines the second quaternion to check
  83739. * @returns true if the two quaternions are close to each other
  83740. */
  83741. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  83742. /**
  83743. * Creates an empty quaternion
  83744. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  83745. */
  83746. static Zero(): Quaternion;
  83747. /**
  83748. * Inverse a given quaternion
  83749. * @param q defines the source quaternion
  83750. * @returns a new quaternion as the inverted current quaternion
  83751. */
  83752. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  83753. /**
  83754. * Inverse a given quaternion
  83755. * @param q defines the source quaternion
  83756. * @param result the quaternion the result will be stored in
  83757. * @returns the result quaternion
  83758. */
  83759. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  83760. /**
  83761. * Creates an identity quaternion
  83762. * @returns the identity quaternion
  83763. */
  83764. static Identity(): Quaternion;
  83765. /**
  83766. * Gets a boolean indicating if the given quaternion is identity
  83767. * @param quaternion defines the quaternion to check
  83768. * @returns true if the quaternion is identity
  83769. */
  83770. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  83771. /**
  83772. * Creates a quaternion from a rotation around an axis
  83773. * @param axis defines the axis to use
  83774. * @param angle defines the angle to use
  83775. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  83776. */
  83777. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  83778. /**
  83779. * Creates a rotation around an axis and stores it into the given quaternion
  83780. * @param axis defines the axis to use
  83781. * @param angle defines the angle to use
  83782. * @param result defines the target quaternion
  83783. * @returns the target quaternion
  83784. */
  83785. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  83786. /**
  83787. * Creates a new quaternion from data stored into an array
  83788. * @param array defines the data source
  83789. * @param offset defines the offset in the source array where the data starts
  83790. * @returns a new quaternion
  83791. */
  83792. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  83793. /**
  83794. * Updates the given quaternion "result" from the starting index of the given array.
  83795. * @param array the array to pull values from
  83796. * @param offset the offset into the array to start at
  83797. * @param result the quaternion to store the result in
  83798. */
  83799. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  83800. /**
  83801. * Create a quaternion from Euler rotation angles
  83802. * @param x Pitch
  83803. * @param y Yaw
  83804. * @param z Roll
  83805. * @returns the new Quaternion
  83806. */
  83807. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  83808. /**
  83809. * Updates a quaternion from Euler rotation angles
  83810. * @param x Pitch
  83811. * @param y Yaw
  83812. * @param z Roll
  83813. * @param result the quaternion to store the result
  83814. * @returns the updated quaternion
  83815. */
  83816. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  83817. /**
  83818. * Create a quaternion from Euler rotation vector
  83819. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83820. * @returns the new Quaternion
  83821. */
  83822. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  83823. /**
  83824. * Updates a quaternion from Euler rotation vector
  83825. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83826. * @param result the quaternion to store the result
  83827. * @returns the updated quaternion
  83828. */
  83829. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  83830. /**
  83831. * Creates a new quaternion from the given Euler float angles (y, x, z)
  83832. * @param yaw defines the rotation around Y axis
  83833. * @param pitch defines the rotation around X axis
  83834. * @param roll defines the rotation around Z axis
  83835. * @returns the new quaternion
  83836. */
  83837. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  83838. /**
  83839. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  83840. * @param yaw defines the rotation around Y axis
  83841. * @param pitch defines the rotation around X axis
  83842. * @param roll defines the rotation around Z axis
  83843. * @param result defines the target quaternion
  83844. */
  83845. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  83846. /**
  83847. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  83848. * @param alpha defines the rotation around first axis
  83849. * @param beta defines the rotation around second axis
  83850. * @param gamma defines the rotation around third axis
  83851. * @returns the new quaternion
  83852. */
  83853. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  83854. /**
  83855. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  83856. * @param alpha defines the rotation around first axis
  83857. * @param beta defines the rotation around second axis
  83858. * @param gamma defines the rotation around third axis
  83859. * @param result defines the target quaternion
  83860. */
  83861. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  83862. /**
  83863. * 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)
  83864. * @param axis1 defines the first axis
  83865. * @param axis2 defines the second axis
  83866. * @param axis3 defines the third axis
  83867. * @returns the new quaternion
  83868. */
  83869. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  83870. /**
  83871. * 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
  83872. * @param axis1 defines the first axis
  83873. * @param axis2 defines the second axis
  83874. * @param axis3 defines the third axis
  83875. * @param ref defines the target quaternion
  83876. */
  83877. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  83878. /**
  83879. * Interpolates between two quaternions
  83880. * @param left defines first quaternion
  83881. * @param right defines second quaternion
  83882. * @param amount defines the gradient to use
  83883. * @returns the new interpolated quaternion
  83884. */
  83885. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83886. /**
  83887. * Interpolates between two quaternions and stores it into a target quaternion
  83888. * @param left defines first quaternion
  83889. * @param right defines second quaternion
  83890. * @param amount defines the gradient to use
  83891. * @param result defines the target quaternion
  83892. */
  83893. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  83894. /**
  83895. * Interpolate between two quaternions using Hermite interpolation
  83896. * @param value1 defines first quaternion
  83897. * @param tangent1 defines the incoming tangent
  83898. * @param value2 defines second quaternion
  83899. * @param tangent2 defines the outgoing tangent
  83900. * @param amount defines the target quaternion
  83901. * @returns the new interpolated quaternion
  83902. */
  83903. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83904. }
  83905. /**
  83906. * Class used to store matrix data (4x4)
  83907. */
  83908. export class Matrix {
  83909. /**
  83910. * Gets the precision of matrix computations
  83911. */
  83912. static get Use64Bits(): boolean;
  83913. private static _updateFlagSeed;
  83914. private static _identityReadOnly;
  83915. private _isIdentity;
  83916. private _isIdentityDirty;
  83917. private _isIdentity3x2;
  83918. private _isIdentity3x2Dirty;
  83919. /**
  83920. * Gets the update flag of the matrix which is an unique number for the matrix.
  83921. * It will be incremented every time the matrix data change.
  83922. * You can use it to speed the comparison between two versions of the same matrix.
  83923. */
  83924. updateFlag: number;
  83925. private readonly _m;
  83926. /**
  83927. * Gets the internal data of the matrix
  83928. */
  83929. get m(): DeepImmutable<Float32Array | Array<number>>;
  83930. /** @hidden */
  83931. _markAsUpdated(): void;
  83932. /** @hidden */
  83933. private _updateIdentityStatus;
  83934. /**
  83935. * Creates an empty matrix (filled with zeros)
  83936. */
  83937. constructor();
  83938. /**
  83939. * Check if the current matrix is identity
  83940. * @returns true is the matrix is the identity matrix
  83941. */
  83942. isIdentity(): boolean;
  83943. /**
  83944. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  83945. * @returns true is the matrix is the identity matrix
  83946. */
  83947. isIdentityAs3x2(): boolean;
  83948. /**
  83949. * Gets the determinant of the matrix
  83950. * @returns the matrix determinant
  83951. */
  83952. determinant(): number;
  83953. /**
  83954. * Returns the matrix as a Float32Array or Array<number>
  83955. * @returns the matrix underlying array
  83956. */
  83957. toArray(): DeepImmutable<Float32Array | Array<number>>;
  83958. /**
  83959. * Returns the matrix as a Float32Array or Array<number>
  83960. * @returns the matrix underlying array.
  83961. */
  83962. asArray(): DeepImmutable<Float32Array | Array<number>>;
  83963. /**
  83964. * Inverts the current matrix in place
  83965. * @returns the current inverted matrix
  83966. */
  83967. invert(): Matrix;
  83968. /**
  83969. * Sets all the matrix elements to zero
  83970. * @returns the current matrix
  83971. */
  83972. reset(): Matrix;
  83973. /**
  83974. * Adds the current matrix with a second one
  83975. * @param other defines the matrix to add
  83976. * @returns a new matrix as the addition of the current matrix and the given one
  83977. */
  83978. add(other: DeepImmutable<Matrix>): Matrix;
  83979. /**
  83980. * Sets the given matrix "result" to the addition of the current matrix and the given one
  83981. * @param other defines the matrix to add
  83982. * @param result defines the target matrix
  83983. * @returns the current matrix
  83984. */
  83985. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83986. /**
  83987. * Adds in place the given matrix to the current matrix
  83988. * @param other defines the second operand
  83989. * @returns the current updated matrix
  83990. */
  83991. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  83992. /**
  83993. * Sets the given matrix to the current inverted Matrix
  83994. * @param other defines the target matrix
  83995. * @returns the unmodified current matrix
  83996. */
  83997. invertToRef(other: Matrix): Matrix;
  83998. /**
  83999. * add a value at the specified position in the current Matrix
  84000. * @param index the index of the value within the matrix. between 0 and 15.
  84001. * @param value the value to be added
  84002. * @returns the current updated matrix
  84003. */
  84004. addAtIndex(index: number, value: number): Matrix;
  84005. /**
  84006. * mutiply the specified position in the current Matrix by a value
  84007. * @param index the index of the value within the matrix. between 0 and 15.
  84008. * @param value the value to be added
  84009. * @returns the current updated matrix
  84010. */
  84011. multiplyAtIndex(index: number, value: number): Matrix;
  84012. /**
  84013. * Inserts the translation vector (using 3 floats) in the current matrix
  84014. * @param x defines the 1st component of the translation
  84015. * @param y defines the 2nd component of the translation
  84016. * @param z defines the 3rd component of the translation
  84017. * @returns the current updated matrix
  84018. */
  84019. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84020. /**
  84021. * Adds the translation vector (using 3 floats) in the current matrix
  84022. * @param x defines the 1st component of the translation
  84023. * @param y defines the 2nd component of the translation
  84024. * @param z defines the 3rd component of the translation
  84025. * @returns the current updated matrix
  84026. */
  84027. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84028. /**
  84029. * Inserts the translation vector in the current matrix
  84030. * @param vector3 defines the translation to insert
  84031. * @returns the current updated matrix
  84032. */
  84033. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84034. /**
  84035. * Gets the translation value of the current matrix
  84036. * @returns a new Vector3 as the extracted translation from the matrix
  84037. */
  84038. getTranslation(): Vector3;
  84039. /**
  84040. * Fill a Vector3 with the extracted translation from the matrix
  84041. * @param result defines the Vector3 where to store the translation
  84042. * @returns the current matrix
  84043. */
  84044. getTranslationToRef(result: Vector3): Matrix;
  84045. /**
  84046. * Remove rotation and scaling part from the matrix
  84047. * @returns the updated matrix
  84048. */
  84049. removeRotationAndScaling(): Matrix;
  84050. /**
  84051. * Multiply two matrices
  84052. * @param other defines the second operand
  84053. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  84054. */
  84055. multiply(other: DeepImmutable<Matrix>): Matrix;
  84056. /**
  84057. * Copy the current matrix from the given one
  84058. * @param other defines the source matrix
  84059. * @returns the current updated matrix
  84060. */
  84061. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  84062. /**
  84063. * Populates the given array from the starting index with the current matrix values
  84064. * @param array defines the target array
  84065. * @param offset defines the offset in the target array where to start storing values
  84066. * @returns the current matrix
  84067. */
  84068. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84069. /**
  84070. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84071. * @param other defines the second operand
  84072. * @param result defines the matrix where to store the multiplication
  84073. * @returns the current matrix
  84074. */
  84075. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84076. /**
  84077. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84078. * @param other defines the second operand
  84079. * @param result defines the array where to store the multiplication
  84080. * @param offset defines the offset in the target array where to start storing values
  84081. * @returns the current matrix
  84082. */
  84083. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84084. /**
  84085. * Check equality between this matrix and a second one
  84086. * @param value defines the second matrix to compare
  84087. * @returns true is the current matrix and the given one values are strictly equal
  84088. */
  84089. equals(value: DeepImmutable<Matrix>): boolean;
  84090. /**
  84091. * Clone the current matrix
  84092. * @returns a new matrix from the current matrix
  84093. */
  84094. clone(): Matrix;
  84095. /**
  84096. * Returns the name of the current matrix class
  84097. * @returns the string "Matrix"
  84098. */
  84099. getClassName(): string;
  84100. /**
  84101. * Gets the hash code of the current matrix
  84102. * @returns the hash code
  84103. */
  84104. getHashCode(): number;
  84105. /**
  84106. * Decomposes the current Matrix into a translation, rotation and scaling components
  84107. * @param scale defines the scale vector3 given as a reference to update
  84108. * @param rotation defines the rotation quaternion given as a reference to update
  84109. * @param translation defines the translation vector3 given as a reference to update
  84110. * @returns true if operation was successful
  84111. */
  84112. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84113. /**
  84114. * Gets specific row of the matrix
  84115. * @param index defines the number of the row to get
  84116. * @returns the index-th row of the current matrix as a new Vector4
  84117. */
  84118. getRow(index: number): Nullable<Vector4>;
  84119. /**
  84120. * Sets the index-th row of the current matrix to the vector4 values
  84121. * @param index defines the number of the row to set
  84122. * @param row defines the target vector4
  84123. * @returns the updated current matrix
  84124. */
  84125. setRow(index: number, row: Vector4): Matrix;
  84126. /**
  84127. * Compute the transpose of the matrix
  84128. * @returns the new transposed matrix
  84129. */
  84130. transpose(): Matrix;
  84131. /**
  84132. * Compute the transpose of the matrix and store it in a given matrix
  84133. * @param result defines the target matrix
  84134. * @returns the current matrix
  84135. */
  84136. transposeToRef(result: Matrix): Matrix;
  84137. /**
  84138. * Sets the index-th row of the current matrix with the given 4 x float values
  84139. * @param index defines the row index
  84140. * @param x defines the x component to set
  84141. * @param y defines the y component to set
  84142. * @param z defines the z component to set
  84143. * @param w defines the w component to set
  84144. * @returns the updated current matrix
  84145. */
  84146. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  84147. /**
  84148. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  84149. * @param scale defines the scale factor
  84150. * @returns a new matrix
  84151. */
  84152. scale(scale: number): Matrix;
  84153. /**
  84154. * Scale the current matrix values by a factor to a given result matrix
  84155. * @param scale defines the scale factor
  84156. * @param result defines the matrix to store the result
  84157. * @returns the current matrix
  84158. */
  84159. scaleToRef(scale: number, result: Matrix): Matrix;
  84160. /**
  84161. * Scale the current matrix values by a factor and add the result to a given matrix
  84162. * @param scale defines the scale factor
  84163. * @param result defines the Matrix to store the result
  84164. * @returns the current matrix
  84165. */
  84166. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  84167. /**
  84168. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  84169. * @param ref matrix to store the result
  84170. */
  84171. toNormalMatrix(ref: Matrix): void;
  84172. /**
  84173. * Gets only rotation part of the current matrix
  84174. * @returns a new matrix sets to the extracted rotation matrix from the current one
  84175. */
  84176. getRotationMatrix(): Matrix;
  84177. /**
  84178. * Extracts the rotation matrix from the current one and sets it as the given "result"
  84179. * @param result defines the target matrix to store data to
  84180. * @returns the current matrix
  84181. */
  84182. getRotationMatrixToRef(result: Matrix): Matrix;
  84183. /**
  84184. * Toggles model matrix from being right handed to left handed in place and vice versa
  84185. */
  84186. toggleModelMatrixHandInPlace(): void;
  84187. /**
  84188. * Toggles projection matrix from being right handed to left handed in place and vice versa
  84189. */
  84190. toggleProjectionMatrixHandInPlace(): void;
  84191. /**
  84192. * Creates a matrix from an array
  84193. * @param array defines the source array
  84194. * @param offset defines an offset in the source array
  84195. * @returns a new Matrix set from the starting index of the given array
  84196. */
  84197. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  84198. /**
  84199. * Copy the content of an array into a given matrix
  84200. * @param array defines the source array
  84201. * @param offset defines an offset in the source array
  84202. * @param result defines the target matrix
  84203. */
  84204. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  84205. /**
  84206. * Stores an array into a matrix after having multiplied each component by a given factor
  84207. * @param array defines the source array
  84208. * @param offset defines the offset in the source array
  84209. * @param scale defines the scaling factor
  84210. * @param result defines the target matrix
  84211. */
  84212. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  84213. /**
  84214. * Gets an identity matrix that must not be updated
  84215. */
  84216. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  84217. /**
  84218. * Stores a list of values (16) inside a given matrix
  84219. * @param initialM11 defines 1st value of 1st row
  84220. * @param initialM12 defines 2nd value of 1st row
  84221. * @param initialM13 defines 3rd value of 1st row
  84222. * @param initialM14 defines 4th value of 1st row
  84223. * @param initialM21 defines 1st value of 2nd row
  84224. * @param initialM22 defines 2nd value of 2nd row
  84225. * @param initialM23 defines 3rd value of 2nd row
  84226. * @param initialM24 defines 4th value of 2nd row
  84227. * @param initialM31 defines 1st value of 3rd row
  84228. * @param initialM32 defines 2nd value of 3rd row
  84229. * @param initialM33 defines 3rd value of 3rd row
  84230. * @param initialM34 defines 4th value of 3rd row
  84231. * @param initialM41 defines 1st value of 4th row
  84232. * @param initialM42 defines 2nd value of 4th row
  84233. * @param initialM43 defines 3rd value of 4th row
  84234. * @param initialM44 defines 4th value of 4th row
  84235. * @param result defines the target matrix
  84236. */
  84237. 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;
  84238. /**
  84239. * Creates new matrix from a list of values (16)
  84240. * @param initialM11 defines 1st value of 1st row
  84241. * @param initialM12 defines 2nd value of 1st row
  84242. * @param initialM13 defines 3rd value of 1st row
  84243. * @param initialM14 defines 4th value of 1st row
  84244. * @param initialM21 defines 1st value of 2nd row
  84245. * @param initialM22 defines 2nd value of 2nd row
  84246. * @param initialM23 defines 3rd value of 2nd row
  84247. * @param initialM24 defines 4th value of 2nd row
  84248. * @param initialM31 defines 1st value of 3rd row
  84249. * @param initialM32 defines 2nd value of 3rd row
  84250. * @param initialM33 defines 3rd value of 3rd row
  84251. * @param initialM34 defines 4th value of 3rd row
  84252. * @param initialM41 defines 1st value of 4th row
  84253. * @param initialM42 defines 2nd value of 4th row
  84254. * @param initialM43 defines 3rd value of 4th row
  84255. * @param initialM44 defines 4th value of 4th row
  84256. * @returns the new matrix
  84257. */
  84258. 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;
  84259. /**
  84260. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84261. * @param scale defines the scale vector3
  84262. * @param rotation defines the rotation quaternion
  84263. * @param translation defines the translation vector3
  84264. * @returns a new matrix
  84265. */
  84266. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  84267. /**
  84268. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84269. * @param scale defines the scale vector3
  84270. * @param rotation defines the rotation quaternion
  84271. * @param translation defines the translation vector3
  84272. * @param result defines the target matrix
  84273. */
  84274. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  84275. /**
  84276. * Creates a new identity matrix
  84277. * @returns a new identity matrix
  84278. */
  84279. static Identity(): Matrix;
  84280. /**
  84281. * Creates a new identity matrix and stores the result in a given matrix
  84282. * @param result defines the target matrix
  84283. */
  84284. static IdentityToRef(result: Matrix): void;
  84285. /**
  84286. * Creates a new zero matrix
  84287. * @returns a new zero matrix
  84288. */
  84289. static Zero(): Matrix;
  84290. /**
  84291. * Creates a new rotation matrix for "angle" radians around the X axis
  84292. * @param angle defines the angle (in radians) to use
  84293. * @return the new matrix
  84294. */
  84295. static RotationX(angle: number): Matrix;
  84296. /**
  84297. * Creates a new matrix as the invert of a given matrix
  84298. * @param source defines the source matrix
  84299. * @returns the new matrix
  84300. */
  84301. static Invert(source: DeepImmutable<Matrix>): Matrix;
  84302. /**
  84303. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  84304. * @param angle defines the angle (in radians) to use
  84305. * @param result defines the target matrix
  84306. */
  84307. static RotationXToRef(angle: number, result: Matrix): void;
  84308. /**
  84309. * Creates a new rotation matrix for "angle" radians around the Y axis
  84310. * @param angle defines the angle (in radians) to use
  84311. * @return the new matrix
  84312. */
  84313. static RotationY(angle: number): Matrix;
  84314. /**
  84315. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  84316. * @param angle defines the angle (in radians) to use
  84317. * @param result defines the target matrix
  84318. */
  84319. static RotationYToRef(angle: number, result: Matrix): void;
  84320. /**
  84321. * Creates a new rotation matrix for "angle" radians around the Z axis
  84322. * @param angle defines the angle (in radians) to use
  84323. * @return the new matrix
  84324. */
  84325. static RotationZ(angle: number): Matrix;
  84326. /**
  84327. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  84328. * @param angle defines the angle (in radians) to use
  84329. * @param result defines the target matrix
  84330. */
  84331. static RotationZToRef(angle: number, result: Matrix): void;
  84332. /**
  84333. * Creates a new rotation matrix for "angle" radians around the given axis
  84334. * @param axis defines the axis to use
  84335. * @param angle defines the angle (in radians) to use
  84336. * @return the new matrix
  84337. */
  84338. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  84339. /**
  84340. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  84341. * @param axis defines the axis to use
  84342. * @param angle defines the angle (in radians) to use
  84343. * @param result defines the target matrix
  84344. */
  84345. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  84346. /**
  84347. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  84348. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  84349. * @param from defines the vector to align
  84350. * @param to defines the vector to align to
  84351. * @param result defines the target matrix
  84352. */
  84353. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  84354. /**
  84355. * Creates a rotation matrix
  84356. * @param yaw defines the yaw angle in radians (Y axis)
  84357. * @param pitch defines the pitch angle in radians (X axis)
  84358. * @param roll defines the roll angle in radians (Z axis)
  84359. * @returns the new rotation matrix
  84360. */
  84361. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  84362. /**
  84363. * Creates a rotation matrix and stores it in a given matrix
  84364. * @param yaw defines the yaw angle in radians (Y axis)
  84365. * @param pitch defines the pitch angle in radians (X axis)
  84366. * @param roll defines the roll angle in radians (Z axis)
  84367. * @param result defines the target matrix
  84368. */
  84369. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  84370. /**
  84371. * Creates a scaling matrix
  84372. * @param x defines the scale factor on X axis
  84373. * @param y defines the scale factor on Y axis
  84374. * @param z defines the scale factor on Z axis
  84375. * @returns the new matrix
  84376. */
  84377. static Scaling(x: number, y: number, z: number): Matrix;
  84378. /**
  84379. * Creates a scaling matrix and stores it in a given matrix
  84380. * @param x defines the scale factor on X axis
  84381. * @param y defines the scale factor on Y axis
  84382. * @param z defines the scale factor on Z axis
  84383. * @param result defines the target matrix
  84384. */
  84385. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  84386. /**
  84387. * Creates a translation matrix
  84388. * @param x defines the translation on X axis
  84389. * @param y defines the translation on Y axis
  84390. * @param z defines the translationon Z axis
  84391. * @returns the new matrix
  84392. */
  84393. static Translation(x: number, y: number, z: number): Matrix;
  84394. /**
  84395. * Creates a translation matrix and stores it in a given matrix
  84396. * @param x defines the translation on X axis
  84397. * @param y defines the translation on Y axis
  84398. * @param z defines the translationon Z axis
  84399. * @param result defines the target matrix
  84400. */
  84401. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  84402. /**
  84403. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84404. * @param startValue defines the start value
  84405. * @param endValue defines the end value
  84406. * @param gradient defines the gradient factor
  84407. * @returns the new matrix
  84408. */
  84409. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84410. /**
  84411. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84412. * @param startValue defines the start value
  84413. * @param endValue defines the end value
  84414. * @param gradient defines the gradient factor
  84415. * @param result defines the Matrix object where to store data
  84416. */
  84417. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84418. /**
  84419. * Builds a new matrix whose values are computed by:
  84420. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84421. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84422. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84423. * @param startValue defines the first matrix
  84424. * @param endValue defines the second matrix
  84425. * @param gradient defines the gradient between the two matrices
  84426. * @returns the new matrix
  84427. */
  84428. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84429. /**
  84430. * Update a matrix to values which are computed by:
  84431. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84432. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84433. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84434. * @param startValue defines the first matrix
  84435. * @param endValue defines the second matrix
  84436. * @param gradient defines the gradient between the two matrices
  84437. * @param result defines the target matrix
  84438. */
  84439. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84440. /**
  84441. * 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"
  84442. * This function works in left handed mode
  84443. * @param eye defines the final position of the entity
  84444. * @param target defines where the entity should look at
  84445. * @param up defines the up vector for the entity
  84446. * @returns the new matrix
  84447. */
  84448. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84449. /**
  84450. * 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".
  84451. * This function works in left handed mode
  84452. * @param eye defines the final position of the entity
  84453. * @param target defines where the entity should look at
  84454. * @param up defines the up vector for the entity
  84455. * @param result defines the target matrix
  84456. */
  84457. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84458. /**
  84459. * 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"
  84460. * This function works in right handed mode
  84461. * @param eye defines the final position of the entity
  84462. * @param target defines where the entity should look at
  84463. * @param up defines the up vector for the entity
  84464. * @returns the new matrix
  84465. */
  84466. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84467. /**
  84468. * 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".
  84469. * This function works in right handed mode
  84470. * @param eye defines the final position of the entity
  84471. * @param target defines where the entity should look at
  84472. * @param up defines the up vector for the entity
  84473. * @param result defines the target matrix
  84474. */
  84475. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84476. /**
  84477. * Create a left-handed orthographic projection matrix
  84478. * @param width defines the viewport width
  84479. * @param height defines the viewport height
  84480. * @param znear defines the near clip plane
  84481. * @param zfar defines the far clip plane
  84482. * @returns a new matrix as a left-handed orthographic projection matrix
  84483. */
  84484. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84485. /**
  84486. * Store a left-handed orthographic projection to a given matrix
  84487. * @param width defines the viewport width
  84488. * @param height defines the viewport height
  84489. * @param znear defines the near clip plane
  84490. * @param zfar defines the far clip plane
  84491. * @param result defines the target matrix
  84492. */
  84493. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  84494. /**
  84495. * Create a left-handed orthographic projection matrix
  84496. * @param left defines the viewport left coordinate
  84497. * @param right defines the viewport right coordinate
  84498. * @param bottom defines the viewport bottom coordinate
  84499. * @param top defines the viewport top coordinate
  84500. * @param znear defines the near clip plane
  84501. * @param zfar defines the far clip plane
  84502. * @returns a new matrix as a left-handed orthographic projection matrix
  84503. */
  84504. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84505. /**
  84506. * Stores a left-handed orthographic projection into a given matrix
  84507. * @param left defines the viewport left coordinate
  84508. * @param right defines the viewport right coordinate
  84509. * @param bottom defines the viewport bottom coordinate
  84510. * @param top defines the viewport top coordinate
  84511. * @param znear defines the near clip plane
  84512. * @param zfar defines the far clip plane
  84513. * @param result defines the target matrix
  84514. */
  84515. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84516. /**
  84517. * Creates a right-handed orthographic projection matrix
  84518. * @param left defines the viewport left coordinate
  84519. * @param right defines the viewport right coordinate
  84520. * @param bottom defines the viewport bottom coordinate
  84521. * @param top defines the viewport top coordinate
  84522. * @param znear defines the near clip plane
  84523. * @param zfar defines the far clip plane
  84524. * @returns a new matrix as a right-handed orthographic projection matrix
  84525. */
  84526. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84527. /**
  84528. * Stores a right-handed orthographic projection into a given matrix
  84529. * @param left defines the viewport left coordinate
  84530. * @param right defines the viewport right coordinate
  84531. * @param bottom defines the viewport bottom coordinate
  84532. * @param top defines the viewport top coordinate
  84533. * @param znear defines the near clip plane
  84534. * @param zfar defines the far clip plane
  84535. * @param result defines the target matrix
  84536. */
  84537. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84538. /**
  84539. * Creates a left-handed perspective projection matrix
  84540. * @param width defines the viewport width
  84541. * @param height defines the viewport height
  84542. * @param znear defines the near clip plane
  84543. * @param zfar defines the far clip plane
  84544. * @returns a new matrix as a left-handed perspective projection matrix
  84545. */
  84546. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84547. /**
  84548. * Creates a left-handed perspective projection matrix
  84549. * @param fov defines the horizontal field of view
  84550. * @param aspect defines the aspect ratio
  84551. * @param znear defines the near clip plane
  84552. * @param zfar defines the far clip plane
  84553. * @returns a new matrix as a left-handed perspective projection matrix
  84554. */
  84555. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84556. /**
  84557. * Stores a left-handed perspective projection into a given matrix
  84558. * @param fov defines the horizontal field of view
  84559. * @param aspect defines the aspect ratio
  84560. * @param znear defines the near clip plane
  84561. * @param zfar defines the far clip plane
  84562. * @param result defines the target matrix
  84563. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84564. */
  84565. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84566. /**
  84567. * Stores a left-handed perspective projection into a given matrix with depth reversed
  84568. * @param fov defines the horizontal field of view
  84569. * @param aspect defines the aspect ratio
  84570. * @param znear defines the near clip plane
  84571. * @param zfar not used as infinity is used as far clip
  84572. * @param result defines the target matrix
  84573. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84574. */
  84575. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84576. /**
  84577. * Creates a right-handed perspective projection matrix
  84578. * @param fov defines the horizontal field of view
  84579. * @param aspect defines the aspect ratio
  84580. * @param znear defines the near clip plane
  84581. * @param zfar defines the far clip plane
  84582. * @returns a new matrix as a right-handed perspective projection matrix
  84583. */
  84584. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84585. /**
  84586. * Stores a right-handed perspective projection into a given matrix
  84587. * @param fov defines the horizontal field of view
  84588. * @param aspect defines the aspect ratio
  84589. * @param znear defines the near clip plane
  84590. * @param zfar defines the far clip plane
  84591. * @param result defines the target matrix
  84592. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84593. */
  84594. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84595. /**
  84596. * Stores a right-handed perspective projection into a given matrix
  84597. * @param fov defines the horizontal field of view
  84598. * @param aspect defines the aspect ratio
  84599. * @param znear defines the near clip plane
  84600. * @param zfar not used as infinity is used as far clip
  84601. * @param result defines the target matrix
  84602. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84603. */
  84604. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84605. /**
  84606. * Stores a perspective projection for WebVR info a given matrix
  84607. * @param fov defines the field of view
  84608. * @param znear defines the near clip plane
  84609. * @param zfar defines the far clip plane
  84610. * @param result defines the target matrix
  84611. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  84612. */
  84613. static PerspectiveFovWebVRToRef(fov: {
  84614. upDegrees: number;
  84615. downDegrees: number;
  84616. leftDegrees: number;
  84617. rightDegrees: number;
  84618. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  84619. /**
  84620. * Computes a complete transformation matrix
  84621. * @param viewport defines the viewport to use
  84622. * @param world defines the world matrix
  84623. * @param view defines the view matrix
  84624. * @param projection defines the projection matrix
  84625. * @param zmin defines the near clip plane
  84626. * @param zmax defines the far clip plane
  84627. * @returns the transformation matrix
  84628. */
  84629. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  84630. /**
  84631. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  84632. * @param matrix defines the matrix to use
  84633. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  84634. */
  84635. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  84636. /**
  84637. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  84638. * @param matrix defines the matrix to use
  84639. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  84640. */
  84641. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  84642. /**
  84643. * Compute the transpose of a given matrix
  84644. * @param matrix defines the matrix to transpose
  84645. * @returns the new matrix
  84646. */
  84647. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  84648. /**
  84649. * Compute the transpose of a matrix and store it in a target matrix
  84650. * @param matrix defines the matrix to transpose
  84651. * @param result defines the target matrix
  84652. */
  84653. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  84654. /**
  84655. * Computes a reflection matrix from a plane
  84656. * @param plane defines the reflection plane
  84657. * @returns a new matrix
  84658. */
  84659. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  84660. /**
  84661. * Computes a reflection matrix from a plane
  84662. * @param plane defines the reflection plane
  84663. * @param result defines the target matrix
  84664. */
  84665. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  84666. /**
  84667. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  84668. * @param xaxis defines the value of the 1st axis
  84669. * @param yaxis defines the value of the 2nd axis
  84670. * @param zaxis defines the value of the 3rd axis
  84671. * @param result defines the target matrix
  84672. */
  84673. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  84674. /**
  84675. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  84676. * @param quat defines the quaternion to use
  84677. * @param result defines the target matrix
  84678. */
  84679. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  84680. }
  84681. /**
  84682. * @hidden
  84683. */
  84684. export class TmpVectors {
  84685. static Vector2: Vector2[];
  84686. static Vector3: Vector3[];
  84687. static Vector4: Vector4[];
  84688. static Quaternion: Quaternion[];
  84689. static Matrix: Matrix[];
  84690. }
  84691. }
  84692. declare module BABYLON {
  84693. /**
  84694. * Defines potential orientation for back face culling
  84695. */
  84696. export enum Orientation {
  84697. /**
  84698. * Clockwise
  84699. */
  84700. CW = 0,
  84701. /** Counter clockwise */
  84702. CCW = 1
  84703. }
  84704. /** Class used to represent a Bezier curve */
  84705. export class BezierCurve {
  84706. /**
  84707. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  84708. * @param t defines the time
  84709. * @param x1 defines the left coordinate on X axis
  84710. * @param y1 defines the left coordinate on Y axis
  84711. * @param x2 defines the right coordinate on X axis
  84712. * @param y2 defines the right coordinate on Y axis
  84713. * @returns the interpolated value
  84714. */
  84715. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  84716. }
  84717. /**
  84718. * Defines angle representation
  84719. */
  84720. export class Angle {
  84721. private _radians;
  84722. /**
  84723. * Creates an Angle object of "radians" radians (float).
  84724. * @param radians the angle in radians
  84725. */
  84726. constructor(radians: number);
  84727. /**
  84728. * Get value in degrees
  84729. * @returns the Angle value in degrees (float)
  84730. */
  84731. degrees(): number;
  84732. /**
  84733. * Get value in radians
  84734. * @returns the Angle value in radians (float)
  84735. */
  84736. radians(): number;
  84737. /**
  84738. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  84739. * @param a defines first point as the origin
  84740. * @param b defines point
  84741. * @returns a new Angle
  84742. */
  84743. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  84744. /**
  84745. * Gets a new Angle object from the given float in radians
  84746. * @param radians defines the angle value in radians
  84747. * @returns a new Angle
  84748. */
  84749. static FromRadians(radians: number): Angle;
  84750. /**
  84751. * Gets a new Angle object from the given float in degrees
  84752. * @param degrees defines the angle value in degrees
  84753. * @returns a new Angle
  84754. */
  84755. static FromDegrees(degrees: number): Angle;
  84756. }
  84757. /**
  84758. * This represents an arc in a 2d space.
  84759. */
  84760. export class Arc2 {
  84761. /** Defines the start point of the arc */
  84762. startPoint: Vector2;
  84763. /** Defines the mid point of the arc */
  84764. midPoint: Vector2;
  84765. /** Defines the end point of the arc */
  84766. endPoint: Vector2;
  84767. /**
  84768. * Defines the center point of the arc.
  84769. */
  84770. centerPoint: Vector2;
  84771. /**
  84772. * Defines the radius of the arc.
  84773. */
  84774. radius: number;
  84775. /**
  84776. * Defines the angle of the arc (from mid point to end point).
  84777. */
  84778. angle: Angle;
  84779. /**
  84780. * Defines the start angle of the arc (from start point to middle point).
  84781. */
  84782. startAngle: Angle;
  84783. /**
  84784. * Defines the orientation of the arc (clock wise/counter clock wise).
  84785. */
  84786. orientation: Orientation;
  84787. /**
  84788. * Creates an Arc object from the three given points : start, middle and end.
  84789. * @param startPoint Defines the start point of the arc
  84790. * @param midPoint Defines the midlle point of the arc
  84791. * @param endPoint Defines the end point of the arc
  84792. */
  84793. constructor(
  84794. /** Defines the start point of the arc */
  84795. startPoint: Vector2,
  84796. /** Defines the mid point of the arc */
  84797. midPoint: Vector2,
  84798. /** Defines the end point of the arc */
  84799. endPoint: Vector2);
  84800. }
  84801. /**
  84802. * Represents a 2D path made up of multiple 2D points
  84803. */
  84804. export class Path2 {
  84805. private _points;
  84806. private _length;
  84807. /**
  84808. * If the path start and end point are the same
  84809. */
  84810. closed: boolean;
  84811. /**
  84812. * Creates a Path2 object from the starting 2D coordinates x and y.
  84813. * @param x the starting points x value
  84814. * @param y the starting points y value
  84815. */
  84816. constructor(x: number, y: number);
  84817. /**
  84818. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  84819. * @param x the added points x value
  84820. * @param y the added points y value
  84821. * @returns the updated Path2.
  84822. */
  84823. addLineTo(x: number, y: number): Path2;
  84824. /**
  84825. * 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.
  84826. * @param midX middle point x value
  84827. * @param midY middle point y value
  84828. * @param endX end point x value
  84829. * @param endY end point y value
  84830. * @param numberOfSegments (default: 36)
  84831. * @returns the updated Path2.
  84832. */
  84833. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  84834. /**
  84835. * Closes the Path2.
  84836. * @returns the Path2.
  84837. */
  84838. close(): Path2;
  84839. /**
  84840. * Gets the sum of the distance between each sequential point in the path
  84841. * @returns the Path2 total length (float).
  84842. */
  84843. length(): number;
  84844. /**
  84845. * Gets the points which construct the path
  84846. * @returns the Path2 internal array of points.
  84847. */
  84848. getPoints(): Vector2[];
  84849. /**
  84850. * Retreives the point at the distance aways from the starting point
  84851. * @param normalizedLengthPosition the length along the path to retreive the point from
  84852. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  84853. */
  84854. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  84855. /**
  84856. * Creates a new path starting from an x and y position
  84857. * @param x starting x value
  84858. * @param y starting y value
  84859. * @returns a new Path2 starting at the coordinates (x, y).
  84860. */
  84861. static StartingAt(x: number, y: number): Path2;
  84862. }
  84863. /**
  84864. * Represents a 3D path made up of multiple 3D points
  84865. */
  84866. export class Path3D {
  84867. /**
  84868. * an array of Vector3, the curve axis of the Path3D
  84869. */
  84870. path: Vector3[];
  84871. private _curve;
  84872. private _distances;
  84873. private _tangents;
  84874. private _normals;
  84875. private _binormals;
  84876. private _raw;
  84877. private _alignTangentsWithPath;
  84878. private readonly _pointAtData;
  84879. /**
  84880. * new Path3D(path, normal, raw)
  84881. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  84882. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  84883. * @param path an array of Vector3, the curve axis of the Path3D
  84884. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  84885. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  84886. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  84887. */
  84888. constructor(
  84889. /**
  84890. * an array of Vector3, the curve axis of the Path3D
  84891. */
  84892. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  84893. /**
  84894. * Returns the Path3D array of successive Vector3 designing its curve.
  84895. * @returns the Path3D array of successive Vector3 designing its curve.
  84896. */
  84897. getCurve(): Vector3[];
  84898. /**
  84899. * Returns the Path3D array of successive Vector3 designing its curve.
  84900. * @returns the Path3D array of successive Vector3 designing its curve.
  84901. */
  84902. getPoints(): Vector3[];
  84903. /**
  84904. * @returns the computed length (float) of the path.
  84905. */
  84906. length(): number;
  84907. /**
  84908. * Returns an array populated with tangent vectors on each Path3D curve point.
  84909. * @returns an array populated with tangent vectors on each Path3D curve point.
  84910. */
  84911. getTangents(): Vector3[];
  84912. /**
  84913. * Returns an array populated with normal vectors on each Path3D curve point.
  84914. * @returns an array populated with normal vectors on each Path3D curve point.
  84915. */
  84916. getNormals(): Vector3[];
  84917. /**
  84918. * Returns an array populated with binormal vectors on each Path3D curve point.
  84919. * @returns an array populated with binormal vectors on each Path3D curve point.
  84920. */
  84921. getBinormals(): Vector3[];
  84922. /**
  84923. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  84924. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  84925. */
  84926. getDistances(): number[];
  84927. /**
  84928. * Returns an interpolated point along this path
  84929. * @param position the position of the point along this path, from 0.0 to 1.0
  84930. * @returns a new Vector3 as the point
  84931. */
  84932. getPointAt(position: number): Vector3;
  84933. /**
  84934. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84935. * @param position the position of the point along this path, from 0.0 to 1.0
  84936. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  84937. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  84938. */
  84939. getTangentAt(position: number, interpolated?: boolean): Vector3;
  84940. /**
  84941. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84942. * @param position the position of the point along this path, from 0.0 to 1.0
  84943. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  84944. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  84945. */
  84946. getNormalAt(position: number, interpolated?: boolean): Vector3;
  84947. /**
  84948. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  84949. * @param position the position of the point along this path, from 0.0 to 1.0
  84950. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  84951. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  84952. */
  84953. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  84954. /**
  84955. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  84956. * @param position the position of the point along this path, from 0.0 to 1.0
  84957. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  84958. */
  84959. getDistanceAt(position: number): number;
  84960. /**
  84961. * Returns the array index of the previous point of an interpolated point along this path
  84962. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84963. * @returns the array index
  84964. */
  84965. getPreviousPointIndexAt(position: number): number;
  84966. /**
  84967. * 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)
  84968. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84969. * @returns the sub position
  84970. */
  84971. getSubPositionAt(position: number): number;
  84972. /**
  84973. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  84974. * @param target the vector of which to get the closest position to
  84975. * @returns the position of the closest virtual point on this path to the target vector
  84976. */
  84977. getClosestPositionTo(target: Vector3): number;
  84978. /**
  84979. * Returns a sub path (slice) of this path
  84980. * @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
  84981. * @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
  84982. * @returns a sub path (slice) of this path
  84983. */
  84984. slice(start?: number, end?: number): Path3D;
  84985. /**
  84986. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  84987. * @param path path which all values are copied into the curves points
  84988. * @param firstNormal which should be projected onto the curve
  84989. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  84990. * @returns the same object updated.
  84991. */
  84992. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  84993. private _compute;
  84994. private _getFirstNonNullVector;
  84995. private _getLastNonNullVector;
  84996. private _normalVector;
  84997. /**
  84998. * Updates the point at data for an interpolated point along this curve
  84999. * @param position the position of the point along this curve, from 0.0 to 1.0
  85000. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85001. * @returns the (updated) point at data
  85002. */
  85003. private _updatePointAtData;
  85004. /**
  85005. * Updates the point at data from the specified parameters
  85006. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85007. * @param point the interpolated point
  85008. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85009. */
  85010. private _setPointAtData;
  85011. /**
  85012. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85013. */
  85014. private _updateInterpolationMatrix;
  85015. }
  85016. /**
  85017. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85018. * A Curve3 is designed from a series of successive Vector3.
  85019. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85020. */
  85021. export class Curve3 {
  85022. private _points;
  85023. private _length;
  85024. /**
  85025. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85026. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85027. * @param v1 (Vector3) the control point
  85028. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85029. * @param nbPoints (integer) the wanted number of points in the curve
  85030. * @returns the created Curve3
  85031. */
  85032. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85033. /**
  85034. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85035. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85036. * @param v1 (Vector3) the first control point
  85037. * @param v2 (Vector3) the second control point
  85038. * @param v3 (Vector3) the end point of the Cubic Bezier
  85039. * @param nbPoints (integer) the wanted number of points in the curve
  85040. * @returns the created Curve3
  85041. */
  85042. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85043. /**
  85044. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85045. * @param p1 (Vector3) the origin point of the Hermite Spline
  85046. * @param t1 (Vector3) the tangent vector at the origin point
  85047. * @param p2 (Vector3) the end point of the Hermite Spline
  85048. * @param t2 (Vector3) the tangent vector at the end point
  85049. * @param nbPoints (integer) the wanted number of points in the curve
  85050. * @returns the created Curve3
  85051. */
  85052. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85053. /**
  85054. * Returns a Curve3 object along a CatmullRom Spline curve :
  85055. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  85056. * @param nbPoints (integer) the wanted number of points between each curve control points
  85057. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  85058. * @returns the created Curve3
  85059. */
  85060. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  85061. /**
  85062. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85063. * A Curve3 is designed from a series of successive Vector3.
  85064. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  85065. * @param points points which make up the curve
  85066. */
  85067. constructor(points: Vector3[]);
  85068. /**
  85069. * @returns the Curve3 stored array of successive Vector3
  85070. */
  85071. getPoints(): Vector3[];
  85072. /**
  85073. * @returns the computed length (float) of the curve.
  85074. */
  85075. length(): number;
  85076. /**
  85077. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85078. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85079. * curveA and curveB keep unchanged.
  85080. * @param curve the curve to continue from this curve
  85081. * @returns the newly constructed curve
  85082. */
  85083. continue(curve: DeepImmutable<Curve3>): Curve3;
  85084. private _computeLength;
  85085. }
  85086. }
  85087. declare module BABYLON {
  85088. /**
  85089. * This represents the main contract an easing function should follow.
  85090. * Easing functions are used throughout the animation system.
  85091. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85092. */
  85093. export interface IEasingFunction {
  85094. /**
  85095. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85096. * of the easing function.
  85097. * The link below provides some of the most common examples of easing functions.
  85098. * @see https://easings.net/
  85099. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85100. * @returns the corresponding value on the curve defined by the easing function
  85101. */
  85102. ease(gradient: number): number;
  85103. }
  85104. /**
  85105. * Base class used for every default easing function.
  85106. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85107. */
  85108. export class EasingFunction implements IEasingFunction {
  85109. /**
  85110. * Interpolation follows the mathematical formula associated with the easing function.
  85111. */
  85112. static readonly EASINGMODE_EASEIN: number;
  85113. /**
  85114. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85115. */
  85116. static readonly EASINGMODE_EASEOUT: number;
  85117. /**
  85118. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85119. */
  85120. static readonly EASINGMODE_EASEINOUT: number;
  85121. private _easingMode;
  85122. /**
  85123. * Sets the easing mode of the current function.
  85124. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85125. */
  85126. setEasingMode(easingMode: number): void;
  85127. /**
  85128. * Gets the current easing mode.
  85129. * @returns the easing mode
  85130. */
  85131. getEasingMode(): number;
  85132. /**
  85133. * @hidden
  85134. */
  85135. easeInCore(gradient: number): number;
  85136. /**
  85137. * Given an input gradient between 0 and 1, this returns the corresponding value
  85138. * of the easing function.
  85139. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85140. * @returns the corresponding value on the curve defined by the easing function
  85141. */
  85142. ease(gradient: number): number;
  85143. }
  85144. /**
  85145. * Easing function with a circle shape (see link below).
  85146. * @see https://easings.net/#easeInCirc
  85147. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85148. */
  85149. export class CircleEase extends EasingFunction implements IEasingFunction {
  85150. /** @hidden */
  85151. easeInCore(gradient: number): number;
  85152. }
  85153. /**
  85154. * Easing function with a ease back shape (see link below).
  85155. * @see https://easings.net/#easeInBack
  85156. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85157. */
  85158. export class BackEase extends EasingFunction implements IEasingFunction {
  85159. /** Defines the amplitude of the function */
  85160. amplitude: number;
  85161. /**
  85162. * Instantiates a back ease easing
  85163. * @see https://easings.net/#easeInBack
  85164. * @param amplitude Defines the amplitude of the function
  85165. */
  85166. constructor(
  85167. /** Defines the amplitude of the function */
  85168. amplitude?: number);
  85169. /** @hidden */
  85170. easeInCore(gradient: number): number;
  85171. }
  85172. /**
  85173. * Easing function with a bouncing shape (see link below).
  85174. * @see https://easings.net/#easeInBounce
  85175. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85176. */
  85177. export class BounceEase extends EasingFunction implements IEasingFunction {
  85178. /** Defines the number of bounces */
  85179. bounces: number;
  85180. /** Defines the amplitude of the bounce */
  85181. bounciness: number;
  85182. /**
  85183. * Instantiates a bounce easing
  85184. * @see https://easings.net/#easeInBounce
  85185. * @param bounces Defines the number of bounces
  85186. * @param bounciness Defines the amplitude of the bounce
  85187. */
  85188. constructor(
  85189. /** Defines the number of bounces */
  85190. bounces?: number,
  85191. /** Defines the amplitude of the bounce */
  85192. bounciness?: number);
  85193. /** @hidden */
  85194. easeInCore(gradient: number): number;
  85195. }
  85196. /**
  85197. * Easing function with a power of 3 shape (see link below).
  85198. * @see https://easings.net/#easeInCubic
  85199. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85200. */
  85201. export class CubicEase extends EasingFunction implements IEasingFunction {
  85202. /** @hidden */
  85203. easeInCore(gradient: number): number;
  85204. }
  85205. /**
  85206. * Easing function with an elastic shape (see link below).
  85207. * @see https://easings.net/#easeInElastic
  85208. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85209. */
  85210. export class ElasticEase extends EasingFunction implements IEasingFunction {
  85211. /** Defines the number of oscillations*/
  85212. oscillations: number;
  85213. /** Defines the amplitude of the oscillations*/
  85214. springiness: number;
  85215. /**
  85216. * Instantiates an elastic easing function
  85217. * @see https://easings.net/#easeInElastic
  85218. * @param oscillations Defines the number of oscillations
  85219. * @param springiness Defines the amplitude of the oscillations
  85220. */
  85221. constructor(
  85222. /** Defines the number of oscillations*/
  85223. oscillations?: number,
  85224. /** Defines the amplitude of the oscillations*/
  85225. springiness?: number);
  85226. /** @hidden */
  85227. easeInCore(gradient: number): number;
  85228. }
  85229. /**
  85230. * Easing function with an exponential shape (see link below).
  85231. * @see https://easings.net/#easeInExpo
  85232. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85233. */
  85234. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  85235. /** Defines the exponent of the function */
  85236. exponent: number;
  85237. /**
  85238. * Instantiates an exponential easing function
  85239. * @see https://easings.net/#easeInExpo
  85240. * @param exponent Defines the exponent of the function
  85241. */
  85242. constructor(
  85243. /** Defines the exponent of the function */
  85244. exponent?: number);
  85245. /** @hidden */
  85246. easeInCore(gradient: number): number;
  85247. }
  85248. /**
  85249. * Easing function with a power shape (see link below).
  85250. * @see https://easings.net/#easeInQuad
  85251. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85252. */
  85253. export class PowerEase extends EasingFunction implements IEasingFunction {
  85254. /** Defines the power of the function */
  85255. power: number;
  85256. /**
  85257. * Instantiates an power base easing function
  85258. * @see https://easings.net/#easeInQuad
  85259. * @param power Defines the power of the function
  85260. */
  85261. constructor(
  85262. /** Defines the power of the function */
  85263. power?: number);
  85264. /** @hidden */
  85265. easeInCore(gradient: number): number;
  85266. }
  85267. /**
  85268. * Easing function with a power of 2 shape (see link below).
  85269. * @see https://easings.net/#easeInQuad
  85270. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85271. */
  85272. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  85273. /** @hidden */
  85274. easeInCore(gradient: number): number;
  85275. }
  85276. /**
  85277. * Easing function with a power of 4 shape (see link below).
  85278. * @see https://easings.net/#easeInQuart
  85279. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85280. */
  85281. export class QuarticEase extends EasingFunction implements IEasingFunction {
  85282. /** @hidden */
  85283. easeInCore(gradient: number): number;
  85284. }
  85285. /**
  85286. * Easing function with a power of 5 shape (see link below).
  85287. * @see https://easings.net/#easeInQuint
  85288. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85289. */
  85290. export class QuinticEase extends EasingFunction implements IEasingFunction {
  85291. /** @hidden */
  85292. easeInCore(gradient: number): number;
  85293. }
  85294. /**
  85295. * Easing function with a sin shape (see link below).
  85296. * @see https://easings.net/#easeInSine
  85297. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85298. */
  85299. export class SineEase extends EasingFunction implements IEasingFunction {
  85300. /** @hidden */
  85301. easeInCore(gradient: number): number;
  85302. }
  85303. /**
  85304. * Easing function with a bezier shape (see link below).
  85305. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85306. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85307. */
  85308. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  85309. /** Defines the x component of the start tangent in the bezier curve */
  85310. x1: number;
  85311. /** Defines the y component of the start tangent in the bezier curve */
  85312. y1: number;
  85313. /** Defines the x component of the end tangent in the bezier curve */
  85314. x2: number;
  85315. /** Defines the y component of the end tangent in the bezier curve */
  85316. y2: number;
  85317. /**
  85318. * Instantiates a bezier function
  85319. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85320. * @param x1 Defines the x component of the start tangent in the bezier curve
  85321. * @param y1 Defines the y component of the start tangent in the bezier curve
  85322. * @param x2 Defines the x component of the end tangent in the bezier curve
  85323. * @param y2 Defines the y component of the end tangent in the bezier curve
  85324. */
  85325. constructor(
  85326. /** Defines the x component of the start tangent in the bezier curve */
  85327. x1?: number,
  85328. /** Defines the y component of the start tangent in the bezier curve */
  85329. y1?: number,
  85330. /** Defines the x component of the end tangent in the bezier curve */
  85331. x2?: number,
  85332. /** Defines the y component of the end tangent in the bezier curve */
  85333. y2?: number);
  85334. /** @hidden */
  85335. easeInCore(gradient: number): number;
  85336. }
  85337. }
  85338. declare module BABYLON {
  85339. /**
  85340. * Class used to hold a RBG color
  85341. */
  85342. export class Color3 {
  85343. /**
  85344. * Defines the red component (between 0 and 1, default is 0)
  85345. */
  85346. r: number;
  85347. /**
  85348. * Defines the green component (between 0 and 1, default is 0)
  85349. */
  85350. g: number;
  85351. /**
  85352. * Defines the blue component (between 0 and 1, default is 0)
  85353. */
  85354. b: number;
  85355. /**
  85356. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  85357. * @param r defines the red component (between 0 and 1, default is 0)
  85358. * @param g defines the green component (between 0 and 1, default is 0)
  85359. * @param b defines the blue component (between 0 and 1, default is 0)
  85360. */
  85361. constructor(
  85362. /**
  85363. * Defines the red component (between 0 and 1, default is 0)
  85364. */
  85365. r?: number,
  85366. /**
  85367. * Defines the green component (between 0 and 1, default is 0)
  85368. */
  85369. g?: number,
  85370. /**
  85371. * Defines the blue component (between 0 and 1, default is 0)
  85372. */
  85373. b?: number);
  85374. /**
  85375. * Creates a string with the Color3 current values
  85376. * @returns the string representation of the Color3 object
  85377. */
  85378. toString(): string;
  85379. /**
  85380. * Returns the string "Color3"
  85381. * @returns "Color3"
  85382. */
  85383. getClassName(): string;
  85384. /**
  85385. * Compute the Color3 hash code
  85386. * @returns an unique number that can be used to hash Color3 objects
  85387. */
  85388. getHashCode(): number;
  85389. /**
  85390. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  85391. * @param array defines the array where to store the r,g,b components
  85392. * @param index defines an optional index in the target array to define where to start storing values
  85393. * @returns the current Color3 object
  85394. */
  85395. toArray(array: FloatArray, index?: number): Color3;
  85396. /**
  85397. * Update the current color with values stored in an array from the starting index of the given array
  85398. * @param array defines the source array
  85399. * @param offset defines an offset in the source array
  85400. * @returns the current Color3 object
  85401. */
  85402. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85403. /**
  85404. * Returns a new Color4 object from the current Color3 and the given alpha
  85405. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  85406. * @returns a new Color4 object
  85407. */
  85408. toColor4(alpha?: number): Color4;
  85409. /**
  85410. * Returns a new array populated with 3 numeric elements : red, green and blue values
  85411. * @returns the new array
  85412. */
  85413. asArray(): number[];
  85414. /**
  85415. * Returns the luminance value
  85416. * @returns a float value
  85417. */
  85418. toLuminance(): number;
  85419. /**
  85420. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  85421. * @param otherColor defines the second operand
  85422. * @returns the new Color3 object
  85423. */
  85424. multiply(otherColor: DeepImmutable<Color3>): Color3;
  85425. /**
  85426. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  85427. * @param otherColor defines the second operand
  85428. * @param result defines the Color3 object where to store the result
  85429. * @returns the current Color3
  85430. */
  85431. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85432. /**
  85433. * Determines equality between Color3 objects
  85434. * @param otherColor defines the second operand
  85435. * @returns true if the rgb values are equal to the given ones
  85436. */
  85437. equals(otherColor: DeepImmutable<Color3>): boolean;
  85438. /**
  85439. * Determines equality between the current Color3 object and a set of r,b,g values
  85440. * @param r defines the red component to check
  85441. * @param g defines the green component to check
  85442. * @param b defines the blue component to check
  85443. * @returns true if the rgb values are equal to the given ones
  85444. */
  85445. equalsFloats(r: number, g: number, b: number): boolean;
  85446. /**
  85447. * Multiplies in place each rgb value by scale
  85448. * @param scale defines the scaling factor
  85449. * @returns the updated Color3
  85450. */
  85451. scale(scale: number): Color3;
  85452. /**
  85453. * Multiplies the rgb values by scale and stores the result into "result"
  85454. * @param scale defines the scaling factor
  85455. * @param result defines the Color3 object where to store the result
  85456. * @returns the unmodified current Color3
  85457. */
  85458. scaleToRef(scale: number, result: Color3): Color3;
  85459. /**
  85460. * Scale the current Color3 values by a factor and add the result to a given Color3
  85461. * @param scale defines the scale factor
  85462. * @param result defines color to store the result into
  85463. * @returns the unmodified current Color3
  85464. */
  85465. scaleAndAddToRef(scale: number, result: Color3): Color3;
  85466. /**
  85467. * Clamps the rgb values by the min and max values and stores the result into "result"
  85468. * @param min defines minimum clamping value (default is 0)
  85469. * @param max defines maximum clamping value (default is 1)
  85470. * @param result defines color to store the result into
  85471. * @returns the original Color3
  85472. */
  85473. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  85474. /**
  85475. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  85476. * @param otherColor defines the second operand
  85477. * @returns the new Color3
  85478. */
  85479. add(otherColor: DeepImmutable<Color3>): Color3;
  85480. /**
  85481. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  85482. * @param otherColor defines the second operand
  85483. * @param result defines Color3 object to store the result into
  85484. * @returns the unmodified current Color3
  85485. */
  85486. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85487. /**
  85488. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  85489. * @param otherColor defines the second operand
  85490. * @returns the new Color3
  85491. */
  85492. subtract(otherColor: DeepImmutable<Color3>): Color3;
  85493. /**
  85494. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  85495. * @param otherColor defines the second operand
  85496. * @param result defines Color3 object to store the result into
  85497. * @returns the unmodified current Color3
  85498. */
  85499. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85500. /**
  85501. * Copy the current object
  85502. * @returns a new Color3 copied the current one
  85503. */
  85504. clone(): Color3;
  85505. /**
  85506. * Copies the rgb values from the source in the current Color3
  85507. * @param source defines the source Color3 object
  85508. * @returns the updated Color3 object
  85509. */
  85510. copyFrom(source: DeepImmutable<Color3>): Color3;
  85511. /**
  85512. * Updates the Color3 rgb values from the given floats
  85513. * @param r defines the red component to read from
  85514. * @param g defines the green component to read from
  85515. * @param b defines the blue component to read from
  85516. * @returns the current Color3 object
  85517. */
  85518. copyFromFloats(r: number, g: number, b: number): Color3;
  85519. /**
  85520. * Updates the Color3 rgb values from the given floats
  85521. * @param r defines the red component to read from
  85522. * @param g defines the green component to read from
  85523. * @param b defines the blue component to read from
  85524. * @returns the current Color3 object
  85525. */
  85526. set(r: number, g: number, b: number): Color3;
  85527. /**
  85528. * Compute the Color3 hexadecimal code as a string
  85529. * @returns a string containing the hexadecimal representation of the Color3 object
  85530. */
  85531. toHexString(): string;
  85532. /**
  85533. * Computes a new Color3 converted from the current one to linear space
  85534. * @returns a new Color3 object
  85535. */
  85536. toLinearSpace(): Color3;
  85537. /**
  85538. * Converts current color in rgb space to HSV values
  85539. * @returns a new color3 representing the HSV values
  85540. */
  85541. toHSV(): Color3;
  85542. /**
  85543. * Converts current color in rgb space to HSV values
  85544. * @param result defines the Color3 where to store the HSV values
  85545. */
  85546. toHSVToRef(result: Color3): void;
  85547. /**
  85548. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  85549. * @param convertedColor defines the Color3 object where to store the linear space version
  85550. * @returns the unmodified Color3
  85551. */
  85552. toLinearSpaceToRef(convertedColor: Color3): Color3;
  85553. /**
  85554. * Computes a new Color3 converted from the current one to gamma space
  85555. * @returns a new Color3 object
  85556. */
  85557. toGammaSpace(): Color3;
  85558. /**
  85559. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  85560. * @param convertedColor defines the Color3 object where to store the gamma space version
  85561. * @returns the unmodified Color3
  85562. */
  85563. toGammaSpaceToRef(convertedColor: Color3): Color3;
  85564. private static _BlackReadOnly;
  85565. /**
  85566. * Convert Hue, saturation and value to a Color3 (RGB)
  85567. * @param hue defines the hue
  85568. * @param saturation defines the saturation
  85569. * @param value defines the value
  85570. * @param result defines the Color3 where to store the RGB values
  85571. */
  85572. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  85573. /**
  85574. * Creates a new Color3 from the string containing valid hexadecimal values
  85575. * @param hex defines a string containing valid hexadecimal values
  85576. * @returns a new Color3 object
  85577. */
  85578. static FromHexString(hex: string): Color3;
  85579. /**
  85580. * Creates a new Color3 from the starting index of the given array
  85581. * @param array defines the source array
  85582. * @param offset defines an offset in the source array
  85583. * @returns a new Color3 object
  85584. */
  85585. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85586. /**
  85587. * Creates a new Color3 from the starting index element of the given array
  85588. * @param array defines the source array to read from
  85589. * @param offset defines the offset in the source array
  85590. * @param result defines the target Color3 object
  85591. */
  85592. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  85593. /**
  85594. * Creates a new Color3 from integer values (< 256)
  85595. * @param r defines the red component to read from (value between 0 and 255)
  85596. * @param g defines the green component to read from (value between 0 and 255)
  85597. * @param b defines the blue component to read from (value between 0 and 255)
  85598. * @returns a new Color3 object
  85599. */
  85600. static FromInts(r: number, g: number, b: number): Color3;
  85601. /**
  85602. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85603. * @param start defines the start Color3 value
  85604. * @param end defines the end Color3 value
  85605. * @param amount defines the gradient value between start and end
  85606. * @returns a new Color3 object
  85607. */
  85608. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  85609. /**
  85610. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85611. * @param left defines the start value
  85612. * @param right defines the end value
  85613. * @param amount defines the gradient factor
  85614. * @param result defines the Color3 object where to store the result
  85615. */
  85616. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  85617. /**
  85618. * Returns a Color3 value containing a red color
  85619. * @returns a new Color3 object
  85620. */
  85621. static Red(): Color3;
  85622. /**
  85623. * Returns a Color3 value containing a green color
  85624. * @returns a new Color3 object
  85625. */
  85626. static Green(): Color3;
  85627. /**
  85628. * Returns a Color3 value containing a blue color
  85629. * @returns a new Color3 object
  85630. */
  85631. static Blue(): Color3;
  85632. /**
  85633. * Returns a Color3 value containing a black color
  85634. * @returns a new Color3 object
  85635. */
  85636. static Black(): Color3;
  85637. /**
  85638. * Gets a Color3 value containing a black color that must not be updated
  85639. */
  85640. static get BlackReadOnly(): DeepImmutable<Color3>;
  85641. /**
  85642. * Returns a Color3 value containing a white color
  85643. * @returns a new Color3 object
  85644. */
  85645. static White(): Color3;
  85646. /**
  85647. * Returns a Color3 value containing a purple color
  85648. * @returns a new Color3 object
  85649. */
  85650. static Purple(): Color3;
  85651. /**
  85652. * Returns a Color3 value containing a magenta color
  85653. * @returns a new Color3 object
  85654. */
  85655. static Magenta(): Color3;
  85656. /**
  85657. * Returns a Color3 value containing a yellow color
  85658. * @returns a new Color3 object
  85659. */
  85660. static Yellow(): Color3;
  85661. /**
  85662. * Returns a Color3 value containing a gray color
  85663. * @returns a new Color3 object
  85664. */
  85665. static Gray(): Color3;
  85666. /**
  85667. * Returns a Color3 value containing a teal color
  85668. * @returns a new Color3 object
  85669. */
  85670. static Teal(): Color3;
  85671. /**
  85672. * Returns a Color3 value containing a random color
  85673. * @returns a new Color3 object
  85674. */
  85675. static Random(): Color3;
  85676. }
  85677. /**
  85678. * Class used to hold a RBGA color
  85679. */
  85680. export class Color4 {
  85681. /**
  85682. * Defines the red component (between 0 and 1, default is 0)
  85683. */
  85684. r: number;
  85685. /**
  85686. * Defines the green component (between 0 and 1, default is 0)
  85687. */
  85688. g: number;
  85689. /**
  85690. * Defines the blue component (between 0 and 1, default is 0)
  85691. */
  85692. b: number;
  85693. /**
  85694. * Defines the alpha component (between 0 and 1, default is 1)
  85695. */
  85696. a: number;
  85697. /**
  85698. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  85699. * @param r defines the red component (between 0 and 1, default is 0)
  85700. * @param g defines the green component (between 0 and 1, default is 0)
  85701. * @param b defines the blue component (between 0 and 1, default is 0)
  85702. * @param a defines the alpha component (between 0 and 1, default is 1)
  85703. */
  85704. constructor(
  85705. /**
  85706. * Defines the red component (between 0 and 1, default is 0)
  85707. */
  85708. r?: number,
  85709. /**
  85710. * Defines the green component (between 0 and 1, default is 0)
  85711. */
  85712. g?: number,
  85713. /**
  85714. * Defines the blue component (between 0 and 1, default is 0)
  85715. */
  85716. b?: number,
  85717. /**
  85718. * Defines the alpha component (between 0 and 1, default is 1)
  85719. */
  85720. a?: number);
  85721. /**
  85722. * Adds in place the given Color4 values to the current Color4 object
  85723. * @param right defines the second operand
  85724. * @returns the current updated Color4 object
  85725. */
  85726. addInPlace(right: DeepImmutable<Color4>): Color4;
  85727. /**
  85728. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  85729. * @returns the new array
  85730. */
  85731. asArray(): number[];
  85732. /**
  85733. * Stores from the starting index in the given array the Color4 successive values
  85734. * @param array defines the array where to store the r,g,b components
  85735. * @param index defines an optional index in the target array to define where to start storing values
  85736. * @returns the current Color4 object
  85737. */
  85738. toArray(array: number[], index?: number): Color4;
  85739. /**
  85740. * Update the current color with values stored in an array from the starting index of the given array
  85741. * @param array defines the source array
  85742. * @param offset defines an offset in the source array
  85743. * @returns the current Color4 object
  85744. */
  85745. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85746. /**
  85747. * Determines equality between Color4 objects
  85748. * @param otherColor defines the second operand
  85749. * @returns true if the rgba values are equal to the given ones
  85750. */
  85751. equals(otherColor: DeepImmutable<Color4>): boolean;
  85752. /**
  85753. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  85754. * @param right defines the second operand
  85755. * @returns a new Color4 object
  85756. */
  85757. add(right: DeepImmutable<Color4>): Color4;
  85758. /**
  85759. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  85760. * @param right defines the second operand
  85761. * @returns a new Color4 object
  85762. */
  85763. subtract(right: DeepImmutable<Color4>): Color4;
  85764. /**
  85765. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  85766. * @param right defines the second operand
  85767. * @param result defines the Color4 object where to store the result
  85768. * @returns the current Color4 object
  85769. */
  85770. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  85771. /**
  85772. * Creates a new Color4 with the current Color4 values multiplied by scale
  85773. * @param scale defines the scaling factor to apply
  85774. * @returns a new Color4 object
  85775. */
  85776. scale(scale: number): Color4;
  85777. /**
  85778. * Multiplies the current Color4 values by scale and stores the result in "result"
  85779. * @param scale defines the scaling factor to apply
  85780. * @param result defines the Color4 object where to store the result
  85781. * @returns the current unmodified Color4
  85782. */
  85783. scaleToRef(scale: number, result: Color4): Color4;
  85784. /**
  85785. * Scale the current Color4 values by a factor and add the result to a given Color4
  85786. * @param scale defines the scale factor
  85787. * @param result defines the Color4 object where to store the result
  85788. * @returns the unmodified current Color4
  85789. */
  85790. scaleAndAddToRef(scale: number, result: Color4): Color4;
  85791. /**
  85792. * Clamps the rgb values by the min and max values and stores the result into "result"
  85793. * @param min defines minimum clamping value (default is 0)
  85794. * @param max defines maximum clamping value (default is 1)
  85795. * @param result defines color to store the result into.
  85796. * @returns the cuurent Color4
  85797. */
  85798. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  85799. /**
  85800. * Multipy an Color4 value by another and return a new Color4 object
  85801. * @param color defines the Color4 value to multiply by
  85802. * @returns a new Color4 object
  85803. */
  85804. multiply(color: Color4): Color4;
  85805. /**
  85806. * Multipy a Color4 value by another and push the result in a reference value
  85807. * @param color defines the Color4 value to multiply by
  85808. * @param result defines the Color4 to fill the result in
  85809. * @returns the result Color4
  85810. */
  85811. multiplyToRef(color: Color4, result: Color4): Color4;
  85812. /**
  85813. * Creates a string with the Color4 current values
  85814. * @returns the string representation of the Color4 object
  85815. */
  85816. toString(): string;
  85817. /**
  85818. * Returns the string "Color4"
  85819. * @returns "Color4"
  85820. */
  85821. getClassName(): string;
  85822. /**
  85823. * Compute the Color4 hash code
  85824. * @returns an unique number that can be used to hash Color4 objects
  85825. */
  85826. getHashCode(): number;
  85827. /**
  85828. * Creates a new Color4 copied from the current one
  85829. * @returns a new Color4 object
  85830. */
  85831. clone(): Color4;
  85832. /**
  85833. * Copies the given Color4 values into the current one
  85834. * @param source defines the source Color4 object
  85835. * @returns the current updated Color4 object
  85836. */
  85837. copyFrom(source: Color4): Color4;
  85838. /**
  85839. * Copies the given float values into the current one
  85840. * @param r defines the red component to read from
  85841. * @param g defines the green component to read from
  85842. * @param b defines the blue component to read from
  85843. * @param a defines the alpha component to read from
  85844. * @returns the current updated Color4 object
  85845. */
  85846. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  85847. /**
  85848. * Copies the given float values into the current one
  85849. * @param r defines the red component to read from
  85850. * @param g defines the green component to read from
  85851. * @param b defines the blue component to read from
  85852. * @param a defines the alpha component to read from
  85853. * @returns the current updated Color4 object
  85854. */
  85855. set(r: number, g: number, b: number, a: number): Color4;
  85856. /**
  85857. * Compute the Color4 hexadecimal code as a string
  85858. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  85859. * @returns a string containing the hexadecimal representation of the Color4 object
  85860. */
  85861. toHexString(returnAsColor3?: boolean): string;
  85862. /**
  85863. * Computes a new Color4 converted from the current one to linear space
  85864. * @returns a new Color4 object
  85865. */
  85866. toLinearSpace(): Color4;
  85867. /**
  85868. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  85869. * @param convertedColor defines the Color4 object where to store the linear space version
  85870. * @returns the unmodified Color4
  85871. */
  85872. toLinearSpaceToRef(convertedColor: Color4): Color4;
  85873. /**
  85874. * Computes a new Color4 converted from the current one to gamma space
  85875. * @returns a new Color4 object
  85876. */
  85877. toGammaSpace(): Color4;
  85878. /**
  85879. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  85880. * @param convertedColor defines the Color4 object where to store the gamma space version
  85881. * @returns the unmodified Color4
  85882. */
  85883. toGammaSpaceToRef(convertedColor: Color4): Color4;
  85884. /**
  85885. * Creates a new Color4 from the string containing valid hexadecimal values
  85886. * @param hex defines a string containing valid hexadecimal values
  85887. * @returns a new Color4 object
  85888. */
  85889. static FromHexString(hex: string): Color4;
  85890. /**
  85891. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85892. * @param left defines the start value
  85893. * @param right defines the end value
  85894. * @param amount defines the gradient factor
  85895. * @returns a new Color4 object
  85896. */
  85897. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  85898. /**
  85899. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85900. * @param left defines the start value
  85901. * @param right defines the end value
  85902. * @param amount defines the gradient factor
  85903. * @param result defines the Color4 object where to store data
  85904. */
  85905. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  85906. /**
  85907. * Creates a new Color4 from a Color3 and an alpha value
  85908. * @param color3 defines the source Color3 to read from
  85909. * @param alpha defines the alpha component (1.0 by default)
  85910. * @returns a new Color4 object
  85911. */
  85912. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  85913. /**
  85914. * Creates a new Color4 from the starting index element of the given array
  85915. * @param array defines the source array to read from
  85916. * @param offset defines the offset in the source array
  85917. * @returns a new Color4 object
  85918. */
  85919. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85920. /**
  85921. * Creates a new Color4 from the starting index element of the given array
  85922. * @param array defines the source array to read from
  85923. * @param offset defines the offset in the source array
  85924. * @param result defines the target Color4 object
  85925. */
  85926. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  85927. /**
  85928. * Creates a new Color3 from integer values (< 256)
  85929. * @param r defines the red component to read from (value between 0 and 255)
  85930. * @param g defines the green component to read from (value between 0 and 255)
  85931. * @param b defines the blue component to read from (value between 0 and 255)
  85932. * @param a defines the alpha component to read from (value between 0 and 255)
  85933. * @returns a new Color3 object
  85934. */
  85935. static FromInts(r: number, g: number, b: number, a: number): Color4;
  85936. /**
  85937. * Check the content of a given array and convert it to an array containing RGBA data
  85938. * If the original array was already containing count * 4 values then it is returned directly
  85939. * @param colors defines the array to check
  85940. * @param count defines the number of RGBA data to expect
  85941. * @returns an array containing count * 4 values (RGBA)
  85942. */
  85943. static CheckColors4(colors: number[], count: number): number[];
  85944. }
  85945. /**
  85946. * @hidden
  85947. */
  85948. export class TmpColors {
  85949. static Color3: Color3[];
  85950. static Color4: Color4[];
  85951. }
  85952. }
  85953. declare module BABYLON {
  85954. /**
  85955. * Defines an interface which represents an animation key frame
  85956. */
  85957. export interface IAnimationKey {
  85958. /**
  85959. * Frame of the key frame
  85960. */
  85961. frame: number;
  85962. /**
  85963. * Value at the specifies key frame
  85964. */
  85965. value: any;
  85966. /**
  85967. * The input tangent for the cubic hermite spline
  85968. */
  85969. inTangent?: any;
  85970. /**
  85971. * The output tangent for the cubic hermite spline
  85972. */
  85973. outTangent?: any;
  85974. /**
  85975. * The animation interpolation type
  85976. */
  85977. interpolation?: AnimationKeyInterpolation;
  85978. }
  85979. /**
  85980. * Enum for the animation key frame interpolation type
  85981. */
  85982. export enum AnimationKeyInterpolation {
  85983. /**
  85984. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  85985. */
  85986. STEP = 1
  85987. }
  85988. }
  85989. declare module BABYLON {
  85990. /**
  85991. * Represents the range of an animation
  85992. */
  85993. export class AnimationRange {
  85994. /**The name of the animation range**/
  85995. name: string;
  85996. /**The starting frame of the animation */
  85997. from: number;
  85998. /**The ending frame of the animation*/
  85999. to: number;
  86000. /**
  86001. * Initializes the range of an animation
  86002. * @param name The name of the animation range
  86003. * @param from The starting frame of the animation
  86004. * @param to The ending frame of the animation
  86005. */
  86006. constructor(
  86007. /**The name of the animation range**/
  86008. name: string,
  86009. /**The starting frame of the animation */
  86010. from: number,
  86011. /**The ending frame of the animation*/
  86012. to: number);
  86013. /**
  86014. * Makes a copy of the animation range
  86015. * @returns A copy of the animation range
  86016. */
  86017. clone(): AnimationRange;
  86018. }
  86019. }
  86020. declare module BABYLON {
  86021. /**
  86022. * Composed of a frame, and an action function
  86023. */
  86024. export class AnimationEvent {
  86025. /** The frame for which the event is triggered **/
  86026. frame: number;
  86027. /** The event to perform when triggered **/
  86028. action: (currentFrame: number) => void;
  86029. /** Specifies if the event should be triggered only once**/
  86030. onlyOnce?: boolean | undefined;
  86031. /**
  86032. * Specifies if the animation event is done
  86033. */
  86034. isDone: boolean;
  86035. /**
  86036. * Initializes the animation event
  86037. * @param frame The frame for which the event is triggered
  86038. * @param action The event to perform when triggered
  86039. * @param onlyOnce Specifies if the event should be triggered only once
  86040. */
  86041. constructor(
  86042. /** The frame for which the event is triggered **/
  86043. frame: number,
  86044. /** The event to perform when triggered **/
  86045. action: (currentFrame: number) => void,
  86046. /** Specifies if the event should be triggered only once**/
  86047. onlyOnce?: boolean | undefined);
  86048. /** @hidden */
  86049. _clone(): AnimationEvent;
  86050. }
  86051. }
  86052. declare module BABYLON {
  86053. /**
  86054. * Interface used to define a behavior
  86055. */
  86056. export interface Behavior<T> {
  86057. /** gets or sets behavior's name */
  86058. name: string;
  86059. /**
  86060. * Function called when the behavior needs to be initialized (after attaching it to a target)
  86061. */
  86062. init(): void;
  86063. /**
  86064. * Called when the behavior is attached to a target
  86065. * @param target defines the target where the behavior is attached to
  86066. */
  86067. attach(target: T): void;
  86068. /**
  86069. * Called when the behavior is detached from its target
  86070. */
  86071. detach(): void;
  86072. }
  86073. /**
  86074. * Interface implemented by classes supporting behaviors
  86075. */
  86076. export interface IBehaviorAware<T> {
  86077. /**
  86078. * Attach a behavior
  86079. * @param behavior defines the behavior to attach
  86080. * @returns the current host
  86081. */
  86082. addBehavior(behavior: Behavior<T>): T;
  86083. /**
  86084. * Remove a behavior from the current object
  86085. * @param behavior defines the behavior to detach
  86086. * @returns the current host
  86087. */
  86088. removeBehavior(behavior: Behavior<T>): T;
  86089. /**
  86090. * Gets a behavior using its name to search
  86091. * @param name defines the name to search
  86092. * @returns the behavior or null if not found
  86093. */
  86094. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86095. }
  86096. }
  86097. declare module BABYLON {
  86098. /**
  86099. * Defines an array and its length.
  86100. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86101. */
  86102. export interface ISmartArrayLike<T> {
  86103. /**
  86104. * The data of the array.
  86105. */
  86106. data: Array<T>;
  86107. /**
  86108. * The active length of the array.
  86109. */
  86110. length: number;
  86111. }
  86112. /**
  86113. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86114. */
  86115. export class SmartArray<T> implements ISmartArrayLike<T> {
  86116. /**
  86117. * The full set of data from the array.
  86118. */
  86119. data: Array<T>;
  86120. /**
  86121. * The active length of the array.
  86122. */
  86123. length: number;
  86124. protected _id: number;
  86125. /**
  86126. * Instantiates a Smart Array.
  86127. * @param capacity defines the default capacity of the array.
  86128. */
  86129. constructor(capacity: number);
  86130. /**
  86131. * Pushes a value at the end of the active data.
  86132. * @param value defines the object to push in the array.
  86133. */
  86134. push(value: T): void;
  86135. /**
  86136. * Iterates over the active data and apply the lambda to them.
  86137. * @param func defines the action to apply on each value.
  86138. */
  86139. forEach(func: (content: T) => void): void;
  86140. /**
  86141. * Sorts the full sets of data.
  86142. * @param compareFn defines the comparison function to apply.
  86143. */
  86144. sort(compareFn: (a: T, b: T) => number): void;
  86145. /**
  86146. * Resets the active data to an empty array.
  86147. */
  86148. reset(): void;
  86149. /**
  86150. * Releases all the data from the array as well as the array.
  86151. */
  86152. dispose(): void;
  86153. /**
  86154. * Concats the active data with a given array.
  86155. * @param array defines the data to concatenate with.
  86156. */
  86157. concat(array: any): void;
  86158. /**
  86159. * Returns the position of a value in the active data.
  86160. * @param value defines the value to find the index for
  86161. * @returns the index if found in the active data otherwise -1
  86162. */
  86163. indexOf(value: T): number;
  86164. /**
  86165. * Returns whether an element is part of the active data.
  86166. * @param value defines the value to look for
  86167. * @returns true if found in the active data otherwise false
  86168. */
  86169. contains(value: T): boolean;
  86170. private static _GlobalId;
  86171. }
  86172. /**
  86173. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86174. * The data in this array can only be present once
  86175. */
  86176. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86177. private _duplicateId;
  86178. /**
  86179. * Pushes a value at the end of the active data.
  86180. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86181. * @param value defines the object to push in the array.
  86182. */
  86183. push(value: T): void;
  86184. /**
  86185. * Pushes a value at the end of the active data.
  86186. * If the data is already present, it won t be added again
  86187. * @param value defines the object to push in the array.
  86188. * @returns true if added false if it was already present
  86189. */
  86190. pushNoDuplicate(value: T): boolean;
  86191. /**
  86192. * Resets the active data to an empty array.
  86193. */
  86194. reset(): void;
  86195. /**
  86196. * Concats the active data with a given array.
  86197. * This ensures no dupplicate will be present in the result.
  86198. * @param array defines the data to concatenate with.
  86199. */
  86200. concatWithNoDuplicate(array: any): void;
  86201. }
  86202. }
  86203. declare module BABYLON {
  86204. /**
  86205. * @ignore
  86206. * This is a list of all the different input types that are available in the application.
  86207. * Fo instance: ArcRotateCameraGamepadInput...
  86208. */
  86209. export var CameraInputTypes: {};
  86210. /**
  86211. * This is the contract to implement in order to create a new input class.
  86212. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  86213. */
  86214. export interface ICameraInput<TCamera extends Camera> {
  86215. /**
  86216. * Defines the camera the input is attached to.
  86217. */
  86218. camera: Nullable<TCamera>;
  86219. /**
  86220. * Gets the class name of the current intput.
  86221. * @returns the class name
  86222. */
  86223. getClassName(): string;
  86224. /**
  86225. * Get the friendly name associated with the input class.
  86226. * @returns the input friendly name
  86227. */
  86228. getSimpleName(): string;
  86229. /**
  86230. * Attach the input controls to a specific dom element to get the input from.
  86231. * @param element Defines the element the controls should be listened from
  86232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86233. */
  86234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86235. /**
  86236. * Detach the current controls from the specified dom element.
  86237. * @param element Defines the element to stop listening the inputs from
  86238. */
  86239. detachControl(element: Nullable<HTMLElement>): void;
  86240. /**
  86241. * Update the current camera state depending on the inputs that have been used this frame.
  86242. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86243. */
  86244. checkInputs?: () => void;
  86245. }
  86246. /**
  86247. * Represents a map of input types to input instance or input index to input instance.
  86248. */
  86249. export interface CameraInputsMap<TCamera extends Camera> {
  86250. /**
  86251. * Accessor to the input by input type.
  86252. */
  86253. [name: string]: ICameraInput<TCamera>;
  86254. /**
  86255. * Accessor to the input by input index.
  86256. */
  86257. [idx: number]: ICameraInput<TCamera>;
  86258. }
  86259. /**
  86260. * This represents the input manager used within a camera.
  86261. * It helps dealing with all the different kind of input attached to a camera.
  86262. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86263. */
  86264. export class CameraInputsManager<TCamera extends Camera> {
  86265. /**
  86266. * Defines the list of inputs attahed to the camera.
  86267. */
  86268. attached: CameraInputsMap<TCamera>;
  86269. /**
  86270. * Defines the dom element the camera is collecting inputs from.
  86271. * This is null if the controls have not been attached.
  86272. */
  86273. attachedElement: Nullable<HTMLElement>;
  86274. /**
  86275. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86276. */
  86277. noPreventDefault: boolean;
  86278. /**
  86279. * Defined the camera the input manager belongs to.
  86280. */
  86281. camera: TCamera;
  86282. /**
  86283. * Update the current camera state depending on the inputs that have been used this frame.
  86284. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86285. */
  86286. checkInputs: () => void;
  86287. /**
  86288. * Instantiate a new Camera Input Manager.
  86289. * @param camera Defines the camera the input manager blongs to
  86290. */
  86291. constructor(camera: TCamera);
  86292. /**
  86293. * Add an input method to a camera
  86294. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86295. * @param input camera input method
  86296. */
  86297. add(input: ICameraInput<TCamera>): void;
  86298. /**
  86299. * Remove a specific input method from a camera
  86300. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  86301. * @param inputToRemove camera input method
  86302. */
  86303. remove(inputToRemove: ICameraInput<TCamera>): void;
  86304. /**
  86305. * Remove a specific input type from a camera
  86306. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  86307. * @param inputType the type of the input to remove
  86308. */
  86309. removeByType(inputType: string): void;
  86310. private _addCheckInputs;
  86311. /**
  86312. * Attach the input controls to the currently attached dom element to listen the events from.
  86313. * @param input Defines the input to attach
  86314. */
  86315. attachInput(input: ICameraInput<TCamera>): void;
  86316. /**
  86317. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  86318. * @param element Defines the dom element to collect the events from
  86319. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86320. */
  86321. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  86322. /**
  86323. * Detach the current manager inputs controls from a specific dom element.
  86324. * @param element Defines the dom element to collect the events from
  86325. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  86326. */
  86327. detachElement(element: HTMLElement, disconnect?: boolean): void;
  86328. /**
  86329. * Rebuild the dynamic inputCheck function from the current list of
  86330. * defined inputs in the manager.
  86331. */
  86332. rebuildInputCheck(): void;
  86333. /**
  86334. * Remove all attached input methods from a camera
  86335. */
  86336. clear(): void;
  86337. /**
  86338. * Serialize the current input manager attached to a camera.
  86339. * This ensures than once parsed,
  86340. * the input associated to the camera will be identical to the current ones
  86341. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  86342. */
  86343. serialize(serializedCamera: any): void;
  86344. /**
  86345. * Parses an input manager serialized JSON to restore the previous list of inputs
  86346. * and states associated to a camera.
  86347. * @param parsedCamera Defines the JSON to parse
  86348. */
  86349. parse(parsedCamera: any): void;
  86350. }
  86351. }
  86352. declare module BABYLON {
  86353. /**
  86354. * Class used to store data that will be store in GPU memory
  86355. */
  86356. export class Buffer {
  86357. private _engine;
  86358. private _buffer;
  86359. /** @hidden */
  86360. _data: Nullable<DataArray>;
  86361. private _updatable;
  86362. private _instanced;
  86363. private _divisor;
  86364. /**
  86365. * Gets the byte stride.
  86366. */
  86367. readonly byteStride: number;
  86368. /**
  86369. * Constructor
  86370. * @param engine the engine
  86371. * @param data the data to use for this buffer
  86372. * @param updatable whether the data is updatable
  86373. * @param stride the stride (optional)
  86374. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86375. * @param instanced whether the buffer is instanced (optional)
  86376. * @param useBytes set to true if the stride in in bytes (optional)
  86377. * @param divisor sets an optional divisor for instances (1 by default)
  86378. */
  86379. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  86380. /**
  86381. * Create a new VertexBuffer based on the current buffer
  86382. * @param kind defines the vertex buffer kind (position, normal, etc.)
  86383. * @param offset defines offset in the buffer (0 by default)
  86384. * @param size defines the size in floats of attributes (position is 3 for instance)
  86385. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  86386. * @param instanced defines if the vertex buffer contains indexed data
  86387. * @param useBytes defines if the offset and stride are in bytes *
  86388. * @param divisor sets an optional divisor for instances (1 by default)
  86389. * @returns the new vertex buffer
  86390. */
  86391. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  86392. /**
  86393. * Gets a boolean indicating if the Buffer is updatable?
  86394. * @returns true if the buffer is updatable
  86395. */
  86396. isUpdatable(): boolean;
  86397. /**
  86398. * Gets current buffer's data
  86399. * @returns a DataArray or null
  86400. */
  86401. getData(): Nullable<DataArray>;
  86402. /**
  86403. * Gets underlying native buffer
  86404. * @returns underlying native buffer
  86405. */
  86406. getBuffer(): Nullable<DataBuffer>;
  86407. /**
  86408. * Gets the stride in float32 units (i.e. byte stride / 4).
  86409. * May not be an integer if the byte stride is not divisible by 4.
  86410. * @returns the stride in float32 units
  86411. * @deprecated Please use byteStride instead.
  86412. */
  86413. getStrideSize(): number;
  86414. /**
  86415. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86416. * @param data defines the data to store
  86417. */
  86418. create(data?: Nullable<DataArray>): void;
  86419. /** @hidden */
  86420. _rebuild(): void;
  86421. /**
  86422. * Update current buffer data
  86423. * @param data defines the data to store
  86424. */
  86425. update(data: DataArray): void;
  86426. /**
  86427. * Updates the data directly.
  86428. * @param data the new data
  86429. * @param offset the new offset
  86430. * @param vertexCount the vertex count (optional)
  86431. * @param useBytes set to true if the offset is in bytes
  86432. */
  86433. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  86434. /**
  86435. * Release all resources
  86436. */
  86437. dispose(): void;
  86438. }
  86439. /**
  86440. * Specialized buffer used to store vertex data
  86441. */
  86442. export class VertexBuffer {
  86443. /** @hidden */
  86444. _buffer: Buffer;
  86445. private _kind;
  86446. private _size;
  86447. private _ownsBuffer;
  86448. private _instanced;
  86449. private _instanceDivisor;
  86450. /**
  86451. * The byte type.
  86452. */
  86453. static readonly BYTE: number;
  86454. /**
  86455. * The unsigned byte type.
  86456. */
  86457. static readonly UNSIGNED_BYTE: number;
  86458. /**
  86459. * The short type.
  86460. */
  86461. static readonly SHORT: number;
  86462. /**
  86463. * The unsigned short type.
  86464. */
  86465. static readonly UNSIGNED_SHORT: number;
  86466. /**
  86467. * The integer type.
  86468. */
  86469. static readonly INT: number;
  86470. /**
  86471. * The unsigned integer type.
  86472. */
  86473. static readonly UNSIGNED_INT: number;
  86474. /**
  86475. * The float type.
  86476. */
  86477. static readonly FLOAT: number;
  86478. /**
  86479. * Gets or sets the instance divisor when in instanced mode
  86480. */
  86481. get instanceDivisor(): number;
  86482. set instanceDivisor(value: number);
  86483. /**
  86484. * Gets the byte stride.
  86485. */
  86486. readonly byteStride: number;
  86487. /**
  86488. * Gets the byte offset.
  86489. */
  86490. readonly byteOffset: number;
  86491. /**
  86492. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  86493. */
  86494. readonly normalized: boolean;
  86495. /**
  86496. * Gets the data type of each component in the array.
  86497. */
  86498. readonly type: number;
  86499. /**
  86500. * Constructor
  86501. * @param engine the engine
  86502. * @param data the data to use for this vertex buffer
  86503. * @param kind the vertex buffer kind
  86504. * @param updatable whether the data is updatable
  86505. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86506. * @param stride the stride (optional)
  86507. * @param instanced whether the buffer is instanced (optional)
  86508. * @param offset the offset of the data (optional)
  86509. * @param size the number of components (optional)
  86510. * @param type the type of the component (optional)
  86511. * @param normalized whether the data contains normalized data (optional)
  86512. * @param useBytes set to true if stride and offset are in bytes (optional)
  86513. * @param divisor defines the instance divisor to use (1 by default)
  86514. */
  86515. 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);
  86516. /** @hidden */
  86517. _rebuild(): void;
  86518. /**
  86519. * Returns the kind of the VertexBuffer (string)
  86520. * @returns a string
  86521. */
  86522. getKind(): string;
  86523. /**
  86524. * Gets a boolean indicating if the VertexBuffer is updatable?
  86525. * @returns true if the buffer is updatable
  86526. */
  86527. isUpdatable(): boolean;
  86528. /**
  86529. * Gets current buffer's data
  86530. * @returns a DataArray or null
  86531. */
  86532. getData(): Nullable<DataArray>;
  86533. /**
  86534. * Gets underlying native buffer
  86535. * @returns underlying native buffer
  86536. */
  86537. getBuffer(): Nullable<DataBuffer>;
  86538. /**
  86539. * Gets the stride in float32 units (i.e. byte stride / 4).
  86540. * May not be an integer if the byte stride is not divisible by 4.
  86541. * @returns the stride in float32 units
  86542. * @deprecated Please use byteStride instead.
  86543. */
  86544. getStrideSize(): number;
  86545. /**
  86546. * Returns the offset as a multiple of the type byte length.
  86547. * @returns the offset in bytes
  86548. * @deprecated Please use byteOffset instead.
  86549. */
  86550. getOffset(): number;
  86551. /**
  86552. * Returns the number of components per vertex attribute (integer)
  86553. * @returns the size in float
  86554. */
  86555. getSize(): number;
  86556. /**
  86557. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  86558. * @returns true if this buffer is instanced
  86559. */
  86560. getIsInstanced(): boolean;
  86561. /**
  86562. * Returns the instancing divisor, zero for non-instanced (integer).
  86563. * @returns a number
  86564. */
  86565. getInstanceDivisor(): number;
  86566. /**
  86567. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86568. * @param data defines the data to store
  86569. */
  86570. create(data?: DataArray): void;
  86571. /**
  86572. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  86573. * This function will create a new buffer if the current one is not updatable
  86574. * @param data defines the data to store
  86575. */
  86576. update(data: DataArray): void;
  86577. /**
  86578. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  86579. * Returns the directly updated WebGLBuffer.
  86580. * @param data the new data
  86581. * @param offset the new offset
  86582. * @param useBytes set to true if the offset is in bytes
  86583. */
  86584. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  86585. /**
  86586. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  86587. */
  86588. dispose(): void;
  86589. /**
  86590. * Enumerates each value of this vertex buffer as numbers.
  86591. * @param count the number of values to enumerate
  86592. * @param callback the callback function called for each value
  86593. */
  86594. forEach(count: number, callback: (value: number, index: number) => void): void;
  86595. /**
  86596. * Positions
  86597. */
  86598. static readonly PositionKind: string;
  86599. /**
  86600. * Normals
  86601. */
  86602. static readonly NormalKind: string;
  86603. /**
  86604. * Tangents
  86605. */
  86606. static readonly TangentKind: string;
  86607. /**
  86608. * Texture coordinates
  86609. */
  86610. static readonly UVKind: string;
  86611. /**
  86612. * Texture coordinates 2
  86613. */
  86614. static readonly UV2Kind: string;
  86615. /**
  86616. * Texture coordinates 3
  86617. */
  86618. static readonly UV3Kind: string;
  86619. /**
  86620. * Texture coordinates 4
  86621. */
  86622. static readonly UV4Kind: string;
  86623. /**
  86624. * Texture coordinates 5
  86625. */
  86626. static readonly UV5Kind: string;
  86627. /**
  86628. * Texture coordinates 6
  86629. */
  86630. static readonly UV6Kind: string;
  86631. /**
  86632. * Colors
  86633. */
  86634. static readonly ColorKind: string;
  86635. /**
  86636. * Matrix indices (for bones)
  86637. */
  86638. static readonly MatricesIndicesKind: string;
  86639. /**
  86640. * Matrix weights (for bones)
  86641. */
  86642. static readonly MatricesWeightsKind: string;
  86643. /**
  86644. * Additional matrix indices (for bones)
  86645. */
  86646. static readonly MatricesIndicesExtraKind: string;
  86647. /**
  86648. * Additional matrix weights (for bones)
  86649. */
  86650. static readonly MatricesWeightsExtraKind: string;
  86651. /**
  86652. * Deduces the stride given a kind.
  86653. * @param kind The kind string to deduce
  86654. * @returns The deduced stride
  86655. */
  86656. static DeduceStride(kind: string): number;
  86657. /**
  86658. * Gets the byte length of the given type.
  86659. * @param type the type
  86660. * @returns the number of bytes
  86661. */
  86662. static GetTypeByteLength(type: number): number;
  86663. /**
  86664. * Enumerates each value of the given parameters as numbers.
  86665. * @param data the data to enumerate
  86666. * @param byteOffset the byte offset of the data
  86667. * @param byteStride the byte stride of the data
  86668. * @param componentCount the number of components per element
  86669. * @param componentType the type of the component
  86670. * @param count the number of values to enumerate
  86671. * @param normalized whether the data is normalized
  86672. * @param callback the callback function called for each value
  86673. */
  86674. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  86675. private static _GetFloatValue;
  86676. }
  86677. }
  86678. declare module BABYLON {
  86679. /**
  86680. * The options Interface for creating a Capsule Mesh
  86681. */
  86682. export interface ICreateCapsuleOptions {
  86683. /** The Orientation of the capsule. Default : Vector3.Up() */
  86684. orientation: Vector3;
  86685. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  86686. subdivisions: number;
  86687. /** Number of cylindrical segments on the capsule. */
  86688. tessellation: number;
  86689. /** Height or Length of the capsule. */
  86690. height: number;
  86691. /** Radius of the capsule. */
  86692. radius: number;
  86693. /** Height or Length of the capsule. */
  86694. capSubdivisions: number;
  86695. /** Overwrite for the top radius. */
  86696. radiusTop?: number;
  86697. /** Overwrite for the bottom radius. */
  86698. radiusBottom?: number;
  86699. /** Overwrite for the top capSubdivisions. */
  86700. topCapSubdivisions?: number;
  86701. /** Overwrite for the bottom capSubdivisions. */
  86702. bottomCapSubdivisions?: number;
  86703. }
  86704. /**
  86705. * Class containing static functions to help procedurally build meshes
  86706. */
  86707. export class CapsuleBuilder {
  86708. /**
  86709. * Creates a capsule or a pill mesh
  86710. * @param name defines the name of the mesh
  86711. * @param options The constructors options.
  86712. * @param scene The scene the mesh is scoped to.
  86713. * @returns Capsule Mesh
  86714. */
  86715. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  86716. }
  86717. }
  86718. declare module BABYLON {
  86719. /**
  86720. * @hidden
  86721. */
  86722. export class IntersectionInfo {
  86723. bu: Nullable<number>;
  86724. bv: Nullable<number>;
  86725. distance: number;
  86726. faceId: number;
  86727. subMeshId: number;
  86728. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  86729. }
  86730. }
  86731. declare module BABYLON {
  86732. /**
  86733. * Class used to store bounding sphere information
  86734. */
  86735. export class BoundingSphere {
  86736. /**
  86737. * Gets the center of the bounding sphere in local space
  86738. */
  86739. readonly center: Vector3;
  86740. /**
  86741. * Radius of the bounding sphere in local space
  86742. */
  86743. radius: number;
  86744. /**
  86745. * Gets the center of the bounding sphere in world space
  86746. */
  86747. readonly centerWorld: Vector3;
  86748. /**
  86749. * Radius of the bounding sphere in world space
  86750. */
  86751. radiusWorld: number;
  86752. /**
  86753. * Gets the minimum vector in local space
  86754. */
  86755. readonly minimum: Vector3;
  86756. /**
  86757. * Gets the maximum vector in local space
  86758. */
  86759. readonly maximum: Vector3;
  86760. private _worldMatrix;
  86761. private static readonly TmpVector3;
  86762. /**
  86763. * Creates a new bounding sphere
  86764. * @param min defines the minimum vector (in local space)
  86765. * @param max defines the maximum vector (in local space)
  86766. * @param worldMatrix defines the new world matrix
  86767. */
  86768. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86769. /**
  86770. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  86771. * @param min defines the new minimum vector (in local space)
  86772. * @param max defines the new maximum vector (in local space)
  86773. * @param worldMatrix defines the new world matrix
  86774. */
  86775. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86776. /**
  86777. * Scale the current bounding sphere by applying a scale factor
  86778. * @param factor defines the scale factor to apply
  86779. * @returns the current bounding box
  86780. */
  86781. scale(factor: number): BoundingSphere;
  86782. /**
  86783. * Gets the world matrix of the bounding box
  86784. * @returns a matrix
  86785. */
  86786. getWorldMatrix(): DeepImmutable<Matrix>;
  86787. /** @hidden */
  86788. _update(worldMatrix: DeepImmutable<Matrix>): void;
  86789. /**
  86790. * Tests if the bounding sphere is intersecting the frustum planes
  86791. * @param frustumPlanes defines the frustum planes to test
  86792. * @returns true if there is an intersection
  86793. */
  86794. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86795. /**
  86796. * Tests if the bounding sphere center is in between the frustum planes.
  86797. * Used for optimistic fast inclusion.
  86798. * @param frustumPlanes defines the frustum planes to test
  86799. * @returns true if the sphere center is in between the frustum planes
  86800. */
  86801. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86802. /**
  86803. * Tests if a point is inside the bounding sphere
  86804. * @param point defines the point to test
  86805. * @returns true if the point is inside the bounding sphere
  86806. */
  86807. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86808. /**
  86809. * Checks if two sphere intersct
  86810. * @param sphere0 sphere 0
  86811. * @param sphere1 sphere 1
  86812. * @returns true if the speres intersect
  86813. */
  86814. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  86815. }
  86816. }
  86817. declare module BABYLON {
  86818. /**
  86819. * Class used to store bounding box information
  86820. */
  86821. export class BoundingBox implements ICullable {
  86822. /**
  86823. * Gets the 8 vectors representing the bounding box in local space
  86824. */
  86825. readonly vectors: Vector3[];
  86826. /**
  86827. * Gets the center of the bounding box in local space
  86828. */
  86829. readonly center: Vector3;
  86830. /**
  86831. * Gets the center of the bounding box in world space
  86832. */
  86833. readonly centerWorld: Vector3;
  86834. /**
  86835. * Gets the extend size in local space
  86836. */
  86837. readonly extendSize: Vector3;
  86838. /**
  86839. * Gets the extend size in world space
  86840. */
  86841. readonly extendSizeWorld: Vector3;
  86842. /**
  86843. * Gets the OBB (object bounding box) directions
  86844. */
  86845. readonly directions: Vector3[];
  86846. /**
  86847. * Gets the 8 vectors representing the bounding box in world space
  86848. */
  86849. readonly vectorsWorld: Vector3[];
  86850. /**
  86851. * Gets the minimum vector in world space
  86852. */
  86853. readonly minimumWorld: Vector3;
  86854. /**
  86855. * Gets the maximum vector in world space
  86856. */
  86857. readonly maximumWorld: Vector3;
  86858. /**
  86859. * Gets the minimum vector in local space
  86860. */
  86861. readonly minimum: Vector3;
  86862. /**
  86863. * Gets the maximum vector in local space
  86864. */
  86865. readonly maximum: Vector3;
  86866. private _worldMatrix;
  86867. private static readonly TmpVector3;
  86868. /**
  86869. * @hidden
  86870. */
  86871. _tag: number;
  86872. /**
  86873. * Creates a new bounding box
  86874. * @param min defines the minimum vector (in local space)
  86875. * @param max defines the maximum vector (in local space)
  86876. * @param worldMatrix defines the new world matrix
  86877. */
  86878. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86879. /**
  86880. * Recreates the entire bounding box from scratch as if we call the constructor in place
  86881. * @param min defines the new minimum vector (in local space)
  86882. * @param max defines the new maximum vector (in local space)
  86883. * @param worldMatrix defines the new world matrix
  86884. */
  86885. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86886. /**
  86887. * Scale the current bounding box by applying a scale factor
  86888. * @param factor defines the scale factor to apply
  86889. * @returns the current bounding box
  86890. */
  86891. scale(factor: number): BoundingBox;
  86892. /**
  86893. * Gets the world matrix of the bounding box
  86894. * @returns a matrix
  86895. */
  86896. getWorldMatrix(): DeepImmutable<Matrix>;
  86897. /** @hidden */
  86898. _update(world: DeepImmutable<Matrix>): void;
  86899. /**
  86900. * Tests if the bounding box is intersecting the frustum planes
  86901. * @param frustumPlanes defines the frustum planes to test
  86902. * @returns true if there is an intersection
  86903. */
  86904. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86905. /**
  86906. * Tests if the bounding box is entirely inside the frustum planes
  86907. * @param frustumPlanes defines the frustum planes to test
  86908. * @returns true if there is an inclusion
  86909. */
  86910. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86911. /**
  86912. * Tests if a point is inside the bounding box
  86913. * @param point defines the point to test
  86914. * @returns true if the point is inside the bounding box
  86915. */
  86916. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86917. /**
  86918. * Tests if the bounding box intersects with a bounding sphere
  86919. * @param sphere defines the sphere to test
  86920. * @returns true if there is an intersection
  86921. */
  86922. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  86923. /**
  86924. * Tests if the bounding box intersects with a box defined by a min and max vectors
  86925. * @param min defines the min vector to use
  86926. * @param max defines the max vector to use
  86927. * @returns true if there is an intersection
  86928. */
  86929. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  86930. /**
  86931. * Tests if two bounding boxes are intersections
  86932. * @param box0 defines the first box to test
  86933. * @param box1 defines the second box to test
  86934. * @returns true if there is an intersection
  86935. */
  86936. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  86937. /**
  86938. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  86939. * @param minPoint defines the minimum vector of the bounding box
  86940. * @param maxPoint defines the maximum vector of the bounding box
  86941. * @param sphereCenter defines the sphere center
  86942. * @param sphereRadius defines the sphere radius
  86943. * @returns true if there is an intersection
  86944. */
  86945. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  86946. /**
  86947. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  86948. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86949. * @param frustumPlanes defines the frustum planes to test
  86950. * @return true if there is an inclusion
  86951. */
  86952. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86953. /**
  86954. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  86955. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86956. * @param frustumPlanes defines the frustum planes to test
  86957. * @return true if there is an intersection
  86958. */
  86959. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86960. }
  86961. }
  86962. declare module BABYLON {
  86963. /** @hidden */
  86964. export class Collider {
  86965. /** Define if a collision was found */
  86966. collisionFound: boolean;
  86967. /**
  86968. * Define last intersection point in local space
  86969. */
  86970. intersectionPoint: Vector3;
  86971. /**
  86972. * Define last collided mesh
  86973. */
  86974. collidedMesh: Nullable<AbstractMesh>;
  86975. private _collisionPoint;
  86976. private _planeIntersectionPoint;
  86977. private _tempVector;
  86978. private _tempVector2;
  86979. private _tempVector3;
  86980. private _tempVector4;
  86981. private _edge;
  86982. private _baseToVertex;
  86983. private _destinationPoint;
  86984. private _slidePlaneNormal;
  86985. private _displacementVector;
  86986. /** @hidden */
  86987. _radius: Vector3;
  86988. /** @hidden */
  86989. _retry: number;
  86990. private _velocity;
  86991. private _basePoint;
  86992. private _epsilon;
  86993. /** @hidden */
  86994. _velocityWorldLength: number;
  86995. /** @hidden */
  86996. _basePointWorld: Vector3;
  86997. private _velocityWorld;
  86998. private _normalizedVelocity;
  86999. /** @hidden */
  87000. _initialVelocity: Vector3;
  87001. /** @hidden */
  87002. _initialPosition: Vector3;
  87003. private _nearestDistance;
  87004. private _collisionMask;
  87005. get collisionMask(): number;
  87006. set collisionMask(mask: number);
  87007. /**
  87008. * Gets the plane normal used to compute the sliding response (in local space)
  87009. */
  87010. get slidePlaneNormal(): Vector3;
  87011. /** @hidden */
  87012. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87013. /** @hidden */
  87014. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87015. /** @hidden */
  87016. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87017. /** @hidden */
  87018. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87019. /** @hidden */
  87020. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87021. /** @hidden */
  87022. _getResponse(pos: Vector3, vel: Vector3): void;
  87023. }
  87024. }
  87025. declare module BABYLON {
  87026. /**
  87027. * Interface for cullable objects
  87028. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87029. */
  87030. export interface ICullable {
  87031. /**
  87032. * Checks if the object or part of the object is in the frustum
  87033. * @param frustumPlanes Camera near/planes
  87034. * @returns true if the object is in frustum otherwise false
  87035. */
  87036. isInFrustum(frustumPlanes: Plane[]): boolean;
  87037. /**
  87038. * Checks if a cullable object (mesh...) is in the camera frustum
  87039. * Unlike isInFrustum this cheks the full bounding box
  87040. * @param frustumPlanes Camera near/planes
  87041. * @returns true if the object is in frustum otherwise false
  87042. */
  87043. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87044. }
  87045. /**
  87046. * Info for a bounding data of a mesh
  87047. */
  87048. export class BoundingInfo implements ICullable {
  87049. /**
  87050. * Bounding box for the mesh
  87051. */
  87052. readonly boundingBox: BoundingBox;
  87053. /**
  87054. * Bounding sphere for the mesh
  87055. */
  87056. readonly boundingSphere: BoundingSphere;
  87057. private _isLocked;
  87058. private static readonly TmpVector3;
  87059. /**
  87060. * Constructs bounding info
  87061. * @param minimum min vector of the bounding box/sphere
  87062. * @param maximum max vector of the bounding box/sphere
  87063. * @param worldMatrix defines the new world matrix
  87064. */
  87065. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87066. /**
  87067. * Recreates the entire bounding info from scratch as if we call the constructor in place
  87068. * @param min defines the new minimum vector (in local space)
  87069. * @param max defines the new maximum vector (in local space)
  87070. * @param worldMatrix defines the new world matrix
  87071. */
  87072. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87073. /**
  87074. * min vector of the bounding box/sphere
  87075. */
  87076. get minimum(): Vector3;
  87077. /**
  87078. * max vector of the bounding box/sphere
  87079. */
  87080. get maximum(): Vector3;
  87081. /**
  87082. * If the info is locked and won't be updated to avoid perf overhead
  87083. */
  87084. get isLocked(): boolean;
  87085. set isLocked(value: boolean);
  87086. /**
  87087. * Updates the bounding sphere and box
  87088. * @param world world matrix to be used to update
  87089. */
  87090. update(world: DeepImmutable<Matrix>): void;
  87091. /**
  87092. * Recreate the bounding info to be centered around a specific point given a specific extend.
  87093. * @param center New center of the bounding info
  87094. * @param extend New extend of the bounding info
  87095. * @returns the current bounding info
  87096. */
  87097. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  87098. /**
  87099. * Scale the current bounding info by applying a scale factor
  87100. * @param factor defines the scale factor to apply
  87101. * @returns the current bounding info
  87102. */
  87103. scale(factor: number): BoundingInfo;
  87104. /**
  87105. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  87106. * @param frustumPlanes defines the frustum to test
  87107. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87108. * @returns true if the bounding info is in the frustum planes
  87109. */
  87110. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87111. /**
  87112. * Gets the world distance between the min and max points of the bounding box
  87113. */
  87114. get diagonalLength(): number;
  87115. /**
  87116. * Checks if a cullable object (mesh...) is in the camera frustum
  87117. * Unlike isInFrustum this cheks the full bounding box
  87118. * @param frustumPlanes Camera near/planes
  87119. * @returns true if the object is in frustum otherwise false
  87120. */
  87121. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87122. /** @hidden */
  87123. _checkCollision(collider: Collider): boolean;
  87124. /**
  87125. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87126. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87127. * @param point the point to check intersection with
  87128. * @returns if the point intersects
  87129. */
  87130. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87131. /**
  87132. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  87133. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87134. * @param boundingInfo the bounding info to check intersection with
  87135. * @param precise if the intersection should be done using OBB
  87136. * @returns if the bounding info intersects
  87137. */
  87138. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  87139. }
  87140. }
  87141. declare module BABYLON {
  87142. /**
  87143. * Extracts minimum and maximum values from a list of indexed positions
  87144. * @param positions defines the positions to use
  87145. * @param indices defines the indices to the positions
  87146. * @param indexStart defines the start index
  87147. * @param indexCount defines the end index
  87148. * @param bias defines bias value to add to the result
  87149. * @return minimum and maximum values
  87150. */
  87151. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87152. minimum: Vector3;
  87153. maximum: Vector3;
  87154. };
  87155. /**
  87156. * Extracts minimum and maximum values from a list of positions
  87157. * @param positions defines the positions to use
  87158. * @param start defines the start index in the positions array
  87159. * @param count defines the number of positions to handle
  87160. * @param bias defines bias value to add to the result
  87161. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87162. * @return minimum and maximum values
  87163. */
  87164. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87165. minimum: Vector3;
  87166. maximum: Vector3;
  87167. };
  87168. }
  87169. declare module BABYLON {
  87170. /** @hidden */
  87171. export class WebGLDataBuffer extends DataBuffer {
  87172. private _buffer;
  87173. constructor(resource: WebGLBuffer);
  87174. get underlyingResource(): any;
  87175. }
  87176. }
  87177. declare module BABYLON {
  87178. /** @hidden */
  87179. export class WebGLPipelineContext implements IPipelineContext {
  87180. engine: ThinEngine;
  87181. program: Nullable<WebGLProgram>;
  87182. context?: WebGLRenderingContext;
  87183. vertexShader?: WebGLShader;
  87184. fragmentShader?: WebGLShader;
  87185. isParallelCompiled: boolean;
  87186. onCompiled?: () => void;
  87187. transformFeedback?: WebGLTransformFeedback | null;
  87188. vertexCompilationError: Nullable<string>;
  87189. fragmentCompilationError: Nullable<string>;
  87190. programLinkError: Nullable<string>;
  87191. programValidationError: Nullable<string>;
  87192. get isAsync(): boolean;
  87193. get isReady(): boolean;
  87194. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  87195. _getVertexShaderCode(): string | null;
  87196. _getFragmentShaderCode(): string | null;
  87197. }
  87198. }
  87199. declare module BABYLON {
  87200. interface ThinEngine {
  87201. /**
  87202. * Create an uniform buffer
  87203. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87204. * @param elements defines the content of the uniform buffer
  87205. * @returns the webGL uniform buffer
  87206. */
  87207. createUniformBuffer(elements: FloatArray): DataBuffer;
  87208. /**
  87209. * Create a dynamic uniform buffer
  87210. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87211. * @param elements defines the content of the uniform buffer
  87212. * @returns the webGL uniform buffer
  87213. */
  87214. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  87215. /**
  87216. * Update an existing uniform buffer
  87217. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87218. * @param uniformBuffer defines the target uniform buffer
  87219. * @param elements defines the content to update
  87220. * @param offset defines the offset in the uniform buffer where update should start
  87221. * @param count defines the size of the data to update
  87222. */
  87223. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87224. /**
  87225. * Bind an uniform buffer to the current webGL context
  87226. * @param buffer defines the buffer to bind
  87227. */
  87228. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  87229. /**
  87230. * Bind a buffer to the current webGL context at a given location
  87231. * @param buffer defines the buffer to bind
  87232. * @param location defines the index where to bind the buffer
  87233. */
  87234. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  87235. /**
  87236. * Bind a specific block at a given index in a specific shader program
  87237. * @param pipelineContext defines the pipeline context to use
  87238. * @param blockName defines the block name
  87239. * @param index defines the index where to bind the block
  87240. */
  87241. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  87242. }
  87243. }
  87244. declare module BABYLON {
  87245. /**
  87246. * Uniform buffer objects.
  87247. *
  87248. * Handles blocks of uniform on the GPU.
  87249. *
  87250. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87251. *
  87252. * For more information, please refer to :
  87253. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87254. */
  87255. export class UniformBuffer {
  87256. private _engine;
  87257. private _buffer;
  87258. private _data;
  87259. private _bufferData;
  87260. private _dynamic?;
  87261. private _uniformLocations;
  87262. private _uniformSizes;
  87263. private _uniformLocationPointer;
  87264. private _needSync;
  87265. private _noUBO;
  87266. private _currentEffect;
  87267. /** @hidden */
  87268. _alreadyBound: boolean;
  87269. private static _MAX_UNIFORM_SIZE;
  87270. private static _tempBuffer;
  87271. /**
  87272. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  87273. * This is dynamic to allow compat with webgl 1 and 2.
  87274. * You will need to pass the name of the uniform as well as the value.
  87275. */
  87276. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  87277. /**
  87278. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  87279. * This is dynamic to allow compat with webgl 1 and 2.
  87280. * You will need to pass the name of the uniform as well as the value.
  87281. */
  87282. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  87283. /**
  87284. * Lambda to Update a single float in a uniform buffer.
  87285. * This is dynamic to allow compat with webgl 1 and 2.
  87286. * You will need to pass the name of the uniform as well as the value.
  87287. */
  87288. updateFloat: (name: string, x: number) => void;
  87289. /**
  87290. * Lambda to Update a vec2 of float in a uniform buffer.
  87291. * This is dynamic to allow compat with webgl 1 and 2.
  87292. * You will need to pass the name of the uniform as well as the value.
  87293. */
  87294. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  87295. /**
  87296. * Lambda to Update a vec3 of float in a uniform buffer.
  87297. * This is dynamic to allow compat with webgl 1 and 2.
  87298. * You will need to pass the name of the uniform as well as the value.
  87299. */
  87300. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  87301. /**
  87302. * Lambda to Update a vec4 of float in a uniform buffer.
  87303. * This is dynamic to allow compat with webgl 1 and 2.
  87304. * You will need to pass the name of the uniform as well as the value.
  87305. */
  87306. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  87307. /**
  87308. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  87309. * This is dynamic to allow compat with webgl 1 and 2.
  87310. * You will need to pass the name of the uniform as well as the value.
  87311. */
  87312. updateMatrix: (name: string, mat: Matrix) => void;
  87313. /**
  87314. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  87315. * This is dynamic to allow compat with webgl 1 and 2.
  87316. * You will need to pass the name of the uniform as well as the value.
  87317. */
  87318. updateVector3: (name: string, vector: Vector3) => void;
  87319. /**
  87320. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  87321. * This is dynamic to allow compat with webgl 1 and 2.
  87322. * You will need to pass the name of the uniform as well as the value.
  87323. */
  87324. updateVector4: (name: string, vector: Vector4) => void;
  87325. /**
  87326. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  87327. * This is dynamic to allow compat with webgl 1 and 2.
  87328. * You will need to pass the name of the uniform as well as the value.
  87329. */
  87330. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  87331. /**
  87332. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  87333. * This is dynamic to allow compat with webgl 1 and 2.
  87334. * You will need to pass the name of the uniform as well as the value.
  87335. */
  87336. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  87337. /**
  87338. * Instantiates a new Uniform buffer objects.
  87339. *
  87340. * Handles blocks of uniform on the GPU.
  87341. *
  87342. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87343. *
  87344. * For more information, please refer to :
  87345. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87346. * @param engine Define the engine the buffer is associated with
  87347. * @param data Define the data contained in the buffer
  87348. * @param dynamic Define if the buffer is updatable
  87349. */
  87350. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  87351. /**
  87352. * Indicates if the buffer is using the WebGL2 UBO implementation,
  87353. * or just falling back on setUniformXXX calls.
  87354. */
  87355. get useUbo(): boolean;
  87356. /**
  87357. * Indicates if the WebGL underlying uniform buffer is in sync
  87358. * with the javascript cache data.
  87359. */
  87360. get isSync(): boolean;
  87361. /**
  87362. * Indicates if the WebGL underlying uniform buffer is dynamic.
  87363. * Also, a dynamic UniformBuffer will disable cache verification and always
  87364. * update the underlying WebGL uniform buffer to the GPU.
  87365. * @returns if Dynamic, otherwise false
  87366. */
  87367. isDynamic(): boolean;
  87368. /**
  87369. * The data cache on JS side.
  87370. * @returns the underlying data as a float array
  87371. */
  87372. getData(): Float32Array;
  87373. /**
  87374. * The underlying WebGL Uniform buffer.
  87375. * @returns the webgl buffer
  87376. */
  87377. getBuffer(): Nullable<DataBuffer>;
  87378. /**
  87379. * std140 layout specifies how to align data within an UBO structure.
  87380. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  87381. * for specs.
  87382. */
  87383. private _fillAlignment;
  87384. /**
  87385. * Adds an uniform in the buffer.
  87386. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  87387. * for the layout to be correct !
  87388. * @param name Name of the uniform, as used in the uniform block in the shader.
  87389. * @param size Data size, or data directly.
  87390. */
  87391. addUniform(name: string, size: number | number[]): void;
  87392. /**
  87393. * Adds a Matrix 4x4 to the uniform buffer.
  87394. * @param name Name of the uniform, as used in the uniform block in the shader.
  87395. * @param mat A 4x4 matrix.
  87396. */
  87397. addMatrix(name: string, mat: Matrix): void;
  87398. /**
  87399. * Adds a vec2 to the uniform buffer.
  87400. * @param name Name of the uniform, as used in the uniform block in the shader.
  87401. * @param x Define the x component value of the vec2
  87402. * @param y Define the y component value of the vec2
  87403. */
  87404. addFloat2(name: string, x: number, y: number): void;
  87405. /**
  87406. * Adds a vec3 to the uniform buffer.
  87407. * @param name Name of the uniform, as used in the uniform block in the shader.
  87408. * @param x Define the x component value of the vec3
  87409. * @param y Define the y component value of the vec3
  87410. * @param z Define the z component value of the vec3
  87411. */
  87412. addFloat3(name: string, x: number, y: number, z: number): void;
  87413. /**
  87414. * Adds a vec3 to the uniform buffer.
  87415. * @param name Name of the uniform, as used in the uniform block in the shader.
  87416. * @param color Define the vec3 from a Color
  87417. */
  87418. addColor3(name: string, color: Color3): void;
  87419. /**
  87420. * Adds a vec4 to the uniform buffer.
  87421. * @param name Name of the uniform, as used in the uniform block in the shader.
  87422. * @param color Define the rgb components from a Color
  87423. * @param alpha Define the a component of the vec4
  87424. */
  87425. addColor4(name: string, color: Color3, alpha: number): void;
  87426. /**
  87427. * Adds a vec3 to the uniform buffer.
  87428. * @param name Name of the uniform, as used in the uniform block in the shader.
  87429. * @param vector Define the vec3 components from a Vector
  87430. */
  87431. addVector3(name: string, vector: Vector3): void;
  87432. /**
  87433. * Adds a Matrix 3x3 to the uniform buffer.
  87434. * @param name Name of the uniform, as used in the uniform block in the shader.
  87435. */
  87436. addMatrix3x3(name: string): void;
  87437. /**
  87438. * Adds a Matrix 2x2 to the uniform buffer.
  87439. * @param name Name of the uniform, as used in the uniform block in the shader.
  87440. */
  87441. addMatrix2x2(name: string): void;
  87442. /**
  87443. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  87444. */
  87445. create(): void;
  87446. /** @hidden */
  87447. _rebuild(): void;
  87448. /**
  87449. * Updates the WebGL Uniform Buffer on the GPU.
  87450. * If the `dynamic` flag is set to true, no cache comparison is done.
  87451. * Otherwise, the buffer will be updated only if the cache differs.
  87452. */
  87453. update(): void;
  87454. /**
  87455. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  87456. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87457. * @param data Define the flattened data
  87458. * @param size Define the size of the data.
  87459. */
  87460. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  87461. private _valueCache;
  87462. private _cacheMatrix;
  87463. private _updateMatrix3x3ForUniform;
  87464. private _updateMatrix3x3ForEffect;
  87465. private _updateMatrix2x2ForEffect;
  87466. private _updateMatrix2x2ForUniform;
  87467. private _updateFloatForEffect;
  87468. private _updateFloatForUniform;
  87469. private _updateFloat2ForEffect;
  87470. private _updateFloat2ForUniform;
  87471. private _updateFloat3ForEffect;
  87472. private _updateFloat3ForUniform;
  87473. private _updateFloat4ForEffect;
  87474. private _updateFloat4ForUniform;
  87475. private _updateMatrixForEffect;
  87476. private _updateMatrixForUniform;
  87477. private _updateVector3ForEffect;
  87478. private _updateVector3ForUniform;
  87479. private _updateVector4ForEffect;
  87480. private _updateVector4ForUniform;
  87481. private _updateColor3ForEffect;
  87482. private _updateColor3ForUniform;
  87483. private _updateColor4ForEffect;
  87484. private _updateColor4ForUniform;
  87485. /**
  87486. * Sets a sampler uniform on the effect.
  87487. * @param name Define the name of the sampler.
  87488. * @param texture Define the texture to set in the sampler
  87489. */
  87490. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  87491. /**
  87492. * Directly updates the value of the uniform in the cache AND on the GPU.
  87493. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87494. * @param data Define the flattened data
  87495. */
  87496. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  87497. /**
  87498. * Binds this uniform buffer to an effect.
  87499. * @param effect Define the effect to bind the buffer to
  87500. * @param name Name of the uniform block in the shader.
  87501. */
  87502. bindToEffect(effect: Effect, name: string): void;
  87503. /**
  87504. * Disposes the uniform buffer.
  87505. */
  87506. dispose(): void;
  87507. }
  87508. }
  87509. declare module BABYLON {
  87510. /**
  87511. * Enum that determines the text-wrapping mode to use.
  87512. */
  87513. export enum InspectableType {
  87514. /**
  87515. * Checkbox for booleans
  87516. */
  87517. Checkbox = 0,
  87518. /**
  87519. * Sliders for numbers
  87520. */
  87521. Slider = 1,
  87522. /**
  87523. * Vector3
  87524. */
  87525. Vector3 = 2,
  87526. /**
  87527. * Quaternions
  87528. */
  87529. Quaternion = 3,
  87530. /**
  87531. * Color3
  87532. */
  87533. Color3 = 4,
  87534. /**
  87535. * String
  87536. */
  87537. String = 5
  87538. }
  87539. /**
  87540. * Interface used to define custom inspectable properties.
  87541. * This interface is used by the inspector to display custom property grids
  87542. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87543. */
  87544. export interface IInspectable {
  87545. /**
  87546. * Gets the label to display
  87547. */
  87548. label: string;
  87549. /**
  87550. * Gets the name of the property to edit
  87551. */
  87552. propertyName: string;
  87553. /**
  87554. * Gets the type of the editor to use
  87555. */
  87556. type: InspectableType;
  87557. /**
  87558. * Gets the minimum value of the property when using in "slider" mode
  87559. */
  87560. min?: number;
  87561. /**
  87562. * Gets the maximum value of the property when using in "slider" mode
  87563. */
  87564. max?: number;
  87565. /**
  87566. * Gets the setp to use when using in "slider" mode
  87567. */
  87568. step?: number;
  87569. }
  87570. }
  87571. declare module BABYLON {
  87572. /**
  87573. * Class used to provide helper for timing
  87574. */
  87575. export class TimingTools {
  87576. /**
  87577. * Polyfill for setImmediate
  87578. * @param action defines the action to execute after the current execution block
  87579. */
  87580. static SetImmediate(action: () => void): void;
  87581. }
  87582. }
  87583. declare module BABYLON {
  87584. /**
  87585. * Class used to enable instatition of objects by class name
  87586. */
  87587. export class InstantiationTools {
  87588. /**
  87589. * Use this object to register external classes like custom textures or material
  87590. * to allow the laoders to instantiate them
  87591. */
  87592. static RegisteredExternalClasses: {
  87593. [key: string]: Object;
  87594. };
  87595. /**
  87596. * Tries to instantiate a new object from a given class name
  87597. * @param className defines the class name to instantiate
  87598. * @returns the new object or null if the system was not able to do the instantiation
  87599. */
  87600. static Instantiate(className: string): any;
  87601. }
  87602. }
  87603. declare module BABYLON {
  87604. /**
  87605. * Define options used to create a depth texture
  87606. */
  87607. export class DepthTextureCreationOptions {
  87608. /** Specifies whether or not a stencil should be allocated in the texture */
  87609. generateStencil?: boolean;
  87610. /** Specifies whether or not bilinear filtering is enable on the texture */
  87611. bilinearFiltering?: boolean;
  87612. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  87613. comparisonFunction?: number;
  87614. /** Specifies if the created texture is a cube texture */
  87615. isCube?: boolean;
  87616. }
  87617. }
  87618. declare module BABYLON {
  87619. interface ThinEngine {
  87620. /**
  87621. * Creates a depth stencil cube texture.
  87622. * This is only available in WebGL 2.
  87623. * @param size The size of face edge in the cube texture.
  87624. * @param options The options defining the cube texture.
  87625. * @returns The cube texture
  87626. */
  87627. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  87628. /**
  87629. * Creates a cube texture
  87630. * @param rootUrl defines the url where the files to load is located
  87631. * @param scene defines the current scene
  87632. * @param files defines the list of files to load (1 per face)
  87633. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87634. * @param onLoad defines an optional callback raised when the texture is loaded
  87635. * @param onError defines an optional callback raised if there is an issue to load the texture
  87636. * @param format defines the format of the data
  87637. * @param forcedExtension defines the extension to use to pick the right loader
  87638. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87639. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87640. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87641. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87642. * @returns the cube texture as an InternalTexture
  87643. */
  87644. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  87645. /**
  87646. * Creates a cube texture
  87647. * @param rootUrl defines the url where the files to load is located
  87648. * @param scene defines the current scene
  87649. * @param files defines the list of files to load (1 per face)
  87650. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87651. * @param onLoad defines an optional callback raised when the texture is loaded
  87652. * @param onError defines an optional callback raised if there is an issue to load the texture
  87653. * @param format defines the format of the data
  87654. * @param forcedExtension defines the extension to use to pick the right loader
  87655. * @returns the cube texture as an InternalTexture
  87656. */
  87657. 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;
  87658. /**
  87659. * Creates a cube texture
  87660. * @param rootUrl defines the url where the files to load is located
  87661. * @param scene defines the current scene
  87662. * @param files defines the list of files to load (1 per face)
  87663. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87664. * @param onLoad defines an optional callback raised when the texture is loaded
  87665. * @param onError defines an optional callback raised if there is an issue to load the texture
  87666. * @param format defines the format of the data
  87667. * @param forcedExtension defines the extension to use to pick the right loader
  87668. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87669. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87670. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87671. * @returns the cube texture as an InternalTexture
  87672. */
  87673. 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;
  87674. /** @hidden */
  87675. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  87676. /** @hidden */
  87677. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  87678. /** @hidden */
  87679. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  87680. /** @hidden */
  87681. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  87682. /**
  87683. * @hidden
  87684. */
  87685. _setCubeMapTextureParams(loadMipmap: boolean): void;
  87686. }
  87687. }
  87688. declare module BABYLON {
  87689. /**
  87690. * Class for creating a cube texture
  87691. */
  87692. export class CubeTexture extends BaseTexture {
  87693. private _delayedOnLoad;
  87694. /**
  87695. * Observable triggered once the texture has been loaded.
  87696. */
  87697. onLoadObservable: Observable<CubeTexture>;
  87698. /**
  87699. * The url of the texture
  87700. */
  87701. url: string;
  87702. /**
  87703. * Gets or sets the center of the bounding box associated with the cube texture.
  87704. * It must define where the camera used to render the texture was set
  87705. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  87706. */
  87707. boundingBoxPosition: Vector3;
  87708. private _boundingBoxSize;
  87709. /**
  87710. * Gets or sets the size of the bounding box associated with the cube texture
  87711. * When defined, the cubemap will switch to local mode
  87712. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87713. * @example https://www.babylonjs-playground.com/#RNASML
  87714. */
  87715. set boundingBoxSize(value: Vector3);
  87716. /**
  87717. * Returns the bounding box size
  87718. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  87719. */
  87720. get boundingBoxSize(): Vector3;
  87721. protected _rotationY: number;
  87722. /**
  87723. * Sets texture matrix rotation angle around Y axis in radians.
  87724. */
  87725. set rotationY(value: number);
  87726. /**
  87727. * Gets texture matrix rotation angle around Y axis radians.
  87728. */
  87729. get rotationY(): number;
  87730. /**
  87731. * Are mip maps generated for this texture or not.
  87732. */
  87733. get noMipmap(): boolean;
  87734. private _noMipmap;
  87735. private _files;
  87736. protected _forcedExtension: Nullable<string>;
  87737. private _extensions;
  87738. private _textureMatrix;
  87739. private _format;
  87740. private _createPolynomials;
  87741. /**
  87742. * Creates a cube texture from an array of image urls
  87743. * @param files defines an array of image urls
  87744. * @param scene defines the hosting scene
  87745. * @param noMipmap specifies if mip maps are not used
  87746. * @returns a cube texture
  87747. */
  87748. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  87749. /**
  87750. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  87751. * @param url defines the url of the prefiltered texture
  87752. * @param scene defines the scene the texture is attached to
  87753. * @param forcedExtension defines the extension of the file if different from the url
  87754. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  87755. * @return the prefiltered texture
  87756. */
  87757. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  87758. /**
  87759. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  87760. * as prefiltered data.
  87761. * @param rootUrl defines the url of the texture or the root name of the six images
  87762. * @param null defines the scene or engine the texture is attached to
  87763. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  87764. * @param noMipmap defines if mipmaps should be created or not
  87765. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  87766. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  87767. * @param onError defines a callback triggered in case of error during load
  87768. * @param format defines the internal format to use for the texture once loaded
  87769. * @param prefiltered defines whether or not the texture is created from prefiltered data
  87770. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  87771. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  87772. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87773. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87774. * @return the cube texture
  87775. */
  87776. 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);
  87777. /**
  87778. * Get the current class name of the texture useful for serialization or dynamic coding.
  87779. * @returns "CubeTexture"
  87780. */
  87781. getClassName(): string;
  87782. /**
  87783. * Update the url (and optional buffer) of this texture if url was null during construction.
  87784. * @param url the url of the texture
  87785. * @param forcedExtension defines the extension to use
  87786. * @param onLoad callback called when the texture is loaded (defaults to null)
  87787. * @param prefiltered Defines whether the updated texture is prefiltered or not
  87788. */
  87789. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  87790. /**
  87791. * Delays loading of the cube texture
  87792. * @param forcedExtension defines the extension to use
  87793. */
  87794. delayLoad(forcedExtension?: string): void;
  87795. /**
  87796. * Returns the reflection texture matrix
  87797. * @returns the reflection texture matrix
  87798. */
  87799. getReflectionTextureMatrix(): Matrix;
  87800. /**
  87801. * Sets the reflection texture matrix
  87802. * @param value Reflection texture matrix
  87803. */
  87804. setReflectionTextureMatrix(value: Matrix): void;
  87805. /**
  87806. * Parses text to create a cube texture
  87807. * @param parsedTexture define the serialized text to read from
  87808. * @param scene defines the hosting scene
  87809. * @param rootUrl defines the root url of the cube texture
  87810. * @returns a cube texture
  87811. */
  87812. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  87813. /**
  87814. * Makes a clone, or deep copy, of the cube texture
  87815. * @returns a new cube texture
  87816. */
  87817. clone(): CubeTexture;
  87818. }
  87819. }
  87820. declare module BABYLON {
  87821. /**
  87822. * Manages the defines for the Material
  87823. */
  87824. export class MaterialDefines {
  87825. /** @hidden */
  87826. protected _keys: string[];
  87827. private _isDirty;
  87828. /** @hidden */
  87829. _renderId: number;
  87830. /** @hidden */
  87831. _areLightsDirty: boolean;
  87832. /** @hidden */
  87833. _areLightsDisposed: boolean;
  87834. /** @hidden */
  87835. _areAttributesDirty: boolean;
  87836. /** @hidden */
  87837. _areTexturesDirty: boolean;
  87838. /** @hidden */
  87839. _areFresnelDirty: boolean;
  87840. /** @hidden */
  87841. _areMiscDirty: boolean;
  87842. /** @hidden */
  87843. _areImageProcessingDirty: boolean;
  87844. /** @hidden */
  87845. _normals: boolean;
  87846. /** @hidden */
  87847. _uvs: boolean;
  87848. /** @hidden */
  87849. _needNormals: boolean;
  87850. /** @hidden */
  87851. _needUVs: boolean;
  87852. [id: string]: any;
  87853. /**
  87854. * Specifies if the material needs to be re-calculated
  87855. */
  87856. get isDirty(): boolean;
  87857. /**
  87858. * Marks the material to indicate that it has been re-calculated
  87859. */
  87860. markAsProcessed(): void;
  87861. /**
  87862. * Marks the material to indicate that it needs to be re-calculated
  87863. */
  87864. markAsUnprocessed(): void;
  87865. /**
  87866. * Marks the material to indicate all of its defines need to be re-calculated
  87867. */
  87868. markAllAsDirty(): void;
  87869. /**
  87870. * Marks the material to indicate that image processing needs to be re-calculated
  87871. */
  87872. markAsImageProcessingDirty(): void;
  87873. /**
  87874. * Marks the material to indicate the lights need to be re-calculated
  87875. * @param disposed Defines whether the light is dirty due to dispose or not
  87876. */
  87877. markAsLightDirty(disposed?: boolean): void;
  87878. /**
  87879. * Marks the attribute state as changed
  87880. */
  87881. markAsAttributesDirty(): void;
  87882. /**
  87883. * Marks the texture state as changed
  87884. */
  87885. markAsTexturesDirty(): void;
  87886. /**
  87887. * Marks the fresnel state as changed
  87888. */
  87889. markAsFresnelDirty(): void;
  87890. /**
  87891. * Marks the misc state as changed
  87892. */
  87893. markAsMiscDirty(): void;
  87894. /**
  87895. * Rebuilds the material defines
  87896. */
  87897. rebuild(): void;
  87898. /**
  87899. * Specifies if two material defines are equal
  87900. * @param other - A material define instance to compare to
  87901. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  87902. */
  87903. isEqual(other: MaterialDefines): boolean;
  87904. /**
  87905. * Clones this instance's defines to another instance
  87906. * @param other - material defines to clone values to
  87907. */
  87908. cloneTo(other: MaterialDefines): void;
  87909. /**
  87910. * Resets the material define values
  87911. */
  87912. reset(): void;
  87913. /**
  87914. * Converts the material define values to a string
  87915. * @returns - String of material define information
  87916. */
  87917. toString(): string;
  87918. }
  87919. }
  87920. declare module BABYLON {
  87921. /**
  87922. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  87923. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  87924. * 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;
  87925. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  87926. */
  87927. export class ColorCurves {
  87928. private _dirty;
  87929. private _tempColor;
  87930. private _globalCurve;
  87931. private _highlightsCurve;
  87932. private _midtonesCurve;
  87933. private _shadowsCurve;
  87934. private _positiveCurve;
  87935. private _negativeCurve;
  87936. private _globalHue;
  87937. private _globalDensity;
  87938. private _globalSaturation;
  87939. private _globalExposure;
  87940. /**
  87941. * Gets the global Hue value.
  87942. * 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).
  87943. */
  87944. get globalHue(): number;
  87945. /**
  87946. * Sets the global Hue value.
  87947. * 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).
  87948. */
  87949. set globalHue(value: number);
  87950. /**
  87951. * Gets the global Density value.
  87952. * 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.
  87953. * Values less than zero provide a filter of opposite hue.
  87954. */
  87955. get globalDensity(): number;
  87956. /**
  87957. * Sets the global Density value.
  87958. * 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.
  87959. * Values less than zero provide a filter of opposite hue.
  87960. */
  87961. set globalDensity(value: number);
  87962. /**
  87963. * Gets the global Saturation value.
  87964. * 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.
  87965. */
  87966. get globalSaturation(): number;
  87967. /**
  87968. * Sets the global Saturation value.
  87969. * 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.
  87970. */
  87971. set globalSaturation(value: number);
  87972. /**
  87973. * Gets the global Exposure value.
  87974. * 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.
  87975. */
  87976. get globalExposure(): number;
  87977. /**
  87978. * Sets the global Exposure value.
  87979. * 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.
  87980. */
  87981. set globalExposure(value: number);
  87982. private _highlightsHue;
  87983. private _highlightsDensity;
  87984. private _highlightsSaturation;
  87985. private _highlightsExposure;
  87986. /**
  87987. * Gets the highlights Hue value.
  87988. * 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).
  87989. */
  87990. get highlightsHue(): number;
  87991. /**
  87992. * Sets the highlights Hue value.
  87993. * 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).
  87994. */
  87995. set highlightsHue(value: number);
  87996. /**
  87997. * Gets the highlights Density value.
  87998. * 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.
  87999. * Values less than zero provide a filter of opposite hue.
  88000. */
  88001. get highlightsDensity(): number;
  88002. /**
  88003. * Sets the highlights Density value.
  88004. * 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.
  88005. * Values less than zero provide a filter of opposite hue.
  88006. */
  88007. set highlightsDensity(value: number);
  88008. /**
  88009. * Gets the highlights Saturation value.
  88010. * 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.
  88011. */
  88012. get highlightsSaturation(): number;
  88013. /**
  88014. * Sets the highlights Saturation value.
  88015. * 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.
  88016. */
  88017. set highlightsSaturation(value: number);
  88018. /**
  88019. * Gets the highlights Exposure value.
  88020. * 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.
  88021. */
  88022. get highlightsExposure(): number;
  88023. /**
  88024. * Sets the highlights Exposure value.
  88025. * 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.
  88026. */
  88027. set highlightsExposure(value: number);
  88028. private _midtonesHue;
  88029. private _midtonesDensity;
  88030. private _midtonesSaturation;
  88031. private _midtonesExposure;
  88032. /**
  88033. * Gets the midtones Hue value.
  88034. * 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).
  88035. */
  88036. get midtonesHue(): number;
  88037. /**
  88038. * Sets the midtones Hue value.
  88039. * 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).
  88040. */
  88041. set midtonesHue(value: number);
  88042. /**
  88043. * Gets the midtones Density value.
  88044. * 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.
  88045. * Values less than zero provide a filter of opposite hue.
  88046. */
  88047. get midtonesDensity(): number;
  88048. /**
  88049. * Sets the midtones Density value.
  88050. * 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.
  88051. * Values less than zero provide a filter of opposite hue.
  88052. */
  88053. set midtonesDensity(value: number);
  88054. /**
  88055. * Gets the midtones Saturation value.
  88056. * 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.
  88057. */
  88058. get midtonesSaturation(): number;
  88059. /**
  88060. * Sets the midtones Saturation value.
  88061. * 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.
  88062. */
  88063. set midtonesSaturation(value: number);
  88064. /**
  88065. * Gets the midtones Exposure value.
  88066. * 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.
  88067. */
  88068. get midtonesExposure(): number;
  88069. /**
  88070. * Sets the midtones Exposure value.
  88071. * 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.
  88072. */
  88073. set midtonesExposure(value: number);
  88074. private _shadowsHue;
  88075. private _shadowsDensity;
  88076. private _shadowsSaturation;
  88077. private _shadowsExposure;
  88078. /**
  88079. * Gets the shadows Hue value.
  88080. * 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).
  88081. */
  88082. get shadowsHue(): number;
  88083. /**
  88084. * Sets the shadows Hue value.
  88085. * 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).
  88086. */
  88087. set shadowsHue(value: number);
  88088. /**
  88089. * Gets the shadows Density value.
  88090. * 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.
  88091. * Values less than zero provide a filter of opposite hue.
  88092. */
  88093. get shadowsDensity(): number;
  88094. /**
  88095. * Sets the shadows Density value.
  88096. * 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.
  88097. * Values less than zero provide a filter of opposite hue.
  88098. */
  88099. set shadowsDensity(value: number);
  88100. /**
  88101. * Gets the shadows Saturation value.
  88102. * 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.
  88103. */
  88104. get shadowsSaturation(): number;
  88105. /**
  88106. * Sets the shadows Saturation value.
  88107. * 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.
  88108. */
  88109. set shadowsSaturation(value: number);
  88110. /**
  88111. * Gets the shadows Exposure value.
  88112. * 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.
  88113. */
  88114. get shadowsExposure(): number;
  88115. /**
  88116. * Sets the shadows Exposure value.
  88117. * 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.
  88118. */
  88119. set shadowsExposure(value: number);
  88120. /**
  88121. * Returns the class name
  88122. * @returns The class name
  88123. */
  88124. getClassName(): string;
  88125. /**
  88126. * Binds the color curves to the shader.
  88127. * @param colorCurves The color curve to bind
  88128. * @param effect The effect to bind to
  88129. * @param positiveUniform The positive uniform shader parameter
  88130. * @param neutralUniform The neutral uniform shader parameter
  88131. * @param negativeUniform The negative uniform shader parameter
  88132. */
  88133. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88134. /**
  88135. * Prepare the list of uniforms associated with the ColorCurves effects.
  88136. * @param uniformsList The list of uniforms used in the effect
  88137. */
  88138. static PrepareUniforms(uniformsList: string[]): void;
  88139. /**
  88140. * Returns color grading data based on a hue, density, saturation and exposure value.
  88141. * @param filterHue The hue of the color filter.
  88142. * @param filterDensity The density of the color filter.
  88143. * @param saturation The saturation.
  88144. * @param exposure The exposure.
  88145. * @param result The result data container.
  88146. */
  88147. private getColorGradingDataToRef;
  88148. /**
  88149. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88150. * @param value The input slider value in range [-100,100].
  88151. * @returns Adjusted value.
  88152. */
  88153. private static applyColorGradingSliderNonlinear;
  88154. /**
  88155. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88156. * @param hue The hue (H) input.
  88157. * @param saturation The saturation (S) input.
  88158. * @param brightness The brightness (B) input.
  88159. * @result An RGBA color represented as Vector4.
  88160. */
  88161. private static fromHSBToRef;
  88162. /**
  88163. * Returns a value clamped between min and max
  88164. * @param value The value to clamp
  88165. * @param min The minimum of value
  88166. * @param max The maximum of value
  88167. * @returns The clamped value.
  88168. */
  88169. private static clamp;
  88170. /**
  88171. * Clones the current color curve instance.
  88172. * @return The cloned curves
  88173. */
  88174. clone(): ColorCurves;
  88175. /**
  88176. * Serializes the current color curve instance to a json representation.
  88177. * @return a JSON representation
  88178. */
  88179. serialize(): any;
  88180. /**
  88181. * Parses the color curve from a json representation.
  88182. * @param source the JSON source to parse
  88183. * @return The parsed curves
  88184. */
  88185. static Parse(source: any): ColorCurves;
  88186. }
  88187. }
  88188. declare module BABYLON {
  88189. /**
  88190. * Interface to follow in your material defines to integrate easily the
  88191. * Image proccessing functions.
  88192. * @hidden
  88193. */
  88194. export interface IImageProcessingConfigurationDefines {
  88195. IMAGEPROCESSING: boolean;
  88196. VIGNETTE: boolean;
  88197. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88198. VIGNETTEBLENDMODEOPAQUE: boolean;
  88199. TONEMAPPING: boolean;
  88200. TONEMAPPING_ACES: boolean;
  88201. CONTRAST: boolean;
  88202. EXPOSURE: boolean;
  88203. COLORCURVES: boolean;
  88204. COLORGRADING: boolean;
  88205. COLORGRADING3D: boolean;
  88206. SAMPLER3DGREENDEPTH: boolean;
  88207. SAMPLER3DBGRMAP: boolean;
  88208. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88209. }
  88210. /**
  88211. * @hidden
  88212. */
  88213. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88214. IMAGEPROCESSING: boolean;
  88215. VIGNETTE: boolean;
  88216. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88217. VIGNETTEBLENDMODEOPAQUE: boolean;
  88218. TONEMAPPING: boolean;
  88219. TONEMAPPING_ACES: boolean;
  88220. CONTRAST: boolean;
  88221. COLORCURVES: boolean;
  88222. COLORGRADING: boolean;
  88223. COLORGRADING3D: boolean;
  88224. SAMPLER3DGREENDEPTH: boolean;
  88225. SAMPLER3DBGRMAP: boolean;
  88226. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88227. EXPOSURE: boolean;
  88228. constructor();
  88229. }
  88230. /**
  88231. * This groups together the common properties used for image processing either in direct forward pass
  88232. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88233. * or not.
  88234. */
  88235. export class ImageProcessingConfiguration {
  88236. /**
  88237. * Default tone mapping applied in BabylonJS.
  88238. */
  88239. static readonly TONEMAPPING_STANDARD: number;
  88240. /**
  88241. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88242. * to other engines rendering to increase portability.
  88243. */
  88244. static readonly TONEMAPPING_ACES: number;
  88245. /**
  88246. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88247. */
  88248. colorCurves: Nullable<ColorCurves>;
  88249. private _colorCurvesEnabled;
  88250. /**
  88251. * Gets wether the color curves effect is enabled.
  88252. */
  88253. get colorCurvesEnabled(): boolean;
  88254. /**
  88255. * Sets wether the color curves effect is enabled.
  88256. */
  88257. set colorCurvesEnabled(value: boolean);
  88258. private _colorGradingTexture;
  88259. /**
  88260. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88261. */
  88262. get colorGradingTexture(): Nullable<BaseTexture>;
  88263. /**
  88264. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88265. */
  88266. set colorGradingTexture(value: Nullable<BaseTexture>);
  88267. private _colorGradingEnabled;
  88268. /**
  88269. * Gets wether the color grading effect is enabled.
  88270. */
  88271. get colorGradingEnabled(): boolean;
  88272. /**
  88273. * Sets wether the color grading effect is enabled.
  88274. */
  88275. set colorGradingEnabled(value: boolean);
  88276. private _colorGradingWithGreenDepth;
  88277. /**
  88278. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88279. */
  88280. get colorGradingWithGreenDepth(): boolean;
  88281. /**
  88282. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88283. */
  88284. set colorGradingWithGreenDepth(value: boolean);
  88285. private _colorGradingBGR;
  88286. /**
  88287. * Gets wether the color grading texture contains BGR values.
  88288. */
  88289. get colorGradingBGR(): boolean;
  88290. /**
  88291. * Sets wether the color grading texture contains BGR values.
  88292. */
  88293. set colorGradingBGR(value: boolean);
  88294. /** @hidden */
  88295. _exposure: number;
  88296. /**
  88297. * Gets the Exposure used in the effect.
  88298. */
  88299. get exposure(): number;
  88300. /**
  88301. * Sets the Exposure used in the effect.
  88302. */
  88303. set exposure(value: number);
  88304. private _toneMappingEnabled;
  88305. /**
  88306. * Gets wether the tone mapping effect is enabled.
  88307. */
  88308. get toneMappingEnabled(): boolean;
  88309. /**
  88310. * Sets wether the tone mapping effect is enabled.
  88311. */
  88312. set toneMappingEnabled(value: boolean);
  88313. private _toneMappingType;
  88314. /**
  88315. * Gets the type of tone mapping effect.
  88316. */
  88317. get toneMappingType(): number;
  88318. /**
  88319. * Sets the type of tone mapping effect used in BabylonJS.
  88320. */
  88321. set toneMappingType(value: number);
  88322. protected _contrast: number;
  88323. /**
  88324. * Gets the contrast used in the effect.
  88325. */
  88326. get contrast(): number;
  88327. /**
  88328. * Sets the contrast used in the effect.
  88329. */
  88330. set contrast(value: number);
  88331. /**
  88332. * Vignette stretch size.
  88333. */
  88334. vignetteStretch: number;
  88335. /**
  88336. * Vignette centre X Offset.
  88337. */
  88338. vignetteCentreX: number;
  88339. /**
  88340. * Vignette centre Y Offset.
  88341. */
  88342. vignetteCentreY: number;
  88343. /**
  88344. * Vignette weight or intensity of the vignette effect.
  88345. */
  88346. vignetteWeight: number;
  88347. /**
  88348. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88349. * if vignetteEnabled is set to true.
  88350. */
  88351. vignetteColor: Color4;
  88352. /**
  88353. * Camera field of view used by the Vignette effect.
  88354. */
  88355. vignetteCameraFov: number;
  88356. private _vignetteBlendMode;
  88357. /**
  88358. * Gets the vignette blend mode allowing different kind of effect.
  88359. */
  88360. get vignetteBlendMode(): number;
  88361. /**
  88362. * Sets the vignette blend mode allowing different kind of effect.
  88363. */
  88364. set vignetteBlendMode(value: number);
  88365. private _vignetteEnabled;
  88366. /**
  88367. * Gets wether the vignette effect is enabled.
  88368. */
  88369. get vignetteEnabled(): boolean;
  88370. /**
  88371. * Sets wether the vignette effect is enabled.
  88372. */
  88373. set vignetteEnabled(value: boolean);
  88374. private _applyByPostProcess;
  88375. /**
  88376. * Gets wether the image processing is applied through a post process or not.
  88377. */
  88378. get applyByPostProcess(): boolean;
  88379. /**
  88380. * Sets wether the image processing is applied through a post process or not.
  88381. */
  88382. set applyByPostProcess(value: boolean);
  88383. private _isEnabled;
  88384. /**
  88385. * Gets wether the image processing is enabled or not.
  88386. */
  88387. get isEnabled(): boolean;
  88388. /**
  88389. * Sets wether the image processing is enabled or not.
  88390. */
  88391. set isEnabled(value: boolean);
  88392. /**
  88393. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88394. */
  88395. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88396. /**
  88397. * Method called each time the image processing information changes requires to recompile the effect.
  88398. */
  88399. protected _updateParameters(): void;
  88400. /**
  88401. * Gets the current class name.
  88402. * @return "ImageProcessingConfiguration"
  88403. */
  88404. getClassName(): string;
  88405. /**
  88406. * Prepare the list of uniforms associated with the Image Processing effects.
  88407. * @param uniforms The list of uniforms used in the effect
  88408. * @param defines the list of defines currently in use
  88409. */
  88410. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88411. /**
  88412. * Prepare the list of samplers associated with the Image Processing effects.
  88413. * @param samplersList The list of uniforms used in the effect
  88414. * @param defines the list of defines currently in use
  88415. */
  88416. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88417. /**
  88418. * Prepare the list of defines associated to the shader.
  88419. * @param defines the list of defines to complete
  88420. * @param forPostProcess Define if we are currently in post process mode or not
  88421. */
  88422. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88423. /**
  88424. * Returns true if all the image processing information are ready.
  88425. * @returns True if ready, otherwise, false
  88426. */
  88427. isReady(): boolean;
  88428. /**
  88429. * Binds the image processing to the shader.
  88430. * @param effect The effect to bind to
  88431. * @param overrideAspectRatio Override the aspect ratio of the effect
  88432. */
  88433. bind(effect: Effect, overrideAspectRatio?: number): void;
  88434. /**
  88435. * Clones the current image processing instance.
  88436. * @return The cloned image processing
  88437. */
  88438. clone(): ImageProcessingConfiguration;
  88439. /**
  88440. * Serializes the current image processing instance to a json representation.
  88441. * @return a JSON representation
  88442. */
  88443. serialize(): any;
  88444. /**
  88445. * Parses the image processing from a json representation.
  88446. * @param source the JSON source to parse
  88447. * @return The parsed image processing
  88448. */
  88449. static Parse(source: any): ImageProcessingConfiguration;
  88450. private static _VIGNETTEMODE_MULTIPLY;
  88451. private static _VIGNETTEMODE_OPAQUE;
  88452. /**
  88453. * Used to apply the vignette as a mix with the pixel color.
  88454. */
  88455. static get VIGNETTEMODE_MULTIPLY(): number;
  88456. /**
  88457. * Used to apply the vignette as a replacement of the pixel color.
  88458. */
  88459. static get VIGNETTEMODE_OPAQUE(): number;
  88460. }
  88461. }
  88462. declare module BABYLON {
  88463. /** @hidden */
  88464. export var postprocessVertexShader: {
  88465. name: string;
  88466. shader: string;
  88467. };
  88468. }
  88469. declare module BABYLON {
  88470. interface ThinEngine {
  88471. /**
  88472. * Creates a new render target texture
  88473. * @param size defines the size of the texture
  88474. * @param options defines the options used to create the texture
  88475. * @returns a new render target texture stored in an InternalTexture
  88476. */
  88477. createRenderTargetTexture(size: number | {
  88478. width: number;
  88479. height: number;
  88480. layers?: number;
  88481. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88482. /**
  88483. * Creates a depth stencil texture.
  88484. * This is only available in WebGL 2 or with the depth texture extension available.
  88485. * @param size The size of face edge in the texture.
  88486. * @param options The options defining the texture.
  88487. * @returns The texture
  88488. */
  88489. createDepthStencilTexture(size: number | {
  88490. width: number;
  88491. height: number;
  88492. layers?: number;
  88493. }, options: DepthTextureCreationOptions): InternalTexture;
  88494. /** @hidden */
  88495. _createDepthStencilTexture(size: number | {
  88496. width: number;
  88497. height: number;
  88498. layers?: number;
  88499. }, options: DepthTextureCreationOptions): InternalTexture;
  88500. }
  88501. }
  88502. declare module BABYLON {
  88503. /**
  88504. * Defines the kind of connection point for node based material
  88505. */
  88506. export enum NodeMaterialBlockConnectionPointTypes {
  88507. /** Float */
  88508. Float = 1,
  88509. /** Int */
  88510. Int = 2,
  88511. /** Vector2 */
  88512. Vector2 = 4,
  88513. /** Vector3 */
  88514. Vector3 = 8,
  88515. /** Vector4 */
  88516. Vector4 = 16,
  88517. /** Color3 */
  88518. Color3 = 32,
  88519. /** Color4 */
  88520. Color4 = 64,
  88521. /** Matrix */
  88522. Matrix = 128,
  88523. /** Custom object */
  88524. Object = 256,
  88525. /** Detect type based on connection */
  88526. AutoDetect = 1024,
  88527. /** Output type that will be defined by input type */
  88528. BasedOnInput = 2048
  88529. }
  88530. }
  88531. declare module BABYLON {
  88532. /**
  88533. * Enum used to define the target of a block
  88534. */
  88535. export enum NodeMaterialBlockTargets {
  88536. /** Vertex shader */
  88537. Vertex = 1,
  88538. /** Fragment shader */
  88539. Fragment = 2,
  88540. /** Neutral */
  88541. Neutral = 4,
  88542. /** Vertex and Fragment */
  88543. VertexAndFragment = 3
  88544. }
  88545. }
  88546. declare module BABYLON {
  88547. /**
  88548. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  88549. */
  88550. export enum NodeMaterialBlockConnectionPointMode {
  88551. /** Value is an uniform */
  88552. Uniform = 0,
  88553. /** Value is a mesh attribute */
  88554. Attribute = 1,
  88555. /** Value is a varying between vertex and fragment shaders */
  88556. Varying = 2,
  88557. /** Mode is undefined */
  88558. Undefined = 3
  88559. }
  88560. }
  88561. declare module BABYLON {
  88562. /**
  88563. * Enum used to define system values e.g. values automatically provided by the system
  88564. */
  88565. export enum NodeMaterialSystemValues {
  88566. /** World */
  88567. World = 1,
  88568. /** View */
  88569. View = 2,
  88570. /** Projection */
  88571. Projection = 3,
  88572. /** ViewProjection */
  88573. ViewProjection = 4,
  88574. /** WorldView */
  88575. WorldView = 5,
  88576. /** WorldViewProjection */
  88577. WorldViewProjection = 6,
  88578. /** CameraPosition */
  88579. CameraPosition = 7,
  88580. /** Fog Color */
  88581. FogColor = 8,
  88582. /** Delta time */
  88583. DeltaTime = 9
  88584. }
  88585. }
  88586. declare module BABYLON {
  88587. /** Defines supported spaces */
  88588. export enum Space {
  88589. /** Local (object) space */
  88590. LOCAL = 0,
  88591. /** World space */
  88592. WORLD = 1,
  88593. /** Bone space */
  88594. BONE = 2
  88595. }
  88596. /** Defines the 3 main axes */
  88597. export class Axis {
  88598. /** X axis */
  88599. static X: Vector3;
  88600. /** Y axis */
  88601. static Y: Vector3;
  88602. /** Z axis */
  88603. static Z: Vector3;
  88604. }
  88605. }
  88606. declare module BABYLON {
  88607. /**
  88608. * Represents a camera frustum
  88609. */
  88610. export class Frustum {
  88611. /**
  88612. * Gets the planes representing the frustum
  88613. * @param transform matrix to be applied to the returned planes
  88614. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  88615. */
  88616. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  88617. /**
  88618. * Gets the near frustum plane transformed by the transform matrix
  88619. * @param transform transformation matrix to be applied to the resulting frustum plane
  88620. * @param frustumPlane the resuling frustum plane
  88621. */
  88622. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88623. /**
  88624. * Gets the far frustum plane transformed by the transform matrix
  88625. * @param transform transformation matrix to be applied to the resulting frustum plane
  88626. * @param frustumPlane the resuling frustum plane
  88627. */
  88628. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88629. /**
  88630. * Gets the left frustum plane transformed by the transform matrix
  88631. * @param transform transformation matrix to be applied to the resulting frustum plane
  88632. * @param frustumPlane the resuling frustum plane
  88633. */
  88634. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88635. /**
  88636. * Gets the right frustum plane transformed by the transform matrix
  88637. * @param transform transformation matrix to be applied to the resulting frustum plane
  88638. * @param frustumPlane the resuling frustum plane
  88639. */
  88640. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88641. /**
  88642. * Gets the top frustum plane transformed by the transform matrix
  88643. * @param transform transformation matrix to be applied to the resulting frustum plane
  88644. * @param frustumPlane the resuling frustum plane
  88645. */
  88646. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88647. /**
  88648. * Gets the bottom frustum plane transformed by the transform matrix
  88649. * @param transform transformation matrix to be applied to the resulting frustum plane
  88650. * @param frustumPlane the resuling frustum plane
  88651. */
  88652. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88653. /**
  88654. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  88655. * @param transform transformation matrix to be applied to the resulting frustum planes
  88656. * @param frustumPlanes the resuling frustum planes
  88657. */
  88658. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  88659. }
  88660. }
  88661. declare module BABYLON {
  88662. /**
  88663. * Interface for the size containing width and height
  88664. */
  88665. export interface ISize {
  88666. /**
  88667. * Width
  88668. */
  88669. width: number;
  88670. /**
  88671. * Heighht
  88672. */
  88673. height: number;
  88674. }
  88675. /**
  88676. * Size containing widht and height
  88677. */
  88678. export class Size implements ISize {
  88679. /**
  88680. * Width
  88681. */
  88682. width: number;
  88683. /**
  88684. * Height
  88685. */
  88686. height: number;
  88687. /**
  88688. * Creates a Size object from the given width and height (floats).
  88689. * @param width width of the new size
  88690. * @param height height of the new size
  88691. */
  88692. constructor(width: number, height: number);
  88693. /**
  88694. * Returns a string with the Size width and height
  88695. * @returns a string with the Size width and height
  88696. */
  88697. toString(): string;
  88698. /**
  88699. * "Size"
  88700. * @returns the string "Size"
  88701. */
  88702. getClassName(): string;
  88703. /**
  88704. * Returns the Size hash code.
  88705. * @returns a hash code for a unique width and height
  88706. */
  88707. getHashCode(): number;
  88708. /**
  88709. * Updates the current size from the given one.
  88710. * @param src the given size
  88711. */
  88712. copyFrom(src: Size): void;
  88713. /**
  88714. * Updates in place the current Size from the given floats.
  88715. * @param width width of the new size
  88716. * @param height height of the new size
  88717. * @returns the updated Size.
  88718. */
  88719. copyFromFloats(width: number, height: number): Size;
  88720. /**
  88721. * Updates in place the current Size from the given floats.
  88722. * @param width width to set
  88723. * @param height height to set
  88724. * @returns the updated Size.
  88725. */
  88726. set(width: number, height: number): Size;
  88727. /**
  88728. * Multiplies the width and height by numbers
  88729. * @param w factor to multiple the width by
  88730. * @param h factor to multiple the height by
  88731. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  88732. */
  88733. multiplyByFloats(w: number, h: number): Size;
  88734. /**
  88735. * Clones the size
  88736. * @returns a new Size copied from the given one.
  88737. */
  88738. clone(): Size;
  88739. /**
  88740. * True if the current Size and the given one width and height are strictly equal.
  88741. * @param other the other size to compare against
  88742. * @returns True if the current Size and the given one width and height are strictly equal.
  88743. */
  88744. equals(other: Size): boolean;
  88745. /**
  88746. * The surface of the Size : width * height (float).
  88747. */
  88748. get surface(): number;
  88749. /**
  88750. * Create a new size of zero
  88751. * @returns a new Size set to (0.0, 0.0)
  88752. */
  88753. static Zero(): Size;
  88754. /**
  88755. * Sums the width and height of two sizes
  88756. * @param otherSize size to add to this size
  88757. * @returns a new Size set as the addition result of the current Size and the given one.
  88758. */
  88759. add(otherSize: Size): Size;
  88760. /**
  88761. * Subtracts the width and height of two
  88762. * @param otherSize size to subtract to this size
  88763. * @returns a new Size set as the subtraction result of the given one from the current Size.
  88764. */
  88765. subtract(otherSize: Size): Size;
  88766. /**
  88767. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  88768. * @param start starting size to lerp between
  88769. * @param end end size to lerp between
  88770. * @param amount amount to lerp between the start and end values
  88771. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  88772. */
  88773. static Lerp(start: Size, end: Size, amount: number): Size;
  88774. }
  88775. }
  88776. declare module BABYLON {
  88777. /**
  88778. * Contains position and normal vectors for a vertex
  88779. */
  88780. export class PositionNormalVertex {
  88781. /** the position of the vertex (defaut: 0,0,0) */
  88782. position: Vector3;
  88783. /** the normal of the vertex (defaut: 0,1,0) */
  88784. normal: Vector3;
  88785. /**
  88786. * Creates a PositionNormalVertex
  88787. * @param position the position of the vertex (defaut: 0,0,0)
  88788. * @param normal the normal of the vertex (defaut: 0,1,0)
  88789. */
  88790. constructor(
  88791. /** the position of the vertex (defaut: 0,0,0) */
  88792. position?: Vector3,
  88793. /** the normal of the vertex (defaut: 0,1,0) */
  88794. normal?: Vector3);
  88795. /**
  88796. * Clones the PositionNormalVertex
  88797. * @returns the cloned PositionNormalVertex
  88798. */
  88799. clone(): PositionNormalVertex;
  88800. }
  88801. /**
  88802. * Contains position, normal and uv vectors for a vertex
  88803. */
  88804. export class PositionNormalTextureVertex {
  88805. /** the position of the vertex (defaut: 0,0,0) */
  88806. position: Vector3;
  88807. /** the normal of the vertex (defaut: 0,1,0) */
  88808. normal: Vector3;
  88809. /** the uv of the vertex (default: 0,0) */
  88810. uv: Vector2;
  88811. /**
  88812. * Creates a PositionNormalTextureVertex
  88813. * @param position the position of the vertex (defaut: 0,0,0)
  88814. * @param normal the normal of the vertex (defaut: 0,1,0)
  88815. * @param uv the uv of the vertex (default: 0,0)
  88816. */
  88817. constructor(
  88818. /** the position of the vertex (defaut: 0,0,0) */
  88819. position?: Vector3,
  88820. /** the normal of the vertex (defaut: 0,1,0) */
  88821. normal?: Vector3,
  88822. /** the uv of the vertex (default: 0,0) */
  88823. uv?: Vector2);
  88824. /**
  88825. * Clones the PositionNormalTextureVertex
  88826. * @returns the cloned PositionNormalTextureVertex
  88827. */
  88828. clone(): PositionNormalTextureVertex;
  88829. }
  88830. }
  88831. declare module BABYLON {
  88832. /**
  88833. * Enum defining the type of animations supported by InputBlock
  88834. */
  88835. export enum AnimatedInputBlockTypes {
  88836. /** No animation */
  88837. None = 0,
  88838. /** Time based animation. Will only work for floats */
  88839. Time = 1
  88840. }
  88841. }
  88842. declare module BABYLON {
  88843. /**
  88844. * Interface describing all the common properties and methods a shadow light needs to implement.
  88845. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  88846. * as well as binding the different shadow properties to the effects.
  88847. */
  88848. export interface IShadowLight extends Light {
  88849. /**
  88850. * The light id in the scene (used in scene.findLighById for instance)
  88851. */
  88852. id: string;
  88853. /**
  88854. * The position the shdow will be casted from.
  88855. */
  88856. position: Vector3;
  88857. /**
  88858. * In 2d mode (needCube being false), the direction used to cast the shadow.
  88859. */
  88860. direction: Vector3;
  88861. /**
  88862. * The transformed position. Position of the light in world space taking parenting in account.
  88863. */
  88864. transformedPosition: Vector3;
  88865. /**
  88866. * The transformed direction. Direction of the light in world space taking parenting in account.
  88867. */
  88868. transformedDirection: Vector3;
  88869. /**
  88870. * The friendly name of the light in the scene.
  88871. */
  88872. name: string;
  88873. /**
  88874. * Defines the shadow projection clipping minimum z value.
  88875. */
  88876. shadowMinZ: number;
  88877. /**
  88878. * Defines the shadow projection clipping maximum z value.
  88879. */
  88880. shadowMaxZ: number;
  88881. /**
  88882. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88883. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88884. */
  88885. computeTransformedInformation(): boolean;
  88886. /**
  88887. * Gets the scene the light belongs to.
  88888. * @returns The scene
  88889. */
  88890. getScene(): Scene;
  88891. /**
  88892. * Callback defining a custom Projection Matrix Builder.
  88893. * This can be used to override the default projection matrix computation.
  88894. */
  88895. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88896. /**
  88897. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88898. * @param matrix The materix to updated with the projection information
  88899. * @param viewMatrix The transform matrix of the light
  88900. * @param renderList The list of mesh to render in the map
  88901. * @returns The current light
  88902. */
  88903. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88904. /**
  88905. * Gets the current depth scale used in ESM.
  88906. * @returns The scale
  88907. */
  88908. getDepthScale(): number;
  88909. /**
  88910. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88911. * @returns true if a cube texture needs to be use
  88912. */
  88913. needCube(): boolean;
  88914. /**
  88915. * Detects if the projection matrix requires to be recomputed this frame.
  88916. * @returns true if it requires to be recomputed otherwise, false.
  88917. */
  88918. needProjectionMatrixCompute(): boolean;
  88919. /**
  88920. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88921. */
  88922. forceProjectionMatrixCompute(): void;
  88923. /**
  88924. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88925. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88926. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88927. */
  88928. getShadowDirection(faceIndex?: number): Vector3;
  88929. /**
  88930. * Gets the minZ used for shadow according to both the scene and the light.
  88931. * @param activeCamera The camera we are returning the min for
  88932. * @returns the depth min z
  88933. */
  88934. getDepthMinZ(activeCamera: Camera): number;
  88935. /**
  88936. * Gets the maxZ used for shadow according to both the scene and the light.
  88937. * @param activeCamera The camera we are returning the max for
  88938. * @returns the depth max z
  88939. */
  88940. getDepthMaxZ(activeCamera: Camera): number;
  88941. }
  88942. /**
  88943. * Base implementation IShadowLight
  88944. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  88945. */
  88946. export abstract class ShadowLight extends Light implements IShadowLight {
  88947. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  88948. protected _position: Vector3;
  88949. protected _setPosition(value: Vector3): void;
  88950. /**
  88951. * Sets the position the shadow will be casted from. Also use as the light position for both
  88952. * point and spot lights.
  88953. */
  88954. get position(): Vector3;
  88955. /**
  88956. * Sets the position the shadow will be casted from. Also use as the light position for both
  88957. * point and spot lights.
  88958. */
  88959. set position(value: Vector3);
  88960. protected _direction: Vector3;
  88961. protected _setDirection(value: Vector3): void;
  88962. /**
  88963. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  88964. * Also use as the light direction on spot and directional lights.
  88965. */
  88966. get direction(): Vector3;
  88967. /**
  88968. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  88969. * Also use as the light direction on spot and directional lights.
  88970. */
  88971. set direction(value: Vector3);
  88972. protected _shadowMinZ: number;
  88973. /**
  88974. * Gets the shadow projection clipping minimum z value.
  88975. */
  88976. get shadowMinZ(): number;
  88977. /**
  88978. * Sets the shadow projection clipping minimum z value.
  88979. */
  88980. set shadowMinZ(value: number);
  88981. protected _shadowMaxZ: number;
  88982. /**
  88983. * Sets the shadow projection clipping maximum z value.
  88984. */
  88985. get shadowMaxZ(): number;
  88986. /**
  88987. * Gets the shadow projection clipping maximum z value.
  88988. */
  88989. set shadowMaxZ(value: number);
  88990. /**
  88991. * Callback defining a custom Projection Matrix Builder.
  88992. * This can be used to override the default projection matrix computation.
  88993. */
  88994. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88995. /**
  88996. * The transformed position. Position of the light in world space taking parenting in account.
  88997. */
  88998. transformedPosition: Vector3;
  88999. /**
  89000. * The transformed direction. Direction of the light in world space taking parenting in account.
  89001. */
  89002. transformedDirection: Vector3;
  89003. private _needProjectionMatrixCompute;
  89004. /**
  89005. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89006. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89007. */
  89008. computeTransformedInformation(): boolean;
  89009. /**
  89010. * Return the depth scale used for the shadow map.
  89011. * @returns the depth scale.
  89012. */
  89013. getDepthScale(): number;
  89014. /**
  89015. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89016. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89017. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89018. */
  89019. getShadowDirection(faceIndex?: number): Vector3;
  89020. /**
  89021. * Returns the ShadowLight absolute position in the World.
  89022. * @returns the position vector in world space
  89023. */
  89024. getAbsolutePosition(): Vector3;
  89025. /**
  89026. * Sets the ShadowLight direction toward the passed target.
  89027. * @param target The point to target in local space
  89028. * @returns the updated ShadowLight direction
  89029. */
  89030. setDirectionToTarget(target: Vector3): Vector3;
  89031. /**
  89032. * Returns the light rotation in euler definition.
  89033. * @returns the x y z rotation in local space.
  89034. */
  89035. getRotation(): Vector3;
  89036. /**
  89037. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89038. * @returns true if a cube texture needs to be use
  89039. */
  89040. needCube(): boolean;
  89041. /**
  89042. * Detects if the projection matrix requires to be recomputed this frame.
  89043. * @returns true if it requires to be recomputed otherwise, false.
  89044. */
  89045. needProjectionMatrixCompute(): boolean;
  89046. /**
  89047. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89048. */
  89049. forceProjectionMatrixCompute(): void;
  89050. /** @hidden */
  89051. _initCache(): void;
  89052. /** @hidden */
  89053. _isSynchronized(): boolean;
  89054. /**
  89055. * Computes the world matrix of the node
  89056. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89057. * @returns the world matrix
  89058. */
  89059. computeWorldMatrix(force?: boolean): Matrix;
  89060. /**
  89061. * Gets the minZ used for shadow according to both the scene and the light.
  89062. * @param activeCamera The camera we are returning the min for
  89063. * @returns the depth min z
  89064. */
  89065. getDepthMinZ(activeCamera: Camera): number;
  89066. /**
  89067. * Gets the maxZ used for shadow according to both the scene and the light.
  89068. * @param activeCamera The camera we are returning the max for
  89069. * @returns the depth max z
  89070. */
  89071. getDepthMaxZ(activeCamera: Camera): number;
  89072. /**
  89073. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89074. * @param matrix The materix to updated with the projection information
  89075. * @param viewMatrix The transform matrix of the light
  89076. * @param renderList The list of mesh to render in the map
  89077. * @returns The current light
  89078. */
  89079. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89080. }
  89081. }
  89082. declare module BABYLON {
  89083. /** @hidden */
  89084. export var packingFunctions: {
  89085. name: string;
  89086. shader: string;
  89087. };
  89088. }
  89089. declare module BABYLON {
  89090. /** @hidden */
  89091. export var bayerDitherFunctions: {
  89092. name: string;
  89093. shader: string;
  89094. };
  89095. }
  89096. declare module BABYLON {
  89097. /** @hidden */
  89098. export var shadowMapFragmentDeclaration: {
  89099. name: string;
  89100. shader: string;
  89101. };
  89102. }
  89103. declare module BABYLON {
  89104. /** @hidden */
  89105. export var clipPlaneFragmentDeclaration: {
  89106. name: string;
  89107. shader: string;
  89108. };
  89109. }
  89110. declare module BABYLON {
  89111. /** @hidden */
  89112. export var clipPlaneFragment: {
  89113. name: string;
  89114. shader: string;
  89115. };
  89116. }
  89117. declare module BABYLON {
  89118. /** @hidden */
  89119. export var shadowMapFragment: {
  89120. name: string;
  89121. shader: string;
  89122. };
  89123. }
  89124. declare module BABYLON {
  89125. /** @hidden */
  89126. export var shadowMapPixelShader: {
  89127. name: string;
  89128. shader: string;
  89129. };
  89130. }
  89131. declare module BABYLON {
  89132. /** @hidden */
  89133. export var bonesDeclaration: {
  89134. name: string;
  89135. shader: string;
  89136. };
  89137. }
  89138. declare module BABYLON {
  89139. /** @hidden */
  89140. export var morphTargetsVertexGlobalDeclaration: {
  89141. name: string;
  89142. shader: string;
  89143. };
  89144. }
  89145. declare module BABYLON {
  89146. /** @hidden */
  89147. export var morphTargetsVertexDeclaration: {
  89148. name: string;
  89149. shader: string;
  89150. };
  89151. }
  89152. declare module BABYLON {
  89153. /** @hidden */
  89154. export var instancesDeclaration: {
  89155. name: string;
  89156. shader: string;
  89157. };
  89158. }
  89159. declare module BABYLON {
  89160. /** @hidden */
  89161. export var helperFunctions: {
  89162. name: string;
  89163. shader: string;
  89164. };
  89165. }
  89166. declare module BABYLON {
  89167. /** @hidden */
  89168. export var shadowMapVertexDeclaration: {
  89169. name: string;
  89170. shader: string;
  89171. };
  89172. }
  89173. declare module BABYLON {
  89174. /** @hidden */
  89175. export var clipPlaneVertexDeclaration: {
  89176. name: string;
  89177. shader: string;
  89178. };
  89179. }
  89180. declare module BABYLON {
  89181. /** @hidden */
  89182. export var morphTargetsVertex: {
  89183. name: string;
  89184. shader: string;
  89185. };
  89186. }
  89187. declare module BABYLON {
  89188. /** @hidden */
  89189. export var instancesVertex: {
  89190. name: string;
  89191. shader: string;
  89192. };
  89193. }
  89194. declare module BABYLON {
  89195. /** @hidden */
  89196. export var bonesVertex: {
  89197. name: string;
  89198. shader: string;
  89199. };
  89200. }
  89201. declare module BABYLON {
  89202. /** @hidden */
  89203. export var shadowMapVertexNormalBias: {
  89204. name: string;
  89205. shader: string;
  89206. };
  89207. }
  89208. declare module BABYLON {
  89209. /** @hidden */
  89210. export var shadowMapVertexMetric: {
  89211. name: string;
  89212. shader: string;
  89213. };
  89214. }
  89215. declare module BABYLON {
  89216. /** @hidden */
  89217. export var clipPlaneVertex: {
  89218. name: string;
  89219. shader: string;
  89220. };
  89221. }
  89222. declare module BABYLON {
  89223. /** @hidden */
  89224. export var shadowMapVertexShader: {
  89225. name: string;
  89226. shader: string;
  89227. };
  89228. }
  89229. declare module BABYLON {
  89230. /** @hidden */
  89231. export var depthBoxBlurPixelShader: {
  89232. name: string;
  89233. shader: string;
  89234. };
  89235. }
  89236. declare module BABYLON {
  89237. /** @hidden */
  89238. export var shadowMapFragmentSoftTransparentShadow: {
  89239. name: string;
  89240. shader: string;
  89241. };
  89242. }
  89243. declare module BABYLON {
  89244. /**
  89245. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  89246. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  89247. */
  89248. export class EffectFallbacks implements IEffectFallbacks {
  89249. private _defines;
  89250. private _currentRank;
  89251. private _maxRank;
  89252. private _mesh;
  89253. /**
  89254. * Removes the fallback from the bound mesh.
  89255. */
  89256. unBindMesh(): void;
  89257. /**
  89258. * Adds a fallback on the specified property.
  89259. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89260. * @param define The name of the define in the shader
  89261. */
  89262. addFallback(rank: number, define: string): void;
  89263. /**
  89264. * Sets the mesh to use CPU skinning when needing to fallback.
  89265. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89266. * @param mesh The mesh to use the fallbacks.
  89267. */
  89268. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  89269. /**
  89270. * Checks to see if more fallbacks are still availible.
  89271. */
  89272. get hasMoreFallbacks(): boolean;
  89273. /**
  89274. * Removes the defines that should be removed when falling back.
  89275. * @param currentDefines defines the current define statements for the shader.
  89276. * @param effect defines the current effect we try to compile
  89277. * @returns The resulting defines with defines of the current rank removed.
  89278. */
  89279. reduce(currentDefines: string, effect: Effect): string;
  89280. }
  89281. }
  89282. declare module BABYLON {
  89283. /**
  89284. * Interface used to define Action
  89285. */
  89286. export interface IAction {
  89287. /**
  89288. * Trigger for the action
  89289. */
  89290. trigger: number;
  89291. /** Options of the trigger */
  89292. triggerOptions: any;
  89293. /**
  89294. * Gets the trigger parameters
  89295. * @returns the trigger parameters
  89296. */
  89297. getTriggerParameter(): any;
  89298. /**
  89299. * Internal only - executes current action event
  89300. * @hidden
  89301. */
  89302. _executeCurrent(evt?: ActionEvent): void;
  89303. /**
  89304. * Serialize placeholder for child classes
  89305. * @param parent of child
  89306. * @returns the serialized object
  89307. */
  89308. serialize(parent: any): any;
  89309. /**
  89310. * Internal only
  89311. * @hidden
  89312. */
  89313. _prepare(): void;
  89314. /**
  89315. * Internal only - manager for action
  89316. * @hidden
  89317. */
  89318. _actionManager: Nullable<AbstractActionManager>;
  89319. /**
  89320. * Adds action to chain of actions, may be a DoNothingAction
  89321. * @param action defines the next action to execute
  89322. * @returns The action passed in
  89323. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89324. */
  89325. then(action: IAction): IAction;
  89326. }
  89327. /**
  89328. * The action to be carried out following a trigger
  89329. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  89330. */
  89331. export class Action implements IAction {
  89332. /** the trigger, with or without parameters, for the action */
  89333. triggerOptions: any;
  89334. /**
  89335. * Trigger for the action
  89336. */
  89337. trigger: number;
  89338. /**
  89339. * Internal only - manager for action
  89340. * @hidden
  89341. */
  89342. _actionManager: ActionManager;
  89343. private _nextActiveAction;
  89344. private _child;
  89345. private _condition?;
  89346. private _triggerParameter;
  89347. /**
  89348. * An event triggered prior to action being executed.
  89349. */
  89350. onBeforeExecuteObservable: Observable<Action>;
  89351. /**
  89352. * Creates a new Action
  89353. * @param triggerOptions the trigger, with or without parameters, for the action
  89354. * @param condition an optional determinant of action
  89355. */
  89356. constructor(
  89357. /** the trigger, with or without parameters, for the action */
  89358. triggerOptions: any, condition?: Condition);
  89359. /**
  89360. * Internal only
  89361. * @hidden
  89362. */
  89363. _prepare(): void;
  89364. /**
  89365. * Gets the trigger parameters
  89366. * @returns the trigger parameters
  89367. */
  89368. getTriggerParameter(): any;
  89369. /**
  89370. * Internal only - executes current action event
  89371. * @hidden
  89372. */
  89373. _executeCurrent(evt?: ActionEvent): void;
  89374. /**
  89375. * Execute placeholder for child classes
  89376. * @param evt optional action event
  89377. */
  89378. execute(evt?: ActionEvent): void;
  89379. /**
  89380. * Skips to next active action
  89381. */
  89382. skipToNextActiveAction(): void;
  89383. /**
  89384. * Adds action to chain of actions, may be a DoNothingAction
  89385. * @param action defines the next action to execute
  89386. * @returns The action passed in
  89387. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89388. */
  89389. then(action: Action): Action;
  89390. /**
  89391. * Internal only
  89392. * @hidden
  89393. */
  89394. _getProperty(propertyPath: string): string;
  89395. /**
  89396. * Internal only
  89397. * @hidden
  89398. */
  89399. _getEffectiveTarget(target: any, propertyPath: string): any;
  89400. /**
  89401. * Serialize placeholder for child classes
  89402. * @param parent of child
  89403. * @returns the serialized object
  89404. */
  89405. serialize(parent: any): any;
  89406. /**
  89407. * Internal only called by serialize
  89408. * @hidden
  89409. */
  89410. protected _serialize(serializedAction: any, parent?: any): any;
  89411. /**
  89412. * Internal only
  89413. * @hidden
  89414. */
  89415. static _SerializeValueAsString: (value: any) => string;
  89416. /**
  89417. * Internal only
  89418. * @hidden
  89419. */
  89420. static _GetTargetProperty: (target: Scene | Node) => {
  89421. name: string;
  89422. targetType: string;
  89423. value: string;
  89424. };
  89425. }
  89426. }
  89427. declare module BABYLON {
  89428. /**
  89429. * A Condition applied to an Action
  89430. */
  89431. export class Condition {
  89432. /**
  89433. * Internal only - manager for action
  89434. * @hidden
  89435. */
  89436. _actionManager: ActionManager;
  89437. /**
  89438. * Internal only
  89439. * @hidden
  89440. */
  89441. _evaluationId: number;
  89442. /**
  89443. * Internal only
  89444. * @hidden
  89445. */
  89446. _currentResult: boolean;
  89447. /**
  89448. * Creates a new Condition
  89449. * @param actionManager the manager of the action the condition is applied to
  89450. */
  89451. constructor(actionManager: ActionManager);
  89452. /**
  89453. * Check if the current condition is valid
  89454. * @returns a boolean
  89455. */
  89456. isValid(): boolean;
  89457. /**
  89458. * Internal only
  89459. * @hidden
  89460. */
  89461. _getProperty(propertyPath: string): string;
  89462. /**
  89463. * Internal only
  89464. * @hidden
  89465. */
  89466. _getEffectiveTarget(target: any, propertyPath: string): any;
  89467. /**
  89468. * Serialize placeholder for child classes
  89469. * @returns the serialized object
  89470. */
  89471. serialize(): any;
  89472. /**
  89473. * Internal only
  89474. * @hidden
  89475. */
  89476. protected _serialize(serializedCondition: any): any;
  89477. }
  89478. /**
  89479. * Defines specific conditional operators as extensions of Condition
  89480. */
  89481. export class ValueCondition extends Condition {
  89482. /** path to specify the property of the target the conditional operator uses */
  89483. propertyPath: string;
  89484. /** the value compared by the conditional operator against the current value of the property */
  89485. value: any;
  89486. /** the conditional operator, default ValueCondition.IsEqual */
  89487. operator: number;
  89488. /**
  89489. * Internal only
  89490. * @hidden
  89491. */
  89492. private static _IsEqual;
  89493. /**
  89494. * Internal only
  89495. * @hidden
  89496. */
  89497. private static _IsDifferent;
  89498. /**
  89499. * Internal only
  89500. * @hidden
  89501. */
  89502. private static _IsGreater;
  89503. /**
  89504. * Internal only
  89505. * @hidden
  89506. */
  89507. private static _IsLesser;
  89508. /**
  89509. * returns the number for IsEqual
  89510. */
  89511. static get IsEqual(): number;
  89512. /**
  89513. * Returns the number for IsDifferent
  89514. */
  89515. static get IsDifferent(): number;
  89516. /**
  89517. * Returns the number for IsGreater
  89518. */
  89519. static get IsGreater(): number;
  89520. /**
  89521. * Returns the number for IsLesser
  89522. */
  89523. static get IsLesser(): number;
  89524. /**
  89525. * Internal only The action manager for the condition
  89526. * @hidden
  89527. */
  89528. _actionManager: ActionManager;
  89529. /**
  89530. * Internal only
  89531. * @hidden
  89532. */
  89533. private _target;
  89534. /**
  89535. * Internal only
  89536. * @hidden
  89537. */
  89538. private _effectiveTarget;
  89539. /**
  89540. * Internal only
  89541. * @hidden
  89542. */
  89543. private _property;
  89544. /**
  89545. * Creates a new ValueCondition
  89546. * @param actionManager manager for the action the condition applies to
  89547. * @param target for the action
  89548. * @param propertyPath path to specify the property of the target the conditional operator uses
  89549. * @param value the value compared by the conditional operator against the current value of the property
  89550. * @param operator the conditional operator, default ValueCondition.IsEqual
  89551. */
  89552. constructor(actionManager: ActionManager, target: any,
  89553. /** path to specify the property of the target the conditional operator uses */
  89554. propertyPath: string,
  89555. /** the value compared by the conditional operator against the current value of the property */
  89556. value: any,
  89557. /** the conditional operator, default ValueCondition.IsEqual */
  89558. operator?: number);
  89559. /**
  89560. * Compares the given value with the property value for the specified conditional operator
  89561. * @returns the result of the comparison
  89562. */
  89563. isValid(): boolean;
  89564. /**
  89565. * Serialize the ValueCondition into a JSON compatible object
  89566. * @returns serialization object
  89567. */
  89568. serialize(): any;
  89569. /**
  89570. * Gets the name of the conditional operator for the ValueCondition
  89571. * @param operator the conditional operator
  89572. * @returns the name
  89573. */
  89574. static GetOperatorName(operator: number): string;
  89575. }
  89576. /**
  89577. * Defines a predicate condition as an extension of Condition
  89578. */
  89579. export class PredicateCondition extends Condition {
  89580. /** defines the predicate function used to validate the condition */
  89581. predicate: () => boolean;
  89582. /**
  89583. * Internal only - manager for action
  89584. * @hidden
  89585. */
  89586. _actionManager: ActionManager;
  89587. /**
  89588. * Creates a new PredicateCondition
  89589. * @param actionManager manager for the action the condition applies to
  89590. * @param predicate defines the predicate function used to validate the condition
  89591. */
  89592. constructor(actionManager: ActionManager,
  89593. /** defines the predicate function used to validate the condition */
  89594. predicate: () => boolean);
  89595. /**
  89596. * @returns the validity of the predicate condition
  89597. */
  89598. isValid(): boolean;
  89599. }
  89600. /**
  89601. * Defines a state condition as an extension of Condition
  89602. */
  89603. export class StateCondition extends Condition {
  89604. /** Value to compare with target state */
  89605. value: string;
  89606. /**
  89607. * Internal only - manager for action
  89608. * @hidden
  89609. */
  89610. _actionManager: ActionManager;
  89611. /**
  89612. * Internal only
  89613. * @hidden
  89614. */
  89615. private _target;
  89616. /**
  89617. * Creates a new StateCondition
  89618. * @param actionManager manager for the action the condition applies to
  89619. * @param target of the condition
  89620. * @param value to compare with target state
  89621. */
  89622. constructor(actionManager: ActionManager, target: any,
  89623. /** Value to compare with target state */
  89624. value: string);
  89625. /**
  89626. * Gets a boolean indicating if the current condition is met
  89627. * @returns the validity of the state
  89628. */
  89629. isValid(): boolean;
  89630. /**
  89631. * Serialize the StateCondition into a JSON compatible object
  89632. * @returns serialization object
  89633. */
  89634. serialize(): any;
  89635. }
  89636. }
  89637. declare module BABYLON {
  89638. /**
  89639. * This defines an action responsible to toggle a boolean once triggered.
  89640. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89641. */
  89642. export class SwitchBooleanAction extends Action {
  89643. /**
  89644. * The path to the boolean property in the target object
  89645. */
  89646. propertyPath: string;
  89647. private _target;
  89648. private _effectiveTarget;
  89649. private _property;
  89650. /**
  89651. * Instantiate the action
  89652. * @param triggerOptions defines the trigger options
  89653. * @param target defines the object containing the boolean
  89654. * @param propertyPath defines the path to the boolean property in the target object
  89655. * @param condition defines the trigger related conditions
  89656. */
  89657. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  89658. /** @hidden */
  89659. _prepare(): void;
  89660. /**
  89661. * Execute the action toggle the boolean value.
  89662. */
  89663. execute(): void;
  89664. /**
  89665. * Serializes the actions and its related information.
  89666. * @param parent defines the object to serialize in
  89667. * @returns the serialized object
  89668. */
  89669. serialize(parent: any): any;
  89670. }
  89671. /**
  89672. * This defines an action responsible to set a the state field of the target
  89673. * to a desired value once triggered.
  89674. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89675. */
  89676. export class SetStateAction extends Action {
  89677. /**
  89678. * The value to store in the state field.
  89679. */
  89680. value: string;
  89681. private _target;
  89682. /**
  89683. * Instantiate the action
  89684. * @param triggerOptions defines the trigger options
  89685. * @param target defines the object containing the state property
  89686. * @param value defines the value to store in the state field
  89687. * @param condition defines the trigger related conditions
  89688. */
  89689. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  89690. /**
  89691. * Execute the action and store the value on the target state property.
  89692. */
  89693. execute(): void;
  89694. /**
  89695. * Serializes the actions and its related information.
  89696. * @param parent defines the object to serialize in
  89697. * @returns the serialized object
  89698. */
  89699. serialize(parent: any): any;
  89700. }
  89701. /**
  89702. * This defines an action responsible to set a property of the target
  89703. * to a desired value once triggered.
  89704. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89705. */
  89706. export class SetValueAction extends Action {
  89707. /**
  89708. * The path of the property to set in the target.
  89709. */
  89710. propertyPath: string;
  89711. /**
  89712. * The value to set in the property
  89713. */
  89714. value: any;
  89715. private _target;
  89716. private _effectiveTarget;
  89717. private _property;
  89718. /**
  89719. * Instantiate the action
  89720. * @param triggerOptions defines the trigger options
  89721. * @param target defines the object containing the property
  89722. * @param propertyPath defines the path of the property to set in the target
  89723. * @param value defines the value to set in the property
  89724. * @param condition defines the trigger related conditions
  89725. */
  89726. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  89727. /** @hidden */
  89728. _prepare(): void;
  89729. /**
  89730. * Execute the action and set the targetted property to the desired value.
  89731. */
  89732. execute(): void;
  89733. /**
  89734. * Serializes the actions and its related information.
  89735. * @param parent defines the object to serialize in
  89736. * @returns the serialized object
  89737. */
  89738. serialize(parent: any): any;
  89739. }
  89740. /**
  89741. * This defines an action responsible to increment the target value
  89742. * to a desired value once triggered.
  89743. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89744. */
  89745. export class IncrementValueAction extends Action {
  89746. /**
  89747. * The path of the property to increment in the target.
  89748. */
  89749. propertyPath: string;
  89750. /**
  89751. * The value we should increment the property by.
  89752. */
  89753. value: any;
  89754. private _target;
  89755. private _effectiveTarget;
  89756. private _property;
  89757. /**
  89758. * Instantiate the action
  89759. * @param triggerOptions defines the trigger options
  89760. * @param target defines the object containing the property
  89761. * @param propertyPath defines the path of the property to increment in the target
  89762. * @param value defines the value value we should increment the property by
  89763. * @param condition defines the trigger related conditions
  89764. */
  89765. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  89766. /** @hidden */
  89767. _prepare(): void;
  89768. /**
  89769. * Execute the action and increment the target of the value amount.
  89770. */
  89771. execute(): void;
  89772. /**
  89773. * Serializes the actions and its related information.
  89774. * @param parent defines the object to serialize in
  89775. * @returns the serialized object
  89776. */
  89777. serialize(parent: any): any;
  89778. }
  89779. /**
  89780. * This defines an action responsible to start an animation once triggered.
  89781. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89782. */
  89783. export class PlayAnimationAction extends Action {
  89784. /**
  89785. * Where the animation should start (animation frame)
  89786. */
  89787. from: number;
  89788. /**
  89789. * Where the animation should stop (animation frame)
  89790. */
  89791. to: number;
  89792. /**
  89793. * Define if the animation should loop or stop after the first play.
  89794. */
  89795. loop?: boolean;
  89796. private _target;
  89797. /**
  89798. * Instantiate the action
  89799. * @param triggerOptions defines the trigger options
  89800. * @param target defines the target animation or animation name
  89801. * @param from defines from where the animation should start (animation frame)
  89802. * @param end defines where the animation should stop (animation frame)
  89803. * @param loop defines if the animation should loop or stop after the first play
  89804. * @param condition defines the trigger related conditions
  89805. */
  89806. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  89807. /** @hidden */
  89808. _prepare(): void;
  89809. /**
  89810. * Execute the action and play the animation.
  89811. */
  89812. execute(): void;
  89813. /**
  89814. * Serializes the actions and its related information.
  89815. * @param parent defines the object to serialize in
  89816. * @returns the serialized object
  89817. */
  89818. serialize(parent: any): any;
  89819. }
  89820. /**
  89821. * This defines an action responsible to stop an animation once triggered.
  89822. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89823. */
  89824. export class StopAnimationAction extends Action {
  89825. private _target;
  89826. /**
  89827. * Instantiate the action
  89828. * @param triggerOptions defines the trigger options
  89829. * @param target defines the target animation or animation name
  89830. * @param condition defines the trigger related conditions
  89831. */
  89832. constructor(triggerOptions: any, target: any, condition?: Condition);
  89833. /** @hidden */
  89834. _prepare(): void;
  89835. /**
  89836. * Execute the action and stop the animation.
  89837. */
  89838. execute(): void;
  89839. /**
  89840. * Serializes the actions and its related information.
  89841. * @param parent defines the object to serialize in
  89842. * @returns the serialized object
  89843. */
  89844. serialize(parent: any): any;
  89845. }
  89846. /**
  89847. * This defines an action responsible that does nothing once triggered.
  89848. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89849. */
  89850. export class DoNothingAction extends Action {
  89851. /**
  89852. * Instantiate the action
  89853. * @param triggerOptions defines the trigger options
  89854. * @param condition defines the trigger related conditions
  89855. */
  89856. constructor(triggerOptions?: any, condition?: Condition);
  89857. /**
  89858. * Execute the action and do nothing.
  89859. */
  89860. execute(): void;
  89861. /**
  89862. * Serializes the actions and its related information.
  89863. * @param parent defines the object to serialize in
  89864. * @returns the serialized object
  89865. */
  89866. serialize(parent: any): any;
  89867. }
  89868. /**
  89869. * This defines an action responsible to trigger several actions once triggered.
  89870. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89871. */
  89872. export class CombineAction extends Action {
  89873. /**
  89874. * The list of aggregated animations to run.
  89875. */
  89876. children: Action[];
  89877. /**
  89878. * Instantiate the action
  89879. * @param triggerOptions defines the trigger options
  89880. * @param children defines the list of aggregated animations to run
  89881. * @param condition defines the trigger related conditions
  89882. */
  89883. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  89884. /** @hidden */
  89885. _prepare(): void;
  89886. /**
  89887. * Execute the action and executes all the aggregated actions.
  89888. */
  89889. execute(evt: ActionEvent): void;
  89890. /**
  89891. * Serializes the actions and its related information.
  89892. * @param parent defines the object to serialize in
  89893. * @returns the serialized object
  89894. */
  89895. serialize(parent: any): any;
  89896. }
  89897. /**
  89898. * This defines an action responsible to run code (external event) once triggered.
  89899. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89900. */
  89901. export class ExecuteCodeAction extends Action {
  89902. /**
  89903. * The callback function to run.
  89904. */
  89905. func: (evt: ActionEvent) => void;
  89906. /**
  89907. * Instantiate the action
  89908. * @param triggerOptions defines the trigger options
  89909. * @param func defines the callback function to run
  89910. * @param condition defines the trigger related conditions
  89911. */
  89912. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  89913. /**
  89914. * Execute the action and run the attached code.
  89915. */
  89916. execute(evt: ActionEvent): void;
  89917. }
  89918. /**
  89919. * This defines an action responsible to set the parent property of the target once triggered.
  89920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89921. */
  89922. export class SetParentAction extends Action {
  89923. private _parent;
  89924. private _target;
  89925. /**
  89926. * Instantiate the action
  89927. * @param triggerOptions defines the trigger options
  89928. * @param target defines the target containing the parent property
  89929. * @param parent defines from where the animation should start (animation frame)
  89930. * @param condition defines the trigger related conditions
  89931. */
  89932. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  89933. /** @hidden */
  89934. _prepare(): void;
  89935. /**
  89936. * Execute the action and set the parent property.
  89937. */
  89938. execute(): void;
  89939. /**
  89940. * Serializes the actions and its related information.
  89941. * @param parent defines the object to serialize in
  89942. * @returns the serialized object
  89943. */
  89944. serialize(parent: any): any;
  89945. }
  89946. }
  89947. declare module BABYLON {
  89948. /**
  89949. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  89950. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  89951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89952. */
  89953. export class ActionManager extends AbstractActionManager {
  89954. /**
  89955. * Nothing
  89956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89957. */
  89958. static readonly NothingTrigger: number;
  89959. /**
  89960. * On pick
  89961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89962. */
  89963. static readonly OnPickTrigger: number;
  89964. /**
  89965. * On left pick
  89966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89967. */
  89968. static readonly OnLeftPickTrigger: number;
  89969. /**
  89970. * On right pick
  89971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89972. */
  89973. static readonly OnRightPickTrigger: number;
  89974. /**
  89975. * On center pick
  89976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89977. */
  89978. static readonly OnCenterPickTrigger: number;
  89979. /**
  89980. * On pick down
  89981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89982. */
  89983. static readonly OnPickDownTrigger: number;
  89984. /**
  89985. * On double pick
  89986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89987. */
  89988. static readonly OnDoublePickTrigger: number;
  89989. /**
  89990. * On pick up
  89991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89992. */
  89993. static readonly OnPickUpTrigger: number;
  89994. /**
  89995. * On pick out.
  89996. * This trigger will only be raised if you also declared a OnPickDown
  89997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89998. */
  89999. static readonly OnPickOutTrigger: number;
  90000. /**
  90001. * On long press
  90002. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90003. */
  90004. static readonly OnLongPressTrigger: number;
  90005. /**
  90006. * On pointer over
  90007. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90008. */
  90009. static readonly OnPointerOverTrigger: number;
  90010. /**
  90011. * On pointer out
  90012. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90013. */
  90014. static readonly OnPointerOutTrigger: number;
  90015. /**
  90016. * On every frame
  90017. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90018. */
  90019. static readonly OnEveryFrameTrigger: number;
  90020. /**
  90021. * On intersection enter
  90022. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90023. */
  90024. static readonly OnIntersectionEnterTrigger: number;
  90025. /**
  90026. * On intersection exit
  90027. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90028. */
  90029. static readonly OnIntersectionExitTrigger: number;
  90030. /**
  90031. * On key down
  90032. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90033. */
  90034. static readonly OnKeyDownTrigger: number;
  90035. /**
  90036. * On key up
  90037. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90038. */
  90039. static readonly OnKeyUpTrigger: number;
  90040. private _scene;
  90041. /**
  90042. * Creates a new action manager
  90043. * @param scene defines the hosting scene
  90044. */
  90045. constructor(scene: Scene);
  90046. /**
  90047. * Releases all associated resources
  90048. */
  90049. dispose(): void;
  90050. /**
  90051. * Gets hosting scene
  90052. * @returns the hosting scene
  90053. */
  90054. getScene(): Scene;
  90055. /**
  90056. * Does this action manager handles actions of any of the given triggers
  90057. * @param triggers defines the triggers to be tested
  90058. * @return a boolean indicating whether one (or more) of the triggers is handled
  90059. */
  90060. hasSpecificTriggers(triggers: number[]): boolean;
  90061. /**
  90062. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90063. * speed.
  90064. * @param triggerA defines the trigger to be tested
  90065. * @param triggerB defines the trigger to be tested
  90066. * @return a boolean indicating whether one (or more) of the triggers is handled
  90067. */
  90068. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90069. /**
  90070. * Does this action manager handles actions of a given trigger
  90071. * @param trigger defines the trigger to be tested
  90072. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90073. * @return whether the trigger is handled
  90074. */
  90075. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90076. /**
  90077. * Does this action manager has pointer triggers
  90078. */
  90079. get hasPointerTriggers(): boolean;
  90080. /**
  90081. * Does this action manager has pick triggers
  90082. */
  90083. get hasPickTriggers(): boolean;
  90084. /**
  90085. * Registers an action to this action manager
  90086. * @param action defines the action to be registered
  90087. * @return the action amended (prepared) after registration
  90088. */
  90089. registerAction(action: IAction): Nullable<IAction>;
  90090. /**
  90091. * Unregisters an action to this action manager
  90092. * @param action defines the action to be unregistered
  90093. * @return a boolean indicating whether the action has been unregistered
  90094. */
  90095. unregisterAction(action: IAction): Boolean;
  90096. /**
  90097. * Process a specific trigger
  90098. * @param trigger defines the trigger to process
  90099. * @param evt defines the event details to be processed
  90100. */
  90101. processTrigger(trigger: number, evt?: IActionEvent): void;
  90102. /** @hidden */
  90103. _getEffectiveTarget(target: any, propertyPath: string): any;
  90104. /** @hidden */
  90105. _getProperty(propertyPath: string): string;
  90106. /**
  90107. * Serialize this manager to a JSON object
  90108. * @param name defines the property name to store this manager
  90109. * @returns a JSON representation of this manager
  90110. */
  90111. serialize(name: string): any;
  90112. /**
  90113. * Creates a new ActionManager from a JSON data
  90114. * @param parsedActions defines the JSON data to read from
  90115. * @param object defines the hosting mesh
  90116. * @param scene defines the hosting scene
  90117. */
  90118. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90119. /**
  90120. * Get a trigger name by index
  90121. * @param trigger defines the trigger index
  90122. * @returns a trigger name
  90123. */
  90124. static GetTriggerName(trigger: number): string;
  90125. }
  90126. }
  90127. declare module BABYLON {
  90128. /**
  90129. * Class used to represent a sprite
  90130. * @see https://doc.babylonjs.com/babylon101/sprites
  90131. */
  90132. export class Sprite implements IAnimatable {
  90133. /** defines the name */
  90134. name: string;
  90135. /** Gets or sets the current world position */
  90136. position: Vector3;
  90137. /** Gets or sets the main color */
  90138. color: Color4;
  90139. /** Gets or sets the width */
  90140. width: number;
  90141. /** Gets or sets the height */
  90142. height: number;
  90143. /** Gets or sets rotation angle */
  90144. angle: number;
  90145. /** Gets or sets the cell index in the sprite sheet */
  90146. cellIndex: number;
  90147. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  90148. cellRef: string;
  90149. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  90150. invertU: boolean;
  90151. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  90152. invertV: boolean;
  90153. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  90154. disposeWhenFinishedAnimating: boolean;
  90155. /** Gets the list of attached animations */
  90156. animations: Nullable<Array<Animation>>;
  90157. /** Gets or sets a boolean indicating if the sprite can be picked */
  90158. isPickable: boolean;
  90159. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  90160. useAlphaForPicking: boolean;
  90161. /** @hidden */
  90162. _xOffset: number;
  90163. /** @hidden */
  90164. _yOffset: number;
  90165. /** @hidden */
  90166. _xSize: number;
  90167. /** @hidden */
  90168. _ySize: number;
  90169. /**
  90170. * Gets or sets the associated action manager
  90171. */
  90172. actionManager: Nullable<ActionManager>;
  90173. /**
  90174. * An event triggered when the control has been disposed
  90175. */
  90176. onDisposeObservable: Observable<Sprite>;
  90177. private _animationStarted;
  90178. private _loopAnimation;
  90179. private _fromIndex;
  90180. private _toIndex;
  90181. private _delay;
  90182. private _direction;
  90183. private _manager;
  90184. private _time;
  90185. private _onAnimationEnd;
  90186. /**
  90187. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  90188. */
  90189. isVisible: boolean;
  90190. /**
  90191. * Gets or sets the sprite size
  90192. */
  90193. get size(): number;
  90194. set size(value: number);
  90195. /**
  90196. * Returns a boolean indicating if the animation is started
  90197. */
  90198. get animationStarted(): boolean;
  90199. /**
  90200. * Gets or sets the unique id of the sprite
  90201. */
  90202. uniqueId: number;
  90203. /**
  90204. * Gets the manager of this sprite
  90205. */
  90206. get manager(): ISpriteManager;
  90207. /**
  90208. * Creates a new Sprite
  90209. * @param name defines the name
  90210. * @param manager defines the manager
  90211. */
  90212. constructor(
  90213. /** defines the name */
  90214. name: string, manager: ISpriteManager);
  90215. /**
  90216. * Returns the string "Sprite"
  90217. * @returns "Sprite"
  90218. */
  90219. getClassName(): string;
  90220. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  90221. get fromIndex(): number;
  90222. set fromIndex(value: number);
  90223. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  90224. get toIndex(): number;
  90225. set toIndex(value: number);
  90226. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  90227. get loopAnimation(): boolean;
  90228. set loopAnimation(value: boolean);
  90229. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  90230. get delay(): number;
  90231. set delay(value: number);
  90232. /**
  90233. * Starts an animation
  90234. * @param from defines the initial key
  90235. * @param to defines the end key
  90236. * @param loop defines if the animation must loop
  90237. * @param delay defines the start delay (in ms)
  90238. * @param onAnimationEnd defines a callback to call when animation ends
  90239. */
  90240. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  90241. /** Stops current animation (if any) */
  90242. stopAnimation(): void;
  90243. /** @hidden */
  90244. _animate(deltaTime: number): void;
  90245. /** Release associated resources */
  90246. dispose(): void;
  90247. /**
  90248. * Serializes the sprite to a JSON object
  90249. * @returns the JSON object
  90250. */
  90251. serialize(): any;
  90252. /**
  90253. * Parses a JSON object to create a new sprite
  90254. * @param parsedSprite The JSON object to parse
  90255. * @param manager defines the hosting manager
  90256. * @returns the new sprite
  90257. */
  90258. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  90259. }
  90260. }
  90261. declare module BABYLON {
  90262. /**
  90263. * Information about the result of picking within a scene
  90264. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  90265. */
  90266. export class PickingInfo {
  90267. /** @hidden */
  90268. _pickingUnavailable: boolean;
  90269. /**
  90270. * If the pick collided with an object
  90271. */
  90272. hit: boolean;
  90273. /**
  90274. * Distance away where the pick collided
  90275. */
  90276. distance: number;
  90277. /**
  90278. * The location of pick collision
  90279. */
  90280. pickedPoint: Nullable<Vector3>;
  90281. /**
  90282. * The mesh corresponding the the pick collision
  90283. */
  90284. pickedMesh: Nullable<AbstractMesh>;
  90285. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  90286. bu: number;
  90287. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  90288. bv: number;
  90289. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90290. faceId: number;
  90291. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90292. subMeshFaceId: number;
  90293. /** Id of the the submesh that was picked */
  90294. subMeshId: number;
  90295. /** If a sprite was picked, this will be the sprite the pick collided with */
  90296. pickedSprite: Nullable<Sprite>;
  90297. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  90298. thinInstanceIndex: number;
  90299. /**
  90300. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  90301. */
  90302. originMesh: Nullable<AbstractMesh>;
  90303. /**
  90304. * The ray that was used to perform the picking.
  90305. */
  90306. ray: Nullable<Ray>;
  90307. /**
  90308. * Gets the normal correspodning to the face the pick collided with
  90309. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  90310. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  90311. * @returns The normal correspodning to the face the pick collided with
  90312. */
  90313. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  90314. /**
  90315. * Gets the texture coordinates of where the pick occured
  90316. * @returns the vector containing the coordnates of the texture
  90317. */
  90318. getTextureCoordinates(): Nullable<Vector2>;
  90319. }
  90320. }
  90321. declare module BABYLON {
  90322. /**
  90323. * Class representing a ray with position and direction
  90324. */
  90325. export class Ray {
  90326. /** origin point */
  90327. origin: Vector3;
  90328. /** direction */
  90329. direction: Vector3;
  90330. /** length of the ray */
  90331. length: number;
  90332. private static readonly _TmpVector3;
  90333. private _tmpRay;
  90334. /**
  90335. * Creates a new ray
  90336. * @param origin origin point
  90337. * @param direction direction
  90338. * @param length length of the ray
  90339. */
  90340. constructor(
  90341. /** origin point */
  90342. origin: Vector3,
  90343. /** direction */
  90344. direction: Vector3,
  90345. /** length of the ray */
  90346. length?: number);
  90347. /**
  90348. * Checks if the ray intersects a box
  90349. * This does not account for the ray lenght by design to improve perfs.
  90350. * @param minimum bound of the box
  90351. * @param maximum bound of the box
  90352. * @param intersectionTreshold extra extend to be added to the box in all direction
  90353. * @returns if the box was hit
  90354. */
  90355. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  90356. /**
  90357. * Checks if the ray intersects a box
  90358. * This does not account for the ray lenght by design to improve perfs.
  90359. * @param box the bounding box to check
  90360. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  90361. * @returns if the box was hit
  90362. */
  90363. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  90364. /**
  90365. * If the ray hits a sphere
  90366. * @param sphere the bounding sphere to check
  90367. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  90368. * @returns true if it hits the sphere
  90369. */
  90370. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  90371. /**
  90372. * If the ray hits a triange
  90373. * @param vertex0 triangle vertex
  90374. * @param vertex1 triangle vertex
  90375. * @param vertex2 triangle vertex
  90376. * @returns intersection information if hit
  90377. */
  90378. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  90379. /**
  90380. * Checks if ray intersects a plane
  90381. * @param plane the plane to check
  90382. * @returns the distance away it was hit
  90383. */
  90384. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  90385. /**
  90386. * Calculate the intercept of a ray on a given axis
  90387. * @param axis to check 'x' | 'y' | 'z'
  90388. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  90389. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  90390. */
  90391. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  90392. /**
  90393. * Checks if ray intersects a mesh
  90394. * @param mesh the mesh to check
  90395. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90396. * @returns picking info of the intersecton
  90397. */
  90398. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  90399. /**
  90400. * Checks if ray intersects a mesh
  90401. * @param meshes the meshes to check
  90402. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90403. * @param results array to store result in
  90404. * @returns Array of picking infos
  90405. */
  90406. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  90407. private _comparePickingInfo;
  90408. private static smallnum;
  90409. private static rayl;
  90410. /**
  90411. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  90412. * @param sega the first point of the segment to test the intersection against
  90413. * @param segb the second point of the segment to test the intersection against
  90414. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  90415. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  90416. */
  90417. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  90418. /**
  90419. * Update the ray from viewport position
  90420. * @param x position
  90421. * @param y y position
  90422. * @param viewportWidth viewport width
  90423. * @param viewportHeight viewport height
  90424. * @param world world matrix
  90425. * @param view view matrix
  90426. * @param projection projection matrix
  90427. * @returns this ray updated
  90428. */
  90429. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90430. /**
  90431. * Creates a ray with origin and direction of 0,0,0
  90432. * @returns the new ray
  90433. */
  90434. static Zero(): Ray;
  90435. /**
  90436. * Creates a new ray from screen space and viewport
  90437. * @param x position
  90438. * @param y y position
  90439. * @param viewportWidth viewport width
  90440. * @param viewportHeight viewport height
  90441. * @param world world matrix
  90442. * @param view view matrix
  90443. * @param projection projection matrix
  90444. * @returns new ray
  90445. */
  90446. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90447. /**
  90448. * 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
  90449. * transformed to the given world matrix.
  90450. * @param origin The origin point
  90451. * @param end The end point
  90452. * @param world a matrix to transform the ray to. Default is the identity matrix.
  90453. * @returns the new ray
  90454. */
  90455. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  90456. /**
  90457. * Transforms a ray by a matrix
  90458. * @param ray ray to transform
  90459. * @param matrix matrix to apply
  90460. * @returns the resulting new ray
  90461. */
  90462. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  90463. /**
  90464. * Transforms a ray by a matrix
  90465. * @param ray ray to transform
  90466. * @param matrix matrix to apply
  90467. * @param result ray to store result in
  90468. */
  90469. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  90470. /**
  90471. * Unproject a ray from screen space to object space
  90472. * @param sourceX defines the screen space x coordinate to use
  90473. * @param sourceY defines the screen space y coordinate to use
  90474. * @param viewportWidth defines the current width of the viewport
  90475. * @param viewportHeight defines the current height of the viewport
  90476. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  90477. * @param view defines the view matrix to use
  90478. * @param projection defines the projection matrix to use
  90479. */
  90480. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  90481. }
  90482. /**
  90483. * Type used to define predicate used to select faces when a mesh intersection is detected
  90484. */
  90485. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  90486. interface Scene {
  90487. /** @hidden */
  90488. _tempPickingRay: Nullable<Ray>;
  90489. /** @hidden */
  90490. _cachedRayForTransform: Ray;
  90491. /** @hidden */
  90492. _pickWithRayInverseMatrix: Matrix;
  90493. /** @hidden */
  90494. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90495. /** @hidden */
  90496. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90497. /** @hidden */
  90498. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90499. }
  90500. }
  90501. declare module BABYLON {
  90502. /**
  90503. * Groups all the scene component constants in one place to ease maintenance.
  90504. * @hidden
  90505. */
  90506. export class SceneComponentConstants {
  90507. static readonly NAME_EFFECTLAYER: string;
  90508. static readonly NAME_LAYER: string;
  90509. static readonly NAME_LENSFLARESYSTEM: string;
  90510. static readonly NAME_BOUNDINGBOXRENDERER: string;
  90511. static readonly NAME_PARTICLESYSTEM: string;
  90512. static readonly NAME_GAMEPAD: string;
  90513. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  90514. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  90515. static readonly NAME_PREPASSRENDERER: string;
  90516. static readonly NAME_DEPTHRENDERER: string;
  90517. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  90518. static readonly NAME_SPRITE: string;
  90519. static readonly NAME_OUTLINERENDERER: string;
  90520. static readonly NAME_PROCEDURALTEXTURE: string;
  90521. static readonly NAME_SHADOWGENERATOR: string;
  90522. static readonly NAME_OCTREE: string;
  90523. static readonly NAME_PHYSICSENGINE: string;
  90524. static readonly NAME_AUDIO: string;
  90525. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  90526. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90527. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  90528. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90529. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  90530. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  90531. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  90532. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  90533. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  90534. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  90535. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  90536. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  90537. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  90538. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  90539. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  90540. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  90541. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  90542. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  90543. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  90544. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  90545. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  90546. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  90547. static readonly STEP_AFTERRENDER_AUDIO: number;
  90548. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  90549. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  90550. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  90551. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  90552. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  90553. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  90554. static readonly STEP_POINTERMOVE_SPRITE: number;
  90555. static readonly STEP_POINTERDOWN_SPRITE: number;
  90556. static readonly STEP_POINTERUP_SPRITE: number;
  90557. }
  90558. /**
  90559. * This represents a scene component.
  90560. *
  90561. * This is used to decouple the dependency the scene is having on the different workloads like
  90562. * layers, post processes...
  90563. */
  90564. export interface ISceneComponent {
  90565. /**
  90566. * The name of the component. Each component must have a unique name.
  90567. */
  90568. name: string;
  90569. /**
  90570. * The scene the component belongs to.
  90571. */
  90572. scene: Scene;
  90573. /**
  90574. * Register the component to one instance of a scene.
  90575. */
  90576. register(): void;
  90577. /**
  90578. * Rebuilds the elements related to this component in case of
  90579. * context lost for instance.
  90580. */
  90581. rebuild(): void;
  90582. /**
  90583. * Disposes the component and the associated ressources.
  90584. */
  90585. dispose(): void;
  90586. }
  90587. /**
  90588. * This represents a SERIALIZABLE scene component.
  90589. *
  90590. * This extends Scene Component to add Serialization methods on top.
  90591. */
  90592. export interface ISceneSerializableComponent extends ISceneComponent {
  90593. /**
  90594. * Adds all the elements from the container to the scene
  90595. * @param container the container holding the elements
  90596. */
  90597. addFromContainer(container: AbstractScene): void;
  90598. /**
  90599. * Removes all the elements in the container from the scene
  90600. * @param container contains the elements to remove
  90601. * @param dispose if the removed element should be disposed (default: false)
  90602. */
  90603. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  90604. /**
  90605. * Serializes the component data to the specified json object
  90606. * @param serializationObject The object to serialize to
  90607. */
  90608. serialize(serializationObject: any): void;
  90609. }
  90610. /**
  90611. * Strong typing of a Mesh related stage step action
  90612. */
  90613. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  90614. /**
  90615. * Strong typing of a Evaluate Sub Mesh related stage step action
  90616. */
  90617. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  90618. /**
  90619. * Strong typing of a Active Mesh related stage step action
  90620. */
  90621. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  90622. /**
  90623. * Strong typing of a Camera related stage step action
  90624. */
  90625. export type CameraStageAction = (camera: Camera) => void;
  90626. /**
  90627. * Strong typing of a Camera Frame buffer related stage step action
  90628. */
  90629. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  90630. /**
  90631. * Strong typing of a Render Target related stage step action
  90632. */
  90633. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  90634. /**
  90635. * Strong typing of a RenderingGroup related stage step action
  90636. */
  90637. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  90638. /**
  90639. * Strong typing of a Mesh Render related stage step action
  90640. */
  90641. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  90642. /**
  90643. * Strong typing of a simple stage step action
  90644. */
  90645. export type SimpleStageAction = () => void;
  90646. /**
  90647. * Strong typing of a render target action.
  90648. */
  90649. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  90650. /**
  90651. * Strong typing of a pointer move action.
  90652. */
  90653. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  90654. /**
  90655. * Strong typing of a pointer up/down action.
  90656. */
  90657. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  90658. /**
  90659. * Representation of a stage in the scene (Basically a list of ordered steps)
  90660. * @hidden
  90661. */
  90662. export class Stage<T extends Function> extends Array<{
  90663. index: number;
  90664. component: ISceneComponent;
  90665. action: T;
  90666. }> {
  90667. /**
  90668. * Hide ctor from the rest of the world.
  90669. * @param items The items to add.
  90670. */
  90671. private constructor();
  90672. /**
  90673. * Creates a new Stage.
  90674. * @returns A new instance of a Stage
  90675. */
  90676. static Create<T extends Function>(): Stage<T>;
  90677. /**
  90678. * Registers a step in an ordered way in the targeted stage.
  90679. * @param index Defines the position to register the step in
  90680. * @param component Defines the component attached to the step
  90681. * @param action Defines the action to launch during the step
  90682. */
  90683. registerStep(index: number, component: ISceneComponent, action: T): void;
  90684. /**
  90685. * Clears all the steps from the stage.
  90686. */
  90687. clear(): void;
  90688. }
  90689. }
  90690. declare module BABYLON {
  90691. interface Scene {
  90692. /** @hidden */
  90693. _pointerOverSprite: Nullable<Sprite>;
  90694. /** @hidden */
  90695. _pickedDownSprite: Nullable<Sprite>;
  90696. /** @hidden */
  90697. _tempSpritePickingRay: Nullable<Ray>;
  90698. /**
  90699. * All of the sprite managers added to this scene
  90700. * @see https://doc.babylonjs.com/babylon101/sprites
  90701. */
  90702. spriteManagers: Array<ISpriteManager>;
  90703. /**
  90704. * An event triggered when sprites rendering is about to start
  90705. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  90706. */
  90707. onBeforeSpritesRenderingObservable: Observable<Scene>;
  90708. /**
  90709. * An event triggered when sprites rendering is done
  90710. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  90711. */
  90712. onAfterSpritesRenderingObservable: Observable<Scene>;
  90713. /** @hidden */
  90714. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90715. /** Launch a ray to try to pick a sprite in the scene
  90716. * @param x position on screen
  90717. * @param y position on screen
  90718. * @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
  90719. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90720. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90721. * @returns a PickingInfo
  90722. */
  90723. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90724. /** Use the given ray to pick a sprite in the scene
  90725. * @param ray The ray (in world space) to use to pick meshes
  90726. * @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
  90727. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90728. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  90729. * @returns a PickingInfo
  90730. */
  90731. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90732. /** @hidden */
  90733. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90734. /** Launch a ray to try to pick sprites in the scene
  90735. * @param x position on screen
  90736. * @param y position on screen
  90737. * @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
  90738. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90739. * @returns a PickingInfo array
  90740. */
  90741. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90742. /** Use the given ray to pick sprites in the scene
  90743. * @param ray The ray (in world space) to use to pick meshes
  90744. * @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
  90745. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  90746. * @returns a PickingInfo array
  90747. */
  90748. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90749. /**
  90750. * Force the sprite under the pointer
  90751. * @param sprite defines the sprite to use
  90752. */
  90753. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  90754. /**
  90755. * Gets the sprite under the pointer
  90756. * @returns a Sprite or null if no sprite is under the pointer
  90757. */
  90758. getPointerOverSprite(): Nullable<Sprite>;
  90759. }
  90760. /**
  90761. * Defines the sprite scene component responsible to manage sprites
  90762. * in a given scene.
  90763. */
  90764. export class SpriteSceneComponent implements ISceneComponent {
  90765. /**
  90766. * The component name helpfull to identify the component in the list of scene components.
  90767. */
  90768. readonly name: string;
  90769. /**
  90770. * The scene the component belongs to.
  90771. */
  90772. scene: Scene;
  90773. /** @hidden */
  90774. private _spritePredicate;
  90775. /**
  90776. * Creates a new instance of the component for the given scene
  90777. * @param scene Defines the scene to register the component in
  90778. */
  90779. constructor(scene: Scene);
  90780. /**
  90781. * Registers the component in a given scene
  90782. */
  90783. register(): void;
  90784. /**
  90785. * Rebuilds the elements related to this component in case of
  90786. * context lost for instance.
  90787. */
  90788. rebuild(): void;
  90789. /**
  90790. * Disposes the component and the associated ressources.
  90791. */
  90792. dispose(): void;
  90793. private _pickSpriteButKeepRay;
  90794. private _pointerMove;
  90795. private _pointerDown;
  90796. private _pointerUp;
  90797. }
  90798. }
  90799. declare module BABYLON {
  90800. /** @hidden */
  90801. export var fogFragmentDeclaration: {
  90802. name: string;
  90803. shader: string;
  90804. };
  90805. }
  90806. declare module BABYLON {
  90807. /** @hidden */
  90808. export var fogFragment: {
  90809. name: string;
  90810. shader: string;
  90811. };
  90812. }
  90813. declare module BABYLON {
  90814. /** @hidden */
  90815. export var spritesPixelShader: {
  90816. name: string;
  90817. shader: string;
  90818. };
  90819. }
  90820. declare module BABYLON {
  90821. /** @hidden */
  90822. export var fogVertexDeclaration: {
  90823. name: string;
  90824. shader: string;
  90825. };
  90826. }
  90827. declare module BABYLON {
  90828. /** @hidden */
  90829. export var spritesVertexShader: {
  90830. name: string;
  90831. shader: string;
  90832. };
  90833. }
  90834. declare module BABYLON {
  90835. /**
  90836. * Defines the minimum interface to fullfil in order to be a sprite manager.
  90837. */
  90838. export interface ISpriteManager extends IDisposable {
  90839. /**
  90840. * Gets manager's name
  90841. */
  90842. name: string;
  90843. /**
  90844. * Restricts the camera to viewing objects with the same layerMask.
  90845. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  90846. */
  90847. layerMask: number;
  90848. /**
  90849. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  90850. */
  90851. isPickable: boolean;
  90852. /**
  90853. * Gets the hosting scene
  90854. */
  90855. scene: Scene;
  90856. /**
  90857. * Specifies the rendering group id for this mesh (0 by default)
  90858. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  90859. */
  90860. renderingGroupId: number;
  90861. /**
  90862. * Defines the list of sprites managed by the manager.
  90863. */
  90864. sprites: Array<Sprite>;
  90865. /**
  90866. * Gets or sets the spritesheet texture
  90867. */
  90868. texture: Texture;
  90869. /** Defines the default width of a cell in the spritesheet */
  90870. cellWidth: number;
  90871. /** Defines the default height of a cell in the spritesheet */
  90872. cellHeight: number;
  90873. /**
  90874. * Tests the intersection of a sprite with a specific ray.
  90875. * @param ray The ray we are sending to test the collision
  90876. * @param camera The camera space we are sending rays in
  90877. * @param predicate A predicate allowing excluding sprites from the list of object to test
  90878. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90879. * @returns picking info or null.
  90880. */
  90881. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90882. /**
  90883. * Intersects the sprites with a ray
  90884. * @param ray defines the ray to intersect with
  90885. * @param camera defines the current active camera
  90886. * @param predicate defines a predicate used to select candidate sprites
  90887. * @returns null if no hit or a PickingInfo array
  90888. */
  90889. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90890. /**
  90891. * Renders the list of sprites on screen.
  90892. */
  90893. render(): void;
  90894. }
  90895. /**
  90896. * Class used to manage multiple sprites on the same spritesheet
  90897. * @see https://doc.babylonjs.com/babylon101/sprites
  90898. */
  90899. export class SpriteManager implements ISpriteManager {
  90900. /** defines the manager's name */
  90901. name: string;
  90902. /** Define the Url to load snippets */
  90903. static SnippetUrl: string;
  90904. /** Snippet ID if the manager was created from the snippet server */
  90905. snippetId: string;
  90906. /** Gets the list of sprites */
  90907. sprites: Sprite[];
  90908. /** Gets or sets the rendering group id (0 by default) */
  90909. renderingGroupId: number;
  90910. /** Gets or sets camera layer mask */
  90911. layerMask: number;
  90912. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  90913. fogEnabled: boolean;
  90914. /** Gets or sets a boolean indicating if the sprites are pickable */
  90915. isPickable: boolean;
  90916. /** Defines the default width of a cell in the spritesheet */
  90917. cellWidth: number;
  90918. /** Defines the default height of a cell in the spritesheet */
  90919. cellHeight: number;
  90920. /** Associative array from JSON sprite data file */
  90921. private _cellData;
  90922. /** Array of sprite names from JSON sprite data file */
  90923. private _spriteMap;
  90924. /** True when packed cell data from JSON file is ready*/
  90925. private _packedAndReady;
  90926. private _textureContent;
  90927. private _useInstancing;
  90928. /**
  90929. * An event triggered when the manager is disposed.
  90930. */
  90931. onDisposeObservable: Observable<SpriteManager>;
  90932. private _onDisposeObserver;
  90933. /**
  90934. * Callback called when the manager is disposed
  90935. */
  90936. set onDispose(callback: () => void);
  90937. private _capacity;
  90938. private _fromPacked;
  90939. private _spriteTexture;
  90940. private _epsilon;
  90941. private _scene;
  90942. private _vertexData;
  90943. private _buffer;
  90944. private _vertexBuffers;
  90945. private _spriteBuffer;
  90946. private _indexBuffer;
  90947. private _effectBase;
  90948. private _effectFog;
  90949. private _vertexBufferSize;
  90950. /**
  90951. * Gets or sets the unique id of the sprite
  90952. */
  90953. uniqueId: number;
  90954. /**
  90955. * Gets the array of sprites
  90956. */
  90957. get children(): Sprite[];
  90958. /**
  90959. * Gets the hosting scene
  90960. */
  90961. get scene(): Scene;
  90962. /**
  90963. * Gets the capacity of the manager
  90964. */
  90965. get capacity(): number;
  90966. /**
  90967. * Gets or sets the spritesheet texture
  90968. */
  90969. get texture(): Texture;
  90970. set texture(value: Texture);
  90971. private _blendMode;
  90972. /**
  90973. * Blend mode use to render the particle, it can be any of
  90974. * the static Constants.ALPHA_x properties provided in this class.
  90975. * Default value is Constants.ALPHA_COMBINE
  90976. */
  90977. get blendMode(): number;
  90978. set blendMode(blendMode: number);
  90979. /** Disables writing to the depth buffer when rendering the sprites.
  90980. * It can be handy to disable depth writing when using textures without alpha channel
  90981. * and setting some specific blend modes.
  90982. */
  90983. disableDepthWrite: boolean;
  90984. /**
  90985. * Creates a new sprite manager
  90986. * @param name defines the manager's name
  90987. * @param imgUrl defines the sprite sheet url
  90988. * @param capacity defines the maximum allowed number of sprites
  90989. * @param cellSize defines the size of a sprite cell
  90990. * @param scene defines the hosting scene
  90991. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  90992. * @param samplingMode defines the smapling mode to use with spritesheet
  90993. * @param fromPacked set to false; do not alter
  90994. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  90995. */
  90996. constructor(
  90997. /** defines the manager's name */
  90998. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  90999. /**
  91000. * Returns the string "SpriteManager"
  91001. * @returns "SpriteManager"
  91002. */
  91003. getClassName(): string;
  91004. private _makePacked;
  91005. private _appendSpriteVertex;
  91006. private _checkTextureAlpha;
  91007. /**
  91008. * Intersects the sprites with a ray
  91009. * @param ray defines the ray to intersect with
  91010. * @param camera defines the current active camera
  91011. * @param predicate defines a predicate used to select candidate sprites
  91012. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91013. * @returns null if no hit or a PickingInfo
  91014. */
  91015. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91016. /**
  91017. * Intersects the sprites with a ray
  91018. * @param ray defines the ray to intersect with
  91019. * @param camera defines the current active camera
  91020. * @param predicate defines a predicate used to select candidate sprites
  91021. * @returns null if no hit or a PickingInfo array
  91022. */
  91023. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91024. /**
  91025. * Render all child sprites
  91026. */
  91027. render(): void;
  91028. /**
  91029. * Release associated resources
  91030. */
  91031. dispose(): void;
  91032. /**
  91033. * Serializes the sprite manager to a JSON object
  91034. * @param serializeTexture defines if the texture must be serialized as well
  91035. * @returns the JSON object
  91036. */
  91037. serialize(serializeTexture?: boolean): any;
  91038. /**
  91039. * Parses a JSON object to create a new sprite manager.
  91040. * @param parsedManager The JSON object to parse
  91041. * @param scene The scene to create the sprite managerin
  91042. * @param rootUrl The root url to use to load external dependencies like texture
  91043. * @returns the new sprite manager
  91044. */
  91045. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  91046. /**
  91047. * Creates a sprite manager from a snippet saved in a remote file
  91048. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  91049. * @param url defines the url to load from
  91050. * @param scene defines the hosting scene
  91051. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91052. * @returns a promise that will resolve to the new sprite manager
  91053. */
  91054. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91055. /**
  91056. * Creates a sprite manager from a snippet saved by the sprite editor
  91057. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  91058. * @param scene defines the hosting scene
  91059. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91060. * @returns a promise that will resolve to the new sprite manager
  91061. */
  91062. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91063. }
  91064. }
  91065. declare module BABYLON {
  91066. /** Interface used by value gradients (color, factor, ...) */
  91067. export interface IValueGradient {
  91068. /**
  91069. * Gets or sets the gradient value (between 0 and 1)
  91070. */
  91071. gradient: number;
  91072. }
  91073. /** Class used to store color4 gradient */
  91074. export class ColorGradient implements IValueGradient {
  91075. /**
  91076. * Gets or sets the gradient value (between 0 and 1)
  91077. */
  91078. gradient: number;
  91079. /**
  91080. * Gets or sets first associated color
  91081. */
  91082. color1: Color4;
  91083. /**
  91084. * Gets or sets second associated color
  91085. */
  91086. color2?: Color4 | undefined;
  91087. /**
  91088. * Creates a new color4 gradient
  91089. * @param gradient gets or sets the gradient value (between 0 and 1)
  91090. * @param color1 gets or sets first associated color
  91091. * @param color2 gets or sets first second color
  91092. */
  91093. constructor(
  91094. /**
  91095. * Gets or sets the gradient value (between 0 and 1)
  91096. */
  91097. gradient: number,
  91098. /**
  91099. * Gets or sets first associated color
  91100. */
  91101. color1: Color4,
  91102. /**
  91103. * Gets or sets second associated color
  91104. */
  91105. color2?: Color4 | undefined);
  91106. /**
  91107. * Will get a color picked randomly between color1 and color2.
  91108. * If color2 is undefined then color1 will be used
  91109. * @param result defines the target Color4 to store the result in
  91110. */
  91111. getColorToRef(result: Color4): void;
  91112. }
  91113. /** Class used to store color 3 gradient */
  91114. export class Color3Gradient implements IValueGradient {
  91115. /**
  91116. * Gets or sets the gradient value (between 0 and 1)
  91117. */
  91118. gradient: number;
  91119. /**
  91120. * Gets or sets the associated color
  91121. */
  91122. color: Color3;
  91123. /**
  91124. * Creates a new color3 gradient
  91125. * @param gradient gets or sets the gradient value (between 0 and 1)
  91126. * @param color gets or sets associated color
  91127. */
  91128. constructor(
  91129. /**
  91130. * Gets or sets the gradient value (between 0 and 1)
  91131. */
  91132. gradient: number,
  91133. /**
  91134. * Gets or sets the associated color
  91135. */
  91136. color: Color3);
  91137. }
  91138. /** Class used to store factor gradient */
  91139. export class FactorGradient implements IValueGradient {
  91140. /**
  91141. * Gets or sets the gradient value (between 0 and 1)
  91142. */
  91143. gradient: number;
  91144. /**
  91145. * Gets or sets first associated factor
  91146. */
  91147. factor1: number;
  91148. /**
  91149. * Gets or sets second associated factor
  91150. */
  91151. factor2?: number | undefined;
  91152. /**
  91153. * Creates a new factor gradient
  91154. * @param gradient gets or sets the gradient value (between 0 and 1)
  91155. * @param factor1 gets or sets first associated factor
  91156. * @param factor2 gets or sets second associated factor
  91157. */
  91158. constructor(
  91159. /**
  91160. * Gets or sets the gradient value (between 0 and 1)
  91161. */
  91162. gradient: number,
  91163. /**
  91164. * Gets or sets first associated factor
  91165. */
  91166. factor1: number,
  91167. /**
  91168. * Gets or sets second associated factor
  91169. */
  91170. factor2?: number | undefined);
  91171. /**
  91172. * Will get a number picked randomly between factor1 and factor2.
  91173. * If factor2 is undefined then factor1 will be used
  91174. * @returns the picked number
  91175. */
  91176. getFactor(): number;
  91177. }
  91178. /**
  91179. * Helper used to simplify some generic gradient tasks
  91180. */
  91181. export class GradientHelper {
  91182. /**
  91183. * Gets the current gradient from an array of IValueGradient
  91184. * @param ratio defines the current ratio to get
  91185. * @param gradients defines the array of IValueGradient
  91186. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91187. */
  91188. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91189. }
  91190. }
  91191. declare module BABYLON {
  91192. interface ThinEngine {
  91193. /**
  91194. * Creates a raw texture
  91195. * @param data defines the data to store in the texture
  91196. * @param width defines the width of the texture
  91197. * @param height defines the height of the texture
  91198. * @param format defines the format of the data
  91199. * @param generateMipMaps defines if the engine should generate the mip levels
  91200. * @param invertY defines if data must be stored with Y axis inverted
  91201. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91202. * @param compression defines the compression used (null by default)
  91203. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91204. * @returns the raw texture inside an InternalTexture
  91205. */
  91206. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  91207. /**
  91208. * Update a raw texture
  91209. * @param texture defines the texture to update
  91210. * @param data defines the data to store in the texture
  91211. * @param format defines the format of the data
  91212. * @param invertY defines if data must be stored with Y axis inverted
  91213. */
  91214. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91215. /**
  91216. * Update a raw texture
  91217. * @param texture defines the texture to update
  91218. * @param data defines the data to store in the texture
  91219. * @param format defines the format of the data
  91220. * @param invertY defines if data must be stored with Y axis inverted
  91221. * @param compression defines the compression used (null by default)
  91222. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91223. */
  91224. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  91225. /**
  91226. * Creates a new raw cube texture
  91227. * @param data defines the array of data to use to create each face
  91228. * @param size defines the size of the textures
  91229. * @param format defines the format of the data
  91230. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91231. * @param generateMipMaps defines if the engine should generate the mip levels
  91232. * @param invertY defines if data must be stored with Y axis inverted
  91233. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91234. * @param compression defines the compression used (null by default)
  91235. * @returns the cube texture as an InternalTexture
  91236. */
  91237. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  91238. /**
  91239. * Update a raw cube texture
  91240. * @param texture defines the texture to udpdate
  91241. * @param data defines the data to store
  91242. * @param format defines the data format
  91243. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91244. * @param invertY defines if data must be stored with Y axis inverted
  91245. */
  91246. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  91247. /**
  91248. * Update a raw cube texture
  91249. * @param texture defines the texture to udpdate
  91250. * @param data defines the data to store
  91251. * @param format defines the data format
  91252. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91253. * @param invertY defines if data must be stored with Y axis inverted
  91254. * @param compression defines the compression used (null by default)
  91255. */
  91256. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  91257. /**
  91258. * Update a raw cube texture
  91259. * @param texture defines the texture to udpdate
  91260. * @param data defines the data to store
  91261. * @param format defines the data format
  91262. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91263. * @param invertY defines if data must be stored with Y axis inverted
  91264. * @param compression defines the compression used (null by default)
  91265. * @param level defines which level of the texture to update
  91266. */
  91267. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  91268. /**
  91269. * Creates a new raw cube texture from a specified url
  91270. * @param url defines the url where the data is located
  91271. * @param scene defines the current scene
  91272. * @param size defines the size of the textures
  91273. * @param format defines the format of the data
  91274. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91275. * @param noMipmap defines if the engine should avoid generating the mip levels
  91276. * @param callback defines a callback used to extract texture data from loaded data
  91277. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91278. * @param onLoad defines a callback called when texture is loaded
  91279. * @param onError defines a callback called if there is an error
  91280. * @returns the cube texture as an InternalTexture
  91281. */
  91282. 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;
  91283. /**
  91284. * Creates a new raw cube texture from a specified url
  91285. * @param url defines the url where the data is located
  91286. * @param scene defines the current scene
  91287. * @param size defines the size of the textures
  91288. * @param format defines the format of the data
  91289. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91290. * @param noMipmap defines if the engine should avoid generating the mip levels
  91291. * @param callback defines a callback used to extract texture data from loaded data
  91292. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91293. * @param onLoad defines a callback called when texture is loaded
  91294. * @param onError defines a callback called if there is an error
  91295. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91296. * @param invertY defines if data must be stored with Y axis inverted
  91297. * @returns the cube texture as an InternalTexture
  91298. */
  91299. 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;
  91300. /**
  91301. * Creates a new raw 3D texture
  91302. * @param data defines the data used to create the texture
  91303. * @param width defines the width of the texture
  91304. * @param height defines the height of the texture
  91305. * @param depth defines the depth of the texture
  91306. * @param format defines the format of the texture
  91307. * @param generateMipMaps defines if the engine must generate mip levels
  91308. * @param invertY defines if data must be stored with Y axis inverted
  91309. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91310. * @param compression defines the compressed used (can be null)
  91311. * @param textureType defines the compressed used (can be null)
  91312. * @returns a new raw 3D texture (stored in an InternalTexture)
  91313. */
  91314. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91315. /**
  91316. * Update a raw 3D texture
  91317. * @param texture defines the texture to update
  91318. * @param data defines the data to store
  91319. * @param format defines the data format
  91320. * @param invertY defines if data must be stored with Y axis inverted
  91321. */
  91322. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91323. /**
  91324. * Update a raw 3D texture
  91325. * @param texture defines the texture to update
  91326. * @param data defines the data to store
  91327. * @param format defines the data format
  91328. * @param invertY defines if data must be stored with Y axis inverted
  91329. * @param compression defines the used compression (can be null)
  91330. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91331. */
  91332. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91333. /**
  91334. * Creates a new raw 2D array texture
  91335. * @param data defines the data used to create the texture
  91336. * @param width defines the width of the texture
  91337. * @param height defines the height of the texture
  91338. * @param depth defines the number of layers of the texture
  91339. * @param format defines the format of the texture
  91340. * @param generateMipMaps defines if the engine must generate mip levels
  91341. * @param invertY defines if data must be stored with Y axis inverted
  91342. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91343. * @param compression defines the compressed used (can be null)
  91344. * @param textureType defines the compressed used (can be null)
  91345. * @returns a new raw 2D array texture (stored in an InternalTexture)
  91346. */
  91347. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91348. /**
  91349. * Update a raw 2D array texture
  91350. * @param texture defines the texture to update
  91351. * @param data defines the data to store
  91352. * @param format defines the data format
  91353. * @param invertY defines if data must be stored with Y axis inverted
  91354. */
  91355. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91356. /**
  91357. * Update a raw 2D array texture
  91358. * @param texture defines the texture to update
  91359. * @param data defines the data to store
  91360. * @param format defines the data format
  91361. * @param invertY defines if data must be stored with Y axis inverted
  91362. * @param compression defines the used compression (can be null)
  91363. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91364. */
  91365. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91366. }
  91367. }
  91368. declare module BABYLON {
  91369. /**
  91370. * Raw texture can help creating a texture directly from an array of data.
  91371. * This can be super useful if you either get the data from an uncompressed source or
  91372. * if you wish to create your texture pixel by pixel.
  91373. */
  91374. export class RawTexture extends Texture {
  91375. /**
  91376. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91377. */
  91378. format: number;
  91379. /**
  91380. * Instantiates a new RawTexture.
  91381. * Raw texture can help creating a texture directly from an array of data.
  91382. * This can be super useful if you either get the data from an uncompressed source or
  91383. * if you wish to create your texture pixel by pixel.
  91384. * @param data define the array of data to use to create the texture
  91385. * @param width define the width of the texture
  91386. * @param height define the height of the texture
  91387. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91388. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91389. * @param generateMipMaps define whether mip maps should be generated or not
  91390. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91391. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91392. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91393. */
  91394. constructor(data: ArrayBufferView, width: number, height: number,
  91395. /**
  91396. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91397. */
  91398. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  91399. /**
  91400. * Updates the texture underlying data.
  91401. * @param data Define the new data of the texture
  91402. */
  91403. update(data: ArrayBufferView): void;
  91404. /**
  91405. * Creates a luminance texture from some data.
  91406. * @param data Define the texture data
  91407. * @param width Define the width of the texture
  91408. * @param height Define the height of the texture
  91409. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91410. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91411. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91412. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91413. * @returns the luminance texture
  91414. */
  91415. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91416. /**
  91417. * Creates a luminance alpha texture from some data.
  91418. * @param data Define the texture data
  91419. * @param width Define the width of the texture
  91420. * @param height Define the height of the texture
  91421. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91422. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91423. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91424. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91425. * @returns the luminance alpha texture
  91426. */
  91427. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91428. /**
  91429. * Creates an alpha texture from some data.
  91430. * @param data Define the texture data
  91431. * @param width Define the width of the texture
  91432. * @param height Define the height of the texture
  91433. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91434. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91435. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91436. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91437. * @returns the alpha texture
  91438. */
  91439. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91440. /**
  91441. * Creates a RGB texture from some data.
  91442. * @param data Define the texture data
  91443. * @param width Define the width of the texture
  91444. * @param height Define the height of the texture
  91445. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91446. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91447. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91448. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91449. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91450. * @returns the RGB alpha texture
  91451. */
  91452. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91453. /**
  91454. * Creates a RGBA texture from some data.
  91455. * @param data Define the texture data
  91456. * @param width Define the width of the texture
  91457. * @param height Define the height of the texture
  91458. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91459. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91460. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91461. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91462. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91463. * @returns the RGBA texture
  91464. */
  91465. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91466. /**
  91467. * Creates a R texture from some data.
  91468. * @param data Define the texture data
  91469. * @param width Define the width of the texture
  91470. * @param height Define the height of the texture
  91471. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91472. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91473. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91474. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91475. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91476. * @returns the R texture
  91477. */
  91478. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91479. }
  91480. }
  91481. declare module BABYLON {
  91482. interface ThinEngine {
  91483. /**
  91484. * Update a dynamic index buffer
  91485. * @param indexBuffer defines the target index buffer
  91486. * @param indices defines the data to update
  91487. * @param offset defines the offset in the target index buffer where update should start
  91488. */
  91489. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91490. /**
  91491. * Updates a dynamic vertex buffer.
  91492. * @param vertexBuffer the vertex buffer to update
  91493. * @param data the data used to update the vertex buffer
  91494. * @param byteOffset the byte offset of the data
  91495. * @param byteLength the byte length of the data
  91496. */
  91497. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91498. }
  91499. }
  91500. declare module BABYLON {
  91501. interface AbstractScene {
  91502. /**
  91503. * The list of procedural textures added to the scene
  91504. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91505. */
  91506. proceduralTextures: Array<ProceduralTexture>;
  91507. }
  91508. /**
  91509. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  91510. * in a given scene.
  91511. */
  91512. export class ProceduralTextureSceneComponent implements ISceneComponent {
  91513. /**
  91514. * The component name helpfull to identify the component in the list of scene components.
  91515. */
  91516. readonly name: string;
  91517. /**
  91518. * The scene the component belongs to.
  91519. */
  91520. scene: Scene;
  91521. /**
  91522. * Creates a new instance of the component for the given scene
  91523. * @param scene Defines the scene to register the component in
  91524. */
  91525. constructor(scene: Scene);
  91526. /**
  91527. * Registers the component in a given scene
  91528. */
  91529. register(): void;
  91530. /**
  91531. * Rebuilds the elements related to this component in case of
  91532. * context lost for instance.
  91533. */
  91534. rebuild(): void;
  91535. /**
  91536. * Disposes the component and the associated ressources.
  91537. */
  91538. dispose(): void;
  91539. private _beforeClear;
  91540. }
  91541. }
  91542. declare module BABYLON {
  91543. interface ThinEngine {
  91544. /**
  91545. * Creates a new render target cube texture
  91546. * @param size defines the size of the texture
  91547. * @param options defines the options used to create the texture
  91548. * @returns a new render target cube texture stored in an InternalTexture
  91549. */
  91550. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  91551. }
  91552. }
  91553. declare module BABYLON {
  91554. /** @hidden */
  91555. export var proceduralVertexShader: {
  91556. name: string;
  91557. shader: string;
  91558. };
  91559. }
  91560. declare module BABYLON {
  91561. /**
  91562. * 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.
  91563. * This is the base class of any Procedural texture and contains most of the shareable code.
  91564. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91565. */
  91566. export class ProceduralTexture extends Texture {
  91567. /**
  91568. * Define if the texture is enabled or not (disabled texture will not render)
  91569. */
  91570. isEnabled: boolean;
  91571. /**
  91572. * Define if the texture must be cleared before rendering (default is true)
  91573. */
  91574. autoClear: boolean;
  91575. /**
  91576. * Callback called when the texture is generated
  91577. */
  91578. onGenerated: () => void;
  91579. /**
  91580. * Event raised when the texture is generated
  91581. */
  91582. onGeneratedObservable: Observable<ProceduralTexture>;
  91583. /** @hidden */
  91584. _generateMipMaps: boolean;
  91585. /** @hidden **/
  91586. _effect: Effect;
  91587. /** @hidden */
  91588. _textures: {
  91589. [key: string]: Texture;
  91590. };
  91591. /** @hidden */
  91592. protected _fallbackTexture: Nullable<Texture>;
  91593. private _size;
  91594. private _currentRefreshId;
  91595. private _frameId;
  91596. private _refreshRate;
  91597. private _vertexBuffers;
  91598. private _indexBuffer;
  91599. private _uniforms;
  91600. private _samplers;
  91601. private _fragment;
  91602. private _floats;
  91603. private _ints;
  91604. private _floatsArrays;
  91605. private _colors3;
  91606. private _colors4;
  91607. private _vectors2;
  91608. private _vectors3;
  91609. private _matrices;
  91610. private _fallbackTextureUsed;
  91611. private _fullEngine;
  91612. private _cachedDefines;
  91613. private _contentUpdateId;
  91614. private _contentData;
  91615. /**
  91616. * Instantiates a new procedural texture.
  91617. * 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.
  91618. * This is the base class of any Procedural texture and contains most of the shareable code.
  91619. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91620. * @param name Define the name of the texture
  91621. * @param size Define the size of the texture to create
  91622. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  91623. * @param scene Define the scene the texture belongs to
  91624. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  91625. * @param generateMipMaps Define if the texture should creates mip maps or not
  91626. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  91627. */
  91628. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  91629. /**
  91630. * The effect that is created when initializing the post process.
  91631. * @returns The created effect corresponding the the postprocess.
  91632. */
  91633. getEffect(): Effect;
  91634. /**
  91635. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  91636. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  91637. */
  91638. getContent(): Nullable<ArrayBufferView>;
  91639. private _createIndexBuffer;
  91640. /** @hidden */
  91641. _rebuild(): void;
  91642. /**
  91643. * Resets the texture in order to recreate its associated resources.
  91644. * This can be called in case of context loss
  91645. */
  91646. reset(): void;
  91647. protected _getDefines(): string;
  91648. /**
  91649. * Is the texture ready to be used ? (rendered at least once)
  91650. * @returns true if ready, otherwise, false.
  91651. */
  91652. isReady(): boolean;
  91653. /**
  91654. * Resets the refresh counter of the texture and start bak from scratch.
  91655. * Could be useful to regenerate the texture if it is setup to render only once.
  91656. */
  91657. resetRefreshCounter(): void;
  91658. /**
  91659. * Set the fragment shader to use in order to render the texture.
  91660. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  91661. */
  91662. setFragment(fragment: any): void;
  91663. /**
  91664. * Define the refresh rate of the texture or the rendering frequency.
  91665. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  91666. */
  91667. get refreshRate(): number;
  91668. set refreshRate(value: number);
  91669. /** @hidden */
  91670. _shouldRender(): boolean;
  91671. /**
  91672. * Get the size the texture is rendering at.
  91673. * @returns the size (texture is always squared)
  91674. */
  91675. getRenderSize(): number;
  91676. /**
  91677. * Resize the texture to new value.
  91678. * @param size Define the new size the texture should have
  91679. * @param generateMipMaps Define whether the new texture should create mip maps
  91680. */
  91681. resize(size: number, generateMipMaps: boolean): void;
  91682. private _checkUniform;
  91683. /**
  91684. * Set a texture in the shader program used to render.
  91685. * @param name Define the name of the uniform samplers as defined in the shader
  91686. * @param texture Define the texture to bind to this sampler
  91687. * @return the texture itself allowing "fluent" like uniform updates
  91688. */
  91689. setTexture(name: string, texture: Texture): ProceduralTexture;
  91690. /**
  91691. * Set a float in the shader.
  91692. * @param name Define the name of the uniform as defined in the shader
  91693. * @param value Define the value to give to the uniform
  91694. * @return the texture itself allowing "fluent" like uniform updates
  91695. */
  91696. setFloat(name: string, value: number): ProceduralTexture;
  91697. /**
  91698. * Set a int in the shader.
  91699. * @param name Define the name of the uniform as defined in the shader
  91700. * @param value Define the value to give to the uniform
  91701. * @return the texture itself allowing "fluent" like uniform updates
  91702. */
  91703. setInt(name: string, value: number): ProceduralTexture;
  91704. /**
  91705. * Set an array of floats in the shader.
  91706. * @param name Define the name of the uniform as defined in the shader
  91707. * @param value Define the value to give to the uniform
  91708. * @return the texture itself allowing "fluent" like uniform updates
  91709. */
  91710. setFloats(name: string, value: number[]): ProceduralTexture;
  91711. /**
  91712. * Set a vec3 in the shader from a Color3.
  91713. * @param name Define the name of the uniform as defined in the shader
  91714. * @param value Define the value to give to the uniform
  91715. * @return the texture itself allowing "fluent" like uniform updates
  91716. */
  91717. setColor3(name: string, value: Color3): ProceduralTexture;
  91718. /**
  91719. * Set a vec4 in the shader from a Color4.
  91720. * @param name Define the name of the uniform as defined in the shader
  91721. * @param value Define the value to give to the uniform
  91722. * @return the texture itself allowing "fluent" like uniform updates
  91723. */
  91724. setColor4(name: string, value: Color4): ProceduralTexture;
  91725. /**
  91726. * Set a vec2 in the shader from a Vector2.
  91727. * @param name Define the name of the uniform as defined in the shader
  91728. * @param value Define the value to give to the uniform
  91729. * @return the texture itself allowing "fluent" like uniform updates
  91730. */
  91731. setVector2(name: string, value: Vector2): ProceduralTexture;
  91732. /**
  91733. * Set a vec3 in the shader from a Vector3.
  91734. * @param name Define the name of the uniform as defined in the shader
  91735. * @param value Define the value to give to the uniform
  91736. * @return the texture itself allowing "fluent" like uniform updates
  91737. */
  91738. setVector3(name: string, value: Vector3): ProceduralTexture;
  91739. /**
  91740. * Set a mat4 in the shader from a MAtrix.
  91741. * @param name Define the name of the uniform as defined in the shader
  91742. * @param value Define the value to give to the uniform
  91743. * @return the texture itself allowing "fluent" like uniform updates
  91744. */
  91745. setMatrix(name: string, value: Matrix): ProceduralTexture;
  91746. /**
  91747. * Render the texture to its associated render target.
  91748. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  91749. */
  91750. render(useCameraPostProcess?: boolean): void;
  91751. /**
  91752. * Clone the texture.
  91753. * @returns the cloned texture
  91754. */
  91755. clone(): ProceduralTexture;
  91756. /**
  91757. * Dispose the texture and release its asoociated resources.
  91758. */
  91759. dispose(): void;
  91760. }
  91761. }
  91762. declare module BABYLON {
  91763. /**
  91764. * This represents the base class for particle system in Babylon.
  91765. * 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.
  91766. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  91767. * @example https://doc.babylonjs.com/babylon101/particles
  91768. */
  91769. export class BaseParticleSystem {
  91770. /**
  91771. * Source color is added to the destination color without alpha affecting the result
  91772. */
  91773. static BLENDMODE_ONEONE: number;
  91774. /**
  91775. * Blend current color and particle color using particle’s alpha
  91776. */
  91777. static BLENDMODE_STANDARD: number;
  91778. /**
  91779. * Add current color and particle color multiplied by particle’s alpha
  91780. */
  91781. static BLENDMODE_ADD: number;
  91782. /**
  91783. * Multiply current color with particle color
  91784. */
  91785. static BLENDMODE_MULTIPLY: number;
  91786. /**
  91787. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  91788. */
  91789. static BLENDMODE_MULTIPLYADD: number;
  91790. /**
  91791. * List of animations used by the particle system.
  91792. */
  91793. animations: Animation[];
  91794. /**
  91795. * Gets or sets the unique id of the particle system
  91796. */
  91797. uniqueId: number;
  91798. /**
  91799. * The id of the Particle system.
  91800. */
  91801. id: string;
  91802. /**
  91803. * The friendly name of the Particle system.
  91804. */
  91805. name: string;
  91806. /**
  91807. * Snippet ID if the particle system was created from the snippet server
  91808. */
  91809. snippetId: string;
  91810. /**
  91811. * The rendering group used by the Particle system to chose when to render.
  91812. */
  91813. renderingGroupId: number;
  91814. /**
  91815. * The emitter represents the Mesh or position we are attaching the particle system to.
  91816. */
  91817. emitter: Nullable<AbstractMesh | Vector3>;
  91818. /**
  91819. * The maximum number of particles to emit per frame
  91820. */
  91821. emitRate: number;
  91822. /**
  91823. * If you want to launch only a few particles at once, that can be done, as well.
  91824. */
  91825. manualEmitCount: number;
  91826. /**
  91827. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91828. */
  91829. updateSpeed: number;
  91830. /**
  91831. * The amount of time the particle system is running (depends of the overall update speed).
  91832. */
  91833. targetStopDuration: number;
  91834. /**
  91835. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91836. */
  91837. disposeOnStop: boolean;
  91838. /**
  91839. * Minimum power of emitting particles.
  91840. */
  91841. minEmitPower: number;
  91842. /**
  91843. * Maximum power of emitting particles.
  91844. */
  91845. maxEmitPower: number;
  91846. /**
  91847. * Minimum life time of emitting particles.
  91848. */
  91849. minLifeTime: number;
  91850. /**
  91851. * Maximum life time of emitting particles.
  91852. */
  91853. maxLifeTime: number;
  91854. /**
  91855. * Minimum Size of emitting particles.
  91856. */
  91857. minSize: number;
  91858. /**
  91859. * Maximum Size of emitting particles.
  91860. */
  91861. maxSize: number;
  91862. /**
  91863. * Minimum scale of emitting particles on X axis.
  91864. */
  91865. minScaleX: number;
  91866. /**
  91867. * Maximum scale of emitting particles on X axis.
  91868. */
  91869. maxScaleX: number;
  91870. /**
  91871. * Minimum scale of emitting particles on Y axis.
  91872. */
  91873. minScaleY: number;
  91874. /**
  91875. * Maximum scale of emitting particles on Y axis.
  91876. */
  91877. maxScaleY: number;
  91878. /**
  91879. * Gets or sets the minimal initial rotation in radians.
  91880. */
  91881. minInitialRotation: number;
  91882. /**
  91883. * Gets or sets the maximal initial rotation in radians.
  91884. */
  91885. maxInitialRotation: number;
  91886. /**
  91887. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91888. */
  91889. minAngularSpeed: number;
  91890. /**
  91891. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91892. */
  91893. maxAngularSpeed: number;
  91894. /**
  91895. * The texture used to render each particle. (this can be a spritesheet)
  91896. */
  91897. particleTexture: Nullable<BaseTexture>;
  91898. /**
  91899. * The layer mask we are rendering the particles through.
  91900. */
  91901. layerMask: number;
  91902. /**
  91903. * This can help using your own shader to render the particle system.
  91904. * The according effect will be created
  91905. */
  91906. customShader: any;
  91907. /**
  91908. * By default particle system starts as soon as they are created. This prevents the
  91909. * automatic start to happen and let you decide when to start emitting particles.
  91910. */
  91911. preventAutoStart: boolean;
  91912. private _noiseTexture;
  91913. /**
  91914. * Gets or sets a texture used to add random noise to particle positions
  91915. */
  91916. get noiseTexture(): Nullable<ProceduralTexture>;
  91917. set noiseTexture(value: Nullable<ProceduralTexture>);
  91918. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91919. noiseStrength: Vector3;
  91920. /**
  91921. * Callback triggered when the particle animation is ending.
  91922. */
  91923. onAnimationEnd: Nullable<() => void>;
  91924. /**
  91925. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  91926. */
  91927. blendMode: number;
  91928. /**
  91929. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  91930. * to override the particles.
  91931. */
  91932. forceDepthWrite: boolean;
  91933. /** 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 */
  91934. preWarmCycles: number;
  91935. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  91936. preWarmStepOffset: number;
  91937. /**
  91938. * 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)
  91939. */
  91940. spriteCellChangeSpeed: number;
  91941. /**
  91942. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91943. */
  91944. startSpriteCellID: number;
  91945. /**
  91946. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91947. */
  91948. endSpriteCellID: number;
  91949. /**
  91950. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91951. */
  91952. spriteCellWidth: number;
  91953. /**
  91954. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91955. */
  91956. spriteCellHeight: number;
  91957. /**
  91958. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91959. */
  91960. spriteRandomStartCell: boolean;
  91961. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91962. translationPivot: Vector2;
  91963. /** @hidden */
  91964. protected _isAnimationSheetEnabled: boolean;
  91965. /**
  91966. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91967. */
  91968. beginAnimationOnStart: boolean;
  91969. /**
  91970. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91971. */
  91972. beginAnimationFrom: number;
  91973. /**
  91974. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91975. */
  91976. beginAnimationTo: number;
  91977. /**
  91978. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91979. */
  91980. beginAnimationLoop: boolean;
  91981. /**
  91982. * Gets or sets a world offset applied to all particles
  91983. */
  91984. worldOffset: Vector3;
  91985. /**
  91986. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  91987. */
  91988. get isAnimationSheetEnabled(): boolean;
  91989. set isAnimationSheetEnabled(value: boolean);
  91990. /**
  91991. * Get hosting scene
  91992. * @returns the scene
  91993. */
  91994. getScene(): Nullable<Scene>;
  91995. /**
  91996. * You can use gravity if you want to give an orientation to your particles.
  91997. */
  91998. gravity: Vector3;
  91999. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92000. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92001. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92002. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92003. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92004. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92005. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92006. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92007. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92008. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92009. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92010. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92011. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92012. /**
  92013. * Defines the delay in milliseconds before starting the system (0 by default)
  92014. */
  92015. startDelay: number;
  92016. /**
  92017. * Gets the current list of drag gradients.
  92018. * You must use addDragGradient and removeDragGradient to udpate this list
  92019. * @returns the list of drag gradients
  92020. */
  92021. getDragGradients(): Nullable<Array<FactorGradient>>;
  92022. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92023. limitVelocityDamping: number;
  92024. /**
  92025. * Gets the current list of limit velocity gradients.
  92026. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92027. * @returns the list of limit velocity gradients
  92028. */
  92029. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92030. /**
  92031. * Gets the current list of color gradients.
  92032. * You must use addColorGradient and removeColorGradient to udpate this list
  92033. * @returns the list of color gradients
  92034. */
  92035. getColorGradients(): Nullable<Array<ColorGradient>>;
  92036. /**
  92037. * Gets the current list of size gradients.
  92038. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92039. * @returns the list of size gradients
  92040. */
  92041. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92042. /**
  92043. * Gets the current list of color remap gradients.
  92044. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92045. * @returns the list of color remap gradients
  92046. */
  92047. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92048. /**
  92049. * Gets the current list of alpha remap gradients.
  92050. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92051. * @returns the list of alpha remap gradients
  92052. */
  92053. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92054. /**
  92055. * Gets the current list of life time gradients.
  92056. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92057. * @returns the list of life time gradients
  92058. */
  92059. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92060. /**
  92061. * Gets the current list of angular speed gradients.
  92062. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92063. * @returns the list of angular speed gradients
  92064. */
  92065. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92066. /**
  92067. * Gets the current list of velocity gradients.
  92068. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92069. * @returns the list of velocity gradients
  92070. */
  92071. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92072. /**
  92073. * Gets the current list of start size gradients.
  92074. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92075. * @returns the list of start size gradients
  92076. */
  92077. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92078. /**
  92079. * Gets the current list of emit rate gradients.
  92080. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92081. * @returns the list of emit rate gradients
  92082. */
  92083. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92084. /**
  92085. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92086. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92087. */
  92088. get direction1(): Vector3;
  92089. set direction1(value: Vector3);
  92090. /**
  92091. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92092. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92093. */
  92094. get direction2(): Vector3;
  92095. set direction2(value: Vector3);
  92096. /**
  92097. * 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.
  92098. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92099. */
  92100. get minEmitBox(): Vector3;
  92101. set minEmitBox(value: Vector3);
  92102. /**
  92103. * 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.
  92104. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92105. */
  92106. get maxEmitBox(): Vector3;
  92107. set maxEmitBox(value: Vector3);
  92108. /**
  92109. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92110. */
  92111. color1: Color4;
  92112. /**
  92113. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92114. */
  92115. color2: Color4;
  92116. /**
  92117. * Color the particle will have at the end of its lifetime
  92118. */
  92119. colorDead: Color4;
  92120. /**
  92121. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  92122. */
  92123. textureMask: Color4;
  92124. /**
  92125. * The particle emitter type defines the emitter used by the particle system.
  92126. * It can be for example box, sphere, or cone...
  92127. */
  92128. particleEmitterType: IParticleEmitterType;
  92129. /** @hidden */
  92130. _isSubEmitter: boolean;
  92131. /**
  92132. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92133. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92134. */
  92135. billboardMode: number;
  92136. protected _isBillboardBased: boolean;
  92137. /**
  92138. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92139. */
  92140. get isBillboardBased(): boolean;
  92141. set isBillboardBased(value: boolean);
  92142. /**
  92143. * The scene the particle system belongs to.
  92144. */
  92145. protected _scene: Nullable<Scene>;
  92146. /**
  92147. * The engine the particle system belongs to.
  92148. */
  92149. protected _engine: ThinEngine;
  92150. /**
  92151. * Local cache of defines for image processing.
  92152. */
  92153. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  92154. /**
  92155. * Default configuration related to image processing available in the standard Material.
  92156. */
  92157. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  92158. /**
  92159. * Gets the image processing configuration used either in this material.
  92160. */
  92161. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  92162. /**
  92163. * Sets the Default image processing configuration used either in the this material.
  92164. *
  92165. * If sets to null, the scene one is in use.
  92166. */
  92167. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  92168. /**
  92169. * Attaches a new image processing configuration to the Standard Material.
  92170. * @param configuration
  92171. */
  92172. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  92173. /** @hidden */
  92174. protected _reset(): void;
  92175. /** @hidden */
  92176. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  92177. /**
  92178. * Instantiates a particle system.
  92179. * 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.
  92180. * @param name The name of the particle system
  92181. */
  92182. constructor(name: string);
  92183. /**
  92184. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92185. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92186. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92187. * @returns the emitter
  92188. */
  92189. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92190. /**
  92191. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92192. * @param radius The radius of the hemisphere to emit from
  92193. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92194. * @returns the emitter
  92195. */
  92196. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  92197. /**
  92198. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92199. * @param radius The radius of the sphere to emit from
  92200. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92201. * @returns the emitter
  92202. */
  92203. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  92204. /**
  92205. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92206. * @param radius The radius of the sphere to emit from
  92207. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92208. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92209. * @returns the emitter
  92210. */
  92211. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  92212. /**
  92213. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92214. * @param radius The radius of the emission cylinder
  92215. * @param height The height of the emission cylinder
  92216. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92217. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92218. * @returns the emitter
  92219. */
  92220. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  92221. /**
  92222. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92223. * @param radius The radius of the cylinder to emit from
  92224. * @param height The height of the emission cylinder
  92225. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92226. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92227. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92228. * @returns the emitter
  92229. */
  92230. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  92231. /**
  92232. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92233. * @param radius The radius of the cone to emit from
  92234. * @param angle The base angle of the cone
  92235. * @returns the emitter
  92236. */
  92237. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  92238. /**
  92239. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92240. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92241. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92242. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92243. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92244. * @returns the emitter
  92245. */
  92246. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92247. }
  92248. }
  92249. declare module BABYLON {
  92250. /**
  92251. * Type of sub emitter
  92252. */
  92253. export enum SubEmitterType {
  92254. /**
  92255. * Attached to the particle over it's lifetime
  92256. */
  92257. ATTACHED = 0,
  92258. /**
  92259. * Created when the particle dies
  92260. */
  92261. END = 1
  92262. }
  92263. /**
  92264. * Sub emitter class used to emit particles from an existing particle
  92265. */
  92266. export class SubEmitter {
  92267. /**
  92268. * the particle system to be used by the sub emitter
  92269. */
  92270. particleSystem: ParticleSystem;
  92271. /**
  92272. * Type of the submitter (Default: END)
  92273. */
  92274. type: SubEmitterType;
  92275. /**
  92276. * 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)
  92277. * Note: This only is supported when using an emitter of type Mesh
  92278. */
  92279. inheritDirection: boolean;
  92280. /**
  92281. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  92282. */
  92283. inheritedVelocityAmount: number;
  92284. /**
  92285. * Creates a sub emitter
  92286. * @param particleSystem the particle system to be used by the sub emitter
  92287. */
  92288. constructor(
  92289. /**
  92290. * the particle system to be used by the sub emitter
  92291. */
  92292. particleSystem: ParticleSystem);
  92293. /**
  92294. * Clones the sub emitter
  92295. * @returns the cloned sub emitter
  92296. */
  92297. clone(): SubEmitter;
  92298. /**
  92299. * Serialize current object to a JSON object
  92300. * @returns the serialized object
  92301. */
  92302. serialize(): any;
  92303. /** @hidden */
  92304. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  92305. /**
  92306. * Creates a new SubEmitter from a serialized JSON version
  92307. * @param serializationObject defines the JSON object to read from
  92308. * @param sceneOrEngine defines the hosting scene or the hosting engine
  92309. * @param rootUrl defines the rootUrl for data loading
  92310. * @returns a new SubEmitter
  92311. */
  92312. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  92313. /** Release associated resources */
  92314. dispose(): void;
  92315. }
  92316. }
  92317. declare module BABYLON {
  92318. /** @hidden */
  92319. export var imageProcessingDeclaration: {
  92320. name: string;
  92321. shader: string;
  92322. };
  92323. }
  92324. declare module BABYLON {
  92325. /** @hidden */
  92326. export var imageProcessingFunctions: {
  92327. name: string;
  92328. shader: string;
  92329. };
  92330. }
  92331. declare module BABYLON {
  92332. /** @hidden */
  92333. export var particlesPixelShader: {
  92334. name: string;
  92335. shader: string;
  92336. };
  92337. }
  92338. declare module BABYLON {
  92339. /** @hidden */
  92340. export var particlesVertexShader: {
  92341. name: string;
  92342. shader: string;
  92343. };
  92344. }
  92345. declare module BABYLON {
  92346. /**
  92347. * Interface used to define entities containing multiple clip planes
  92348. */
  92349. export interface IClipPlanesHolder {
  92350. /**
  92351. * Gets or sets the active clipplane 1
  92352. */
  92353. clipPlane: Nullable<Plane>;
  92354. /**
  92355. * Gets or sets the active clipplane 2
  92356. */
  92357. clipPlane2: Nullable<Plane>;
  92358. /**
  92359. * Gets or sets the active clipplane 3
  92360. */
  92361. clipPlane3: Nullable<Plane>;
  92362. /**
  92363. * Gets or sets the active clipplane 4
  92364. */
  92365. clipPlane4: Nullable<Plane>;
  92366. /**
  92367. * Gets or sets the active clipplane 5
  92368. */
  92369. clipPlane5: Nullable<Plane>;
  92370. /**
  92371. * Gets or sets the active clipplane 6
  92372. */
  92373. clipPlane6: Nullable<Plane>;
  92374. }
  92375. }
  92376. declare module BABYLON {
  92377. /**
  92378. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  92379. *
  92380. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  92381. *
  92382. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  92383. */
  92384. export class ThinMaterialHelper {
  92385. /**
  92386. * Binds the clip plane information from the holder to the effect.
  92387. * @param effect The effect we are binding the data to
  92388. * @param holder The entity containing the clip plane information
  92389. */
  92390. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  92391. }
  92392. }
  92393. declare module BABYLON {
  92394. interface ThinEngine {
  92395. /**
  92396. * Sets alpha constants used by some alpha blending modes
  92397. * @param r defines the red component
  92398. * @param g defines the green component
  92399. * @param b defines the blue component
  92400. * @param a defines the alpha component
  92401. */
  92402. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  92403. /**
  92404. * Sets the current alpha mode
  92405. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  92406. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  92407. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92408. */
  92409. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  92410. /**
  92411. * Gets the current alpha mode
  92412. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92413. * @returns the current alpha mode
  92414. */
  92415. getAlphaMode(): number;
  92416. /**
  92417. * Sets the current alpha equation
  92418. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  92419. */
  92420. setAlphaEquation(equation: number): void;
  92421. /**
  92422. * Gets the current alpha equation.
  92423. * @returns the current alpha equation
  92424. */
  92425. getAlphaEquation(): number;
  92426. }
  92427. }
  92428. declare module BABYLON {
  92429. /**
  92430. * This represents a particle system in Babylon.
  92431. * 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.
  92432. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92433. * @example https://doc.babylonjs.com/babylon101/particles
  92434. */
  92435. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  92436. /**
  92437. * Billboard mode will only apply to Y axis
  92438. */
  92439. static readonly BILLBOARDMODE_Y: number;
  92440. /**
  92441. * Billboard mode will apply to all axes
  92442. */
  92443. static readonly BILLBOARDMODE_ALL: number;
  92444. /**
  92445. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  92446. */
  92447. static readonly BILLBOARDMODE_STRETCHED: number;
  92448. /**
  92449. * This function can be defined to provide custom update for active particles.
  92450. * This function will be called instead of regular update (age, position, color, etc.).
  92451. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  92452. */
  92453. updateFunction: (particles: Particle[]) => void;
  92454. private _emitterWorldMatrix;
  92455. /**
  92456. * This function can be defined to specify initial direction for every new particle.
  92457. * It by default use the emitterType defined function
  92458. */
  92459. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92460. /**
  92461. * This function can be defined to specify initial position for every new particle.
  92462. * It by default use the emitterType defined function
  92463. */
  92464. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92465. /**
  92466. * @hidden
  92467. */
  92468. _inheritedVelocityOffset: Vector3;
  92469. /**
  92470. * An event triggered when the system is disposed
  92471. */
  92472. onDisposeObservable: Observable<IParticleSystem>;
  92473. private _onDisposeObserver;
  92474. /**
  92475. * Sets a callback that will be triggered when the system is disposed
  92476. */
  92477. set onDispose(callback: () => void);
  92478. private _particles;
  92479. private _epsilon;
  92480. private _capacity;
  92481. private _stockParticles;
  92482. private _newPartsExcess;
  92483. private _vertexData;
  92484. private _vertexBuffer;
  92485. private _vertexBuffers;
  92486. private _spriteBuffer;
  92487. private _indexBuffer;
  92488. private _effect;
  92489. private _customEffect;
  92490. private _cachedDefines;
  92491. private _scaledColorStep;
  92492. private _colorDiff;
  92493. private _scaledDirection;
  92494. private _scaledGravity;
  92495. private _currentRenderId;
  92496. private _alive;
  92497. private _useInstancing;
  92498. private _started;
  92499. private _stopped;
  92500. private _actualFrame;
  92501. private _scaledUpdateSpeed;
  92502. private _vertexBufferSize;
  92503. /** @hidden */
  92504. _currentEmitRateGradient: Nullable<FactorGradient>;
  92505. /** @hidden */
  92506. _currentEmitRate1: number;
  92507. /** @hidden */
  92508. _currentEmitRate2: number;
  92509. /** @hidden */
  92510. _currentStartSizeGradient: Nullable<FactorGradient>;
  92511. /** @hidden */
  92512. _currentStartSize1: number;
  92513. /** @hidden */
  92514. _currentStartSize2: number;
  92515. private readonly _rawTextureWidth;
  92516. private _rampGradientsTexture;
  92517. private _useRampGradients;
  92518. /** Gets or sets a matrix to use to compute projection */
  92519. defaultProjectionMatrix: Matrix;
  92520. /** Gets or sets a matrix to use to compute view */
  92521. defaultViewMatrix: Matrix;
  92522. /** Gets or sets a boolean indicating that ramp gradients must be used
  92523. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92524. */
  92525. get useRampGradients(): boolean;
  92526. set useRampGradients(value: boolean);
  92527. /**
  92528. * 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.
  92529. * 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: [])
  92530. */
  92531. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  92532. private _subEmitters;
  92533. /**
  92534. * @hidden
  92535. * If the particle systems emitter should be disposed when the particle system is disposed
  92536. */
  92537. _disposeEmitterOnDispose: boolean;
  92538. /**
  92539. * The current active Sub-systems, this property is used by the root particle system only.
  92540. */
  92541. activeSubSystems: Array<ParticleSystem>;
  92542. /**
  92543. * Specifies if the particles are updated in emitter local space or world space
  92544. */
  92545. isLocal: boolean;
  92546. private _rootParticleSystem;
  92547. /**
  92548. * Gets the current list of active particles
  92549. */
  92550. get particles(): Particle[];
  92551. /**
  92552. * Gets the number of particles active at the same time.
  92553. * @returns The number of active particles.
  92554. */
  92555. getActiveCount(): number;
  92556. /**
  92557. * Returns the string "ParticleSystem"
  92558. * @returns a string containing the class name
  92559. */
  92560. getClassName(): string;
  92561. /**
  92562. * Gets a boolean indicating that the system is stopping
  92563. * @returns true if the system is currently stopping
  92564. */
  92565. isStopping(): boolean;
  92566. /**
  92567. * Gets the custom effect used to render the particles
  92568. * @param blendMode Blend mode for which the effect should be retrieved
  92569. * @returns The effect
  92570. */
  92571. getCustomEffect(blendMode?: number): Nullable<Effect>;
  92572. /**
  92573. * Sets the custom effect used to render the particles
  92574. * @param effect The effect to set
  92575. * @param blendMode Blend mode for which the effect should be set
  92576. */
  92577. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  92578. /** @hidden */
  92579. private _onBeforeDrawParticlesObservable;
  92580. /**
  92581. * Observable that will be called just before the particles are drawn
  92582. */
  92583. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  92584. /**
  92585. * Gets the name of the particle vertex shader
  92586. */
  92587. get vertexShaderName(): string;
  92588. /**
  92589. * Instantiates a particle system.
  92590. * 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.
  92591. * @param name The name of the particle system
  92592. * @param capacity The max number of particles alive at the same time
  92593. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  92594. * @param customEffect a custom effect used to change the way particles are rendered by default
  92595. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  92596. * @param epsilon Offset used to render the particles
  92597. */
  92598. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  92599. private _addFactorGradient;
  92600. private _removeFactorGradient;
  92601. /**
  92602. * Adds a new life time gradient
  92603. * @param gradient defines the gradient to use (between 0 and 1)
  92604. * @param factor defines the life time factor to affect to the specified gradient
  92605. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92606. * @returns the current particle system
  92607. */
  92608. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92609. /**
  92610. * Remove a specific life time gradient
  92611. * @param gradient defines the gradient to remove
  92612. * @returns the current particle system
  92613. */
  92614. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92615. /**
  92616. * Adds a new size gradient
  92617. * @param gradient defines the gradient to use (between 0 and 1)
  92618. * @param factor defines the size factor to affect to the specified gradient
  92619. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92620. * @returns the current particle system
  92621. */
  92622. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92623. /**
  92624. * Remove a specific size gradient
  92625. * @param gradient defines the gradient to remove
  92626. * @returns the current particle system
  92627. */
  92628. removeSizeGradient(gradient: number): IParticleSystem;
  92629. /**
  92630. * Adds a new color remap gradient
  92631. * @param gradient defines the gradient to use (between 0 and 1)
  92632. * @param min defines the color remap minimal range
  92633. * @param max defines the color remap maximal range
  92634. * @returns the current particle system
  92635. */
  92636. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92637. /**
  92638. * Remove a specific color remap gradient
  92639. * @param gradient defines the gradient to remove
  92640. * @returns the current particle system
  92641. */
  92642. removeColorRemapGradient(gradient: number): IParticleSystem;
  92643. /**
  92644. * Adds a new alpha remap gradient
  92645. * @param gradient defines the gradient to use (between 0 and 1)
  92646. * @param min defines the alpha remap minimal range
  92647. * @param max defines the alpha remap maximal range
  92648. * @returns the current particle system
  92649. */
  92650. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92651. /**
  92652. * Remove a specific alpha remap gradient
  92653. * @param gradient defines the gradient to remove
  92654. * @returns the current particle system
  92655. */
  92656. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  92657. /**
  92658. * Adds a new angular speed gradient
  92659. * @param gradient defines the gradient to use (between 0 and 1)
  92660. * @param factor defines the angular speed to affect to the specified gradient
  92661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92662. * @returns the current particle system
  92663. */
  92664. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92665. /**
  92666. * Remove a specific angular speed gradient
  92667. * @param gradient defines the gradient to remove
  92668. * @returns the current particle system
  92669. */
  92670. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92671. /**
  92672. * Adds a new velocity gradient
  92673. * @param gradient defines the gradient to use (between 0 and 1)
  92674. * @param factor defines the velocity to affect to the specified gradient
  92675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92676. * @returns the current particle system
  92677. */
  92678. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92679. /**
  92680. * Remove a specific velocity gradient
  92681. * @param gradient defines the gradient to remove
  92682. * @returns the current particle system
  92683. */
  92684. removeVelocityGradient(gradient: number): IParticleSystem;
  92685. /**
  92686. * Adds a new limit velocity gradient
  92687. * @param gradient defines the gradient to use (between 0 and 1)
  92688. * @param factor defines the limit velocity value to affect to the specified gradient
  92689. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92690. * @returns the current particle system
  92691. */
  92692. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92693. /**
  92694. * Remove a specific limit velocity gradient
  92695. * @param gradient defines the gradient to remove
  92696. * @returns the current particle system
  92697. */
  92698. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92699. /**
  92700. * Adds a new drag gradient
  92701. * @param gradient defines the gradient to use (between 0 and 1)
  92702. * @param factor defines the drag value to affect to the specified gradient
  92703. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92704. * @returns the current particle system
  92705. */
  92706. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92707. /**
  92708. * Remove a specific drag gradient
  92709. * @param gradient defines the gradient to remove
  92710. * @returns the current particle system
  92711. */
  92712. removeDragGradient(gradient: number): IParticleSystem;
  92713. /**
  92714. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92715. * @param gradient defines the gradient to use (between 0 and 1)
  92716. * @param factor defines the emit rate value to affect to the specified gradient
  92717. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92718. * @returns the current particle system
  92719. */
  92720. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92721. /**
  92722. * Remove a specific emit rate gradient
  92723. * @param gradient defines the gradient to remove
  92724. * @returns the current particle system
  92725. */
  92726. removeEmitRateGradient(gradient: number): IParticleSystem;
  92727. /**
  92728. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92729. * @param gradient defines the gradient to use (between 0 and 1)
  92730. * @param factor defines the start size value to affect to the specified gradient
  92731. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92732. * @returns the current particle system
  92733. */
  92734. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92735. /**
  92736. * Remove a specific start size gradient
  92737. * @param gradient defines the gradient to remove
  92738. * @returns the current particle system
  92739. */
  92740. removeStartSizeGradient(gradient: number): IParticleSystem;
  92741. private _createRampGradientTexture;
  92742. /**
  92743. * Gets the current list of ramp gradients.
  92744. * You must use addRampGradient and removeRampGradient to udpate this list
  92745. * @returns the list of ramp gradients
  92746. */
  92747. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92748. /** Force the system to rebuild all gradients that need to be resync */
  92749. forceRefreshGradients(): void;
  92750. private _syncRampGradientTexture;
  92751. /**
  92752. * Adds a new ramp gradient used to remap particle colors
  92753. * @param gradient defines the gradient to use (between 0 and 1)
  92754. * @param color defines the color to affect to the specified gradient
  92755. * @returns the current particle system
  92756. */
  92757. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  92758. /**
  92759. * Remove a specific ramp gradient
  92760. * @param gradient defines the gradient to remove
  92761. * @returns the current particle system
  92762. */
  92763. removeRampGradient(gradient: number): ParticleSystem;
  92764. /**
  92765. * Adds a new color gradient
  92766. * @param gradient defines the gradient to use (between 0 and 1)
  92767. * @param color1 defines the color to affect to the specified gradient
  92768. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92769. * @returns this particle system
  92770. */
  92771. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92772. /**
  92773. * Remove a specific color gradient
  92774. * @param gradient defines the gradient to remove
  92775. * @returns this particle system
  92776. */
  92777. removeColorGradient(gradient: number): IParticleSystem;
  92778. private _fetchR;
  92779. protected _reset(): void;
  92780. private _resetEffect;
  92781. private _createVertexBuffers;
  92782. private _createIndexBuffer;
  92783. /**
  92784. * Gets the maximum number of particles active at the same time.
  92785. * @returns The max number of active particles.
  92786. */
  92787. getCapacity(): number;
  92788. /**
  92789. * Gets whether there are still active particles in the system.
  92790. * @returns True if it is alive, otherwise false.
  92791. */
  92792. isAlive(): boolean;
  92793. /**
  92794. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92795. * @returns True if it has been started, otherwise false.
  92796. */
  92797. isStarted(): boolean;
  92798. private _prepareSubEmitterInternalArray;
  92799. /**
  92800. * Starts the particle system and begins to emit
  92801. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  92802. */
  92803. start(delay?: number): void;
  92804. /**
  92805. * Stops the particle system.
  92806. * @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.
  92807. */
  92808. stop(stopSubEmitters?: boolean): void;
  92809. /**
  92810. * Remove all active particles
  92811. */
  92812. reset(): void;
  92813. /**
  92814. * @hidden (for internal use only)
  92815. */
  92816. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  92817. /**
  92818. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  92819. * Its lifetime will start back at 0.
  92820. */
  92821. recycleParticle: (particle: Particle) => void;
  92822. private _stopSubEmitters;
  92823. private _createParticle;
  92824. private _removeFromRoot;
  92825. private _emitFromParticle;
  92826. private _update;
  92827. /** @hidden */
  92828. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  92829. /** @hidden */
  92830. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  92831. /**
  92832. * Fill the defines array according to the current settings of the particle system
  92833. * @param defines Array to be updated
  92834. * @param blendMode blend mode to take into account when updating the array
  92835. */
  92836. fillDefines(defines: Array<string>, blendMode: number): void;
  92837. /**
  92838. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  92839. * @param uniforms Uniforms array to fill
  92840. * @param attributes Attributes array to fill
  92841. * @param samplers Samplers array to fill
  92842. */
  92843. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  92844. /** @hidden */
  92845. private _getEffect;
  92846. /**
  92847. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  92848. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  92849. */
  92850. animate(preWarmOnly?: boolean): void;
  92851. private _appendParticleVertices;
  92852. /**
  92853. * Rebuilds the particle system.
  92854. */
  92855. rebuild(): void;
  92856. /**
  92857. * Is this system ready to be used/rendered
  92858. * @return true if the system is ready
  92859. */
  92860. isReady(): boolean;
  92861. private _render;
  92862. /**
  92863. * Renders the particle system in its current state.
  92864. * @returns the current number of particles
  92865. */
  92866. render(): number;
  92867. /**
  92868. * Disposes the particle system and free the associated resources
  92869. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92870. */
  92871. dispose(disposeTexture?: boolean): void;
  92872. /**
  92873. * Clones the particle system.
  92874. * @param name The name of the cloned object
  92875. * @param newEmitter The new emitter to use
  92876. * @returns the cloned particle system
  92877. */
  92878. clone(name: string, newEmitter: any): ParticleSystem;
  92879. /**
  92880. * Serializes the particle system to a JSON object
  92881. * @param serializeTexture defines if the texture must be serialized as well
  92882. * @returns the JSON object
  92883. */
  92884. serialize(serializeTexture?: boolean): any;
  92885. /** @hidden */
  92886. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  92887. /** @hidden */
  92888. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  92889. /**
  92890. * Parses a JSON object to create a particle system.
  92891. * @param parsedParticleSystem The JSON object to parse
  92892. * @param sceneOrEngine The scene or the engine to create the particle system in
  92893. * @param rootUrl The root url to use to load external dependencies like texture
  92894. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  92895. * @returns the Parsed particle system
  92896. */
  92897. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  92898. }
  92899. }
  92900. declare module BABYLON {
  92901. /**
  92902. * A particle represents one of the element emitted by a particle system.
  92903. * This is mainly define by its coordinates, direction, velocity and age.
  92904. */
  92905. export class Particle {
  92906. /**
  92907. * The particle system the particle belongs to.
  92908. */
  92909. particleSystem: ParticleSystem;
  92910. private static _Count;
  92911. /**
  92912. * Unique ID of the particle
  92913. */
  92914. id: number;
  92915. /**
  92916. * The world position of the particle in the scene.
  92917. */
  92918. position: Vector3;
  92919. /**
  92920. * The world direction of the particle in the scene.
  92921. */
  92922. direction: Vector3;
  92923. /**
  92924. * The color of the particle.
  92925. */
  92926. color: Color4;
  92927. /**
  92928. * The color change of the particle per step.
  92929. */
  92930. colorStep: Color4;
  92931. /**
  92932. * Defines how long will the life of the particle be.
  92933. */
  92934. lifeTime: number;
  92935. /**
  92936. * The current age of the particle.
  92937. */
  92938. age: number;
  92939. /**
  92940. * The current size of the particle.
  92941. */
  92942. size: number;
  92943. /**
  92944. * The current scale of the particle.
  92945. */
  92946. scale: Vector2;
  92947. /**
  92948. * The current angle of the particle.
  92949. */
  92950. angle: number;
  92951. /**
  92952. * Defines how fast is the angle changing.
  92953. */
  92954. angularSpeed: number;
  92955. /**
  92956. * Defines the cell index used by the particle to be rendered from a sprite.
  92957. */
  92958. cellIndex: number;
  92959. /**
  92960. * The information required to support color remapping
  92961. */
  92962. remapData: Vector4;
  92963. /** @hidden */
  92964. _randomCellOffset?: number;
  92965. /** @hidden */
  92966. _initialDirection: Nullable<Vector3>;
  92967. /** @hidden */
  92968. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  92969. /** @hidden */
  92970. _initialStartSpriteCellID: number;
  92971. /** @hidden */
  92972. _initialEndSpriteCellID: number;
  92973. /** @hidden */
  92974. _currentColorGradient: Nullable<ColorGradient>;
  92975. /** @hidden */
  92976. _currentColor1: Color4;
  92977. /** @hidden */
  92978. _currentColor2: Color4;
  92979. /** @hidden */
  92980. _currentSizeGradient: Nullable<FactorGradient>;
  92981. /** @hidden */
  92982. _currentSize1: number;
  92983. /** @hidden */
  92984. _currentSize2: number;
  92985. /** @hidden */
  92986. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  92987. /** @hidden */
  92988. _currentAngularSpeed1: number;
  92989. /** @hidden */
  92990. _currentAngularSpeed2: number;
  92991. /** @hidden */
  92992. _currentVelocityGradient: Nullable<FactorGradient>;
  92993. /** @hidden */
  92994. _currentVelocity1: number;
  92995. /** @hidden */
  92996. _currentVelocity2: number;
  92997. /** @hidden */
  92998. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  92999. /** @hidden */
  93000. _currentLimitVelocity1: number;
  93001. /** @hidden */
  93002. _currentLimitVelocity2: number;
  93003. /** @hidden */
  93004. _currentDragGradient: Nullable<FactorGradient>;
  93005. /** @hidden */
  93006. _currentDrag1: number;
  93007. /** @hidden */
  93008. _currentDrag2: number;
  93009. /** @hidden */
  93010. _randomNoiseCoordinates1: Vector3;
  93011. /** @hidden */
  93012. _randomNoiseCoordinates2: Vector3;
  93013. /** @hidden */
  93014. _localPosition?: Vector3;
  93015. /**
  93016. * Creates a new instance Particle
  93017. * @param particleSystem the particle system the particle belongs to
  93018. */
  93019. constructor(
  93020. /**
  93021. * The particle system the particle belongs to.
  93022. */
  93023. particleSystem: ParticleSystem);
  93024. private updateCellInfoFromSystem;
  93025. /**
  93026. * Defines how the sprite cell index is updated for the particle
  93027. */
  93028. updateCellIndex(): void;
  93029. /** @hidden */
  93030. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  93031. /** @hidden */
  93032. _inheritParticleInfoToSubEmitters(): void;
  93033. /** @hidden */
  93034. _reset(): void;
  93035. /**
  93036. * Copy the properties of particle to another one.
  93037. * @param other the particle to copy the information to.
  93038. */
  93039. copyTo(other: Particle): void;
  93040. }
  93041. }
  93042. declare module BABYLON {
  93043. /**
  93044. * Particle emitter represents a volume emitting particles.
  93045. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  93046. */
  93047. export interface IParticleEmitterType {
  93048. /**
  93049. * Called by the particle System when the direction is computed for the created particle.
  93050. * @param worldMatrix is the world matrix of the particle system
  93051. * @param directionToUpdate is the direction vector to update with the result
  93052. * @param particle is the particle we are computed the direction for
  93053. * @param isLocal defines if the direction should be set in local space
  93054. */
  93055. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93056. /**
  93057. * Called by the particle System when the position is computed for the created particle.
  93058. * @param worldMatrix is the world matrix of the particle system
  93059. * @param positionToUpdate is the position vector to update with the result
  93060. * @param particle is the particle we are computed the position for
  93061. * @param isLocal defines if the position should be set in local space
  93062. */
  93063. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93064. /**
  93065. * Clones the current emitter and returns a copy of it
  93066. * @returns the new emitter
  93067. */
  93068. clone(): IParticleEmitterType;
  93069. /**
  93070. * Called by the GPUParticleSystem to setup the update shader
  93071. * @param effect defines the update shader
  93072. */
  93073. applyToShader(effect: Effect): void;
  93074. /**
  93075. * Returns a string to use to update the GPU particles update shader
  93076. * @returns the effect defines string
  93077. */
  93078. getEffectDefines(): string;
  93079. /**
  93080. * Returns a string representing the class name
  93081. * @returns a string containing the class name
  93082. */
  93083. getClassName(): string;
  93084. /**
  93085. * Serializes the particle system to a JSON object.
  93086. * @returns the JSON object
  93087. */
  93088. serialize(): any;
  93089. /**
  93090. * Parse properties from a JSON object
  93091. * @param serializationObject defines the JSON object
  93092. * @param scene defines the hosting scene
  93093. */
  93094. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93095. }
  93096. }
  93097. declare module BABYLON {
  93098. /**
  93099. * Particle emitter emitting particles from the inside of a box.
  93100. * It emits the particles randomly between 2 given directions.
  93101. */
  93102. export class BoxParticleEmitter implements IParticleEmitterType {
  93103. /**
  93104. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93105. */
  93106. direction1: Vector3;
  93107. /**
  93108. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93109. */
  93110. direction2: Vector3;
  93111. /**
  93112. * 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.
  93113. */
  93114. minEmitBox: Vector3;
  93115. /**
  93116. * 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.
  93117. */
  93118. maxEmitBox: Vector3;
  93119. /**
  93120. * Creates a new instance BoxParticleEmitter
  93121. */
  93122. constructor();
  93123. /**
  93124. * Called by the particle System when the direction is computed for the created particle.
  93125. * @param worldMatrix is the world matrix of the particle system
  93126. * @param directionToUpdate is the direction vector to update with the result
  93127. * @param particle is the particle we are computed the direction for
  93128. * @param isLocal defines if the direction should be set in local space
  93129. */
  93130. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93131. /**
  93132. * Called by the particle System when the position is computed for the created particle.
  93133. * @param worldMatrix is the world matrix of the particle system
  93134. * @param positionToUpdate is the position vector to update with the result
  93135. * @param particle is the particle we are computed the position for
  93136. * @param isLocal defines if the position should be set in local space
  93137. */
  93138. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93139. /**
  93140. * Clones the current emitter and returns a copy of it
  93141. * @returns the new emitter
  93142. */
  93143. clone(): BoxParticleEmitter;
  93144. /**
  93145. * Called by the GPUParticleSystem to setup the update shader
  93146. * @param effect defines the update shader
  93147. */
  93148. applyToShader(effect: Effect): void;
  93149. /**
  93150. * Returns a string to use to update the GPU particles update shader
  93151. * @returns a string containng the defines string
  93152. */
  93153. getEffectDefines(): string;
  93154. /**
  93155. * Returns the string "BoxParticleEmitter"
  93156. * @returns a string containing the class name
  93157. */
  93158. getClassName(): string;
  93159. /**
  93160. * Serializes the particle system to a JSON object.
  93161. * @returns the JSON object
  93162. */
  93163. serialize(): any;
  93164. /**
  93165. * Parse properties from a JSON object
  93166. * @param serializationObject defines the JSON object
  93167. */
  93168. parse(serializationObject: any): void;
  93169. }
  93170. }
  93171. declare module BABYLON {
  93172. /**
  93173. * Particle emitter emitting particles from the inside of a cone.
  93174. * It emits the particles alongside the cone volume from the base to the particle.
  93175. * The emission direction might be randomized.
  93176. */
  93177. export class ConeParticleEmitter implements IParticleEmitterType {
  93178. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93179. directionRandomizer: number;
  93180. private _radius;
  93181. private _angle;
  93182. private _height;
  93183. /**
  93184. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  93185. */
  93186. radiusRange: number;
  93187. /**
  93188. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  93189. */
  93190. heightRange: number;
  93191. /**
  93192. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  93193. */
  93194. emitFromSpawnPointOnly: boolean;
  93195. /**
  93196. * Gets or sets the radius of the emission cone
  93197. */
  93198. get radius(): number;
  93199. set radius(value: number);
  93200. /**
  93201. * Gets or sets the angle of the emission cone
  93202. */
  93203. get angle(): number;
  93204. set angle(value: number);
  93205. private _buildHeight;
  93206. /**
  93207. * Creates a new instance ConeParticleEmitter
  93208. * @param radius the radius of the emission cone (1 by default)
  93209. * @param angle the cone base angle (PI by default)
  93210. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  93211. */
  93212. constructor(radius?: number, angle?: number,
  93213. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93214. directionRandomizer?: number);
  93215. /**
  93216. * Called by the particle System when the direction is computed for the created particle.
  93217. * @param worldMatrix is the world matrix of the particle system
  93218. * @param directionToUpdate is the direction vector to update with the result
  93219. * @param particle is the particle we are computed the direction for
  93220. * @param isLocal defines if the direction should be set in local space
  93221. */
  93222. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93223. /**
  93224. * Called by the particle System when the position is computed for the created particle.
  93225. * @param worldMatrix is the world matrix of the particle system
  93226. * @param positionToUpdate is the position vector to update with the result
  93227. * @param particle is the particle we are computed the position for
  93228. * @param isLocal defines if the position should be set in local space
  93229. */
  93230. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93231. /**
  93232. * Clones the current emitter and returns a copy of it
  93233. * @returns the new emitter
  93234. */
  93235. clone(): ConeParticleEmitter;
  93236. /**
  93237. * Called by the GPUParticleSystem to setup the update shader
  93238. * @param effect defines the update shader
  93239. */
  93240. applyToShader(effect: Effect): void;
  93241. /**
  93242. * Returns a string to use to update the GPU particles update shader
  93243. * @returns a string containng the defines string
  93244. */
  93245. getEffectDefines(): string;
  93246. /**
  93247. * Returns the string "ConeParticleEmitter"
  93248. * @returns a string containing the class name
  93249. */
  93250. getClassName(): string;
  93251. /**
  93252. * Serializes the particle system to a JSON object.
  93253. * @returns the JSON object
  93254. */
  93255. serialize(): any;
  93256. /**
  93257. * Parse properties from a JSON object
  93258. * @param serializationObject defines the JSON object
  93259. */
  93260. parse(serializationObject: any): void;
  93261. }
  93262. }
  93263. declare module BABYLON {
  93264. /**
  93265. * Particle emitter emitting particles from the inside of a cylinder.
  93266. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  93267. */
  93268. export class CylinderParticleEmitter implements IParticleEmitterType {
  93269. /**
  93270. * The radius of the emission cylinder.
  93271. */
  93272. radius: number;
  93273. /**
  93274. * The height of the emission cylinder.
  93275. */
  93276. height: number;
  93277. /**
  93278. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93279. */
  93280. radiusRange: number;
  93281. /**
  93282. * How much to randomize the particle direction [0-1].
  93283. */
  93284. directionRandomizer: number;
  93285. /**
  93286. * Creates a new instance CylinderParticleEmitter
  93287. * @param radius the radius of the emission cylinder (1 by default)
  93288. * @param height the height of the emission cylinder (1 by default)
  93289. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93290. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93291. */
  93292. constructor(
  93293. /**
  93294. * The radius of the emission cylinder.
  93295. */
  93296. radius?: number,
  93297. /**
  93298. * The height of the emission cylinder.
  93299. */
  93300. height?: number,
  93301. /**
  93302. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93303. */
  93304. radiusRange?: number,
  93305. /**
  93306. * How much to randomize the particle direction [0-1].
  93307. */
  93308. directionRandomizer?: number);
  93309. /**
  93310. * Called by the particle System when the direction is computed for the created particle.
  93311. * @param worldMatrix is the world matrix of the particle system
  93312. * @param directionToUpdate is the direction vector to update with the result
  93313. * @param particle is the particle we are computed the direction for
  93314. * @param isLocal defines if the direction should be set in local space
  93315. */
  93316. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93317. /**
  93318. * Called by the particle System when the position is computed for the created particle.
  93319. * @param worldMatrix is the world matrix of the particle system
  93320. * @param positionToUpdate is the position vector to update with the result
  93321. * @param particle is the particle we are computed the position for
  93322. * @param isLocal defines if the position should be set in local space
  93323. */
  93324. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93325. /**
  93326. * Clones the current emitter and returns a copy of it
  93327. * @returns the new emitter
  93328. */
  93329. clone(): CylinderParticleEmitter;
  93330. /**
  93331. * Called by the GPUParticleSystem to setup the update shader
  93332. * @param effect defines the update shader
  93333. */
  93334. applyToShader(effect: Effect): void;
  93335. /**
  93336. * Returns a string to use to update the GPU particles update shader
  93337. * @returns a string containng the defines string
  93338. */
  93339. getEffectDefines(): string;
  93340. /**
  93341. * Returns the string "CylinderParticleEmitter"
  93342. * @returns a string containing the class name
  93343. */
  93344. getClassName(): string;
  93345. /**
  93346. * Serializes the particle system to a JSON object.
  93347. * @returns the JSON object
  93348. */
  93349. serialize(): any;
  93350. /**
  93351. * Parse properties from a JSON object
  93352. * @param serializationObject defines the JSON object
  93353. */
  93354. parse(serializationObject: any): void;
  93355. }
  93356. /**
  93357. * Particle emitter emitting particles from the inside of a cylinder.
  93358. * It emits the particles randomly between two vectors.
  93359. */
  93360. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  93361. /**
  93362. * The min limit of the emission direction.
  93363. */
  93364. direction1: Vector3;
  93365. /**
  93366. * The max limit of the emission direction.
  93367. */
  93368. direction2: Vector3;
  93369. /**
  93370. * Creates a new instance CylinderDirectedParticleEmitter
  93371. * @param radius the radius of the emission cylinder (1 by default)
  93372. * @param height the height of the emission cylinder (1 by default)
  93373. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93374. * @param direction1 the min limit of the emission direction (up vector by default)
  93375. * @param direction2 the max limit of the emission direction (up vector by default)
  93376. */
  93377. constructor(radius?: number, height?: number, radiusRange?: number,
  93378. /**
  93379. * The min limit of the emission direction.
  93380. */
  93381. direction1?: Vector3,
  93382. /**
  93383. * The max limit of the emission direction.
  93384. */
  93385. direction2?: Vector3);
  93386. /**
  93387. * Called by the particle System when the direction is computed for the created particle.
  93388. * @param worldMatrix is the world matrix of the particle system
  93389. * @param directionToUpdate is the direction vector to update with the result
  93390. * @param particle is the particle we are computed the direction for
  93391. */
  93392. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93393. /**
  93394. * Clones the current emitter and returns a copy of it
  93395. * @returns the new emitter
  93396. */
  93397. clone(): CylinderDirectedParticleEmitter;
  93398. /**
  93399. * Called by the GPUParticleSystem to setup the update shader
  93400. * @param effect defines the update shader
  93401. */
  93402. applyToShader(effect: Effect): void;
  93403. /**
  93404. * Returns a string to use to update the GPU particles update shader
  93405. * @returns a string containng the defines string
  93406. */
  93407. getEffectDefines(): string;
  93408. /**
  93409. * Returns the string "CylinderDirectedParticleEmitter"
  93410. * @returns a string containing the class name
  93411. */
  93412. getClassName(): string;
  93413. /**
  93414. * Serializes the particle system to a JSON object.
  93415. * @returns the JSON object
  93416. */
  93417. serialize(): any;
  93418. /**
  93419. * Parse properties from a JSON object
  93420. * @param serializationObject defines the JSON object
  93421. */
  93422. parse(serializationObject: any): void;
  93423. }
  93424. }
  93425. declare module BABYLON {
  93426. /**
  93427. * Particle emitter emitting particles from the inside of a hemisphere.
  93428. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  93429. */
  93430. export class HemisphericParticleEmitter implements IParticleEmitterType {
  93431. /**
  93432. * The radius of the emission hemisphere.
  93433. */
  93434. radius: number;
  93435. /**
  93436. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93437. */
  93438. radiusRange: number;
  93439. /**
  93440. * How much to randomize the particle direction [0-1].
  93441. */
  93442. directionRandomizer: number;
  93443. /**
  93444. * Creates a new instance HemisphericParticleEmitter
  93445. * @param radius the radius of the emission hemisphere (1 by default)
  93446. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93447. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93448. */
  93449. constructor(
  93450. /**
  93451. * The radius of the emission hemisphere.
  93452. */
  93453. radius?: number,
  93454. /**
  93455. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93456. */
  93457. radiusRange?: number,
  93458. /**
  93459. * How much to randomize the particle direction [0-1].
  93460. */
  93461. directionRandomizer?: number);
  93462. /**
  93463. * Called by the particle System when the direction is computed for the created particle.
  93464. * @param worldMatrix is the world matrix of the particle system
  93465. * @param directionToUpdate is the direction vector to update with the result
  93466. * @param particle is the particle we are computed the direction for
  93467. * @param isLocal defines if the direction should be set in local space
  93468. */
  93469. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93470. /**
  93471. * Called by the particle System when the position is computed for the created particle.
  93472. * @param worldMatrix is the world matrix of the particle system
  93473. * @param positionToUpdate is the position vector to update with the result
  93474. * @param particle is the particle we are computed the position for
  93475. * @param isLocal defines if the position should be set in local space
  93476. */
  93477. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93478. /**
  93479. * Clones the current emitter and returns a copy of it
  93480. * @returns the new emitter
  93481. */
  93482. clone(): HemisphericParticleEmitter;
  93483. /**
  93484. * Called by the GPUParticleSystem to setup the update shader
  93485. * @param effect defines the update shader
  93486. */
  93487. applyToShader(effect: Effect): void;
  93488. /**
  93489. * Returns a string to use to update the GPU particles update shader
  93490. * @returns a string containng the defines string
  93491. */
  93492. getEffectDefines(): string;
  93493. /**
  93494. * Returns the string "HemisphericParticleEmitter"
  93495. * @returns a string containing the class name
  93496. */
  93497. getClassName(): string;
  93498. /**
  93499. * Serializes the particle system to a JSON object.
  93500. * @returns the JSON object
  93501. */
  93502. serialize(): any;
  93503. /**
  93504. * Parse properties from a JSON object
  93505. * @param serializationObject defines the JSON object
  93506. */
  93507. parse(serializationObject: any): void;
  93508. }
  93509. }
  93510. declare module BABYLON {
  93511. /**
  93512. * Particle emitter emitting particles from a point.
  93513. * It emits the particles randomly between 2 given directions.
  93514. */
  93515. export class PointParticleEmitter implements IParticleEmitterType {
  93516. /**
  93517. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93518. */
  93519. direction1: Vector3;
  93520. /**
  93521. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93522. */
  93523. direction2: Vector3;
  93524. /**
  93525. * Creates a new instance PointParticleEmitter
  93526. */
  93527. constructor();
  93528. /**
  93529. * Called by the particle System when the direction is computed for the created particle.
  93530. * @param worldMatrix is the world matrix of the particle system
  93531. * @param directionToUpdate is the direction vector to update with the result
  93532. * @param particle is the particle we are computed the direction for
  93533. * @param isLocal defines if the direction should be set in local space
  93534. */
  93535. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93536. /**
  93537. * Called by the particle System when the position is computed for the created particle.
  93538. * @param worldMatrix is the world matrix of the particle system
  93539. * @param positionToUpdate is the position vector to update with the result
  93540. * @param particle is the particle we are computed the position for
  93541. * @param isLocal defines if the position should be set in local space
  93542. */
  93543. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93544. /**
  93545. * Clones the current emitter and returns a copy of it
  93546. * @returns the new emitter
  93547. */
  93548. clone(): PointParticleEmitter;
  93549. /**
  93550. * Called by the GPUParticleSystem to setup the update shader
  93551. * @param effect defines the update shader
  93552. */
  93553. applyToShader(effect: Effect): void;
  93554. /**
  93555. * Returns a string to use to update the GPU particles update shader
  93556. * @returns a string containng the defines string
  93557. */
  93558. getEffectDefines(): string;
  93559. /**
  93560. * Returns the string "PointParticleEmitter"
  93561. * @returns a string containing the class name
  93562. */
  93563. getClassName(): string;
  93564. /**
  93565. * Serializes the particle system to a JSON object.
  93566. * @returns the JSON object
  93567. */
  93568. serialize(): any;
  93569. /**
  93570. * Parse properties from a JSON object
  93571. * @param serializationObject defines the JSON object
  93572. */
  93573. parse(serializationObject: any): void;
  93574. }
  93575. }
  93576. declare module BABYLON {
  93577. /**
  93578. * Particle emitter emitting particles from the inside of a sphere.
  93579. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  93580. */
  93581. export class SphereParticleEmitter implements IParticleEmitterType {
  93582. /**
  93583. * The radius of the emission sphere.
  93584. */
  93585. radius: number;
  93586. /**
  93587. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93588. */
  93589. radiusRange: number;
  93590. /**
  93591. * How much to randomize the particle direction [0-1].
  93592. */
  93593. directionRandomizer: number;
  93594. /**
  93595. * Creates a new instance SphereParticleEmitter
  93596. * @param radius the radius of the emission sphere (1 by default)
  93597. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93598. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93599. */
  93600. constructor(
  93601. /**
  93602. * The radius of the emission sphere.
  93603. */
  93604. radius?: number,
  93605. /**
  93606. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93607. */
  93608. radiusRange?: number,
  93609. /**
  93610. * How much to randomize the particle direction [0-1].
  93611. */
  93612. directionRandomizer?: number);
  93613. /**
  93614. * Called by the particle System when the direction is computed for the created particle.
  93615. * @param worldMatrix is the world matrix of the particle system
  93616. * @param directionToUpdate is the direction vector to update with the result
  93617. * @param particle is the particle we are computed the direction for
  93618. * @param isLocal defines if the direction should be set in local space
  93619. */
  93620. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93621. /**
  93622. * Called by the particle System when the position is computed for the created particle.
  93623. * @param worldMatrix is the world matrix of the particle system
  93624. * @param positionToUpdate is the position vector to update with the result
  93625. * @param particle is the particle we are computed the position for
  93626. * @param isLocal defines if the position should be set in local space
  93627. */
  93628. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93629. /**
  93630. * Clones the current emitter and returns a copy of it
  93631. * @returns the new emitter
  93632. */
  93633. clone(): SphereParticleEmitter;
  93634. /**
  93635. * Called by the GPUParticleSystem to setup the update shader
  93636. * @param effect defines the update shader
  93637. */
  93638. applyToShader(effect: Effect): void;
  93639. /**
  93640. * Returns a string to use to update the GPU particles update shader
  93641. * @returns a string containng the defines string
  93642. */
  93643. getEffectDefines(): string;
  93644. /**
  93645. * Returns the string "SphereParticleEmitter"
  93646. * @returns a string containing the class name
  93647. */
  93648. getClassName(): string;
  93649. /**
  93650. * Serializes the particle system to a JSON object.
  93651. * @returns the JSON object
  93652. */
  93653. serialize(): any;
  93654. /**
  93655. * Parse properties from a JSON object
  93656. * @param serializationObject defines the JSON object
  93657. */
  93658. parse(serializationObject: any): void;
  93659. }
  93660. /**
  93661. * Particle emitter emitting particles from the inside of a sphere.
  93662. * It emits the particles randomly between two vectors.
  93663. */
  93664. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  93665. /**
  93666. * The min limit of the emission direction.
  93667. */
  93668. direction1: Vector3;
  93669. /**
  93670. * The max limit of the emission direction.
  93671. */
  93672. direction2: Vector3;
  93673. /**
  93674. * Creates a new instance SphereDirectedParticleEmitter
  93675. * @param radius the radius of the emission sphere (1 by default)
  93676. * @param direction1 the min limit of the emission direction (up vector by default)
  93677. * @param direction2 the max limit of the emission direction (up vector by default)
  93678. */
  93679. constructor(radius?: number,
  93680. /**
  93681. * The min limit of the emission direction.
  93682. */
  93683. direction1?: Vector3,
  93684. /**
  93685. * The max limit of the emission direction.
  93686. */
  93687. direction2?: Vector3);
  93688. /**
  93689. * Called by the particle System when the direction is computed for the created particle.
  93690. * @param worldMatrix is the world matrix of the particle system
  93691. * @param directionToUpdate is the direction vector to update with the result
  93692. * @param particle is the particle we are computed the direction for
  93693. */
  93694. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93695. /**
  93696. * Clones the current emitter and returns a copy of it
  93697. * @returns the new emitter
  93698. */
  93699. clone(): SphereDirectedParticleEmitter;
  93700. /**
  93701. * Called by the GPUParticleSystem to setup the update shader
  93702. * @param effect defines the update shader
  93703. */
  93704. applyToShader(effect: Effect): void;
  93705. /**
  93706. * Returns a string to use to update the GPU particles update shader
  93707. * @returns a string containng the defines string
  93708. */
  93709. getEffectDefines(): string;
  93710. /**
  93711. * Returns the string "SphereDirectedParticleEmitter"
  93712. * @returns a string containing the class name
  93713. */
  93714. getClassName(): string;
  93715. /**
  93716. * Serializes the particle system to a JSON object.
  93717. * @returns the JSON object
  93718. */
  93719. serialize(): any;
  93720. /**
  93721. * Parse properties from a JSON object
  93722. * @param serializationObject defines the JSON object
  93723. */
  93724. parse(serializationObject: any): void;
  93725. }
  93726. }
  93727. declare module BABYLON {
  93728. /**
  93729. * Particle emitter emitting particles from a custom list of positions.
  93730. */
  93731. export class CustomParticleEmitter implements IParticleEmitterType {
  93732. /**
  93733. * Gets or sets the position generator that will create the inital position of each particle.
  93734. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  93735. */
  93736. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  93737. /**
  93738. * Gets or sets the destination generator that will create the final destination of each particle.
  93739. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  93740. */
  93741. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  93742. /**
  93743. * Creates a new instance CustomParticleEmitter
  93744. */
  93745. constructor();
  93746. /**
  93747. * Called by the particle System when the direction is computed for the created particle.
  93748. * @param worldMatrix is the world matrix of the particle system
  93749. * @param directionToUpdate is the direction vector to update with the result
  93750. * @param particle is the particle we are computed the direction for
  93751. * @param isLocal defines if the direction should be set in local space
  93752. */
  93753. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93754. /**
  93755. * Called by the particle System when the position is computed for the created particle.
  93756. * @param worldMatrix is the world matrix of the particle system
  93757. * @param positionToUpdate is the position vector to update with the result
  93758. * @param particle is the particle we are computed the position for
  93759. * @param isLocal defines if the position should be set in local space
  93760. */
  93761. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93762. /**
  93763. * Clones the current emitter and returns a copy of it
  93764. * @returns the new emitter
  93765. */
  93766. clone(): CustomParticleEmitter;
  93767. /**
  93768. * Called by the GPUParticleSystem to setup the update shader
  93769. * @param effect defines the update shader
  93770. */
  93771. applyToShader(effect: Effect): void;
  93772. /**
  93773. * Returns a string to use to update the GPU particles update shader
  93774. * @returns a string containng the defines string
  93775. */
  93776. getEffectDefines(): string;
  93777. /**
  93778. * Returns the string "PointParticleEmitter"
  93779. * @returns a string containing the class name
  93780. */
  93781. getClassName(): string;
  93782. /**
  93783. * Serializes the particle system to a JSON object.
  93784. * @returns the JSON object
  93785. */
  93786. serialize(): any;
  93787. /**
  93788. * Parse properties from a JSON object
  93789. * @param serializationObject defines the JSON object
  93790. */
  93791. parse(serializationObject: any): void;
  93792. }
  93793. }
  93794. declare module BABYLON {
  93795. /**
  93796. * Particle emitter emitting particles from the inside of a box.
  93797. * It emits the particles randomly between 2 given directions.
  93798. */
  93799. export class MeshParticleEmitter implements IParticleEmitterType {
  93800. private _indices;
  93801. private _positions;
  93802. private _normals;
  93803. private _storedNormal;
  93804. private _mesh;
  93805. /**
  93806. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93807. */
  93808. direction1: Vector3;
  93809. /**
  93810. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93811. */
  93812. direction2: Vector3;
  93813. /**
  93814. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  93815. */
  93816. useMeshNormalsForDirection: boolean;
  93817. /** Defines the mesh to use as source */
  93818. get mesh(): Nullable<AbstractMesh>;
  93819. set mesh(value: Nullable<AbstractMesh>);
  93820. /**
  93821. * Creates a new instance MeshParticleEmitter
  93822. * @param mesh defines the mesh to use as source
  93823. */
  93824. constructor(mesh?: Nullable<AbstractMesh>);
  93825. /**
  93826. * Called by the particle System when the direction is computed for the created particle.
  93827. * @param worldMatrix is the world matrix of the particle system
  93828. * @param directionToUpdate is the direction vector to update with the result
  93829. * @param particle is the particle we are computed the direction for
  93830. * @param isLocal defines if the direction should be set in local space
  93831. */
  93832. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93833. /**
  93834. * Called by the particle System when the position is computed for the created particle.
  93835. * @param worldMatrix is the world matrix of the particle system
  93836. * @param positionToUpdate is the position vector to update with the result
  93837. * @param particle is the particle we are computed the position for
  93838. * @param isLocal defines if the position should be set in local space
  93839. */
  93840. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93841. /**
  93842. * Clones the current emitter and returns a copy of it
  93843. * @returns the new emitter
  93844. */
  93845. clone(): MeshParticleEmitter;
  93846. /**
  93847. * Called by the GPUParticleSystem to setup the update shader
  93848. * @param effect defines the update shader
  93849. */
  93850. applyToShader(effect: Effect): void;
  93851. /**
  93852. * Returns a string to use to update the GPU particles update shader
  93853. * @returns a string containng the defines string
  93854. */
  93855. getEffectDefines(): string;
  93856. /**
  93857. * Returns the string "BoxParticleEmitter"
  93858. * @returns a string containing the class name
  93859. */
  93860. getClassName(): string;
  93861. /**
  93862. * Serializes the particle system to a JSON object.
  93863. * @returns the JSON object
  93864. */
  93865. serialize(): any;
  93866. /**
  93867. * Parse properties from a JSON object
  93868. * @param serializationObject defines the JSON object
  93869. * @param scene defines the hosting scene
  93870. */
  93871. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93872. }
  93873. }
  93874. declare module BABYLON {
  93875. /**
  93876. * Interface representing a particle system in Babylon.js.
  93877. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  93878. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  93879. */
  93880. export interface IParticleSystem {
  93881. /**
  93882. * List of animations used by the particle system.
  93883. */
  93884. animations: Animation[];
  93885. /**
  93886. * The id of the Particle system.
  93887. */
  93888. id: string;
  93889. /**
  93890. * The name of the Particle system.
  93891. */
  93892. name: string;
  93893. /**
  93894. * The emitter represents the Mesh or position we are attaching the particle system to.
  93895. */
  93896. emitter: Nullable<AbstractMesh | Vector3>;
  93897. /**
  93898. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93899. */
  93900. isBillboardBased: boolean;
  93901. /**
  93902. * The rendering group used by the Particle system to chose when to render.
  93903. */
  93904. renderingGroupId: number;
  93905. /**
  93906. * The layer mask we are rendering the particles through.
  93907. */
  93908. layerMask: number;
  93909. /**
  93910. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  93911. */
  93912. updateSpeed: number;
  93913. /**
  93914. * The amount of time the particle system is running (depends of the overall update speed).
  93915. */
  93916. targetStopDuration: number;
  93917. /**
  93918. * The texture used to render each particle. (this can be a spritesheet)
  93919. */
  93920. particleTexture: Nullable<BaseTexture>;
  93921. /**
  93922. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  93923. */
  93924. blendMode: number;
  93925. /**
  93926. * Minimum life time of emitting particles.
  93927. */
  93928. minLifeTime: number;
  93929. /**
  93930. * Maximum life time of emitting particles.
  93931. */
  93932. maxLifeTime: number;
  93933. /**
  93934. * Minimum Size of emitting particles.
  93935. */
  93936. minSize: number;
  93937. /**
  93938. * Maximum Size of emitting particles.
  93939. */
  93940. maxSize: number;
  93941. /**
  93942. * Minimum scale of emitting particles on X axis.
  93943. */
  93944. minScaleX: number;
  93945. /**
  93946. * Maximum scale of emitting particles on X axis.
  93947. */
  93948. maxScaleX: number;
  93949. /**
  93950. * Minimum scale of emitting particles on Y axis.
  93951. */
  93952. minScaleY: number;
  93953. /**
  93954. * Maximum scale of emitting particles on Y axis.
  93955. */
  93956. maxScaleY: number;
  93957. /**
  93958. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93959. */
  93960. color1: Color4;
  93961. /**
  93962. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93963. */
  93964. color2: Color4;
  93965. /**
  93966. * Color the particle will have at the end of its lifetime.
  93967. */
  93968. colorDead: Color4;
  93969. /**
  93970. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  93971. */
  93972. emitRate: number;
  93973. /**
  93974. * You can use gravity if you want to give an orientation to your particles.
  93975. */
  93976. gravity: Vector3;
  93977. /**
  93978. * Minimum power of emitting particles.
  93979. */
  93980. minEmitPower: number;
  93981. /**
  93982. * Maximum power of emitting particles.
  93983. */
  93984. maxEmitPower: number;
  93985. /**
  93986. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  93987. */
  93988. minAngularSpeed: number;
  93989. /**
  93990. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  93991. */
  93992. maxAngularSpeed: number;
  93993. /**
  93994. * Gets or sets the minimal initial rotation in radians.
  93995. */
  93996. minInitialRotation: number;
  93997. /**
  93998. * Gets or sets the maximal initial rotation in radians.
  93999. */
  94000. maxInitialRotation: number;
  94001. /**
  94002. * The particle emitter type defines the emitter used by the particle system.
  94003. * It can be for example box, sphere, or cone...
  94004. */
  94005. particleEmitterType: Nullable<IParticleEmitterType>;
  94006. /**
  94007. * Defines the delay in milliseconds before starting the system (0 by default)
  94008. */
  94009. startDelay: number;
  94010. /**
  94011. * 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
  94012. */
  94013. preWarmCycles: number;
  94014. /**
  94015. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94016. */
  94017. preWarmStepOffset: number;
  94018. /**
  94019. * 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)
  94020. */
  94021. spriteCellChangeSpeed: number;
  94022. /**
  94023. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94024. */
  94025. startSpriteCellID: number;
  94026. /**
  94027. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  94028. */
  94029. endSpriteCellID: number;
  94030. /**
  94031. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  94032. */
  94033. spriteCellWidth: number;
  94034. /**
  94035. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  94036. */
  94037. spriteCellHeight: number;
  94038. /**
  94039. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  94040. */
  94041. spriteRandomStartCell: boolean;
  94042. /**
  94043. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  94044. */
  94045. isAnimationSheetEnabled: boolean;
  94046. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  94047. translationPivot: Vector2;
  94048. /**
  94049. * Gets or sets a texture used to add random noise to particle positions
  94050. */
  94051. noiseTexture: Nullable<BaseTexture>;
  94052. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  94053. noiseStrength: Vector3;
  94054. /**
  94055. * Gets or sets the billboard mode to use when isBillboardBased = true.
  94056. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  94057. */
  94058. billboardMode: number;
  94059. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  94060. limitVelocityDamping: number;
  94061. /**
  94062. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  94063. */
  94064. beginAnimationOnStart: boolean;
  94065. /**
  94066. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  94067. */
  94068. beginAnimationFrom: number;
  94069. /**
  94070. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  94071. */
  94072. beginAnimationTo: number;
  94073. /**
  94074. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  94075. */
  94076. beginAnimationLoop: boolean;
  94077. /**
  94078. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  94079. */
  94080. disposeOnStop: boolean;
  94081. /**
  94082. * Specifies if the particles are updated in emitter local space or world space
  94083. */
  94084. isLocal: boolean;
  94085. /** Snippet ID if the particle system was created from the snippet server */
  94086. snippetId: string;
  94087. /** Gets or sets a matrix to use to compute projection */
  94088. defaultProjectionMatrix: Matrix;
  94089. /**
  94090. * Gets the maximum number of particles active at the same time.
  94091. * @returns The max number of active particles.
  94092. */
  94093. getCapacity(): number;
  94094. /**
  94095. * Gets the number of particles active at the same time.
  94096. * @returns The number of active particles.
  94097. */
  94098. getActiveCount(): number;
  94099. /**
  94100. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94101. * @returns True if it has been started, otherwise false.
  94102. */
  94103. isStarted(): boolean;
  94104. /**
  94105. * Animates the particle system for this frame.
  94106. */
  94107. animate(): void;
  94108. /**
  94109. * Renders the particle system in its current state.
  94110. * @returns the current number of particles
  94111. */
  94112. render(): number;
  94113. /**
  94114. * Dispose the particle system and frees its associated resources.
  94115. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94116. */
  94117. dispose(disposeTexture?: boolean): void;
  94118. /**
  94119. * An event triggered when the system is disposed
  94120. */
  94121. onDisposeObservable: Observable<IParticleSystem>;
  94122. /**
  94123. * Clones the particle system.
  94124. * @param name The name of the cloned object
  94125. * @param newEmitter The new emitter to use
  94126. * @returns the cloned particle system
  94127. */
  94128. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  94129. /**
  94130. * Serializes the particle system to a JSON object
  94131. * @param serializeTexture defines if the texture must be serialized as well
  94132. * @returns the JSON object
  94133. */
  94134. serialize(serializeTexture: boolean): any;
  94135. /**
  94136. * Rebuild the particle system
  94137. */
  94138. rebuild(): void;
  94139. /** Force the system to rebuild all gradients that need to be resync */
  94140. forceRefreshGradients(): void;
  94141. /**
  94142. * Starts the particle system and begins to emit
  94143. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  94144. */
  94145. start(delay?: number): void;
  94146. /**
  94147. * Stops the particle system.
  94148. */
  94149. stop(): void;
  94150. /**
  94151. * Remove all active particles
  94152. */
  94153. reset(): void;
  94154. /**
  94155. * Gets a boolean indicating that the system is stopping
  94156. * @returns true if the system is currently stopping
  94157. */
  94158. isStopping(): boolean;
  94159. /**
  94160. * Is this system ready to be used/rendered
  94161. * @return true if the system is ready
  94162. */
  94163. isReady(): boolean;
  94164. /**
  94165. * Returns the string "ParticleSystem"
  94166. * @returns a string containing the class name
  94167. */
  94168. getClassName(): string;
  94169. /**
  94170. * Gets the custom effect used to render the particles
  94171. * @param blendMode Blend mode for which the effect should be retrieved
  94172. * @returns The effect
  94173. */
  94174. getCustomEffect(blendMode: number): Nullable<Effect>;
  94175. /**
  94176. * Sets the custom effect used to render the particles
  94177. * @param effect The effect to set
  94178. * @param blendMode Blend mode for which the effect should be set
  94179. */
  94180. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  94181. /**
  94182. * Fill the defines array according to the current settings of the particle system
  94183. * @param defines Array to be updated
  94184. * @param blendMode blend mode to take into account when updating the array
  94185. */
  94186. fillDefines(defines: Array<string>, blendMode: number): void;
  94187. /**
  94188. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94189. * @param uniforms Uniforms array to fill
  94190. * @param attributes Attributes array to fill
  94191. * @param samplers Samplers array to fill
  94192. */
  94193. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94194. /**
  94195. * Observable that will be called just before the particles are drawn
  94196. */
  94197. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  94198. /**
  94199. * Gets the name of the particle vertex shader
  94200. */
  94201. vertexShaderName: string;
  94202. /**
  94203. * Adds a new color gradient
  94204. * @param gradient defines the gradient to use (between 0 and 1)
  94205. * @param color1 defines the color to affect to the specified gradient
  94206. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94207. * @returns the current particle system
  94208. */
  94209. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94210. /**
  94211. * Remove a specific color gradient
  94212. * @param gradient defines the gradient to remove
  94213. * @returns the current particle system
  94214. */
  94215. removeColorGradient(gradient: number): IParticleSystem;
  94216. /**
  94217. * Adds a new size gradient
  94218. * @param gradient defines the gradient to use (between 0 and 1)
  94219. * @param factor defines the size factor to affect to the specified gradient
  94220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94221. * @returns the current particle system
  94222. */
  94223. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94224. /**
  94225. * Remove a specific size gradient
  94226. * @param gradient defines the gradient to remove
  94227. * @returns the current particle system
  94228. */
  94229. removeSizeGradient(gradient: number): IParticleSystem;
  94230. /**
  94231. * Gets the current list of color gradients.
  94232. * You must use addColorGradient and removeColorGradient to udpate this list
  94233. * @returns the list of color gradients
  94234. */
  94235. getColorGradients(): Nullable<Array<ColorGradient>>;
  94236. /**
  94237. * Gets the current list of size gradients.
  94238. * You must use addSizeGradient and removeSizeGradient to udpate this list
  94239. * @returns the list of size gradients
  94240. */
  94241. getSizeGradients(): Nullable<Array<FactorGradient>>;
  94242. /**
  94243. * Gets the current list of angular speed gradients.
  94244. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  94245. * @returns the list of angular speed gradients
  94246. */
  94247. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  94248. /**
  94249. * Adds a new angular speed gradient
  94250. * @param gradient defines the gradient to use (between 0 and 1)
  94251. * @param factor defines the angular speed to affect to the specified gradient
  94252. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94253. * @returns the current particle system
  94254. */
  94255. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94256. /**
  94257. * Remove a specific angular speed gradient
  94258. * @param gradient defines the gradient to remove
  94259. * @returns the current particle system
  94260. */
  94261. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94262. /**
  94263. * Gets the current list of velocity gradients.
  94264. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  94265. * @returns the list of velocity gradients
  94266. */
  94267. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  94268. /**
  94269. * Adds a new velocity gradient
  94270. * @param gradient defines the gradient to use (between 0 and 1)
  94271. * @param factor defines the velocity to affect to the specified gradient
  94272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94273. * @returns the current particle system
  94274. */
  94275. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94276. /**
  94277. * Remove a specific velocity gradient
  94278. * @param gradient defines the gradient to remove
  94279. * @returns the current particle system
  94280. */
  94281. removeVelocityGradient(gradient: number): IParticleSystem;
  94282. /**
  94283. * Gets the current list of limit velocity gradients.
  94284. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  94285. * @returns the list of limit velocity gradients
  94286. */
  94287. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  94288. /**
  94289. * Adds a new limit velocity gradient
  94290. * @param gradient defines the gradient to use (between 0 and 1)
  94291. * @param factor defines the limit velocity to affect to the specified gradient
  94292. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94293. * @returns the current particle system
  94294. */
  94295. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94296. /**
  94297. * Remove a specific limit velocity gradient
  94298. * @param gradient defines the gradient to remove
  94299. * @returns the current particle system
  94300. */
  94301. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94302. /**
  94303. * Adds a new drag gradient
  94304. * @param gradient defines the gradient to use (between 0 and 1)
  94305. * @param factor defines the drag to affect to the specified gradient
  94306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94307. * @returns the current particle system
  94308. */
  94309. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94310. /**
  94311. * Remove a specific drag gradient
  94312. * @param gradient defines the gradient to remove
  94313. * @returns the current particle system
  94314. */
  94315. removeDragGradient(gradient: number): IParticleSystem;
  94316. /**
  94317. * Gets the current list of drag gradients.
  94318. * You must use addDragGradient and removeDragGradient to udpate this list
  94319. * @returns the list of drag gradients
  94320. */
  94321. getDragGradients(): Nullable<Array<FactorGradient>>;
  94322. /**
  94323. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94324. * @param gradient defines the gradient to use (between 0 and 1)
  94325. * @param factor defines the emit rate to affect to the specified gradient
  94326. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94327. * @returns the current particle system
  94328. */
  94329. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94330. /**
  94331. * Remove a specific emit rate gradient
  94332. * @param gradient defines the gradient to remove
  94333. * @returns the current particle system
  94334. */
  94335. removeEmitRateGradient(gradient: number): IParticleSystem;
  94336. /**
  94337. * Gets the current list of emit rate gradients.
  94338. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  94339. * @returns the list of emit rate gradients
  94340. */
  94341. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  94342. /**
  94343. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94344. * @param gradient defines the gradient to use (between 0 and 1)
  94345. * @param factor defines the start size to affect to the specified gradient
  94346. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94347. * @returns the current particle system
  94348. */
  94349. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94350. /**
  94351. * Remove a specific start size gradient
  94352. * @param gradient defines the gradient to remove
  94353. * @returns the current particle system
  94354. */
  94355. removeStartSizeGradient(gradient: number): IParticleSystem;
  94356. /**
  94357. * Gets the current list of start size gradients.
  94358. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  94359. * @returns the list of start size gradients
  94360. */
  94361. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  94362. /**
  94363. * Adds a new life time gradient
  94364. * @param gradient defines the gradient to use (between 0 and 1)
  94365. * @param factor defines the life time factor to affect to the specified gradient
  94366. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94367. * @returns the current particle system
  94368. */
  94369. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94370. /**
  94371. * Remove a specific life time gradient
  94372. * @param gradient defines the gradient to remove
  94373. * @returns the current particle system
  94374. */
  94375. removeLifeTimeGradient(gradient: number): IParticleSystem;
  94376. /**
  94377. * Gets the current list of life time gradients.
  94378. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  94379. * @returns the list of life time gradients
  94380. */
  94381. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  94382. /**
  94383. * Gets the current list of color gradients.
  94384. * You must use addColorGradient and removeColorGradient to udpate this list
  94385. * @returns the list of color gradients
  94386. */
  94387. getColorGradients(): Nullable<Array<ColorGradient>>;
  94388. /**
  94389. * Adds a new ramp gradient used to remap particle colors
  94390. * @param gradient defines the gradient to use (between 0 and 1)
  94391. * @param color defines the color to affect to the specified gradient
  94392. * @returns the current particle system
  94393. */
  94394. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  94395. /**
  94396. * Gets the current list of ramp gradients.
  94397. * You must use addRampGradient and removeRampGradient to udpate this list
  94398. * @returns the list of ramp gradients
  94399. */
  94400. getRampGradients(): Nullable<Array<Color3Gradient>>;
  94401. /** Gets or sets a boolean indicating that ramp gradients must be used
  94402. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  94403. */
  94404. useRampGradients: boolean;
  94405. /**
  94406. * Adds a new color remap gradient
  94407. * @param gradient defines the gradient to use (between 0 and 1)
  94408. * @param min defines the color remap minimal range
  94409. * @param max defines the color remap maximal range
  94410. * @returns the current particle system
  94411. */
  94412. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94413. /**
  94414. * Gets the current list of color remap gradients.
  94415. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  94416. * @returns the list of color remap gradients
  94417. */
  94418. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  94419. /**
  94420. * Adds a new alpha remap gradient
  94421. * @param gradient defines the gradient to use (between 0 and 1)
  94422. * @param min defines the alpha remap minimal range
  94423. * @param max defines the alpha remap maximal range
  94424. * @returns the current particle system
  94425. */
  94426. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94427. /**
  94428. * Gets the current list of alpha remap gradients.
  94429. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  94430. * @returns the list of alpha remap gradients
  94431. */
  94432. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  94433. /**
  94434. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  94435. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94436. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94437. * @returns the emitter
  94438. */
  94439. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  94440. /**
  94441. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  94442. * @param radius The radius of the hemisphere to emit from
  94443. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94444. * @returns the emitter
  94445. */
  94446. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  94447. /**
  94448. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  94449. * @param radius The radius of the sphere to emit from
  94450. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94451. * @returns the emitter
  94452. */
  94453. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  94454. /**
  94455. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  94456. * @param radius The radius of the sphere to emit from
  94457. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  94458. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  94459. * @returns the emitter
  94460. */
  94461. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94462. /**
  94463. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  94464. * @param radius The radius of the emission cylinder
  94465. * @param height The height of the emission cylinder
  94466. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  94467. * @param directionRandomizer How much to randomize the particle direction [0-1]
  94468. * @returns the emitter
  94469. */
  94470. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  94471. /**
  94472. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  94473. * @param radius The radius of the cylinder to emit from
  94474. * @param height The height of the emission cylinder
  94475. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94476. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  94477. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  94478. * @returns the emitter
  94479. */
  94480. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94481. /**
  94482. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  94483. * @param radius The radius of the cone to emit from
  94484. * @param angle The base angle of the cone
  94485. * @returns the emitter
  94486. */
  94487. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  94488. /**
  94489. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  94490. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94491. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94492. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94493. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94494. * @returns the emitter
  94495. */
  94496. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  94497. /**
  94498. * Get hosting scene
  94499. * @returns the scene
  94500. */
  94501. getScene(): Nullable<Scene>;
  94502. }
  94503. }
  94504. declare module BABYLON {
  94505. /**
  94506. * 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.
  94507. * @see https://doc.babylonjs.com/how_to/transformnode
  94508. */
  94509. export class TransformNode extends Node {
  94510. /**
  94511. * Object will not rotate to face the camera
  94512. */
  94513. static BILLBOARDMODE_NONE: number;
  94514. /**
  94515. * Object will rotate to face the camera but only on the x axis
  94516. */
  94517. static BILLBOARDMODE_X: number;
  94518. /**
  94519. * Object will rotate to face the camera but only on the y axis
  94520. */
  94521. static BILLBOARDMODE_Y: number;
  94522. /**
  94523. * Object will rotate to face the camera but only on the z axis
  94524. */
  94525. static BILLBOARDMODE_Z: number;
  94526. /**
  94527. * Object will rotate to face the camera
  94528. */
  94529. static BILLBOARDMODE_ALL: number;
  94530. /**
  94531. * Object will rotate to face the camera's position instead of orientation
  94532. */
  94533. static BILLBOARDMODE_USE_POSITION: number;
  94534. private static _TmpRotation;
  94535. private static _TmpScaling;
  94536. private static _TmpTranslation;
  94537. private _forward;
  94538. private _forwardInverted;
  94539. private _up;
  94540. private _right;
  94541. private _rightInverted;
  94542. private _position;
  94543. private _rotation;
  94544. private _rotationQuaternion;
  94545. protected _scaling: Vector3;
  94546. protected _isDirty: boolean;
  94547. private _transformToBoneReferal;
  94548. private _isAbsoluteSynced;
  94549. private _billboardMode;
  94550. /**
  94551. * Gets or sets the billboard mode. Default is 0.
  94552. *
  94553. * | Value | Type | Description |
  94554. * | --- | --- | --- |
  94555. * | 0 | BILLBOARDMODE_NONE | |
  94556. * | 1 | BILLBOARDMODE_X | |
  94557. * | 2 | BILLBOARDMODE_Y | |
  94558. * | 4 | BILLBOARDMODE_Z | |
  94559. * | 7 | BILLBOARDMODE_ALL | |
  94560. *
  94561. */
  94562. get billboardMode(): number;
  94563. set billboardMode(value: number);
  94564. private _preserveParentRotationForBillboard;
  94565. /**
  94566. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  94567. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  94568. */
  94569. get preserveParentRotationForBillboard(): boolean;
  94570. set preserveParentRotationForBillboard(value: boolean);
  94571. /**
  94572. * 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
  94573. */
  94574. scalingDeterminant: number;
  94575. private _infiniteDistance;
  94576. /**
  94577. * Gets or sets the distance of the object to max, often used by skybox
  94578. */
  94579. get infiniteDistance(): boolean;
  94580. set infiniteDistance(value: boolean);
  94581. /**
  94582. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  94583. * By default the system will update normals to compensate
  94584. */
  94585. ignoreNonUniformScaling: boolean;
  94586. /**
  94587. * 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
  94588. */
  94589. reIntegrateRotationIntoRotationQuaternion: boolean;
  94590. /** @hidden */
  94591. _poseMatrix: Nullable<Matrix>;
  94592. /** @hidden */
  94593. _localMatrix: Matrix;
  94594. private _usePivotMatrix;
  94595. private _absolutePosition;
  94596. private _absoluteScaling;
  94597. private _absoluteRotationQuaternion;
  94598. private _pivotMatrix;
  94599. private _pivotMatrixInverse;
  94600. /** @hidden */
  94601. _postMultiplyPivotMatrix: boolean;
  94602. protected _isWorldMatrixFrozen: boolean;
  94603. /** @hidden */
  94604. _indexInSceneTransformNodesArray: number;
  94605. /**
  94606. * An event triggered after the world matrix is updated
  94607. */
  94608. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  94609. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  94610. /**
  94611. * Gets a string identifying the name of the class
  94612. * @returns "TransformNode" string
  94613. */
  94614. getClassName(): string;
  94615. /**
  94616. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  94617. */
  94618. get position(): Vector3;
  94619. set position(newPosition: Vector3);
  94620. /**
  94621. * 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)).
  94622. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  94623. */
  94624. get rotation(): Vector3;
  94625. set rotation(newRotation: Vector3);
  94626. /**
  94627. * 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)).
  94628. */
  94629. get scaling(): Vector3;
  94630. set scaling(newScaling: Vector3);
  94631. /**
  94632. * 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).
  94633. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  94634. */
  94635. get rotationQuaternion(): Nullable<Quaternion>;
  94636. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  94637. /**
  94638. * The forward direction of that transform in world space.
  94639. */
  94640. get forward(): Vector3;
  94641. /**
  94642. * The up direction of that transform in world space.
  94643. */
  94644. get up(): Vector3;
  94645. /**
  94646. * The right direction of that transform in world space.
  94647. */
  94648. get right(): Vector3;
  94649. /**
  94650. * Copies the parameter passed Matrix into the mesh Pose matrix.
  94651. * @param matrix the matrix to copy the pose from
  94652. * @returns this TransformNode.
  94653. */
  94654. updatePoseMatrix(matrix: Matrix): TransformNode;
  94655. /**
  94656. * Returns the mesh Pose matrix.
  94657. * @returns the pose matrix
  94658. */
  94659. getPoseMatrix(): Matrix;
  94660. /** @hidden */
  94661. _isSynchronized(): boolean;
  94662. /** @hidden */
  94663. _initCache(): void;
  94664. /**
  94665. * Flag the transform node as dirty (Forcing it to update everything)
  94666. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  94667. * @returns this transform node
  94668. */
  94669. markAsDirty(property: string): TransformNode;
  94670. /**
  94671. * Returns the current mesh absolute position.
  94672. * Returns a Vector3.
  94673. */
  94674. get absolutePosition(): Vector3;
  94675. /**
  94676. * Returns the current mesh absolute scaling.
  94677. * Returns a Vector3.
  94678. */
  94679. get absoluteScaling(): Vector3;
  94680. /**
  94681. * Returns the current mesh absolute rotation.
  94682. * Returns a Quaternion.
  94683. */
  94684. get absoluteRotationQuaternion(): Quaternion;
  94685. /**
  94686. * Sets a new matrix to apply before all other transformation
  94687. * @param matrix defines the transform matrix
  94688. * @returns the current TransformNode
  94689. */
  94690. setPreTransformMatrix(matrix: Matrix): TransformNode;
  94691. /**
  94692. * Sets a new pivot matrix to the current node
  94693. * @param matrix defines the new pivot matrix to use
  94694. * @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
  94695. * @returns the current TransformNode
  94696. */
  94697. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  94698. /**
  94699. * Returns the mesh pivot matrix.
  94700. * Default : Identity.
  94701. * @returns the matrix
  94702. */
  94703. getPivotMatrix(): Matrix;
  94704. /**
  94705. * Instantiate (when possible) or clone that node with its hierarchy
  94706. * @param newParent defines the new parent to use for the instance (or clone)
  94707. * @param options defines options to configure how copy is done
  94708. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  94709. * @returns an instance (or a clone) of the current node with its hiearchy
  94710. */
  94711. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  94712. doNotInstantiate: boolean;
  94713. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  94714. /**
  94715. * Prevents the World matrix to be computed any longer
  94716. * @param newWorldMatrix defines an optional matrix to use as world matrix
  94717. * @returns the TransformNode.
  94718. */
  94719. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  94720. /**
  94721. * Allows back the World matrix computation.
  94722. * @returns the TransformNode.
  94723. */
  94724. unfreezeWorldMatrix(): this;
  94725. /**
  94726. * True if the World matrix has been frozen.
  94727. */
  94728. get isWorldMatrixFrozen(): boolean;
  94729. /**
  94730. * Retuns the mesh absolute position in the World.
  94731. * @returns a Vector3.
  94732. */
  94733. getAbsolutePosition(): Vector3;
  94734. /**
  94735. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  94736. * @param absolutePosition the absolute position to set
  94737. * @returns the TransformNode.
  94738. */
  94739. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94740. /**
  94741. * Sets the mesh position in its local space.
  94742. * @param vector3 the position to set in localspace
  94743. * @returns the TransformNode.
  94744. */
  94745. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  94746. /**
  94747. * Returns the mesh position in the local space from the current World matrix values.
  94748. * @returns a new Vector3.
  94749. */
  94750. getPositionExpressedInLocalSpace(): Vector3;
  94751. /**
  94752. * Translates the mesh along the passed Vector3 in its local space.
  94753. * @param vector3 the distance to translate in localspace
  94754. * @returns the TransformNode.
  94755. */
  94756. locallyTranslate(vector3: Vector3): TransformNode;
  94757. private static _lookAtVectorCache;
  94758. /**
  94759. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  94760. * @param targetPoint the position (must be in same space as current mesh) to look at
  94761. * @param yawCor optional yaw (y-axis) correction in radians
  94762. * @param pitchCor optional pitch (x-axis) correction in radians
  94763. * @param rollCor optional roll (z-axis) correction in radians
  94764. * @param space the choosen space of the target
  94765. * @returns the TransformNode.
  94766. */
  94767. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  94768. /**
  94769. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94770. * This Vector3 is expressed in the World space.
  94771. * @param localAxis axis to rotate
  94772. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94773. */
  94774. getDirection(localAxis: Vector3): Vector3;
  94775. /**
  94776. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  94777. * localAxis is expressed in the mesh local space.
  94778. * result is computed in the Wordl space from the mesh World matrix.
  94779. * @param localAxis axis to rotate
  94780. * @param result the resulting transformnode
  94781. * @returns this TransformNode.
  94782. */
  94783. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  94784. /**
  94785. * Sets this transform node rotation to the given local axis.
  94786. * @param localAxis the axis in local space
  94787. * @param yawCor optional yaw (y-axis) correction in radians
  94788. * @param pitchCor optional pitch (x-axis) correction in radians
  94789. * @param rollCor optional roll (z-axis) correction in radians
  94790. * @returns this TransformNode
  94791. */
  94792. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  94793. /**
  94794. * Sets a new pivot point to the current node
  94795. * @param point defines the new pivot point to use
  94796. * @param space defines if the point is in world or local space (local by default)
  94797. * @returns the current TransformNode
  94798. */
  94799. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  94800. /**
  94801. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  94802. * @returns the pivot point
  94803. */
  94804. getPivotPoint(): Vector3;
  94805. /**
  94806. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  94807. * @param result the vector3 to store the result
  94808. * @returns this TransformNode.
  94809. */
  94810. getPivotPointToRef(result: Vector3): TransformNode;
  94811. /**
  94812. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  94813. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  94814. */
  94815. getAbsolutePivotPoint(): Vector3;
  94816. /**
  94817. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  94818. * @param result vector3 to store the result
  94819. * @returns this TransformNode.
  94820. */
  94821. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  94822. /**
  94823. * Defines the passed node as the parent of the current node.
  94824. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  94825. * @see https://doc.babylonjs.com/how_to/parenting
  94826. * @param node the node ot set as the parent
  94827. * @returns this TransformNode.
  94828. */
  94829. setParent(node: Nullable<Node>): TransformNode;
  94830. private _nonUniformScaling;
  94831. /**
  94832. * True if the scaling property of this object is non uniform eg. (1,2,1)
  94833. */
  94834. get nonUniformScaling(): boolean;
  94835. /** @hidden */
  94836. _updateNonUniformScalingState(value: boolean): boolean;
  94837. /**
  94838. * Attach the current TransformNode to another TransformNode associated with a bone
  94839. * @param bone Bone affecting the TransformNode
  94840. * @param affectedTransformNode TransformNode associated with the bone
  94841. * @returns this object
  94842. */
  94843. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  94844. /**
  94845. * Detach the transform node if its associated with a bone
  94846. * @returns this object
  94847. */
  94848. detachFromBone(): TransformNode;
  94849. private static _rotationAxisCache;
  94850. /**
  94851. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  94852. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94853. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94854. * The passed axis is also normalized.
  94855. * @param axis the axis to rotate around
  94856. * @param amount the amount to rotate in radians
  94857. * @param space Space to rotate in (Default: local)
  94858. * @returns the TransformNode.
  94859. */
  94860. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94861. /**
  94862. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  94863. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94864. * The passed axis is also normalized. .
  94865. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  94866. * @param point the point to rotate around
  94867. * @param axis the axis to rotate around
  94868. * @param amount the amount to rotate in radians
  94869. * @returns the TransformNode
  94870. */
  94871. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  94872. /**
  94873. * Translates the mesh along the axis vector for the passed distance in the given space.
  94874. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94875. * @param axis the axis to translate in
  94876. * @param distance the distance to translate
  94877. * @param space Space to rotate in (Default: local)
  94878. * @returns the TransformNode.
  94879. */
  94880. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94881. /**
  94882. * Adds a rotation step to the mesh current rotation.
  94883. * x, y, z are Euler angles expressed in radians.
  94884. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  94885. * This means this rotation is made in the mesh local space only.
  94886. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  94887. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  94888. * ```javascript
  94889. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  94890. * ```
  94891. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  94892. * 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.
  94893. * @param x Rotation to add
  94894. * @param y Rotation to add
  94895. * @param z Rotation to add
  94896. * @returns the TransformNode.
  94897. */
  94898. addRotation(x: number, y: number, z: number): TransformNode;
  94899. /**
  94900. * @hidden
  94901. */
  94902. protected _getEffectiveParent(): Nullable<Node>;
  94903. /**
  94904. * Computes the world matrix of the node
  94905. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94906. * @returns the world matrix
  94907. */
  94908. computeWorldMatrix(force?: boolean): Matrix;
  94909. /**
  94910. * Resets this nodeTransform's local matrix to Matrix.Identity().
  94911. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  94912. */
  94913. resetLocalMatrix(independentOfChildren?: boolean): void;
  94914. protected _afterComputeWorldMatrix(): void;
  94915. /**
  94916. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  94917. * @param func callback function to add
  94918. *
  94919. * @returns the TransformNode.
  94920. */
  94921. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94922. /**
  94923. * Removes a registered callback function.
  94924. * @param func callback function to remove
  94925. * @returns the TransformNode.
  94926. */
  94927. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94928. /**
  94929. * Gets the position of the current mesh in camera space
  94930. * @param camera defines the camera to use
  94931. * @returns a position
  94932. */
  94933. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  94934. /**
  94935. * Returns the distance from the mesh to the active camera
  94936. * @param camera defines the camera to use
  94937. * @returns the distance
  94938. */
  94939. getDistanceToCamera(camera?: Nullable<Camera>): number;
  94940. /**
  94941. * Clone the current transform node
  94942. * @param name Name of the new clone
  94943. * @param newParent New parent for the clone
  94944. * @param doNotCloneChildren Do not clone children hierarchy
  94945. * @returns the new transform node
  94946. */
  94947. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  94948. /**
  94949. * Serializes the objects information.
  94950. * @param currentSerializationObject defines the object to serialize in
  94951. * @returns the serialized object
  94952. */
  94953. serialize(currentSerializationObject?: any): any;
  94954. /**
  94955. * Returns a new TransformNode object parsed from the source provided.
  94956. * @param parsedTransformNode is the source.
  94957. * @param scene the scne the object belongs to
  94958. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  94959. * @returns a new TransformNode object parsed from the source provided.
  94960. */
  94961. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  94962. /**
  94963. * Get all child-transformNodes of this node
  94964. * @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
  94965. * @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
  94966. * @returns an array of TransformNode
  94967. */
  94968. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  94969. /**
  94970. * Releases resources associated with this transform node.
  94971. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94972. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94973. */
  94974. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94975. /**
  94976. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94977. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94978. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94979. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94980. * @returns the current mesh
  94981. */
  94982. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  94983. private _syncAbsoluteScalingAndRotation;
  94984. }
  94985. }
  94986. declare module BABYLON {
  94987. /**
  94988. * Class used to override all child animations of a given target
  94989. */
  94990. export class AnimationPropertiesOverride {
  94991. /**
  94992. * Gets or sets a value indicating if animation blending must be used
  94993. */
  94994. enableBlending: boolean;
  94995. /**
  94996. * Gets or sets the blending speed to use when enableBlending is true
  94997. */
  94998. blendingSpeed: number;
  94999. /**
  95000. * Gets or sets the default loop mode to use
  95001. */
  95002. loopMode: number;
  95003. }
  95004. }
  95005. declare module BABYLON {
  95006. /**
  95007. * Class used to store bone information
  95008. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95009. */
  95010. export class Bone extends Node {
  95011. /**
  95012. * defines the bone name
  95013. */
  95014. name: string;
  95015. private static _tmpVecs;
  95016. private static _tmpQuat;
  95017. private static _tmpMats;
  95018. /**
  95019. * Gets the list of child bones
  95020. */
  95021. children: Bone[];
  95022. /** Gets the animations associated with this bone */
  95023. animations: Animation[];
  95024. /**
  95025. * Gets or sets bone length
  95026. */
  95027. length: number;
  95028. /**
  95029. * @hidden Internal only
  95030. * Set this value to map this bone to a different index in the transform matrices
  95031. * Set this value to -1 to exclude the bone from the transform matrices
  95032. */
  95033. _index: Nullable<number>;
  95034. private _skeleton;
  95035. private _localMatrix;
  95036. private _restPose;
  95037. private _bindPose;
  95038. private _baseMatrix;
  95039. private _absoluteTransform;
  95040. private _invertedAbsoluteTransform;
  95041. private _parent;
  95042. private _scalingDeterminant;
  95043. private _worldTransform;
  95044. private _localScaling;
  95045. private _localRotation;
  95046. private _localPosition;
  95047. private _needToDecompose;
  95048. private _needToCompose;
  95049. /** @hidden */
  95050. _linkedTransformNode: Nullable<TransformNode>;
  95051. /** @hidden */
  95052. _waitingTransformNodeId: Nullable<string>;
  95053. /** @hidden */
  95054. get _matrix(): Matrix;
  95055. /** @hidden */
  95056. set _matrix(value: Matrix);
  95057. /**
  95058. * Create a new bone
  95059. * @param name defines the bone name
  95060. * @param skeleton defines the parent skeleton
  95061. * @param parentBone defines the parent (can be null if the bone is the root)
  95062. * @param localMatrix defines the local matrix
  95063. * @param restPose defines the rest pose matrix
  95064. * @param baseMatrix defines the base matrix
  95065. * @param index defines index of the bone in the hiearchy
  95066. */
  95067. constructor(
  95068. /**
  95069. * defines the bone name
  95070. */
  95071. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  95072. /**
  95073. * Gets the current object class name.
  95074. * @return the class name
  95075. */
  95076. getClassName(): string;
  95077. /**
  95078. * Gets the parent skeleton
  95079. * @returns a skeleton
  95080. */
  95081. getSkeleton(): Skeleton;
  95082. /**
  95083. * Gets parent bone
  95084. * @returns a bone or null if the bone is the root of the bone hierarchy
  95085. */
  95086. getParent(): Nullable<Bone>;
  95087. /**
  95088. * Returns an array containing the root bones
  95089. * @returns an array containing the root bones
  95090. */
  95091. getChildren(): Array<Bone>;
  95092. /**
  95093. * Gets the node index in matrix array generated for rendering
  95094. * @returns the node index
  95095. */
  95096. getIndex(): number;
  95097. /**
  95098. * Sets the parent bone
  95099. * @param parent defines the parent (can be null if the bone is the root)
  95100. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95101. */
  95102. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  95103. /**
  95104. * Gets the local matrix
  95105. * @returns a matrix
  95106. */
  95107. getLocalMatrix(): Matrix;
  95108. /**
  95109. * Gets the base matrix (initial matrix which remains unchanged)
  95110. * @returns a matrix
  95111. */
  95112. getBaseMatrix(): Matrix;
  95113. /**
  95114. * Gets the rest pose matrix
  95115. * @returns a matrix
  95116. */
  95117. getRestPose(): Matrix;
  95118. /**
  95119. * Sets the rest pose matrix
  95120. * @param matrix the local-space rest pose to set for this bone
  95121. */
  95122. setRestPose(matrix: Matrix): void;
  95123. /**
  95124. * Gets the bind pose matrix
  95125. * @returns the bind pose matrix
  95126. */
  95127. getBindPose(): Matrix;
  95128. /**
  95129. * Sets the bind pose matrix
  95130. * @param matrix the local-space bind pose to set for this bone
  95131. */
  95132. setBindPose(matrix: Matrix): void;
  95133. /**
  95134. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  95135. */
  95136. getWorldMatrix(): Matrix;
  95137. /**
  95138. * Sets the local matrix to rest pose matrix
  95139. */
  95140. returnToRest(): void;
  95141. /**
  95142. * Gets the inverse of the absolute transform matrix.
  95143. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  95144. * @returns a matrix
  95145. */
  95146. getInvertedAbsoluteTransform(): Matrix;
  95147. /**
  95148. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  95149. * @returns a matrix
  95150. */
  95151. getAbsoluteTransform(): Matrix;
  95152. /**
  95153. * Links with the given transform node.
  95154. * The local matrix of this bone is copied from the transform node every frame.
  95155. * @param transformNode defines the transform node to link to
  95156. */
  95157. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  95158. /**
  95159. * Gets the node used to drive the bone's transformation
  95160. * @returns a transform node or null
  95161. */
  95162. getTransformNode(): Nullable<TransformNode>;
  95163. /** Gets or sets current position (in local space) */
  95164. get position(): Vector3;
  95165. set position(newPosition: Vector3);
  95166. /** Gets or sets current rotation (in local space) */
  95167. get rotation(): Vector3;
  95168. set rotation(newRotation: Vector3);
  95169. /** Gets or sets current rotation quaternion (in local space) */
  95170. get rotationQuaternion(): Quaternion;
  95171. set rotationQuaternion(newRotation: Quaternion);
  95172. /** Gets or sets current scaling (in local space) */
  95173. get scaling(): Vector3;
  95174. set scaling(newScaling: Vector3);
  95175. /**
  95176. * Gets the animation properties override
  95177. */
  95178. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95179. private _decompose;
  95180. private _compose;
  95181. /**
  95182. * Update the base and local matrices
  95183. * @param matrix defines the new base or local matrix
  95184. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95185. * @param updateLocalMatrix defines if the local matrix should be updated
  95186. */
  95187. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  95188. /** @hidden */
  95189. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  95190. /**
  95191. * Flag the bone as dirty (Forcing it to update everything)
  95192. */
  95193. markAsDirty(): void;
  95194. /** @hidden */
  95195. _markAsDirtyAndCompose(): void;
  95196. private _markAsDirtyAndDecompose;
  95197. /**
  95198. * Translate the bone in local or world space
  95199. * @param vec The amount to translate the bone
  95200. * @param space The space that the translation is in
  95201. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95202. */
  95203. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95204. /**
  95205. * Set the postion of the bone in local or world space
  95206. * @param position The position to set the bone
  95207. * @param space The space that the position is in
  95208. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95209. */
  95210. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95211. /**
  95212. * Set the absolute position of the bone (world space)
  95213. * @param position The position to set the bone
  95214. * @param mesh The mesh that this bone is attached to
  95215. */
  95216. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  95217. /**
  95218. * Scale the bone on the x, y and z axes (in local space)
  95219. * @param x The amount to scale the bone on the x axis
  95220. * @param y The amount to scale the bone on the y axis
  95221. * @param z The amount to scale the bone on the z axis
  95222. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  95223. */
  95224. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  95225. /**
  95226. * Set the bone scaling in local space
  95227. * @param scale defines the scaling vector
  95228. */
  95229. setScale(scale: Vector3): void;
  95230. /**
  95231. * Gets the current scaling in local space
  95232. * @returns the current scaling vector
  95233. */
  95234. getScale(): Vector3;
  95235. /**
  95236. * Gets the current scaling in local space and stores it in a target vector
  95237. * @param result defines the target vector
  95238. */
  95239. getScaleToRef(result: Vector3): void;
  95240. /**
  95241. * Set the yaw, pitch, and roll of the bone in local or world space
  95242. * @param yaw The rotation of the bone on the y axis
  95243. * @param pitch The rotation of the bone on the x axis
  95244. * @param roll The rotation of the bone on the z axis
  95245. * @param space The space that the axes of rotation are in
  95246. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95247. */
  95248. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  95249. /**
  95250. * Add a rotation to the bone on an axis in local or world space
  95251. * @param axis The axis to rotate the bone on
  95252. * @param amount The amount to rotate the bone
  95253. * @param space The space that the axis is in
  95254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95255. */
  95256. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  95257. /**
  95258. * Set the rotation of the bone to a particular axis angle in local or world space
  95259. * @param axis The axis to rotate the bone on
  95260. * @param angle The angle that the bone should be rotated to
  95261. * @param space The space that the axis is in
  95262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95263. */
  95264. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  95265. /**
  95266. * Set the euler rotation of the bone in local of world space
  95267. * @param rotation The euler rotation that the bone should be set to
  95268. * @param space The space that the rotation is in
  95269. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95270. */
  95271. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95272. /**
  95273. * Set the quaternion rotation of the bone in local of world space
  95274. * @param quat The quaternion rotation that the bone should be set to
  95275. * @param space The space that the rotation is in
  95276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95277. */
  95278. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  95279. /**
  95280. * Set the rotation matrix of the bone in local of world space
  95281. * @param rotMat The rotation matrix that the bone should be set to
  95282. * @param space The space that the rotation is in
  95283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95284. */
  95285. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  95286. private _rotateWithMatrix;
  95287. private _getNegativeRotationToRef;
  95288. /**
  95289. * Get the position of the bone in local or world space
  95290. * @param space The space that the returned position is in
  95291. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95292. * @returns The position of the bone
  95293. */
  95294. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95295. /**
  95296. * Copy the position of the bone to a vector3 in local or world space
  95297. * @param space The space that the returned position is in
  95298. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95299. * @param result The vector3 to copy the position to
  95300. */
  95301. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  95302. /**
  95303. * Get the absolute position of the bone (world space)
  95304. * @param mesh The mesh that this bone is attached to
  95305. * @returns The absolute position of the bone
  95306. */
  95307. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  95308. /**
  95309. * Copy the absolute position of the bone (world space) to the result param
  95310. * @param mesh The mesh that this bone is attached to
  95311. * @param result The vector3 to copy the absolute position to
  95312. */
  95313. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  95314. /**
  95315. * Compute the absolute transforms of this bone and its children
  95316. */
  95317. computeAbsoluteTransforms(): void;
  95318. /**
  95319. * Get the world direction from an axis that is in the local space of the bone
  95320. * @param localAxis The local direction that is used to compute the world direction
  95321. * @param mesh The mesh that this bone is attached to
  95322. * @returns The world direction
  95323. */
  95324. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95325. /**
  95326. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  95327. * @param localAxis The local direction that is used to compute the world direction
  95328. * @param mesh The mesh that this bone is attached to
  95329. * @param result The vector3 that the world direction will be copied to
  95330. */
  95331. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95332. /**
  95333. * Get the euler rotation of the bone in local or world space
  95334. * @param space The space that the rotation should be in
  95335. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95336. * @returns The euler rotation
  95337. */
  95338. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95339. /**
  95340. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  95341. * @param space The space that the rotation should be in
  95342. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95343. * @param result The vector3 that the rotation should be copied to
  95344. */
  95345. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95346. /**
  95347. * Get the quaternion rotation of the bone in either local or world space
  95348. * @param space The space that the rotation should be in
  95349. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95350. * @returns The quaternion rotation
  95351. */
  95352. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  95353. /**
  95354. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  95355. * @param space The space that the rotation should be in
  95356. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95357. * @param result The quaternion that the rotation should be copied to
  95358. */
  95359. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  95360. /**
  95361. * Get the rotation matrix of the bone in local or world space
  95362. * @param space The space that the rotation should be in
  95363. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95364. * @returns The rotation matrix
  95365. */
  95366. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  95367. /**
  95368. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  95369. * @param space The space that the rotation should be in
  95370. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95371. * @param result The quaternion that the rotation should be copied to
  95372. */
  95373. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  95374. /**
  95375. * Get the world position of a point that is in the local space of the bone
  95376. * @param position The local position
  95377. * @param mesh The mesh that this bone is attached to
  95378. * @returns The world position
  95379. */
  95380. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95381. /**
  95382. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  95383. * @param position The local position
  95384. * @param mesh The mesh that this bone is attached to
  95385. * @param result The vector3 that the world position should be copied to
  95386. */
  95387. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95388. /**
  95389. * Get the local position of a point that is in world space
  95390. * @param position The world position
  95391. * @param mesh The mesh that this bone is attached to
  95392. * @returns The local position
  95393. */
  95394. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95395. /**
  95396. * Get the local position of a point that is in world space and copy it to the result param
  95397. * @param position The world position
  95398. * @param mesh The mesh that this bone is attached to
  95399. * @param result The vector3 that the local position should be copied to
  95400. */
  95401. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95402. }
  95403. }
  95404. declare module BABYLON {
  95405. /**
  95406. * Defines a runtime animation
  95407. */
  95408. export class RuntimeAnimation {
  95409. private _events;
  95410. /**
  95411. * The current frame of the runtime animation
  95412. */
  95413. private _currentFrame;
  95414. /**
  95415. * The animation used by the runtime animation
  95416. */
  95417. private _animation;
  95418. /**
  95419. * The target of the runtime animation
  95420. */
  95421. private _target;
  95422. /**
  95423. * The initiating animatable
  95424. */
  95425. private _host;
  95426. /**
  95427. * The original value of the runtime animation
  95428. */
  95429. private _originalValue;
  95430. /**
  95431. * The original blend value of the runtime animation
  95432. */
  95433. private _originalBlendValue;
  95434. /**
  95435. * The offsets cache of the runtime animation
  95436. */
  95437. private _offsetsCache;
  95438. /**
  95439. * The high limits cache of the runtime animation
  95440. */
  95441. private _highLimitsCache;
  95442. /**
  95443. * Specifies if the runtime animation has been stopped
  95444. */
  95445. private _stopped;
  95446. /**
  95447. * The blending factor of the runtime animation
  95448. */
  95449. private _blendingFactor;
  95450. /**
  95451. * The BabylonJS scene
  95452. */
  95453. private _scene;
  95454. /**
  95455. * The current value of the runtime animation
  95456. */
  95457. private _currentValue;
  95458. /** @hidden */
  95459. _animationState: _IAnimationState;
  95460. /**
  95461. * The active target of the runtime animation
  95462. */
  95463. private _activeTargets;
  95464. private _currentActiveTarget;
  95465. private _directTarget;
  95466. /**
  95467. * The target path of the runtime animation
  95468. */
  95469. private _targetPath;
  95470. /**
  95471. * The weight of the runtime animation
  95472. */
  95473. private _weight;
  95474. /**
  95475. * The ratio offset of the runtime animation
  95476. */
  95477. private _ratioOffset;
  95478. /**
  95479. * The previous delay of the runtime animation
  95480. */
  95481. private _previousDelay;
  95482. /**
  95483. * The previous ratio of the runtime animation
  95484. */
  95485. private _previousRatio;
  95486. private _enableBlending;
  95487. private _keys;
  95488. private _minFrame;
  95489. private _maxFrame;
  95490. private _minValue;
  95491. private _maxValue;
  95492. private _targetIsArray;
  95493. /**
  95494. * Gets the current frame of the runtime animation
  95495. */
  95496. get currentFrame(): number;
  95497. /**
  95498. * Gets the weight of the runtime animation
  95499. */
  95500. get weight(): number;
  95501. /**
  95502. * Gets the current value of the runtime animation
  95503. */
  95504. get currentValue(): any;
  95505. /**
  95506. * Gets the target path of the runtime animation
  95507. */
  95508. get targetPath(): string;
  95509. /**
  95510. * Gets the actual target of the runtime animation
  95511. */
  95512. get target(): any;
  95513. /**
  95514. * Gets the additive state of the runtime animation
  95515. */
  95516. get isAdditive(): boolean;
  95517. /** @hidden */
  95518. _onLoop: () => void;
  95519. /**
  95520. * Create a new RuntimeAnimation object
  95521. * @param target defines the target of the animation
  95522. * @param animation defines the source animation object
  95523. * @param scene defines the hosting scene
  95524. * @param host defines the initiating Animatable
  95525. */
  95526. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  95527. private _preparePath;
  95528. /**
  95529. * Gets the animation from the runtime animation
  95530. */
  95531. get animation(): Animation;
  95532. /**
  95533. * Resets the runtime animation to the beginning
  95534. * @param restoreOriginal defines whether to restore the target property to the original value
  95535. */
  95536. reset(restoreOriginal?: boolean): void;
  95537. /**
  95538. * Specifies if the runtime animation is stopped
  95539. * @returns Boolean specifying if the runtime animation is stopped
  95540. */
  95541. isStopped(): boolean;
  95542. /**
  95543. * Disposes of the runtime animation
  95544. */
  95545. dispose(): void;
  95546. /**
  95547. * Apply the interpolated value to the target
  95548. * @param currentValue defines the value computed by the animation
  95549. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  95550. */
  95551. setValue(currentValue: any, weight: number): void;
  95552. private _getOriginalValues;
  95553. private _setValue;
  95554. /**
  95555. * Gets the loop pmode of the runtime animation
  95556. * @returns Loop Mode
  95557. */
  95558. private _getCorrectLoopMode;
  95559. /**
  95560. * Move the current animation to a given frame
  95561. * @param frame defines the frame to move to
  95562. */
  95563. goToFrame(frame: number): void;
  95564. /**
  95565. * @hidden Internal use only
  95566. */
  95567. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  95568. /**
  95569. * Execute the current animation
  95570. * @param delay defines the delay to add to the current frame
  95571. * @param from defines the lower bound of the animation range
  95572. * @param to defines the upper bound of the animation range
  95573. * @param loop defines if the current animation must loop
  95574. * @param speedRatio defines the current speed ratio
  95575. * @param weight defines the weight of the animation (default is -1 so no weight)
  95576. * @param onLoop optional callback called when animation loops
  95577. * @returns a boolean indicating if the animation is running
  95578. */
  95579. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  95580. }
  95581. }
  95582. declare module BABYLON {
  95583. /**
  95584. * Class used to store an actual running animation
  95585. */
  95586. export class Animatable {
  95587. /** defines the target object */
  95588. target: any;
  95589. /** defines the starting frame number (default is 0) */
  95590. fromFrame: number;
  95591. /** defines the ending frame number (default is 100) */
  95592. toFrame: number;
  95593. /** defines if the animation must loop (default is false) */
  95594. loopAnimation: boolean;
  95595. /** defines a callback to call when animation ends if it is not looping */
  95596. onAnimationEnd?: (() => void) | null | undefined;
  95597. /** defines a callback to call when animation loops */
  95598. onAnimationLoop?: (() => void) | null | undefined;
  95599. /** defines whether the animation should be evaluated additively */
  95600. isAdditive: boolean;
  95601. private _localDelayOffset;
  95602. private _pausedDelay;
  95603. private _runtimeAnimations;
  95604. private _paused;
  95605. private _scene;
  95606. private _speedRatio;
  95607. private _weight;
  95608. private _syncRoot;
  95609. /**
  95610. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  95611. * This will only apply for non looping animation (default is true)
  95612. */
  95613. disposeOnEnd: boolean;
  95614. /**
  95615. * Gets a boolean indicating if the animation has started
  95616. */
  95617. animationStarted: boolean;
  95618. /**
  95619. * Observer raised when the animation ends
  95620. */
  95621. onAnimationEndObservable: Observable<Animatable>;
  95622. /**
  95623. * Observer raised when the animation loops
  95624. */
  95625. onAnimationLoopObservable: Observable<Animatable>;
  95626. /**
  95627. * Gets the root Animatable used to synchronize and normalize animations
  95628. */
  95629. get syncRoot(): Nullable<Animatable>;
  95630. /**
  95631. * Gets the current frame of the first RuntimeAnimation
  95632. * Used to synchronize Animatables
  95633. */
  95634. get masterFrame(): number;
  95635. /**
  95636. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  95637. */
  95638. get weight(): number;
  95639. set weight(value: number);
  95640. /**
  95641. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  95642. */
  95643. get speedRatio(): number;
  95644. set speedRatio(value: number);
  95645. /**
  95646. * Creates a new Animatable
  95647. * @param scene defines the hosting scene
  95648. * @param target defines the target object
  95649. * @param fromFrame defines the starting frame number (default is 0)
  95650. * @param toFrame defines the ending frame number (default is 100)
  95651. * @param loopAnimation defines if the animation must loop (default is false)
  95652. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  95653. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  95654. * @param animations defines a group of animation to add to the new Animatable
  95655. * @param onAnimationLoop defines a callback to call when animation loops
  95656. * @param isAdditive defines whether the animation should be evaluated additively
  95657. */
  95658. constructor(scene: Scene,
  95659. /** defines the target object */
  95660. target: any,
  95661. /** defines the starting frame number (default is 0) */
  95662. fromFrame?: number,
  95663. /** defines the ending frame number (default is 100) */
  95664. toFrame?: number,
  95665. /** defines if the animation must loop (default is false) */
  95666. loopAnimation?: boolean, speedRatio?: number,
  95667. /** defines a callback to call when animation ends if it is not looping */
  95668. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  95669. /** defines a callback to call when animation loops */
  95670. onAnimationLoop?: (() => void) | null | undefined,
  95671. /** defines whether the animation should be evaluated additively */
  95672. isAdditive?: boolean);
  95673. /**
  95674. * Synchronize and normalize current Animatable with a source Animatable
  95675. * This is useful when using animation weights and when animations are not of the same length
  95676. * @param root defines the root Animatable to synchronize with
  95677. * @returns the current Animatable
  95678. */
  95679. syncWith(root: Animatable): Animatable;
  95680. /**
  95681. * Gets the list of runtime animations
  95682. * @returns an array of RuntimeAnimation
  95683. */
  95684. getAnimations(): RuntimeAnimation[];
  95685. /**
  95686. * Adds more animations to the current animatable
  95687. * @param target defines the target of the animations
  95688. * @param animations defines the new animations to add
  95689. */
  95690. appendAnimations(target: any, animations: Animation[]): void;
  95691. /**
  95692. * Gets the source animation for a specific property
  95693. * @param property defines the propertyu to look for
  95694. * @returns null or the source animation for the given property
  95695. */
  95696. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  95697. /**
  95698. * Gets the runtime animation for a specific property
  95699. * @param property defines the propertyu to look for
  95700. * @returns null or the runtime animation for the given property
  95701. */
  95702. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  95703. /**
  95704. * Resets the animatable to its original state
  95705. */
  95706. reset(): void;
  95707. /**
  95708. * Allows the animatable to blend with current running animations
  95709. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95710. * @param blendingSpeed defines the blending speed to use
  95711. */
  95712. enableBlending(blendingSpeed: number): void;
  95713. /**
  95714. * Disable animation blending
  95715. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95716. */
  95717. disableBlending(): void;
  95718. /**
  95719. * Jump directly to a given frame
  95720. * @param frame defines the frame to jump to
  95721. */
  95722. goToFrame(frame: number): void;
  95723. /**
  95724. * Pause the animation
  95725. */
  95726. pause(): void;
  95727. /**
  95728. * Restart the animation
  95729. */
  95730. restart(): void;
  95731. private _raiseOnAnimationEnd;
  95732. /**
  95733. * Stop and delete the current animation
  95734. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  95735. * @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)
  95736. */
  95737. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  95738. /**
  95739. * Wait asynchronously for the animation to end
  95740. * @returns a promise which will be fullfilled when the animation ends
  95741. */
  95742. waitAsync(): Promise<Animatable>;
  95743. /** @hidden */
  95744. _animate(delay: number): boolean;
  95745. }
  95746. interface Scene {
  95747. /** @hidden */
  95748. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  95749. /** @hidden */
  95750. _processLateAnimationBindingsForMatrices(holder: {
  95751. totalWeight: number;
  95752. totalAdditiveWeight: number;
  95753. animations: RuntimeAnimation[];
  95754. additiveAnimations: RuntimeAnimation[];
  95755. originalValue: Matrix;
  95756. }): any;
  95757. /** @hidden */
  95758. _processLateAnimationBindingsForQuaternions(holder: {
  95759. totalWeight: number;
  95760. totalAdditiveWeight: number;
  95761. animations: RuntimeAnimation[];
  95762. additiveAnimations: RuntimeAnimation[];
  95763. originalValue: Quaternion;
  95764. }, refQuaternion: Quaternion): Quaternion;
  95765. /** @hidden */
  95766. _processLateAnimationBindings(): void;
  95767. /**
  95768. * Will start the animation sequence of a given target
  95769. * @param target defines the target
  95770. * @param from defines from which frame should animation start
  95771. * @param to defines until which frame should animation run.
  95772. * @param weight defines the weight to apply to the animation (1.0 by default)
  95773. * @param loop defines if the animation loops
  95774. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95775. * @param onAnimationEnd defines the function to be executed when the animation ends
  95776. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95777. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  95778. * @param onAnimationLoop defines the callback to call when an animation loops
  95779. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95780. * @returns the animatable object created for this animation
  95781. */
  95782. 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;
  95783. /**
  95784. * Will start the animation sequence of a given target
  95785. * @param target defines the target
  95786. * @param from defines from which frame should animation start
  95787. * @param to defines until which frame should animation run.
  95788. * @param loop defines if the animation loops
  95789. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95790. * @param onAnimationEnd defines the function to be executed when the animation ends
  95791. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95792. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  95793. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  95794. * @param onAnimationLoop defines the callback to call when an animation loops
  95795. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95796. * @returns the animatable object created for this animation
  95797. */
  95798. 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;
  95799. /**
  95800. * Will start the animation sequence of a given target and its hierarchy
  95801. * @param target defines the target
  95802. * @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.
  95803. * @param from defines from which frame should animation start
  95804. * @param to defines until which frame should animation run.
  95805. * @param loop defines if the animation loops
  95806. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95807. * @param onAnimationEnd defines the function to be executed when the animation ends
  95808. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95809. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  95810. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  95811. * @param onAnimationLoop defines the callback to call when an animation loops
  95812. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95813. * @returns the list of created animatables
  95814. */
  95815. 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[];
  95816. /**
  95817. * Begin a new animation on a given node
  95818. * @param target defines the target where the animation will take place
  95819. * @param animations defines the list of animations to start
  95820. * @param from defines the initial value
  95821. * @param to defines the final value
  95822. * @param loop defines if you want animation to loop (off by default)
  95823. * @param speedRatio defines the speed ratio to apply to all animations
  95824. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95825. * @param onAnimationLoop defines the callback to call when an animation loops
  95826. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95827. * @returns the list of created animatables
  95828. */
  95829. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  95830. /**
  95831. * Begin a new animation on a given node and its hierarchy
  95832. * @param target defines the root node where the animation will take place
  95833. * @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.
  95834. * @param animations defines the list of animations to start
  95835. * @param from defines the initial value
  95836. * @param to defines the final value
  95837. * @param loop defines if you want animation to loop (off by default)
  95838. * @param speedRatio defines the speed ratio to apply to all animations
  95839. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95840. * @param onAnimationLoop defines the callback to call when an animation loops
  95841. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95842. * @returns the list of animatables created for all nodes
  95843. */
  95844. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  95845. /**
  95846. * Gets the animatable associated with a specific target
  95847. * @param target defines the target of the animatable
  95848. * @returns the required animatable if found
  95849. */
  95850. getAnimatableByTarget(target: any): Nullable<Animatable>;
  95851. /**
  95852. * Gets all animatables associated with a given target
  95853. * @param target defines the target to look animatables for
  95854. * @returns an array of Animatables
  95855. */
  95856. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  95857. /**
  95858. * Stops and removes all animations that have been applied to the scene
  95859. */
  95860. stopAllAnimations(): void;
  95861. /**
  95862. * Gets the current delta time used by animation engine
  95863. */
  95864. deltaTime: number;
  95865. }
  95866. interface Bone {
  95867. /**
  95868. * Copy an animation range from another bone
  95869. * @param source defines the source bone
  95870. * @param rangeName defines the range name to copy
  95871. * @param frameOffset defines the frame offset
  95872. * @param rescaleAsRequired defines if rescaling must be applied if required
  95873. * @param skelDimensionsRatio defines the scaling ratio
  95874. * @returns true if operation was successful
  95875. */
  95876. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  95877. }
  95878. }
  95879. declare module BABYLON {
  95880. /**
  95881. * Class used to handle skinning animations
  95882. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95883. */
  95884. export class Skeleton implements IAnimatable {
  95885. /** defines the skeleton name */
  95886. name: string;
  95887. /** defines the skeleton Id */
  95888. id: string;
  95889. /**
  95890. * Defines the list of child bones
  95891. */
  95892. bones: Bone[];
  95893. /**
  95894. * Defines an estimate of the dimension of the skeleton at rest
  95895. */
  95896. dimensionsAtRest: Vector3;
  95897. /**
  95898. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  95899. */
  95900. needInitialSkinMatrix: boolean;
  95901. /**
  95902. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  95903. */
  95904. overrideMesh: Nullable<AbstractMesh>;
  95905. /**
  95906. * Gets the list of animations attached to this skeleton
  95907. */
  95908. animations: Array<Animation>;
  95909. private _scene;
  95910. private _isDirty;
  95911. private _transformMatrices;
  95912. private _transformMatrixTexture;
  95913. private _meshesWithPoseMatrix;
  95914. private _animatables;
  95915. private _identity;
  95916. private _synchronizedWithMesh;
  95917. private _ranges;
  95918. private _lastAbsoluteTransformsUpdateId;
  95919. private _canUseTextureForBones;
  95920. private _uniqueId;
  95921. /** @hidden */
  95922. _numBonesWithLinkedTransformNode: number;
  95923. /** @hidden */
  95924. _hasWaitingData: Nullable<boolean>;
  95925. /** @hidden */
  95926. _waitingOverrideMeshId: Nullable<string>;
  95927. /**
  95928. * Specifies if the skeleton should be serialized
  95929. */
  95930. doNotSerialize: boolean;
  95931. private _useTextureToStoreBoneMatrices;
  95932. /**
  95933. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  95934. * Please note that this option is not available if the hardware does not support it
  95935. */
  95936. get useTextureToStoreBoneMatrices(): boolean;
  95937. set useTextureToStoreBoneMatrices(value: boolean);
  95938. private _animationPropertiesOverride;
  95939. /**
  95940. * Gets or sets the animation properties override
  95941. */
  95942. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95943. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95944. /**
  95945. * List of inspectable custom properties (used by the Inspector)
  95946. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95947. */
  95948. inspectableCustomProperties: IInspectable[];
  95949. /**
  95950. * An observable triggered before computing the skeleton's matrices
  95951. */
  95952. onBeforeComputeObservable: Observable<Skeleton>;
  95953. /**
  95954. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  95955. */
  95956. get isUsingTextureForMatrices(): boolean;
  95957. /**
  95958. * Gets the unique ID of this skeleton
  95959. */
  95960. get uniqueId(): number;
  95961. /**
  95962. * Creates a new skeleton
  95963. * @param name defines the skeleton name
  95964. * @param id defines the skeleton Id
  95965. * @param scene defines the hosting scene
  95966. */
  95967. constructor(
  95968. /** defines the skeleton name */
  95969. name: string,
  95970. /** defines the skeleton Id */
  95971. id: string, scene: Scene);
  95972. /**
  95973. * Gets the current object class name.
  95974. * @return the class name
  95975. */
  95976. getClassName(): string;
  95977. /**
  95978. * Returns an array containing the root bones
  95979. * @returns an array containing the root bones
  95980. */
  95981. getChildren(): Array<Bone>;
  95982. /**
  95983. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  95984. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  95985. * @returns a Float32Array containing matrices data
  95986. */
  95987. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  95988. /**
  95989. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  95990. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  95991. * @returns a raw texture containing the data
  95992. */
  95993. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  95994. /**
  95995. * Gets the current hosting scene
  95996. * @returns a scene object
  95997. */
  95998. getScene(): Scene;
  95999. /**
  96000. * Gets a string representing the current skeleton data
  96001. * @param fullDetails defines a boolean indicating if we want a verbose version
  96002. * @returns a string representing the current skeleton data
  96003. */
  96004. toString(fullDetails?: boolean): string;
  96005. /**
  96006. * Get bone's index searching by name
  96007. * @param name defines bone's name to search for
  96008. * @return the indice of the bone. Returns -1 if not found
  96009. */
  96010. getBoneIndexByName(name: string): number;
  96011. /**
  96012. * Creater a new animation range
  96013. * @param name defines the name of the range
  96014. * @param from defines the start key
  96015. * @param to defines the end key
  96016. */
  96017. createAnimationRange(name: string, from: number, to: number): void;
  96018. /**
  96019. * Delete a specific animation range
  96020. * @param name defines the name of the range
  96021. * @param deleteFrames defines if frames must be removed as well
  96022. */
  96023. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96024. /**
  96025. * Gets a specific animation range
  96026. * @param name defines the name of the range to look for
  96027. * @returns the requested animation range or null if not found
  96028. */
  96029. getAnimationRange(name: string): Nullable<AnimationRange>;
  96030. /**
  96031. * Gets the list of all animation ranges defined on this skeleton
  96032. * @returns an array
  96033. */
  96034. getAnimationRanges(): Nullable<AnimationRange>[];
  96035. /**
  96036. * Copy animation range from a source skeleton.
  96037. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  96038. * @param source defines the source skeleton
  96039. * @param name defines the name of the range to copy
  96040. * @param rescaleAsRequired defines if rescaling must be applied if required
  96041. * @returns true if operation was successful
  96042. */
  96043. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  96044. /**
  96045. * Forces the skeleton to go to rest pose
  96046. */
  96047. returnToRest(): void;
  96048. private _getHighestAnimationFrame;
  96049. /**
  96050. * Begin a specific animation range
  96051. * @param name defines the name of the range to start
  96052. * @param loop defines if looping must be turned on (false by default)
  96053. * @param speedRatio defines the speed ratio to apply (1 by default)
  96054. * @param onAnimationEnd defines a callback which will be called when animation will end
  96055. * @returns a new animatable
  96056. */
  96057. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96058. /**
  96059. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  96060. * @param skeleton defines the Skeleton containing the animation range to convert
  96061. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  96062. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  96063. * @returns the original skeleton
  96064. */
  96065. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  96066. /** @hidden */
  96067. _markAsDirty(): void;
  96068. /** @hidden */
  96069. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96070. /** @hidden */
  96071. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96072. private _computeTransformMatrices;
  96073. /**
  96074. * Build all resources required to render a skeleton
  96075. */
  96076. prepare(): void;
  96077. /**
  96078. * Gets the list of animatables currently running for this skeleton
  96079. * @returns an array of animatables
  96080. */
  96081. getAnimatables(): IAnimatable[];
  96082. /**
  96083. * Clone the current skeleton
  96084. * @param name defines the name of the new skeleton
  96085. * @param id defines the id of the new skeleton
  96086. * @returns the new skeleton
  96087. */
  96088. clone(name: string, id?: string): Skeleton;
  96089. /**
  96090. * Enable animation blending for this skeleton
  96091. * @param blendingSpeed defines the blending speed to apply
  96092. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96093. */
  96094. enableBlending(blendingSpeed?: number): void;
  96095. /**
  96096. * Releases all resources associated with the current skeleton
  96097. */
  96098. dispose(): void;
  96099. /**
  96100. * Serialize the skeleton in a JSON object
  96101. * @returns a JSON object
  96102. */
  96103. serialize(): any;
  96104. /**
  96105. * Creates a new skeleton from serialized data
  96106. * @param parsedSkeleton defines the serialized data
  96107. * @param scene defines the hosting scene
  96108. * @returns a new skeleton
  96109. */
  96110. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  96111. /**
  96112. * Compute all node absolute transforms
  96113. * @param forceUpdate defines if computation must be done even if cache is up to date
  96114. */
  96115. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  96116. /**
  96117. * Gets the root pose matrix
  96118. * @returns a matrix
  96119. */
  96120. getPoseMatrix(): Nullable<Matrix>;
  96121. /**
  96122. * Sorts bones per internal index
  96123. */
  96124. sortBones(): void;
  96125. private _sortBones;
  96126. }
  96127. }
  96128. declare module BABYLON {
  96129. /**
  96130. * Creates an instance based on a source mesh.
  96131. */
  96132. export class InstancedMesh extends AbstractMesh {
  96133. private _sourceMesh;
  96134. private _currentLOD;
  96135. /** @hidden */
  96136. _indexInSourceMeshInstanceArray: number;
  96137. constructor(name: string, source: Mesh);
  96138. /**
  96139. * Returns the string "InstancedMesh".
  96140. */
  96141. getClassName(): string;
  96142. /** Gets the list of lights affecting that mesh */
  96143. get lightSources(): Light[];
  96144. _resyncLightSources(): void;
  96145. _resyncLightSource(light: Light): void;
  96146. _removeLightSource(light: Light, dispose: boolean): void;
  96147. /**
  96148. * If the source mesh receives shadows
  96149. */
  96150. get receiveShadows(): boolean;
  96151. /**
  96152. * The material of the source mesh
  96153. */
  96154. get material(): Nullable<Material>;
  96155. /**
  96156. * Visibility of the source mesh
  96157. */
  96158. get visibility(): number;
  96159. /**
  96160. * Skeleton of the source mesh
  96161. */
  96162. get skeleton(): Nullable<Skeleton>;
  96163. /**
  96164. * Rendering ground id of the source mesh
  96165. */
  96166. get renderingGroupId(): number;
  96167. set renderingGroupId(value: number);
  96168. /**
  96169. * Returns the total number of vertices (integer).
  96170. */
  96171. getTotalVertices(): number;
  96172. /**
  96173. * Returns a positive integer : the total number of indices in this mesh geometry.
  96174. * @returns the numner of indices or zero if the mesh has no geometry.
  96175. */
  96176. getTotalIndices(): number;
  96177. /**
  96178. * The source mesh of the instance
  96179. */
  96180. get sourceMesh(): Mesh;
  96181. /**
  96182. * Creates a new InstancedMesh object from the mesh model.
  96183. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96184. * @param name defines the name of the new instance
  96185. * @returns a new InstancedMesh
  96186. */
  96187. createInstance(name: string): InstancedMesh;
  96188. /**
  96189. * Is this node ready to be used/rendered
  96190. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96191. * @return {boolean} is it ready
  96192. */
  96193. isReady(completeCheck?: boolean): boolean;
  96194. /**
  96195. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96196. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  96197. * @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.
  96198. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  96199. */
  96200. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  96201. /**
  96202. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96203. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96204. * The `data` are either a numeric array either a Float32Array.
  96205. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  96206. * 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).
  96207. * Note that a new underlying VertexBuffer object is created each call.
  96208. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96209. *
  96210. * Possible `kind` values :
  96211. * - VertexBuffer.PositionKind
  96212. * - VertexBuffer.UVKind
  96213. * - VertexBuffer.UV2Kind
  96214. * - VertexBuffer.UV3Kind
  96215. * - VertexBuffer.UV4Kind
  96216. * - VertexBuffer.UV5Kind
  96217. * - VertexBuffer.UV6Kind
  96218. * - VertexBuffer.ColorKind
  96219. * - VertexBuffer.MatricesIndicesKind
  96220. * - VertexBuffer.MatricesIndicesExtraKind
  96221. * - VertexBuffer.MatricesWeightsKind
  96222. * - VertexBuffer.MatricesWeightsExtraKind
  96223. *
  96224. * Returns the Mesh.
  96225. */
  96226. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96227. /**
  96228. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96229. * If the mesh has no geometry, it is simply returned as it is.
  96230. * The `data` are either a numeric array either a Float32Array.
  96231. * No new underlying VertexBuffer object is created.
  96232. * 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.
  96233. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  96234. *
  96235. * Possible `kind` values :
  96236. * - VertexBuffer.PositionKind
  96237. * - VertexBuffer.UVKind
  96238. * - VertexBuffer.UV2Kind
  96239. * - VertexBuffer.UV3Kind
  96240. * - VertexBuffer.UV4Kind
  96241. * - VertexBuffer.UV5Kind
  96242. * - VertexBuffer.UV6Kind
  96243. * - VertexBuffer.ColorKind
  96244. * - VertexBuffer.MatricesIndicesKind
  96245. * - VertexBuffer.MatricesIndicesExtraKind
  96246. * - VertexBuffer.MatricesWeightsKind
  96247. * - VertexBuffer.MatricesWeightsExtraKind
  96248. *
  96249. * Returns the Mesh.
  96250. */
  96251. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  96252. /**
  96253. * Sets the mesh indices.
  96254. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  96255. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96256. * This method creates a new index buffer each call.
  96257. * Returns the Mesh.
  96258. */
  96259. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  96260. /**
  96261. * Boolean : True if the mesh owns the requested kind of data.
  96262. */
  96263. isVerticesDataPresent(kind: string): boolean;
  96264. /**
  96265. * Returns an array of indices (IndicesArray).
  96266. */
  96267. getIndices(): Nullable<IndicesArray>;
  96268. get _positions(): Nullable<Vector3[]>;
  96269. /**
  96270. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96271. * This means the mesh underlying bounding box and sphere are recomputed.
  96272. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96273. * @returns the current mesh
  96274. */
  96275. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  96276. /** @hidden */
  96277. _preActivate(): InstancedMesh;
  96278. /** @hidden */
  96279. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96280. /** @hidden */
  96281. _postActivate(): void;
  96282. getWorldMatrix(): Matrix;
  96283. get isAnInstance(): boolean;
  96284. /**
  96285. * Returns the current associated LOD AbstractMesh.
  96286. */
  96287. getLOD(camera: Camera): AbstractMesh;
  96288. /** @hidden */
  96289. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96290. /** @hidden */
  96291. _syncSubMeshes(): InstancedMesh;
  96292. /** @hidden */
  96293. _generatePointsArray(): boolean;
  96294. /** @hidden */
  96295. _updateBoundingInfo(): AbstractMesh;
  96296. /**
  96297. * Creates a new InstancedMesh from the current mesh.
  96298. * - name (string) : the cloned mesh name
  96299. * - newParent (optional Node) : the optional Node to parent the clone to.
  96300. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  96301. *
  96302. * Returns the clone.
  96303. */
  96304. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  96305. /**
  96306. * Disposes the InstancedMesh.
  96307. * Returns nothing.
  96308. */
  96309. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96310. }
  96311. interface Mesh {
  96312. /**
  96313. * Register a custom buffer that will be instanced
  96314. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96315. * @param kind defines the buffer kind
  96316. * @param stride defines the stride in floats
  96317. */
  96318. registerInstancedBuffer(kind: string, stride: number): void;
  96319. /**
  96320. * true to use the edge renderer for all instances of this mesh
  96321. */
  96322. edgesShareWithInstances: boolean;
  96323. /** @hidden */
  96324. _userInstancedBuffersStorage: {
  96325. data: {
  96326. [key: string]: Float32Array;
  96327. };
  96328. sizes: {
  96329. [key: string]: number;
  96330. };
  96331. vertexBuffers: {
  96332. [key: string]: Nullable<VertexBuffer>;
  96333. };
  96334. strides: {
  96335. [key: string]: number;
  96336. };
  96337. };
  96338. }
  96339. interface AbstractMesh {
  96340. /**
  96341. * Object used to store instanced buffers defined by user
  96342. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96343. */
  96344. instancedBuffers: {
  96345. [key: string]: any;
  96346. };
  96347. }
  96348. }
  96349. declare module BABYLON {
  96350. /**
  96351. * Defines the options associated with the creation of a shader material.
  96352. */
  96353. export interface IShaderMaterialOptions {
  96354. /**
  96355. * Does the material work in alpha blend mode
  96356. */
  96357. needAlphaBlending: boolean;
  96358. /**
  96359. * Does the material work in alpha test mode
  96360. */
  96361. needAlphaTesting: boolean;
  96362. /**
  96363. * The list of attribute names used in the shader
  96364. */
  96365. attributes: string[];
  96366. /**
  96367. * The list of unifrom names used in the shader
  96368. */
  96369. uniforms: string[];
  96370. /**
  96371. * The list of UBO names used in the shader
  96372. */
  96373. uniformBuffers: string[];
  96374. /**
  96375. * The list of sampler names used in the shader
  96376. */
  96377. samplers: string[];
  96378. /**
  96379. * The list of defines used in the shader
  96380. */
  96381. defines: string[];
  96382. }
  96383. /**
  96384. * 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.
  96385. *
  96386. * This returned material effects how the mesh will look based on the code in the shaders.
  96387. *
  96388. * @see https://doc.babylonjs.com/how_to/shader_material
  96389. */
  96390. export class ShaderMaterial extends Material {
  96391. private _shaderPath;
  96392. private _options;
  96393. private _textures;
  96394. private _textureArrays;
  96395. private _floats;
  96396. private _ints;
  96397. private _floatsArrays;
  96398. private _colors3;
  96399. private _colors3Arrays;
  96400. private _colors4;
  96401. private _colors4Arrays;
  96402. private _vectors2;
  96403. private _vectors3;
  96404. private _vectors4;
  96405. private _matrices;
  96406. private _matrixArrays;
  96407. private _matrices3x3;
  96408. private _matrices2x2;
  96409. private _vectors2Arrays;
  96410. private _vectors3Arrays;
  96411. private _vectors4Arrays;
  96412. private _cachedWorldViewMatrix;
  96413. private _cachedWorldViewProjectionMatrix;
  96414. private _renderId;
  96415. private _multiview;
  96416. private _cachedDefines;
  96417. /** Define the Url to load snippets */
  96418. static SnippetUrl: string;
  96419. /** Snippet ID if the material was created from the snippet server */
  96420. snippetId: string;
  96421. /**
  96422. * Instantiate a new shader material.
  96423. * 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.
  96424. * This returned material effects how the mesh will look based on the code in the shaders.
  96425. * @see https://doc.babylonjs.com/how_to/shader_material
  96426. * @param name Define the name of the material in the scene
  96427. * @param scene Define the scene the material belongs to
  96428. * @param shaderPath Defines the route to the shader code in one of three ways:
  96429. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  96430. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  96431. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  96432. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  96433. * @param options Define the options used to create the shader
  96434. */
  96435. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  96436. /**
  96437. * Gets the shader path used to define the shader code
  96438. * It can be modified to trigger a new compilation
  96439. */
  96440. get shaderPath(): any;
  96441. /**
  96442. * Sets the shader path used to define the shader code
  96443. * It can be modified to trigger a new compilation
  96444. */
  96445. set shaderPath(shaderPath: any);
  96446. /**
  96447. * Gets the options used to compile the shader.
  96448. * They can be modified to trigger a new compilation
  96449. */
  96450. get options(): IShaderMaterialOptions;
  96451. /**
  96452. * Gets the current class name of the material e.g. "ShaderMaterial"
  96453. * Mainly use in serialization.
  96454. * @returns the class name
  96455. */
  96456. getClassName(): string;
  96457. /**
  96458. * Specifies if the material will require alpha blending
  96459. * @returns a boolean specifying if alpha blending is needed
  96460. */
  96461. needAlphaBlending(): boolean;
  96462. /**
  96463. * Specifies if this material should be rendered in alpha test mode
  96464. * @returns a boolean specifying if an alpha test is needed.
  96465. */
  96466. needAlphaTesting(): boolean;
  96467. private _checkUniform;
  96468. /**
  96469. * Set a texture in the shader.
  96470. * @param name Define the name of the uniform samplers as defined in the shader
  96471. * @param texture Define the texture to bind to this sampler
  96472. * @return the material itself allowing "fluent" like uniform updates
  96473. */
  96474. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  96475. /**
  96476. * Set a texture array in the shader.
  96477. * @param name Define the name of the uniform sampler array as defined in the shader
  96478. * @param textures Define the list of textures to bind to this sampler
  96479. * @return the material itself allowing "fluent" like uniform updates
  96480. */
  96481. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  96482. /**
  96483. * Set a float in the shader.
  96484. * @param name Define the name of the uniform as defined in the shader
  96485. * @param value Define the value to give to the uniform
  96486. * @return the material itself allowing "fluent" like uniform updates
  96487. */
  96488. setFloat(name: string, value: number): ShaderMaterial;
  96489. /**
  96490. * Set a int in the shader.
  96491. * @param name Define the name of the uniform as defined in the shader
  96492. * @param value Define the value to give to the uniform
  96493. * @return the material itself allowing "fluent" like uniform updates
  96494. */
  96495. setInt(name: string, value: number): ShaderMaterial;
  96496. /**
  96497. * Set an array of floats in the shader.
  96498. * @param name Define the name of the uniform as defined in the shader
  96499. * @param value Define the value to give to the uniform
  96500. * @return the material itself allowing "fluent" like uniform updates
  96501. */
  96502. setFloats(name: string, value: number[]): ShaderMaterial;
  96503. /**
  96504. * Set a vec3 in the shader from a Color3.
  96505. * @param name Define the name of the uniform as defined in the shader
  96506. * @param value Define the value to give to the uniform
  96507. * @return the material itself allowing "fluent" like uniform updates
  96508. */
  96509. setColor3(name: string, value: Color3): ShaderMaterial;
  96510. /**
  96511. * Set a vec3 array in the shader from a Color3 array.
  96512. * @param name Define the name of the uniform as defined in the shader
  96513. * @param value Define the value to give to the uniform
  96514. * @return the material itself allowing "fluent" like uniform updates
  96515. */
  96516. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  96517. /**
  96518. * Set a vec4 in the shader from a Color4.
  96519. * @param name Define the name of the uniform as defined in the shader
  96520. * @param value Define the value to give to the uniform
  96521. * @return the material itself allowing "fluent" like uniform updates
  96522. */
  96523. setColor4(name: string, value: Color4): ShaderMaterial;
  96524. /**
  96525. * Set a vec4 array in the shader from a Color4 array.
  96526. * @param name Define the name of the uniform as defined in the shader
  96527. * @param value Define the value to give to the uniform
  96528. * @return the material itself allowing "fluent" like uniform updates
  96529. */
  96530. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  96531. /**
  96532. * Set a vec2 in the shader from a Vector2.
  96533. * @param name Define the name of the uniform as defined in the shader
  96534. * @param value Define the value to give to the uniform
  96535. * @return the material itself allowing "fluent" like uniform updates
  96536. */
  96537. setVector2(name: string, value: Vector2): ShaderMaterial;
  96538. /**
  96539. * Set a vec3 in the shader from a Vector3.
  96540. * @param name Define the name of the uniform as defined in the shader
  96541. * @param value Define the value to give to the uniform
  96542. * @return the material itself allowing "fluent" like uniform updates
  96543. */
  96544. setVector3(name: string, value: Vector3): ShaderMaterial;
  96545. /**
  96546. * Set a vec4 in the shader from a Vector4.
  96547. * @param name Define the name of the uniform as defined in the shader
  96548. * @param value Define the value to give to the uniform
  96549. * @return the material itself allowing "fluent" like uniform updates
  96550. */
  96551. setVector4(name: string, value: Vector4): ShaderMaterial;
  96552. /**
  96553. * Set a mat4 in the shader from a Matrix.
  96554. * @param name Define the name of the uniform as defined in the shader
  96555. * @param value Define the value to give to the uniform
  96556. * @return the material itself allowing "fluent" like uniform updates
  96557. */
  96558. setMatrix(name: string, value: Matrix): ShaderMaterial;
  96559. /**
  96560. * Set a float32Array in the shader from a matrix array.
  96561. * @param name Define the name of the uniform as defined in the shader
  96562. * @param value Define the value to give to the uniform
  96563. * @return the material itself allowing "fluent" like uniform updates
  96564. */
  96565. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  96566. /**
  96567. * Set a mat3 in the shader from a Float32Array.
  96568. * @param name Define the name of the uniform as defined in the shader
  96569. * @param value Define the value to give to the uniform
  96570. * @return the material itself allowing "fluent" like uniform updates
  96571. */
  96572. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  96573. /**
  96574. * Set a mat2 in the shader from a Float32Array.
  96575. * @param name Define the name of the uniform as defined in the shader
  96576. * @param value Define the value to give to the uniform
  96577. * @return the material itself allowing "fluent" like uniform updates
  96578. */
  96579. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  96580. /**
  96581. * Set a vec2 array in the shader from a number array.
  96582. * @param name Define the name of the uniform as defined in the shader
  96583. * @param value Define the value to give to the uniform
  96584. * @return the material itself allowing "fluent" like uniform updates
  96585. */
  96586. setArray2(name: string, value: number[]): ShaderMaterial;
  96587. /**
  96588. * Set a vec3 array in the shader from a number array.
  96589. * @param name Define the name of the uniform as defined in the shader
  96590. * @param value Define the value to give to the uniform
  96591. * @return the material itself allowing "fluent" like uniform updates
  96592. */
  96593. setArray3(name: string, value: number[]): ShaderMaterial;
  96594. /**
  96595. * Set a vec4 array in the shader from a number array.
  96596. * @param name Define the name of the uniform as defined in the shader
  96597. * @param value Define the value to give to the uniform
  96598. * @return the material itself allowing "fluent" like uniform updates
  96599. */
  96600. setArray4(name: string, value: number[]): ShaderMaterial;
  96601. private _checkCache;
  96602. /**
  96603. * Specifies that the submesh is ready to be used
  96604. * @param mesh defines the mesh to check
  96605. * @param subMesh defines which submesh to check
  96606. * @param useInstances specifies that instances should be used
  96607. * @returns a boolean indicating that the submesh is ready or not
  96608. */
  96609. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  96610. /**
  96611. * Checks if the material is ready to render the requested mesh
  96612. * @param mesh Define the mesh to render
  96613. * @param useInstances Define whether or not the material is used with instances
  96614. * @returns true if ready, otherwise false
  96615. */
  96616. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96617. /**
  96618. * Binds the world matrix to the material
  96619. * @param world defines the world transformation matrix
  96620. * @param effectOverride - If provided, use this effect instead of internal effect
  96621. */
  96622. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  96623. /**
  96624. * Binds the submesh to this material by preparing the effect and shader to draw
  96625. * @param world defines the world transformation matrix
  96626. * @param mesh defines the mesh containing the submesh
  96627. * @param subMesh defines the submesh to bind the material to
  96628. */
  96629. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  96630. /**
  96631. * Binds the material to the mesh
  96632. * @param world defines the world transformation matrix
  96633. * @param mesh defines the mesh to bind the material to
  96634. * @param effectOverride - If provided, use this effect instead of internal effect
  96635. */
  96636. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  96637. protected _afterBind(mesh?: Mesh): void;
  96638. /**
  96639. * Gets the active textures from the material
  96640. * @returns an array of textures
  96641. */
  96642. getActiveTextures(): BaseTexture[];
  96643. /**
  96644. * Specifies if the material uses a texture
  96645. * @param texture defines the texture to check against the material
  96646. * @returns a boolean specifying if the material uses the texture
  96647. */
  96648. hasTexture(texture: BaseTexture): boolean;
  96649. /**
  96650. * Makes a duplicate of the material, and gives it a new name
  96651. * @param name defines the new name for the duplicated material
  96652. * @returns the cloned material
  96653. */
  96654. clone(name: string): ShaderMaterial;
  96655. /**
  96656. * Disposes the material
  96657. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  96658. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  96659. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  96660. */
  96661. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  96662. /**
  96663. * Serializes this material in a JSON representation
  96664. * @returns the serialized material object
  96665. */
  96666. serialize(): any;
  96667. /**
  96668. * Creates a shader material from parsed shader material data
  96669. * @param source defines the JSON represnetation of the material
  96670. * @param scene defines the hosting scene
  96671. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96672. * @returns a new material
  96673. */
  96674. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  96675. /**
  96676. * Creates a new ShaderMaterial from a snippet saved in a remote file
  96677. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  96678. * @param url defines the url to load from
  96679. * @param scene defines the hosting scene
  96680. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96681. * @returns a promise that will resolve to the new ShaderMaterial
  96682. */
  96683. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  96684. /**
  96685. * Creates a ShaderMaterial from a snippet saved by the Inspector
  96686. * @param snippetId defines the snippet to load
  96687. * @param scene defines the hosting scene
  96688. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96689. * @returns a promise that will resolve to the new ShaderMaterial
  96690. */
  96691. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  96692. }
  96693. }
  96694. declare module BABYLON {
  96695. /** @hidden */
  96696. export var colorPixelShader: {
  96697. name: string;
  96698. shader: string;
  96699. };
  96700. }
  96701. declare module BABYLON {
  96702. /** @hidden */
  96703. export var colorVertexShader: {
  96704. name: string;
  96705. shader: string;
  96706. };
  96707. }
  96708. declare module BABYLON {
  96709. /**
  96710. * Line mesh
  96711. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  96712. */
  96713. export class LinesMesh extends Mesh {
  96714. /**
  96715. * If vertex color should be applied to the mesh
  96716. */
  96717. readonly useVertexColor?: boolean | undefined;
  96718. /**
  96719. * If vertex alpha should be applied to the mesh
  96720. */
  96721. readonly useVertexAlpha?: boolean | undefined;
  96722. /**
  96723. * Color of the line (Default: White)
  96724. */
  96725. color: Color3;
  96726. /**
  96727. * Alpha of the line (Default: 1)
  96728. */
  96729. alpha: number;
  96730. /**
  96731. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  96732. * This margin is expressed in world space coordinates, so its value may vary.
  96733. * Default value is 0.1
  96734. */
  96735. intersectionThreshold: number;
  96736. private _colorShader;
  96737. private color4;
  96738. /**
  96739. * Creates a new LinesMesh
  96740. * @param name defines the name
  96741. * @param scene defines the hosting scene
  96742. * @param parent defines the parent mesh if any
  96743. * @param source defines the optional source LinesMesh used to clone data from
  96744. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  96745. * When false, achieved by calling a clone(), also passing False.
  96746. * This will make creation of children, recursive.
  96747. * @param useVertexColor defines if this LinesMesh supports vertex color
  96748. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  96749. */
  96750. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  96751. /**
  96752. * If vertex color should be applied to the mesh
  96753. */
  96754. useVertexColor?: boolean | undefined,
  96755. /**
  96756. * If vertex alpha should be applied to the mesh
  96757. */
  96758. useVertexAlpha?: boolean | undefined);
  96759. private _addClipPlaneDefine;
  96760. private _removeClipPlaneDefine;
  96761. isReady(): boolean;
  96762. /**
  96763. * Returns the string "LineMesh"
  96764. */
  96765. getClassName(): string;
  96766. /**
  96767. * @hidden
  96768. */
  96769. get material(): Material;
  96770. /**
  96771. * @hidden
  96772. */
  96773. set material(value: Material);
  96774. /**
  96775. * @hidden
  96776. */
  96777. get checkCollisions(): boolean;
  96778. /** @hidden */
  96779. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  96780. /** @hidden */
  96781. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  96782. /**
  96783. * Disposes of the line mesh
  96784. * @param doNotRecurse If children should be disposed
  96785. */
  96786. dispose(doNotRecurse?: boolean): void;
  96787. /**
  96788. * Returns a new LineMesh object cloned from the current one.
  96789. */
  96790. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  96791. /**
  96792. * Creates a new InstancedLinesMesh object from the mesh model.
  96793. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96794. * @param name defines the name of the new instance
  96795. * @returns a new InstancedLinesMesh
  96796. */
  96797. createInstance(name: string): InstancedLinesMesh;
  96798. }
  96799. /**
  96800. * Creates an instance based on a source LinesMesh
  96801. */
  96802. export class InstancedLinesMesh extends InstancedMesh {
  96803. /**
  96804. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  96805. * This margin is expressed in world space coordinates, so its value may vary.
  96806. * Initilized with the intersectionThreshold value of the source LinesMesh
  96807. */
  96808. intersectionThreshold: number;
  96809. constructor(name: string, source: LinesMesh);
  96810. /**
  96811. * Returns the string "InstancedLinesMesh".
  96812. */
  96813. getClassName(): string;
  96814. }
  96815. }
  96816. declare module BABYLON {
  96817. /** @hidden */
  96818. export var linePixelShader: {
  96819. name: string;
  96820. shader: string;
  96821. };
  96822. }
  96823. declare module BABYLON {
  96824. /** @hidden */
  96825. export var lineVertexShader: {
  96826. name: string;
  96827. shader: string;
  96828. };
  96829. }
  96830. declare module BABYLON {
  96831. interface Scene {
  96832. /** @hidden */
  96833. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  96834. }
  96835. interface AbstractMesh {
  96836. /**
  96837. * Gets the edgesRenderer associated with the mesh
  96838. */
  96839. edgesRenderer: Nullable<EdgesRenderer>;
  96840. }
  96841. interface LinesMesh {
  96842. /**
  96843. * Enables the edge rendering mode on the mesh.
  96844. * This mode makes the mesh edges visible
  96845. * @param epsilon defines the maximal distance between two angles to detect a face
  96846. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96847. * @returns the currentAbstractMesh
  96848. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96849. */
  96850. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  96851. }
  96852. interface InstancedLinesMesh {
  96853. /**
  96854. * Enables the edge rendering mode on the mesh.
  96855. * This mode makes the mesh edges visible
  96856. * @param epsilon defines the maximal distance between two angles to detect a face
  96857. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96858. * @returns the current InstancedLinesMesh
  96859. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96860. */
  96861. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  96862. }
  96863. /**
  96864. * Defines the minimum contract an Edges renderer should follow.
  96865. */
  96866. export interface IEdgesRenderer extends IDisposable {
  96867. /**
  96868. * Gets or sets a boolean indicating if the edgesRenderer is active
  96869. */
  96870. isEnabled: boolean;
  96871. /**
  96872. * Renders the edges of the attached mesh,
  96873. */
  96874. render(): void;
  96875. /**
  96876. * Checks wether or not the edges renderer is ready to render.
  96877. * @return true if ready, otherwise false.
  96878. */
  96879. isReady(): boolean;
  96880. /**
  96881. * List of instances to render in case the source mesh has instances
  96882. */
  96883. customInstances: SmartArray<Matrix>;
  96884. }
  96885. /**
  96886. * Defines the additional options of the edges renderer
  96887. */
  96888. export interface IEdgesRendererOptions {
  96889. /**
  96890. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  96891. * If not defined, the default value is true
  96892. */
  96893. useAlternateEdgeFinder?: boolean;
  96894. /**
  96895. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  96896. * If not defined, the default value is true.
  96897. * 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)
  96898. * This option is used only if useAlternateEdgeFinder = true
  96899. */
  96900. useFastVertexMerger?: boolean;
  96901. /**
  96902. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  96903. * The default value is 1e-6
  96904. * This option is used only if useAlternateEdgeFinder = true
  96905. */
  96906. epsilonVertexMerge?: number;
  96907. /**
  96908. * 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
  96909. * 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.
  96910. * This option is used only if useAlternateEdgeFinder = true
  96911. */
  96912. applyTessellation?: boolean;
  96913. /**
  96914. * 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
  96915. * The default value is 1e-6
  96916. * This option is used only if useAlternateEdgeFinder = true
  96917. */
  96918. epsilonVertexAligned?: number;
  96919. }
  96920. /**
  96921. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  96922. */
  96923. export class EdgesRenderer implements IEdgesRenderer {
  96924. /**
  96925. * Define the size of the edges with an orthographic camera
  96926. */
  96927. edgesWidthScalerForOrthographic: number;
  96928. /**
  96929. * Define the size of the edges with a perspective camera
  96930. */
  96931. edgesWidthScalerForPerspective: number;
  96932. protected _source: AbstractMesh;
  96933. protected _linesPositions: number[];
  96934. protected _linesNormals: number[];
  96935. protected _linesIndices: number[];
  96936. protected _epsilon: number;
  96937. protected _indicesCount: number;
  96938. protected _lineShader: ShaderMaterial;
  96939. protected _ib: DataBuffer;
  96940. protected _buffers: {
  96941. [key: string]: Nullable<VertexBuffer>;
  96942. };
  96943. protected _buffersForInstances: {
  96944. [key: string]: Nullable<VertexBuffer>;
  96945. };
  96946. protected _checkVerticesInsteadOfIndices: boolean;
  96947. protected _options: Nullable<IEdgesRendererOptions>;
  96948. private _meshRebuildObserver;
  96949. private _meshDisposeObserver;
  96950. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  96951. isEnabled: boolean;
  96952. /**
  96953. * List of instances to render in case the source mesh has instances
  96954. */
  96955. customInstances: SmartArray<Matrix>;
  96956. private static GetShader;
  96957. /**
  96958. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  96959. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  96960. * @param source Mesh used to create edges
  96961. * @param epsilon sum of angles in adjacency to check for edge
  96962. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  96963. * @param generateEdgesLines - should generate Lines or only prepare resources.
  96964. * @param options The options to apply when generating the edges
  96965. */
  96966. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  96967. protected _prepareRessources(): void;
  96968. /** @hidden */
  96969. _rebuild(): void;
  96970. /**
  96971. * Releases the required resources for the edges renderer
  96972. */
  96973. dispose(): void;
  96974. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  96975. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  96976. /**
  96977. * Checks if the pair of p0 and p1 is en edge
  96978. * @param faceIndex
  96979. * @param edge
  96980. * @param faceNormals
  96981. * @param p0
  96982. * @param p1
  96983. * @private
  96984. */
  96985. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  96986. /**
  96987. * push line into the position, normal and index buffer
  96988. * @protected
  96989. */
  96990. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  96991. /**
  96992. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  96993. */
  96994. private _tessellateTriangle;
  96995. private _generateEdgesLinesAlternate;
  96996. /**
  96997. * Generates lines edges from adjacencjes
  96998. * @private
  96999. */
  97000. _generateEdgesLines(): void;
  97001. /**
  97002. * Checks wether or not the edges renderer is ready to render.
  97003. * @return true if ready, otherwise false.
  97004. */
  97005. isReady(): boolean;
  97006. /**
  97007. * Renders the edges of the attached mesh,
  97008. */
  97009. render(): void;
  97010. }
  97011. /**
  97012. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97013. */
  97014. export class LineEdgesRenderer extends EdgesRenderer {
  97015. /**
  97016. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  97017. * @param source LineMesh used to generate edges
  97018. * @param epsilon not important (specified angle for edge detection)
  97019. * @param checkVerticesInsteadOfIndices not important for LineMesh
  97020. */
  97021. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  97022. /**
  97023. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  97024. */
  97025. _generateEdgesLines(): void;
  97026. }
  97027. }
  97028. declare module BABYLON {
  97029. /**
  97030. * This represents the object necessary to create a rendering group.
  97031. * This is exclusively used and created by the rendering manager.
  97032. * To modify the behavior, you use the available helpers in your scene or meshes.
  97033. * @hidden
  97034. */
  97035. export class RenderingGroup {
  97036. index: number;
  97037. private static _zeroVector;
  97038. private _scene;
  97039. private _opaqueSubMeshes;
  97040. private _transparentSubMeshes;
  97041. private _alphaTestSubMeshes;
  97042. private _depthOnlySubMeshes;
  97043. private _particleSystems;
  97044. private _spriteManagers;
  97045. private _opaqueSortCompareFn;
  97046. private _alphaTestSortCompareFn;
  97047. private _transparentSortCompareFn;
  97048. private _renderOpaque;
  97049. private _renderAlphaTest;
  97050. private _renderTransparent;
  97051. /** @hidden */
  97052. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  97053. onBeforeTransparentRendering: () => void;
  97054. /**
  97055. * Set the opaque sort comparison function.
  97056. * If null the sub meshes will be render in the order they were created
  97057. */
  97058. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97059. /**
  97060. * Set the alpha test sort comparison function.
  97061. * If null the sub meshes will be render in the order they were created
  97062. */
  97063. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97064. /**
  97065. * Set the transparent sort comparison function.
  97066. * If null the sub meshes will be render in the order they were created
  97067. */
  97068. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97069. /**
  97070. * Creates a new rendering group.
  97071. * @param index The rendering group index
  97072. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  97073. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  97074. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  97075. */
  97076. 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>);
  97077. /**
  97078. * Render all the sub meshes contained in the group.
  97079. * @param customRenderFunction Used to override the default render behaviour of the group.
  97080. * @returns true if rendered some submeshes.
  97081. */
  97082. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  97083. /**
  97084. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  97085. * @param subMeshes The submeshes to render
  97086. */
  97087. private renderOpaqueSorted;
  97088. /**
  97089. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  97090. * @param subMeshes The submeshes to render
  97091. */
  97092. private renderAlphaTestSorted;
  97093. /**
  97094. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  97095. * @param subMeshes The submeshes to render
  97096. */
  97097. private renderTransparentSorted;
  97098. /**
  97099. * Renders the submeshes in a specified order.
  97100. * @param subMeshes The submeshes to sort before render
  97101. * @param sortCompareFn The comparison function use to sort
  97102. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  97103. * @param transparent Specifies to activate blending if true
  97104. */
  97105. private static renderSorted;
  97106. /**
  97107. * Renders the submeshes in the order they were dispatched (no sort applied).
  97108. * @param subMeshes The submeshes to render
  97109. */
  97110. private static renderUnsorted;
  97111. /**
  97112. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97113. * are rendered back to front if in the same alpha index.
  97114. *
  97115. * @param a The first submesh
  97116. * @param b The second submesh
  97117. * @returns The result of the comparison
  97118. */
  97119. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  97120. /**
  97121. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97122. * are rendered back to front.
  97123. *
  97124. * @param a The first submesh
  97125. * @param b The second submesh
  97126. * @returns The result of the comparison
  97127. */
  97128. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  97129. /**
  97130. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97131. * are rendered front to back (prevent overdraw).
  97132. *
  97133. * @param a The first submesh
  97134. * @param b The second submesh
  97135. * @returns The result of the comparison
  97136. */
  97137. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  97138. /**
  97139. * Resets the different lists of submeshes to prepare a new frame.
  97140. */
  97141. prepare(): void;
  97142. dispose(): void;
  97143. /**
  97144. * Inserts the submesh in its correct queue depending on its material.
  97145. * @param subMesh The submesh to dispatch
  97146. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97147. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97148. */
  97149. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97150. dispatchSprites(spriteManager: ISpriteManager): void;
  97151. dispatchParticles(particleSystem: IParticleSystem): void;
  97152. private _renderParticles;
  97153. private _renderSprites;
  97154. }
  97155. }
  97156. declare module BABYLON {
  97157. /**
  97158. * Interface describing the different options available in the rendering manager
  97159. * regarding Auto Clear between groups.
  97160. */
  97161. export interface IRenderingManagerAutoClearSetup {
  97162. /**
  97163. * Defines whether or not autoclear is enable.
  97164. */
  97165. autoClear: boolean;
  97166. /**
  97167. * Defines whether or not to autoclear the depth buffer.
  97168. */
  97169. depth: boolean;
  97170. /**
  97171. * Defines whether or not to autoclear the stencil buffer.
  97172. */
  97173. stencil: boolean;
  97174. }
  97175. /**
  97176. * This class is used by the onRenderingGroupObservable
  97177. */
  97178. export class RenderingGroupInfo {
  97179. /**
  97180. * The Scene that being rendered
  97181. */
  97182. scene: Scene;
  97183. /**
  97184. * The camera currently used for the rendering pass
  97185. */
  97186. camera: Nullable<Camera>;
  97187. /**
  97188. * The ID of the renderingGroup being processed
  97189. */
  97190. renderingGroupId: number;
  97191. }
  97192. /**
  97193. * This is the manager responsible of all the rendering for meshes sprites and particles.
  97194. * It is enable to manage the different groups as well as the different necessary sort functions.
  97195. * This should not be used directly aside of the few static configurations
  97196. */
  97197. export class RenderingManager {
  97198. /**
  97199. * The max id used for rendering groups (not included)
  97200. */
  97201. static MAX_RENDERINGGROUPS: number;
  97202. /**
  97203. * The min id used for rendering groups (included)
  97204. */
  97205. static MIN_RENDERINGGROUPS: number;
  97206. /**
  97207. * Used to globally prevent autoclearing scenes.
  97208. */
  97209. static AUTOCLEAR: boolean;
  97210. /**
  97211. * @hidden
  97212. */
  97213. _useSceneAutoClearSetup: boolean;
  97214. private _scene;
  97215. private _renderingGroups;
  97216. private _depthStencilBufferAlreadyCleaned;
  97217. private _autoClearDepthStencil;
  97218. private _customOpaqueSortCompareFn;
  97219. private _customAlphaTestSortCompareFn;
  97220. private _customTransparentSortCompareFn;
  97221. private _renderingGroupInfo;
  97222. /**
  97223. * Instantiates a new rendering group for a particular scene
  97224. * @param scene Defines the scene the groups belongs to
  97225. */
  97226. constructor(scene: Scene);
  97227. private _clearDepthStencilBuffer;
  97228. /**
  97229. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  97230. * @hidden
  97231. */
  97232. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  97233. /**
  97234. * Resets the different information of the group to prepare a new frame
  97235. * @hidden
  97236. */
  97237. reset(): void;
  97238. /**
  97239. * Dispose and release the group and its associated resources.
  97240. * @hidden
  97241. */
  97242. dispose(): void;
  97243. /**
  97244. * Clear the info related to rendering groups preventing retention points during dispose.
  97245. */
  97246. freeRenderingGroups(): void;
  97247. private _prepareRenderingGroup;
  97248. /**
  97249. * Add a sprite manager to the rendering manager in order to render it this frame.
  97250. * @param spriteManager Define the sprite manager to render
  97251. */
  97252. dispatchSprites(spriteManager: ISpriteManager): void;
  97253. /**
  97254. * Add a particle system to the rendering manager in order to render it this frame.
  97255. * @param particleSystem Define the particle system to render
  97256. */
  97257. dispatchParticles(particleSystem: IParticleSystem): void;
  97258. /**
  97259. * Add a submesh to the manager in order to render it this frame
  97260. * @param subMesh The submesh to dispatch
  97261. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97262. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97263. */
  97264. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97265. /**
  97266. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97267. * This allowed control for front to back rendering or reversly depending of the special needs.
  97268. *
  97269. * @param renderingGroupId The rendering group id corresponding to its index
  97270. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97271. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97272. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97273. */
  97274. 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;
  97275. /**
  97276. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97277. *
  97278. * @param renderingGroupId The rendering group id corresponding to its index
  97279. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97280. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97281. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97282. */
  97283. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97284. /**
  97285. * Gets the current auto clear configuration for one rendering group of the rendering
  97286. * manager.
  97287. * @param index the rendering group index to get the information for
  97288. * @returns The auto clear setup for the requested rendering group
  97289. */
  97290. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97291. }
  97292. }
  97293. declare module BABYLON {
  97294. /**
  97295. * Defines the options associated with the creation of a custom shader for a shadow generator.
  97296. */
  97297. export interface ICustomShaderOptions {
  97298. /**
  97299. * Gets or sets the custom shader name to use
  97300. */
  97301. shaderName: string;
  97302. /**
  97303. * The list of attribute names used in the shader
  97304. */
  97305. attributes?: string[];
  97306. /**
  97307. * The list of unifrom names used in the shader
  97308. */
  97309. uniforms?: string[];
  97310. /**
  97311. * The list of sampler names used in the shader
  97312. */
  97313. samplers?: string[];
  97314. /**
  97315. * The list of defines used in the shader
  97316. */
  97317. defines?: string[];
  97318. }
  97319. /**
  97320. * Interface to implement to create a shadow generator compatible with BJS.
  97321. */
  97322. export interface IShadowGenerator {
  97323. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97324. id: string;
  97325. /**
  97326. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97327. * @returns The render target texture if present otherwise, null
  97328. */
  97329. getShadowMap(): Nullable<RenderTargetTexture>;
  97330. /**
  97331. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97332. * @param subMesh The submesh we want to render in the shadow map
  97333. * @param useInstances Defines wether will draw in the map using instances
  97334. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97335. * @returns true if ready otherwise, false
  97336. */
  97337. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97338. /**
  97339. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97340. * @param defines Defines of the material we want to update
  97341. * @param lightIndex Index of the light in the enabled light list of the material
  97342. */
  97343. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  97344. /**
  97345. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97346. * defined in the generator but impacting the effect).
  97347. * It implies the unifroms available on the materials are the standard BJS ones.
  97348. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97349. * @param effect The effect we are binfing the information for
  97350. */
  97351. bindShadowLight(lightIndex: string, effect: Effect): void;
  97352. /**
  97353. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97354. * (eq to shadow prjection matrix * light transform matrix)
  97355. * @returns The transform matrix used to create the shadow map
  97356. */
  97357. getTransformMatrix(): Matrix;
  97358. /**
  97359. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97360. * Cube and 2D textures for instance.
  97361. */
  97362. recreateShadowMap(): void;
  97363. /**
  97364. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97365. * @param onCompiled Callback triggered at the and of the effects compilation
  97366. * @param options Sets of optional options forcing the compilation with different modes
  97367. */
  97368. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97369. useInstances: boolean;
  97370. }>): void;
  97371. /**
  97372. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97373. * @param options Sets of optional options forcing the compilation with different modes
  97374. * @returns A promise that resolves when the compilation completes
  97375. */
  97376. forceCompilationAsync(options?: Partial<{
  97377. useInstances: boolean;
  97378. }>): Promise<void>;
  97379. /**
  97380. * Serializes the shadow generator setup to a json object.
  97381. * @returns The serialized JSON object
  97382. */
  97383. serialize(): any;
  97384. /**
  97385. * Disposes the Shadow map and related Textures and effects.
  97386. */
  97387. dispose(): void;
  97388. }
  97389. /**
  97390. * Default implementation IShadowGenerator.
  97391. * This is the main object responsible of generating shadows in the framework.
  97392. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  97393. */
  97394. export class ShadowGenerator implements IShadowGenerator {
  97395. /**
  97396. * Name of the shadow generator class
  97397. */
  97398. static CLASSNAME: string;
  97399. /**
  97400. * Shadow generator mode None: no filtering applied.
  97401. */
  97402. static readonly FILTER_NONE: number;
  97403. /**
  97404. * Shadow generator mode ESM: Exponential Shadow Mapping.
  97405. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97406. */
  97407. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  97408. /**
  97409. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  97410. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  97411. */
  97412. static readonly FILTER_POISSONSAMPLING: number;
  97413. /**
  97414. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  97415. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97416. */
  97417. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  97418. /**
  97419. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  97420. * edge artifacts on steep falloff.
  97421. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97422. */
  97423. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  97424. /**
  97425. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  97426. * edge artifacts on steep falloff.
  97427. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97428. */
  97429. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  97430. /**
  97431. * Shadow generator mode PCF: Percentage Closer Filtering
  97432. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97433. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  97434. */
  97435. static readonly FILTER_PCF: number;
  97436. /**
  97437. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  97438. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97439. * Contact Hardening
  97440. */
  97441. static readonly FILTER_PCSS: number;
  97442. /**
  97443. * Reserved for PCF and PCSS
  97444. * Highest Quality.
  97445. *
  97446. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  97447. *
  97448. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  97449. */
  97450. static readonly QUALITY_HIGH: number;
  97451. /**
  97452. * Reserved for PCF and PCSS
  97453. * Good tradeoff for quality/perf cross devices
  97454. *
  97455. * Execute PCF on a 3*3 kernel.
  97456. *
  97457. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  97458. */
  97459. static readonly QUALITY_MEDIUM: number;
  97460. /**
  97461. * Reserved for PCF and PCSS
  97462. * The lowest quality but the fastest.
  97463. *
  97464. * Execute PCF on a 1*1 kernel.
  97465. *
  97466. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  97467. */
  97468. static readonly QUALITY_LOW: number;
  97469. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97470. id: string;
  97471. /** Gets or sets the custom shader name to use */
  97472. customShaderOptions: ICustomShaderOptions;
  97473. /**
  97474. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  97475. */
  97476. onBeforeShadowMapRenderObservable: Observable<Effect>;
  97477. /**
  97478. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  97479. */
  97480. onAfterShadowMapRenderObservable: Observable<Effect>;
  97481. /**
  97482. * Observable triggered before a mesh is rendered in the shadow map.
  97483. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  97484. */
  97485. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  97486. /**
  97487. * Observable triggered after a mesh is rendered in the shadow map.
  97488. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  97489. */
  97490. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  97491. protected _bias: number;
  97492. /**
  97493. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  97494. */
  97495. get bias(): number;
  97496. /**
  97497. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  97498. */
  97499. set bias(bias: number);
  97500. protected _normalBias: number;
  97501. /**
  97502. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97503. */
  97504. get normalBias(): number;
  97505. /**
  97506. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97507. */
  97508. set normalBias(normalBias: number);
  97509. protected _blurBoxOffset: number;
  97510. /**
  97511. * Gets the blur box offset: offset applied during the blur pass.
  97512. * Only useful if useKernelBlur = false
  97513. */
  97514. get blurBoxOffset(): number;
  97515. /**
  97516. * Sets the blur box offset: offset applied during the blur pass.
  97517. * Only useful if useKernelBlur = false
  97518. */
  97519. set blurBoxOffset(value: number);
  97520. protected _blurScale: number;
  97521. /**
  97522. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  97523. * 2 means half of the size.
  97524. */
  97525. get blurScale(): number;
  97526. /**
  97527. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  97528. * 2 means half of the size.
  97529. */
  97530. set blurScale(value: number);
  97531. protected _blurKernel: number;
  97532. /**
  97533. * Gets the blur kernel: kernel size of the blur pass.
  97534. * Only useful if useKernelBlur = true
  97535. */
  97536. get blurKernel(): number;
  97537. /**
  97538. * Sets the blur kernel: kernel size of the blur pass.
  97539. * Only useful if useKernelBlur = true
  97540. */
  97541. set blurKernel(value: number);
  97542. protected _useKernelBlur: boolean;
  97543. /**
  97544. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  97545. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97546. */
  97547. get useKernelBlur(): boolean;
  97548. /**
  97549. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  97550. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97551. */
  97552. set useKernelBlur(value: boolean);
  97553. protected _depthScale: number;
  97554. /**
  97555. * Gets the depth scale used in ESM mode.
  97556. */
  97557. get depthScale(): number;
  97558. /**
  97559. * Sets the depth scale used in ESM mode.
  97560. * This can override the scale stored on the light.
  97561. */
  97562. set depthScale(value: number);
  97563. protected _validateFilter(filter: number): number;
  97564. protected _filter: number;
  97565. /**
  97566. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  97567. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  97568. */
  97569. get filter(): number;
  97570. /**
  97571. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  97572. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  97573. */
  97574. set filter(value: number);
  97575. /**
  97576. * Gets if the current filter is set to Poisson Sampling.
  97577. */
  97578. get usePoissonSampling(): boolean;
  97579. /**
  97580. * Sets the current filter to Poisson Sampling.
  97581. */
  97582. set usePoissonSampling(value: boolean);
  97583. /**
  97584. * Gets if the current filter is set to ESM.
  97585. */
  97586. get useExponentialShadowMap(): boolean;
  97587. /**
  97588. * Sets the current filter is to ESM.
  97589. */
  97590. set useExponentialShadowMap(value: boolean);
  97591. /**
  97592. * Gets if the current filter is set to filtered ESM.
  97593. */
  97594. get useBlurExponentialShadowMap(): boolean;
  97595. /**
  97596. * Gets if the current filter is set to filtered ESM.
  97597. */
  97598. set useBlurExponentialShadowMap(value: boolean);
  97599. /**
  97600. * Gets if the current filter is set to "close ESM" (using the inverse of the
  97601. * exponential to prevent steep falloff artifacts).
  97602. */
  97603. get useCloseExponentialShadowMap(): boolean;
  97604. /**
  97605. * Sets the current filter to "close ESM" (using the inverse of the
  97606. * exponential to prevent steep falloff artifacts).
  97607. */
  97608. set useCloseExponentialShadowMap(value: boolean);
  97609. /**
  97610. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  97611. * exponential to prevent steep falloff artifacts).
  97612. */
  97613. get useBlurCloseExponentialShadowMap(): boolean;
  97614. /**
  97615. * Sets the current filter to filtered "close ESM" (using the inverse of the
  97616. * exponential to prevent steep falloff artifacts).
  97617. */
  97618. set useBlurCloseExponentialShadowMap(value: boolean);
  97619. /**
  97620. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  97621. */
  97622. get usePercentageCloserFiltering(): boolean;
  97623. /**
  97624. * Sets the current filter to "PCF" (percentage closer filtering).
  97625. */
  97626. set usePercentageCloserFiltering(value: boolean);
  97627. protected _filteringQuality: number;
  97628. /**
  97629. * Gets the PCF or PCSS Quality.
  97630. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  97631. */
  97632. get filteringQuality(): number;
  97633. /**
  97634. * Sets the PCF or PCSS Quality.
  97635. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  97636. */
  97637. set filteringQuality(filteringQuality: number);
  97638. /**
  97639. * Gets if the current filter is set to "PCSS" (contact hardening).
  97640. */
  97641. get useContactHardeningShadow(): boolean;
  97642. /**
  97643. * Sets the current filter to "PCSS" (contact hardening).
  97644. */
  97645. set useContactHardeningShadow(value: boolean);
  97646. protected _contactHardeningLightSizeUVRatio: number;
  97647. /**
  97648. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  97649. * Using a ratio helps keeping shape stability independently of the map size.
  97650. *
  97651. * It does not account for the light projection as it was having too much
  97652. * instability during the light setup or during light position changes.
  97653. *
  97654. * Only valid if useContactHardeningShadow is true.
  97655. */
  97656. get contactHardeningLightSizeUVRatio(): number;
  97657. /**
  97658. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  97659. * Using a ratio helps keeping shape stability independently of the map size.
  97660. *
  97661. * It does not account for the light projection as it was having too much
  97662. * instability during the light setup or during light position changes.
  97663. *
  97664. * Only valid if useContactHardeningShadow is true.
  97665. */
  97666. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  97667. protected _darkness: number;
  97668. /** Gets or sets the actual darkness of a shadow */
  97669. get darkness(): number;
  97670. set darkness(value: number);
  97671. /**
  97672. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  97673. * 0 means strongest and 1 would means no shadow.
  97674. * @returns the darkness.
  97675. */
  97676. getDarkness(): number;
  97677. /**
  97678. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  97679. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  97680. * @returns the shadow generator allowing fluent coding.
  97681. */
  97682. setDarkness(darkness: number): ShadowGenerator;
  97683. protected _transparencyShadow: boolean;
  97684. /** Gets or sets the ability to have transparent shadow */
  97685. get transparencyShadow(): boolean;
  97686. set transparencyShadow(value: boolean);
  97687. /**
  97688. * Sets the ability to have transparent shadow (boolean).
  97689. * @param transparent True if transparent else False
  97690. * @returns the shadow generator allowing fluent coding
  97691. */
  97692. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  97693. /**
  97694. * Enables or disables shadows with varying strength based on the transparency
  97695. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  97696. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  97697. * mesh.visibility * alphaTexture.a
  97698. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  97699. */
  97700. enableSoftTransparentShadow: boolean;
  97701. protected _shadowMap: Nullable<RenderTargetTexture>;
  97702. protected _shadowMap2: Nullable<RenderTargetTexture>;
  97703. /**
  97704. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97705. * @returns The render target texture if present otherwise, null
  97706. */
  97707. getShadowMap(): Nullable<RenderTargetTexture>;
  97708. /**
  97709. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  97710. * @returns The render target texture if the shadow map is present otherwise, null
  97711. */
  97712. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  97713. /**
  97714. * Gets the class name of that object
  97715. * @returns "ShadowGenerator"
  97716. */
  97717. getClassName(): string;
  97718. /**
  97719. * Helper function to add a mesh and its descendants to the list of shadow casters.
  97720. * @param mesh Mesh to add
  97721. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  97722. * @returns the Shadow Generator itself
  97723. */
  97724. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  97725. /**
  97726. * Helper function to remove a mesh and its descendants from the list of shadow casters
  97727. * @param mesh Mesh to remove
  97728. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  97729. * @returns the Shadow Generator itself
  97730. */
  97731. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  97732. /**
  97733. * Controls the extent to which the shadows fade out at the edge of the frustum
  97734. */
  97735. frustumEdgeFalloff: number;
  97736. protected _light: IShadowLight;
  97737. /**
  97738. * Returns the associated light object.
  97739. * @returns the light generating the shadow
  97740. */
  97741. getLight(): IShadowLight;
  97742. /**
  97743. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  97744. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  97745. * It might on the other hand introduce peter panning.
  97746. */
  97747. forceBackFacesOnly: boolean;
  97748. protected _scene: Scene;
  97749. protected _lightDirection: Vector3;
  97750. protected _effect: Effect;
  97751. protected _viewMatrix: Matrix;
  97752. protected _projectionMatrix: Matrix;
  97753. protected _transformMatrix: Matrix;
  97754. protected _cachedPosition: Vector3;
  97755. protected _cachedDirection: Vector3;
  97756. protected _cachedDefines: string;
  97757. protected _currentRenderID: number;
  97758. protected _boxBlurPostprocess: Nullable<PostProcess>;
  97759. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  97760. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  97761. protected _blurPostProcesses: PostProcess[];
  97762. protected _mapSize: number;
  97763. protected _currentFaceIndex: number;
  97764. protected _currentFaceIndexCache: number;
  97765. protected _textureType: number;
  97766. protected _defaultTextureMatrix: Matrix;
  97767. protected _storedUniqueId: Nullable<number>;
  97768. /** @hidden */
  97769. static _SceneComponentInitialization: (scene: Scene) => void;
  97770. /**
  97771. * Creates a ShadowGenerator object.
  97772. * A ShadowGenerator is the required tool to use the shadows.
  97773. * Each light casting shadows needs to use its own ShadowGenerator.
  97774. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  97775. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  97776. * @param light The light object generating the shadows.
  97777. * @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.
  97778. */
  97779. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  97780. protected _initializeGenerator(): void;
  97781. protected _createTargetRenderTexture(): void;
  97782. protected _initializeShadowMap(): void;
  97783. protected _initializeBlurRTTAndPostProcesses(): void;
  97784. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  97785. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  97786. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  97787. protected _applyFilterValues(): void;
  97788. /**
  97789. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97790. * @param onCompiled Callback triggered at the and of the effects compilation
  97791. * @param options Sets of optional options forcing the compilation with different modes
  97792. */
  97793. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97794. useInstances: boolean;
  97795. }>): void;
  97796. /**
  97797. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97798. * @param options Sets of optional options forcing the compilation with different modes
  97799. * @returns A promise that resolves when the compilation completes
  97800. */
  97801. forceCompilationAsync(options?: Partial<{
  97802. useInstances: boolean;
  97803. }>): Promise<void>;
  97804. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  97805. private _prepareShadowDefines;
  97806. /**
  97807. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97808. * @param subMesh The submesh we want to render in the shadow map
  97809. * @param useInstances Defines wether will draw in the map using instances
  97810. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97811. * @returns true if ready otherwise, false
  97812. */
  97813. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97814. /**
  97815. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97816. * @param defines Defines of the material we want to update
  97817. * @param lightIndex Index of the light in the enabled light list of the material
  97818. */
  97819. prepareDefines(defines: any, lightIndex: number): void;
  97820. /**
  97821. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97822. * defined in the generator but impacting the effect).
  97823. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97824. * @param effect The effect we are binfing the information for
  97825. */
  97826. bindShadowLight(lightIndex: string, effect: Effect): void;
  97827. /**
  97828. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97829. * (eq to shadow prjection matrix * light transform matrix)
  97830. * @returns The transform matrix used to create the shadow map
  97831. */
  97832. getTransformMatrix(): Matrix;
  97833. /**
  97834. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97835. * Cube and 2D textures for instance.
  97836. */
  97837. recreateShadowMap(): void;
  97838. protected _disposeBlurPostProcesses(): void;
  97839. protected _disposeRTTandPostProcesses(): void;
  97840. /**
  97841. * Disposes the ShadowGenerator.
  97842. * Returns nothing.
  97843. */
  97844. dispose(): void;
  97845. /**
  97846. * Serializes the shadow generator setup to a json object.
  97847. * @returns The serialized JSON object
  97848. */
  97849. serialize(): any;
  97850. /**
  97851. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  97852. * @param parsedShadowGenerator The JSON object to parse
  97853. * @param scene The scene to create the shadow map for
  97854. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  97855. * @returns The parsed shadow generator
  97856. */
  97857. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  97858. }
  97859. }
  97860. declare module BABYLON {
  97861. /**
  97862. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  97863. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  97864. * 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.
  97865. */
  97866. export abstract class Light extends Node {
  97867. /**
  97868. * Falloff Default: light is falling off following the material specification:
  97869. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  97870. */
  97871. static readonly FALLOFF_DEFAULT: number;
  97872. /**
  97873. * Falloff Physical: light is falling off following the inverse squared distance law.
  97874. */
  97875. static readonly FALLOFF_PHYSICAL: number;
  97876. /**
  97877. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  97878. * to enhance interoperability with other engines.
  97879. */
  97880. static readonly FALLOFF_GLTF: number;
  97881. /**
  97882. * Falloff Standard: light is falling off like in the standard material
  97883. * to enhance interoperability with other materials.
  97884. */
  97885. static readonly FALLOFF_STANDARD: number;
  97886. /**
  97887. * If every light affecting the material is in this lightmapMode,
  97888. * material.lightmapTexture adds or multiplies
  97889. * (depends on material.useLightmapAsShadowmap)
  97890. * after every other light calculations.
  97891. */
  97892. static readonly LIGHTMAP_DEFAULT: number;
  97893. /**
  97894. * material.lightmapTexture as only diffuse lighting from this light
  97895. * adds only specular lighting from this light
  97896. * adds dynamic shadows
  97897. */
  97898. static readonly LIGHTMAP_SPECULAR: number;
  97899. /**
  97900. * material.lightmapTexture as only lighting
  97901. * no light calculation from this light
  97902. * only adds dynamic shadows from this light
  97903. */
  97904. static readonly LIGHTMAP_SHADOWSONLY: number;
  97905. /**
  97906. * Each light type uses the default quantity according to its type:
  97907. * point/spot lights use luminous intensity
  97908. * directional lights use illuminance
  97909. */
  97910. static readonly INTENSITYMODE_AUTOMATIC: number;
  97911. /**
  97912. * lumen (lm)
  97913. */
  97914. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  97915. /**
  97916. * candela (lm/sr)
  97917. */
  97918. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  97919. /**
  97920. * lux (lm/m^2)
  97921. */
  97922. static readonly INTENSITYMODE_ILLUMINANCE: number;
  97923. /**
  97924. * nit (cd/m^2)
  97925. */
  97926. static readonly INTENSITYMODE_LUMINANCE: number;
  97927. /**
  97928. * Light type const id of the point light.
  97929. */
  97930. static readonly LIGHTTYPEID_POINTLIGHT: number;
  97931. /**
  97932. * Light type const id of the directional light.
  97933. */
  97934. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  97935. /**
  97936. * Light type const id of the spot light.
  97937. */
  97938. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  97939. /**
  97940. * Light type const id of the hemispheric light.
  97941. */
  97942. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  97943. /**
  97944. * Diffuse gives the basic color to an object.
  97945. */
  97946. diffuse: Color3;
  97947. /**
  97948. * Specular produces a highlight color on an object.
  97949. * Note: This is note affecting PBR materials.
  97950. */
  97951. specular: Color3;
  97952. /**
  97953. * Defines the falloff type for this light. This lets overrriding how punctual light are
  97954. * falling off base on range or angle.
  97955. * This can be set to any values in Light.FALLOFF_x.
  97956. *
  97957. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  97958. * other types of materials.
  97959. */
  97960. falloffType: number;
  97961. /**
  97962. * Strength of the light.
  97963. * Note: By default it is define in the framework own unit.
  97964. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  97965. */
  97966. intensity: number;
  97967. private _range;
  97968. protected _inverseSquaredRange: number;
  97969. /**
  97970. * Defines how far from the source the light is impacting in scene units.
  97971. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  97972. */
  97973. get range(): number;
  97974. /**
  97975. * Defines how far from the source the light is impacting in scene units.
  97976. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  97977. */
  97978. set range(value: number);
  97979. /**
  97980. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  97981. * of light.
  97982. */
  97983. private _photometricScale;
  97984. private _intensityMode;
  97985. /**
  97986. * Gets the photometric scale used to interpret the intensity.
  97987. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  97988. */
  97989. get intensityMode(): number;
  97990. /**
  97991. * Sets the photometric scale used to interpret the intensity.
  97992. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  97993. */
  97994. set intensityMode(value: number);
  97995. private _radius;
  97996. /**
  97997. * Gets the light radius used by PBR Materials to simulate soft area lights.
  97998. */
  97999. get radius(): number;
  98000. /**
  98001. * sets the light radius used by PBR Materials to simulate soft area lights.
  98002. */
  98003. set radius(value: number);
  98004. private _renderPriority;
  98005. /**
  98006. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98007. * exceeding the number allowed of the materials.
  98008. */
  98009. renderPriority: number;
  98010. private _shadowEnabled;
  98011. /**
  98012. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98013. * the current shadow generator.
  98014. */
  98015. get shadowEnabled(): boolean;
  98016. /**
  98017. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98018. * the current shadow generator.
  98019. */
  98020. set shadowEnabled(value: boolean);
  98021. private _includedOnlyMeshes;
  98022. /**
  98023. * Gets the only meshes impacted by this light.
  98024. */
  98025. get includedOnlyMeshes(): AbstractMesh[];
  98026. /**
  98027. * Sets the only meshes impacted by this light.
  98028. */
  98029. set includedOnlyMeshes(value: AbstractMesh[]);
  98030. private _excludedMeshes;
  98031. /**
  98032. * Gets the meshes not impacted by this light.
  98033. */
  98034. get excludedMeshes(): AbstractMesh[];
  98035. /**
  98036. * Sets the meshes not impacted by this light.
  98037. */
  98038. set excludedMeshes(value: AbstractMesh[]);
  98039. private _excludeWithLayerMask;
  98040. /**
  98041. * Gets the layer id use to find what meshes are not impacted by the light.
  98042. * Inactive if 0
  98043. */
  98044. get excludeWithLayerMask(): number;
  98045. /**
  98046. * Sets the layer id use to find what meshes are not impacted by the light.
  98047. * Inactive if 0
  98048. */
  98049. set excludeWithLayerMask(value: number);
  98050. private _includeOnlyWithLayerMask;
  98051. /**
  98052. * Gets the layer id use to find what meshes are impacted by the light.
  98053. * Inactive if 0
  98054. */
  98055. get includeOnlyWithLayerMask(): number;
  98056. /**
  98057. * Sets the layer id use to find what meshes are impacted by the light.
  98058. * Inactive if 0
  98059. */
  98060. set includeOnlyWithLayerMask(value: number);
  98061. private _lightmapMode;
  98062. /**
  98063. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98064. */
  98065. get lightmapMode(): number;
  98066. /**
  98067. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98068. */
  98069. set lightmapMode(value: number);
  98070. /**
  98071. * Shadow generator associted to the light.
  98072. * @hidden Internal use only.
  98073. */
  98074. _shadowGenerator: Nullable<IShadowGenerator>;
  98075. /**
  98076. * @hidden Internal use only.
  98077. */
  98078. _excludedMeshesIds: string[];
  98079. /**
  98080. * @hidden Internal use only.
  98081. */
  98082. _includedOnlyMeshesIds: string[];
  98083. /**
  98084. * The current light unifom buffer.
  98085. * @hidden Internal use only.
  98086. */
  98087. _uniformBuffer: UniformBuffer;
  98088. /** @hidden */
  98089. _renderId: number;
  98090. /**
  98091. * Creates a Light object in the scene.
  98092. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98093. * @param name The firendly name of the light
  98094. * @param scene The scene the light belongs too
  98095. */
  98096. constructor(name: string, scene: Scene);
  98097. protected abstract _buildUniformLayout(): void;
  98098. /**
  98099. * Sets the passed Effect "effect" with the Light information.
  98100. * @param effect The effect to update
  98101. * @param lightIndex The index of the light in the effect to update
  98102. * @returns The light
  98103. */
  98104. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  98105. /**
  98106. * Sets the passed Effect "effect" with the Light textures.
  98107. * @param effect The effect to update
  98108. * @param lightIndex The index of the light in the effect to update
  98109. * @returns The light
  98110. */
  98111. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  98112. /**
  98113. * Binds the lights information from the scene to the effect for the given mesh.
  98114. * @param lightIndex Light index
  98115. * @param scene The scene where the light belongs to
  98116. * @param effect The effect we are binding the data to
  98117. * @param useSpecular Defines if specular is supported
  98118. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98119. */
  98120. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98121. /**
  98122. * Sets the passed Effect "effect" with the Light information.
  98123. * @param effect The effect to update
  98124. * @param lightDataUniformName The uniform used to store light data (position or direction)
  98125. * @returns The light
  98126. */
  98127. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  98128. /**
  98129. * Returns the string "Light".
  98130. * @returns the class name
  98131. */
  98132. getClassName(): string;
  98133. /** @hidden */
  98134. readonly _isLight: boolean;
  98135. /**
  98136. * Converts the light information to a readable string for debug purpose.
  98137. * @param fullDetails Supports for multiple levels of logging within scene loading
  98138. * @returns the human readable light info
  98139. */
  98140. toString(fullDetails?: boolean): string;
  98141. /** @hidden */
  98142. protected _syncParentEnabledState(): void;
  98143. /**
  98144. * Set the enabled state of this node.
  98145. * @param value - the new enabled state
  98146. */
  98147. setEnabled(value: boolean): void;
  98148. /**
  98149. * Returns the Light associated shadow generator if any.
  98150. * @return the associated shadow generator.
  98151. */
  98152. getShadowGenerator(): Nullable<IShadowGenerator>;
  98153. /**
  98154. * Returns a Vector3, the absolute light position in the World.
  98155. * @returns the world space position of the light
  98156. */
  98157. getAbsolutePosition(): Vector3;
  98158. /**
  98159. * Specifies if the light will affect the passed mesh.
  98160. * @param mesh The mesh to test against the light
  98161. * @return true the mesh is affected otherwise, false.
  98162. */
  98163. canAffectMesh(mesh: AbstractMesh): boolean;
  98164. /**
  98165. * Sort function to order lights for rendering.
  98166. * @param a First Light object to compare to second.
  98167. * @param b Second Light object to compare first.
  98168. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  98169. */
  98170. static CompareLightsPriority(a: Light, b: Light): number;
  98171. /**
  98172. * Releases resources associated with this node.
  98173. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98174. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98175. */
  98176. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98177. /**
  98178. * Returns the light type ID (integer).
  98179. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98180. */
  98181. getTypeID(): number;
  98182. /**
  98183. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  98184. * @returns the scaled intensity in intensity mode unit
  98185. */
  98186. getScaledIntensity(): number;
  98187. /**
  98188. * Returns a new Light object, named "name", from the current one.
  98189. * @param name The name of the cloned light
  98190. * @param newParent The parent of this light, if it has one
  98191. * @returns the new created light
  98192. */
  98193. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  98194. /**
  98195. * Serializes the current light into a Serialization object.
  98196. * @returns the serialized object.
  98197. */
  98198. serialize(): any;
  98199. /**
  98200. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  98201. * This new light is named "name" and added to the passed scene.
  98202. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  98203. * @param name The friendly name of the light
  98204. * @param scene The scene the new light will belong to
  98205. * @returns the constructor function
  98206. */
  98207. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  98208. /**
  98209. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  98210. * @param parsedLight The JSON representation of the light
  98211. * @param scene The scene to create the parsed light in
  98212. * @returns the created light after parsing
  98213. */
  98214. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  98215. private _hookArrayForExcluded;
  98216. private _hookArrayForIncludedOnly;
  98217. private _resyncMeshes;
  98218. /**
  98219. * Forces the meshes to update their light related information in their rendering used effects
  98220. * @hidden Internal Use Only
  98221. */
  98222. _markMeshesAsLightDirty(): void;
  98223. /**
  98224. * Recomputes the cached photometric scale if needed.
  98225. */
  98226. private _computePhotometricScale;
  98227. /**
  98228. * Returns the Photometric Scale according to the light type and intensity mode.
  98229. */
  98230. private _getPhotometricScale;
  98231. /**
  98232. * Reorder the light in the scene according to their defined priority.
  98233. * @hidden Internal Use Only
  98234. */
  98235. _reorderLightsInScene(): void;
  98236. /**
  98237. * Prepares the list of defines specific to the light type.
  98238. * @param defines the list of defines
  98239. * @param lightIndex defines the index of the light for the effect
  98240. */
  98241. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98242. }
  98243. }
  98244. declare module BABYLON {
  98245. /**
  98246. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  98247. * This is the base of the follow, arc rotate cameras and Free camera
  98248. * @see https://doc.babylonjs.com/features/cameras
  98249. */
  98250. export class TargetCamera extends Camera {
  98251. private static _RigCamTransformMatrix;
  98252. private static _TargetTransformMatrix;
  98253. private static _TargetFocalPoint;
  98254. private _tmpUpVector;
  98255. private _tmpTargetVector;
  98256. /**
  98257. * Define the current direction the camera is moving to
  98258. */
  98259. cameraDirection: Vector3;
  98260. /**
  98261. * Define the current rotation the camera is rotating to
  98262. */
  98263. cameraRotation: Vector2;
  98264. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  98265. ignoreParentScaling: boolean;
  98266. /**
  98267. * When set, the up vector of the camera will be updated by the rotation of the camera
  98268. */
  98269. updateUpVectorFromRotation: boolean;
  98270. private _tmpQuaternion;
  98271. /**
  98272. * Define the current rotation of the camera
  98273. */
  98274. rotation: Vector3;
  98275. /**
  98276. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  98277. */
  98278. rotationQuaternion: Quaternion;
  98279. /**
  98280. * Define the current speed of the camera
  98281. */
  98282. speed: number;
  98283. /**
  98284. * Add constraint to the camera to prevent it to move freely in all directions and
  98285. * around all axis.
  98286. */
  98287. noRotationConstraint: boolean;
  98288. /**
  98289. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  98290. * panning
  98291. */
  98292. invertRotation: boolean;
  98293. /**
  98294. * Speed multiplier for inverse camera panning
  98295. */
  98296. inverseRotationSpeed: number;
  98297. /**
  98298. * Define the current target of the camera as an object or a position.
  98299. */
  98300. lockedTarget: any;
  98301. /** @hidden */
  98302. _currentTarget: Vector3;
  98303. /** @hidden */
  98304. _initialFocalDistance: number;
  98305. /** @hidden */
  98306. _viewMatrix: Matrix;
  98307. /** @hidden */
  98308. _camMatrix: Matrix;
  98309. /** @hidden */
  98310. _cameraTransformMatrix: Matrix;
  98311. /** @hidden */
  98312. _cameraRotationMatrix: Matrix;
  98313. /** @hidden */
  98314. _referencePoint: Vector3;
  98315. /** @hidden */
  98316. _transformedReferencePoint: Vector3;
  98317. /** @hidden */
  98318. _reset: () => void;
  98319. private _defaultUp;
  98320. /**
  98321. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  98322. * This is the base of the follow, arc rotate cameras and Free camera
  98323. * @see https://doc.babylonjs.com/features/cameras
  98324. * @param name Defines the name of the camera in the scene
  98325. * @param position Defines the start position of the camera in the scene
  98326. * @param scene Defines the scene the camera belongs to
  98327. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98328. */
  98329. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98330. /**
  98331. * Gets the position in front of the camera at a given distance.
  98332. * @param distance The distance from the camera we want the position to be
  98333. * @returns the position
  98334. */
  98335. getFrontPosition(distance: number): Vector3;
  98336. /** @hidden */
  98337. _getLockedTargetPosition(): Nullable<Vector3>;
  98338. private _storedPosition;
  98339. private _storedRotation;
  98340. private _storedRotationQuaternion;
  98341. /**
  98342. * Store current camera state of the camera (fov, position, rotation, etc..)
  98343. * @returns the camera
  98344. */
  98345. storeState(): Camera;
  98346. /**
  98347. * Restored camera state. You must call storeState() first
  98348. * @returns whether it was successful or not
  98349. * @hidden
  98350. */
  98351. _restoreStateValues(): boolean;
  98352. /** @hidden */
  98353. _initCache(): void;
  98354. /** @hidden */
  98355. _updateCache(ignoreParentClass?: boolean): void;
  98356. /** @hidden */
  98357. _isSynchronizedViewMatrix(): boolean;
  98358. /** @hidden */
  98359. _computeLocalCameraSpeed(): number;
  98360. /**
  98361. * Defines the target the camera should look at.
  98362. * @param target Defines the new target as a Vector or a mesh
  98363. */
  98364. setTarget(target: Vector3): void;
  98365. /**
  98366. * Defines the target point of the camera.
  98367. * The camera looks towards it form the radius distance.
  98368. */
  98369. get target(): Vector3;
  98370. set target(value: Vector3);
  98371. /**
  98372. * Return the current target position of the camera. This value is expressed in local space.
  98373. * @returns the target position
  98374. */
  98375. getTarget(): Vector3;
  98376. /** @hidden */
  98377. _decideIfNeedsToMove(): boolean;
  98378. /** @hidden */
  98379. _updatePosition(): void;
  98380. /** @hidden */
  98381. _checkInputs(): void;
  98382. protected _updateCameraRotationMatrix(): void;
  98383. /**
  98384. * 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)
  98385. * @returns the current camera
  98386. */
  98387. private _rotateUpVectorWithCameraRotationMatrix;
  98388. private _cachedRotationZ;
  98389. private _cachedQuaternionRotationZ;
  98390. /** @hidden */
  98391. _getViewMatrix(): Matrix;
  98392. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  98393. /**
  98394. * @hidden
  98395. */
  98396. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98397. /**
  98398. * @hidden
  98399. */
  98400. _updateRigCameras(): void;
  98401. private _getRigCamPositionAndTarget;
  98402. /**
  98403. * Gets the current object class name.
  98404. * @return the class name
  98405. */
  98406. getClassName(): string;
  98407. }
  98408. }
  98409. declare module BABYLON {
  98410. /**
  98411. * Gather the list of keyboard event types as constants.
  98412. */
  98413. export class KeyboardEventTypes {
  98414. /**
  98415. * The keydown event is fired when a key becomes active (pressed).
  98416. */
  98417. static readonly KEYDOWN: number;
  98418. /**
  98419. * The keyup event is fired when a key has been released.
  98420. */
  98421. static readonly KEYUP: number;
  98422. }
  98423. /**
  98424. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98425. */
  98426. export class KeyboardInfo {
  98427. /**
  98428. * Defines the type of event (KeyboardEventTypes)
  98429. */
  98430. type: number;
  98431. /**
  98432. * Defines the related dom event
  98433. */
  98434. event: KeyboardEvent;
  98435. /**
  98436. * Instantiates a new keyboard info.
  98437. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98438. * @param type Defines the type of event (KeyboardEventTypes)
  98439. * @param event Defines the related dom event
  98440. */
  98441. constructor(
  98442. /**
  98443. * Defines the type of event (KeyboardEventTypes)
  98444. */
  98445. type: number,
  98446. /**
  98447. * Defines the related dom event
  98448. */
  98449. event: KeyboardEvent);
  98450. }
  98451. /**
  98452. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98453. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  98454. */
  98455. export class KeyboardInfoPre extends KeyboardInfo {
  98456. /**
  98457. * Defines the type of event (KeyboardEventTypes)
  98458. */
  98459. type: number;
  98460. /**
  98461. * Defines the related dom event
  98462. */
  98463. event: KeyboardEvent;
  98464. /**
  98465. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  98466. */
  98467. skipOnPointerObservable: boolean;
  98468. /**
  98469. * Instantiates a new keyboard pre info.
  98470. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98471. * @param type Defines the type of event (KeyboardEventTypes)
  98472. * @param event Defines the related dom event
  98473. */
  98474. constructor(
  98475. /**
  98476. * Defines the type of event (KeyboardEventTypes)
  98477. */
  98478. type: number,
  98479. /**
  98480. * Defines the related dom event
  98481. */
  98482. event: KeyboardEvent);
  98483. }
  98484. }
  98485. declare module BABYLON {
  98486. /**
  98487. * Manage the keyboard inputs to control the movement of a free camera.
  98488. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98489. */
  98490. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  98491. /**
  98492. * Defines the camera the input is attached to.
  98493. */
  98494. camera: FreeCamera;
  98495. /**
  98496. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98497. */
  98498. keysUp: number[];
  98499. /**
  98500. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98501. */
  98502. keysUpward: number[];
  98503. /**
  98504. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98505. */
  98506. keysDown: number[];
  98507. /**
  98508. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98509. */
  98510. keysDownward: number[];
  98511. /**
  98512. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98513. */
  98514. keysLeft: number[];
  98515. /**
  98516. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98517. */
  98518. keysRight: number[];
  98519. private _keys;
  98520. private _onCanvasBlurObserver;
  98521. private _onKeyboardObserver;
  98522. private _engine;
  98523. private _scene;
  98524. /**
  98525. * Attach the input controls to a specific dom element to get the input from.
  98526. * @param element Defines the element the controls should be listened from
  98527. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98528. */
  98529. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98530. /**
  98531. * Detach the current controls from the specified dom element.
  98532. * @param element Defines the element to stop listening the inputs from
  98533. */
  98534. detachControl(element: Nullable<HTMLElement>): void;
  98535. /**
  98536. * Update the current camera state depending on the inputs that have been used this frame.
  98537. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98538. */
  98539. checkInputs(): void;
  98540. /**
  98541. * Gets the class name of the current intput.
  98542. * @returns the class name
  98543. */
  98544. getClassName(): string;
  98545. /** @hidden */
  98546. _onLostFocus(): void;
  98547. /**
  98548. * Get the friendly name associated with the input class.
  98549. * @returns the input friendly name
  98550. */
  98551. getSimpleName(): string;
  98552. }
  98553. }
  98554. declare module BABYLON {
  98555. /**
  98556. * Gather the list of pointer event types as constants.
  98557. */
  98558. export class PointerEventTypes {
  98559. /**
  98560. * 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.
  98561. */
  98562. static readonly POINTERDOWN: number;
  98563. /**
  98564. * The pointerup event is fired when a pointer is no longer active.
  98565. */
  98566. static readonly POINTERUP: number;
  98567. /**
  98568. * The pointermove event is fired when a pointer changes coordinates.
  98569. */
  98570. static readonly POINTERMOVE: number;
  98571. /**
  98572. * The pointerwheel event is fired when a mouse wheel has been rotated.
  98573. */
  98574. static readonly POINTERWHEEL: number;
  98575. /**
  98576. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  98577. */
  98578. static readonly POINTERPICK: number;
  98579. /**
  98580. * The pointertap event is fired when a the object has been touched and released without drag.
  98581. */
  98582. static readonly POINTERTAP: number;
  98583. /**
  98584. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  98585. */
  98586. static readonly POINTERDOUBLETAP: number;
  98587. }
  98588. /**
  98589. * Base class of pointer info types.
  98590. */
  98591. export class PointerInfoBase {
  98592. /**
  98593. * Defines the type of event (PointerEventTypes)
  98594. */
  98595. type: number;
  98596. /**
  98597. * Defines the related dom event
  98598. */
  98599. event: PointerEvent | MouseWheelEvent;
  98600. /**
  98601. * Instantiates the base class of pointers info.
  98602. * @param type Defines the type of event (PointerEventTypes)
  98603. * @param event Defines the related dom event
  98604. */
  98605. constructor(
  98606. /**
  98607. * Defines the type of event (PointerEventTypes)
  98608. */
  98609. type: number,
  98610. /**
  98611. * Defines the related dom event
  98612. */
  98613. event: PointerEvent | MouseWheelEvent);
  98614. }
  98615. /**
  98616. * This class is used to store pointer related info for the onPrePointerObservable event.
  98617. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  98618. */
  98619. export class PointerInfoPre extends PointerInfoBase {
  98620. /**
  98621. * Ray from a pointer if availible (eg. 6dof controller)
  98622. */
  98623. ray: Nullable<Ray>;
  98624. /**
  98625. * Defines the local position of the pointer on the canvas.
  98626. */
  98627. localPosition: Vector2;
  98628. /**
  98629. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  98630. */
  98631. skipOnPointerObservable: boolean;
  98632. /**
  98633. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  98634. * @param type Defines the type of event (PointerEventTypes)
  98635. * @param event Defines the related dom event
  98636. * @param localX Defines the local x coordinates of the pointer when the event occured
  98637. * @param localY Defines the local y coordinates of the pointer when the event occured
  98638. */
  98639. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  98640. }
  98641. /**
  98642. * This type contains all the data related to a pointer event in Babylon.js.
  98643. * 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.
  98644. */
  98645. export class PointerInfo extends PointerInfoBase {
  98646. /**
  98647. * Defines the picking info associated to the info (if any)\
  98648. */
  98649. pickInfo: Nullable<PickingInfo>;
  98650. /**
  98651. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  98652. * @param type Defines the type of event (PointerEventTypes)
  98653. * @param event Defines the related dom event
  98654. * @param pickInfo Defines the picking info associated to the info (if any)\
  98655. */
  98656. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  98657. /**
  98658. * Defines the picking info associated to the info (if any)\
  98659. */
  98660. pickInfo: Nullable<PickingInfo>);
  98661. }
  98662. /**
  98663. * Data relating to a touch event on the screen.
  98664. */
  98665. export interface PointerTouch {
  98666. /**
  98667. * X coordinate of touch.
  98668. */
  98669. x: number;
  98670. /**
  98671. * Y coordinate of touch.
  98672. */
  98673. y: number;
  98674. /**
  98675. * Id of touch. Unique for each finger.
  98676. */
  98677. pointerId: number;
  98678. /**
  98679. * Event type passed from DOM.
  98680. */
  98681. type: any;
  98682. }
  98683. }
  98684. declare module BABYLON {
  98685. /**
  98686. * Manage the mouse inputs to control the movement of a free camera.
  98687. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98688. */
  98689. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  98690. /**
  98691. * Define if touch is enabled in the mouse input
  98692. */
  98693. touchEnabled: boolean;
  98694. /**
  98695. * Defines the camera the input is attached to.
  98696. */
  98697. camera: FreeCamera;
  98698. /**
  98699. * Defines the buttons associated with the input to handle camera move.
  98700. */
  98701. buttons: number[];
  98702. /**
  98703. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  98704. */
  98705. angularSensibility: number;
  98706. private _pointerInput;
  98707. private _onMouseMove;
  98708. private _observer;
  98709. private previousPosition;
  98710. /**
  98711. * Observable for when a pointer move event occurs containing the move offset
  98712. */
  98713. onPointerMovedObservable: Observable<{
  98714. offsetX: number;
  98715. offsetY: number;
  98716. }>;
  98717. /**
  98718. * @hidden
  98719. * If the camera should be rotated automatically based on pointer movement
  98720. */
  98721. _allowCameraRotation: boolean;
  98722. /**
  98723. * Manage the mouse inputs to control the movement of a free camera.
  98724. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98725. * @param touchEnabled Defines if touch is enabled or not
  98726. */
  98727. constructor(
  98728. /**
  98729. * Define if touch is enabled in the mouse input
  98730. */
  98731. touchEnabled?: boolean);
  98732. /**
  98733. * Attach the input controls to a specific dom element to get the input from.
  98734. * @param element Defines the element the controls should be listened from
  98735. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98736. */
  98737. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98738. /**
  98739. * Called on JS contextmenu event.
  98740. * Override this method to provide functionality.
  98741. */
  98742. protected onContextMenu(evt: PointerEvent): void;
  98743. /**
  98744. * Detach the current controls from the specified dom element.
  98745. * @param element Defines the element to stop listening the inputs from
  98746. */
  98747. detachControl(element: Nullable<HTMLElement>): void;
  98748. /**
  98749. * Gets the class name of the current intput.
  98750. * @returns the class name
  98751. */
  98752. getClassName(): string;
  98753. /**
  98754. * Get the friendly name associated with the input class.
  98755. * @returns the input friendly name
  98756. */
  98757. getSimpleName(): string;
  98758. }
  98759. }
  98760. declare module BABYLON {
  98761. /**
  98762. * Manage the touch inputs to control the movement of a free camera.
  98763. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98764. */
  98765. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  98766. /**
  98767. * Define if mouse events can be treated as touch events
  98768. */
  98769. allowMouse: boolean;
  98770. /**
  98771. * Defines the camera the input is attached to.
  98772. */
  98773. camera: FreeCamera;
  98774. /**
  98775. * Defines the touch sensibility for rotation.
  98776. * The higher the faster.
  98777. */
  98778. touchAngularSensibility: number;
  98779. /**
  98780. * Defines the touch sensibility for move.
  98781. * The higher the faster.
  98782. */
  98783. touchMoveSensibility: number;
  98784. private _offsetX;
  98785. private _offsetY;
  98786. private _pointerPressed;
  98787. private _pointerInput;
  98788. private _observer;
  98789. private _onLostFocus;
  98790. /**
  98791. * Manage the touch inputs to control the movement of a free camera.
  98792. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98793. * @param allowMouse Defines if mouse events can be treated as touch events
  98794. */
  98795. constructor(
  98796. /**
  98797. * Define if mouse events can be treated as touch events
  98798. */
  98799. allowMouse?: boolean);
  98800. /**
  98801. * Attach the input controls to a specific dom element to get the input from.
  98802. * @param element Defines the element the controls should be listened from
  98803. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98804. */
  98805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98806. /**
  98807. * Detach the current controls from the specified dom element.
  98808. * @param element Defines the element to stop listening the inputs from
  98809. */
  98810. detachControl(element: Nullable<HTMLElement>): void;
  98811. /**
  98812. * Update the current camera state depending on the inputs that have been used this frame.
  98813. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98814. */
  98815. checkInputs(): void;
  98816. /**
  98817. * Gets the class name of the current intput.
  98818. * @returns the class name
  98819. */
  98820. getClassName(): string;
  98821. /**
  98822. * Get the friendly name associated with the input class.
  98823. * @returns the input friendly name
  98824. */
  98825. getSimpleName(): string;
  98826. }
  98827. }
  98828. declare module BABYLON {
  98829. /**
  98830. * Default Inputs manager for the FreeCamera.
  98831. * It groups all the default supported inputs for ease of use.
  98832. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98833. */
  98834. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  98835. /**
  98836. * @hidden
  98837. */
  98838. _mouseInput: Nullable<FreeCameraMouseInput>;
  98839. /**
  98840. * Instantiates a new FreeCameraInputsManager.
  98841. * @param camera Defines the camera the inputs belong to
  98842. */
  98843. constructor(camera: FreeCamera);
  98844. /**
  98845. * Add keyboard input support to the input manager.
  98846. * @returns the current input manager
  98847. */
  98848. addKeyboard(): FreeCameraInputsManager;
  98849. /**
  98850. * Add mouse input support to the input manager.
  98851. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  98852. * @returns the current input manager
  98853. */
  98854. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  98855. /**
  98856. * Removes the mouse input support from the manager
  98857. * @returns the current input manager
  98858. */
  98859. removeMouse(): FreeCameraInputsManager;
  98860. /**
  98861. * Add touch input support to the input manager.
  98862. * @returns the current input manager
  98863. */
  98864. addTouch(): FreeCameraInputsManager;
  98865. /**
  98866. * Remove all attached input methods from a camera
  98867. */
  98868. clear(): void;
  98869. }
  98870. }
  98871. declare module BABYLON {
  98872. /**
  98873. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98874. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  98875. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  98876. */
  98877. export class FreeCamera extends TargetCamera {
  98878. /**
  98879. * Define the collision ellipsoid of the camera.
  98880. * This is helpful to simulate a camera body like the player body around the camera
  98881. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98882. */
  98883. ellipsoid: Vector3;
  98884. /**
  98885. * Define an offset for the position of the ellipsoid around the camera.
  98886. * This can be helpful to determine the center of the body near the gravity center of the body
  98887. * instead of its head.
  98888. */
  98889. ellipsoidOffset: Vector3;
  98890. /**
  98891. * Enable or disable collisions of the camera with the rest of the scene objects.
  98892. */
  98893. checkCollisions: boolean;
  98894. /**
  98895. * Enable or disable gravity on the camera.
  98896. */
  98897. applyGravity: boolean;
  98898. /**
  98899. * Define the input manager associated to the camera.
  98900. */
  98901. inputs: FreeCameraInputsManager;
  98902. /**
  98903. * Gets the input sensibility for a mouse input. (default is 2000.0)
  98904. * Higher values reduce sensitivity.
  98905. */
  98906. get angularSensibility(): number;
  98907. /**
  98908. * Sets the input sensibility for a mouse input. (default is 2000.0)
  98909. * Higher values reduce sensitivity.
  98910. */
  98911. set angularSensibility(value: number);
  98912. /**
  98913. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98914. */
  98915. get keysUp(): number[];
  98916. set keysUp(value: number[]);
  98917. /**
  98918. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98919. */
  98920. get keysUpward(): number[];
  98921. set keysUpward(value: number[]);
  98922. /**
  98923. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98924. */
  98925. get keysDown(): number[];
  98926. set keysDown(value: number[]);
  98927. /**
  98928. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98929. */
  98930. get keysDownward(): number[];
  98931. set keysDownward(value: number[]);
  98932. /**
  98933. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98934. */
  98935. get keysLeft(): number[];
  98936. set keysLeft(value: number[]);
  98937. /**
  98938. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98939. */
  98940. get keysRight(): number[];
  98941. set keysRight(value: number[]);
  98942. /**
  98943. * Event raised when the camera collide with a mesh in the scene.
  98944. */
  98945. onCollide: (collidedMesh: AbstractMesh) => void;
  98946. private _collider;
  98947. private _needMoveForGravity;
  98948. private _oldPosition;
  98949. private _diffPosition;
  98950. private _newPosition;
  98951. /** @hidden */
  98952. _localDirection: Vector3;
  98953. /** @hidden */
  98954. _transformedDirection: Vector3;
  98955. /**
  98956. * Instantiates a Free Camera.
  98957. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98958. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  98959. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  98960. * @param name Define the name of the camera in the scene
  98961. * @param position Define the start position of the camera in the scene
  98962. * @param scene Define the scene the camera belongs to
  98963. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98964. */
  98965. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98966. /**
  98967. * Attached controls to the current camera.
  98968. * @param element Defines the element the controls should be listened from
  98969. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98970. */
  98971. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98972. /**
  98973. * Detach the current controls from the camera.
  98974. * The camera will stop reacting to inputs.
  98975. * @param element Defines the element to stop listening the inputs from
  98976. */
  98977. detachControl(element: HTMLElement): void;
  98978. private _collisionMask;
  98979. /**
  98980. * Define a collision mask to limit the list of object the camera can collide with
  98981. */
  98982. get collisionMask(): number;
  98983. set collisionMask(mask: number);
  98984. /** @hidden */
  98985. _collideWithWorld(displacement: Vector3): void;
  98986. private _onCollisionPositionChange;
  98987. /** @hidden */
  98988. _checkInputs(): void;
  98989. /** @hidden */
  98990. _decideIfNeedsToMove(): boolean;
  98991. /** @hidden */
  98992. _updatePosition(): void;
  98993. /**
  98994. * Destroy the camera and release the current resources hold by it.
  98995. */
  98996. dispose(): void;
  98997. /**
  98998. * Gets the current object class name.
  98999. * @return the class name
  99000. */
  99001. getClassName(): string;
  99002. }
  99003. }
  99004. declare module BABYLON {
  99005. /**
  99006. * Represents a gamepad control stick position
  99007. */
  99008. export class StickValues {
  99009. /**
  99010. * The x component of the control stick
  99011. */
  99012. x: number;
  99013. /**
  99014. * The y component of the control stick
  99015. */
  99016. y: number;
  99017. /**
  99018. * Initializes the gamepad x and y control stick values
  99019. * @param x The x component of the gamepad control stick value
  99020. * @param y The y component of the gamepad control stick value
  99021. */
  99022. constructor(
  99023. /**
  99024. * The x component of the control stick
  99025. */
  99026. x: number,
  99027. /**
  99028. * The y component of the control stick
  99029. */
  99030. y: number);
  99031. }
  99032. /**
  99033. * An interface which manages callbacks for gamepad button changes
  99034. */
  99035. export interface GamepadButtonChanges {
  99036. /**
  99037. * Called when a gamepad has been changed
  99038. */
  99039. changed: boolean;
  99040. /**
  99041. * Called when a gamepad press event has been triggered
  99042. */
  99043. pressChanged: boolean;
  99044. /**
  99045. * Called when a touch event has been triggered
  99046. */
  99047. touchChanged: boolean;
  99048. /**
  99049. * Called when a value has changed
  99050. */
  99051. valueChanged: boolean;
  99052. }
  99053. /**
  99054. * Represents a gamepad
  99055. */
  99056. export class Gamepad {
  99057. /**
  99058. * The id of the gamepad
  99059. */
  99060. id: string;
  99061. /**
  99062. * The index of the gamepad
  99063. */
  99064. index: number;
  99065. /**
  99066. * The browser gamepad
  99067. */
  99068. browserGamepad: any;
  99069. /**
  99070. * Specifies what type of gamepad this represents
  99071. */
  99072. type: number;
  99073. private _leftStick;
  99074. private _rightStick;
  99075. /** @hidden */
  99076. _isConnected: boolean;
  99077. private _leftStickAxisX;
  99078. private _leftStickAxisY;
  99079. private _rightStickAxisX;
  99080. private _rightStickAxisY;
  99081. /**
  99082. * Triggered when the left control stick has been changed
  99083. */
  99084. private _onleftstickchanged;
  99085. /**
  99086. * Triggered when the right control stick has been changed
  99087. */
  99088. private _onrightstickchanged;
  99089. /**
  99090. * Represents a gamepad controller
  99091. */
  99092. static GAMEPAD: number;
  99093. /**
  99094. * Represents a generic controller
  99095. */
  99096. static GENERIC: number;
  99097. /**
  99098. * Represents an XBox controller
  99099. */
  99100. static XBOX: number;
  99101. /**
  99102. * Represents a pose-enabled controller
  99103. */
  99104. static POSE_ENABLED: number;
  99105. /**
  99106. * Represents an Dual Shock controller
  99107. */
  99108. static DUALSHOCK: number;
  99109. /**
  99110. * Specifies whether the left control stick should be Y-inverted
  99111. */
  99112. protected _invertLeftStickY: boolean;
  99113. /**
  99114. * Specifies if the gamepad has been connected
  99115. */
  99116. get isConnected(): boolean;
  99117. /**
  99118. * Initializes the gamepad
  99119. * @param id The id of the gamepad
  99120. * @param index The index of the gamepad
  99121. * @param browserGamepad The browser gamepad
  99122. * @param leftStickX The x component of the left joystick
  99123. * @param leftStickY The y component of the left joystick
  99124. * @param rightStickX The x component of the right joystick
  99125. * @param rightStickY The y component of the right joystick
  99126. */
  99127. constructor(
  99128. /**
  99129. * The id of the gamepad
  99130. */
  99131. id: string,
  99132. /**
  99133. * The index of the gamepad
  99134. */
  99135. index: number,
  99136. /**
  99137. * The browser gamepad
  99138. */
  99139. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  99140. /**
  99141. * Callback triggered when the left joystick has changed
  99142. * @param callback
  99143. */
  99144. onleftstickchanged(callback: (values: StickValues) => void): void;
  99145. /**
  99146. * Callback triggered when the right joystick has changed
  99147. * @param callback
  99148. */
  99149. onrightstickchanged(callback: (values: StickValues) => void): void;
  99150. /**
  99151. * Gets the left joystick
  99152. */
  99153. get leftStick(): StickValues;
  99154. /**
  99155. * Sets the left joystick values
  99156. */
  99157. set leftStick(newValues: StickValues);
  99158. /**
  99159. * Gets the right joystick
  99160. */
  99161. get rightStick(): StickValues;
  99162. /**
  99163. * Sets the right joystick value
  99164. */
  99165. set rightStick(newValues: StickValues);
  99166. /**
  99167. * Updates the gamepad joystick positions
  99168. */
  99169. update(): void;
  99170. /**
  99171. * Disposes the gamepad
  99172. */
  99173. dispose(): void;
  99174. }
  99175. /**
  99176. * Represents a generic gamepad
  99177. */
  99178. export class GenericPad extends Gamepad {
  99179. private _buttons;
  99180. private _onbuttondown;
  99181. private _onbuttonup;
  99182. /**
  99183. * Observable triggered when a button has been pressed
  99184. */
  99185. onButtonDownObservable: Observable<number>;
  99186. /**
  99187. * Observable triggered when a button has been released
  99188. */
  99189. onButtonUpObservable: Observable<number>;
  99190. /**
  99191. * Callback triggered when a button has been pressed
  99192. * @param callback Called when a button has been pressed
  99193. */
  99194. onbuttondown(callback: (buttonPressed: number) => void): void;
  99195. /**
  99196. * Callback triggered when a button has been released
  99197. * @param callback Called when a button has been released
  99198. */
  99199. onbuttonup(callback: (buttonReleased: number) => void): void;
  99200. /**
  99201. * Initializes the generic gamepad
  99202. * @param id The id of the generic gamepad
  99203. * @param index The index of the generic gamepad
  99204. * @param browserGamepad The browser gamepad
  99205. */
  99206. constructor(id: string, index: number, browserGamepad: any);
  99207. private _setButtonValue;
  99208. /**
  99209. * Updates the generic gamepad
  99210. */
  99211. update(): void;
  99212. /**
  99213. * Disposes the generic gamepad
  99214. */
  99215. dispose(): void;
  99216. }
  99217. }
  99218. declare module BABYLON {
  99219. /**
  99220. * Defines the types of pose enabled controllers that are supported
  99221. */
  99222. export enum PoseEnabledControllerType {
  99223. /**
  99224. * HTC Vive
  99225. */
  99226. VIVE = 0,
  99227. /**
  99228. * Oculus Rift
  99229. */
  99230. OCULUS = 1,
  99231. /**
  99232. * Windows mixed reality
  99233. */
  99234. WINDOWS = 2,
  99235. /**
  99236. * Samsung gear VR
  99237. */
  99238. GEAR_VR = 3,
  99239. /**
  99240. * Google Daydream
  99241. */
  99242. DAYDREAM = 4,
  99243. /**
  99244. * Generic
  99245. */
  99246. GENERIC = 5
  99247. }
  99248. /**
  99249. * Defines the MutableGamepadButton interface for the state of a gamepad button
  99250. */
  99251. export interface MutableGamepadButton {
  99252. /**
  99253. * Value of the button/trigger
  99254. */
  99255. value: number;
  99256. /**
  99257. * If the button/trigger is currently touched
  99258. */
  99259. touched: boolean;
  99260. /**
  99261. * If the button/trigger is currently pressed
  99262. */
  99263. pressed: boolean;
  99264. }
  99265. /**
  99266. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  99267. * @hidden
  99268. */
  99269. export interface ExtendedGamepadButton extends GamepadButton {
  99270. /**
  99271. * If the button/trigger is currently pressed
  99272. */
  99273. readonly pressed: boolean;
  99274. /**
  99275. * If the button/trigger is currently touched
  99276. */
  99277. readonly touched: boolean;
  99278. /**
  99279. * Value of the button/trigger
  99280. */
  99281. readonly value: number;
  99282. }
  99283. /** @hidden */
  99284. export interface _GamePadFactory {
  99285. /**
  99286. * Returns whether or not the current gamepad can be created for this type of controller.
  99287. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99288. * @returns true if it can be created, otherwise false
  99289. */
  99290. canCreate(gamepadInfo: any): boolean;
  99291. /**
  99292. * Creates a new instance of the Gamepad.
  99293. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99294. * @returns the new gamepad instance
  99295. */
  99296. create(gamepadInfo: any): Gamepad;
  99297. }
  99298. /**
  99299. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99300. */
  99301. export class PoseEnabledControllerHelper {
  99302. /** @hidden */
  99303. static _ControllerFactories: _GamePadFactory[];
  99304. /** @hidden */
  99305. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  99306. /**
  99307. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99308. * @param vrGamepad the gamepad to initialized
  99309. * @returns a vr controller of the type the gamepad identified as
  99310. */
  99311. static InitiateController(vrGamepad: any): Gamepad;
  99312. }
  99313. /**
  99314. * Defines the PoseEnabledController object that contains state of a vr capable controller
  99315. */
  99316. export class PoseEnabledController extends Gamepad implements PoseControlled {
  99317. /**
  99318. * If the controller is used in a webXR session
  99319. */
  99320. isXR: boolean;
  99321. private _deviceRoomPosition;
  99322. private _deviceRoomRotationQuaternion;
  99323. /**
  99324. * The device position in babylon space
  99325. */
  99326. devicePosition: Vector3;
  99327. /**
  99328. * The device rotation in babylon space
  99329. */
  99330. deviceRotationQuaternion: Quaternion;
  99331. /**
  99332. * The scale factor of the device in babylon space
  99333. */
  99334. deviceScaleFactor: number;
  99335. /**
  99336. * (Likely devicePosition should be used instead) The device position in its room space
  99337. */
  99338. position: Vector3;
  99339. /**
  99340. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  99341. */
  99342. rotationQuaternion: Quaternion;
  99343. /**
  99344. * The type of controller (Eg. Windows mixed reality)
  99345. */
  99346. controllerType: PoseEnabledControllerType;
  99347. protected _calculatedPosition: Vector3;
  99348. private _calculatedRotation;
  99349. /**
  99350. * The raw pose from the device
  99351. */
  99352. rawPose: DevicePose;
  99353. private _trackPosition;
  99354. private _maxRotationDistFromHeadset;
  99355. private _draggedRoomRotation;
  99356. /**
  99357. * @hidden
  99358. */
  99359. _disableTrackPosition(fixedPosition: Vector3): void;
  99360. /**
  99361. * Internal, the mesh attached to the controller
  99362. * @hidden
  99363. */
  99364. _mesh: Nullable<AbstractMesh>;
  99365. private _poseControlledCamera;
  99366. private _leftHandSystemQuaternion;
  99367. /**
  99368. * Internal, matrix used to convert room space to babylon space
  99369. * @hidden
  99370. */
  99371. _deviceToWorld: Matrix;
  99372. /**
  99373. * Node to be used when casting a ray from the controller
  99374. * @hidden
  99375. */
  99376. _pointingPoseNode: Nullable<TransformNode>;
  99377. /**
  99378. * Name of the child mesh that can be used to cast a ray from the controller
  99379. */
  99380. static readonly POINTING_POSE: string;
  99381. /**
  99382. * Creates a new PoseEnabledController from a gamepad
  99383. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  99384. */
  99385. constructor(browserGamepad: any);
  99386. private _workingMatrix;
  99387. /**
  99388. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  99389. */
  99390. update(): void;
  99391. /**
  99392. * Updates only the pose device and mesh without doing any button event checking
  99393. */
  99394. protected _updatePoseAndMesh(): void;
  99395. /**
  99396. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  99397. * @param poseData raw pose fromthe device
  99398. */
  99399. updateFromDevice(poseData: DevicePose): void;
  99400. /**
  99401. * @hidden
  99402. */
  99403. _meshAttachedObservable: Observable<AbstractMesh>;
  99404. /**
  99405. * Attaches a mesh to the controller
  99406. * @param mesh the mesh to be attached
  99407. */
  99408. attachToMesh(mesh: AbstractMesh): void;
  99409. /**
  99410. * Attaches the controllers mesh to a camera
  99411. * @param camera the camera the mesh should be attached to
  99412. */
  99413. attachToPoseControlledCamera(camera: TargetCamera): void;
  99414. /**
  99415. * Disposes of the controller
  99416. */
  99417. dispose(): void;
  99418. /**
  99419. * The mesh that is attached to the controller
  99420. */
  99421. get mesh(): Nullable<AbstractMesh>;
  99422. /**
  99423. * Gets the ray of the controller in the direction the controller is pointing
  99424. * @param length the length the resulting ray should be
  99425. * @returns a ray in the direction the controller is pointing
  99426. */
  99427. getForwardRay(length?: number): Ray;
  99428. }
  99429. }
  99430. declare module BABYLON {
  99431. /**
  99432. * Defines the WebVRController object that represents controllers tracked in 3D space
  99433. */
  99434. export abstract class WebVRController extends PoseEnabledController {
  99435. /**
  99436. * Internal, the default controller model for the controller
  99437. */
  99438. protected _defaultModel: Nullable<AbstractMesh>;
  99439. /**
  99440. * Fired when the trigger state has changed
  99441. */
  99442. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99443. /**
  99444. * Fired when the main button state has changed
  99445. */
  99446. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99447. /**
  99448. * Fired when the secondary button state has changed
  99449. */
  99450. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99451. /**
  99452. * Fired when the pad state has changed
  99453. */
  99454. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  99455. /**
  99456. * Fired when controllers stick values have changed
  99457. */
  99458. onPadValuesChangedObservable: Observable<StickValues>;
  99459. /**
  99460. * Array of button availible on the controller
  99461. */
  99462. protected _buttons: Array<MutableGamepadButton>;
  99463. private _onButtonStateChange;
  99464. /**
  99465. * Fired when a controller button's state has changed
  99466. * @param callback the callback containing the button that was modified
  99467. */
  99468. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  99469. /**
  99470. * X and Y axis corresponding to the controllers joystick
  99471. */
  99472. pad: StickValues;
  99473. /**
  99474. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  99475. */
  99476. hand: string;
  99477. /**
  99478. * The default controller model for the controller
  99479. */
  99480. get defaultModel(): Nullable<AbstractMesh>;
  99481. /**
  99482. * Creates a new WebVRController from a gamepad
  99483. * @param vrGamepad the gamepad that the WebVRController should be created from
  99484. */
  99485. constructor(vrGamepad: any);
  99486. /**
  99487. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  99488. */
  99489. update(): void;
  99490. /**
  99491. * Function to be called when a button is modified
  99492. */
  99493. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99494. /**
  99495. * Loads a mesh and attaches it to the controller
  99496. * @param scene the scene the mesh should be added to
  99497. * @param meshLoaded callback for when the mesh has been loaded
  99498. */
  99499. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99500. private _setButtonValue;
  99501. private _changes;
  99502. private _checkChanges;
  99503. /**
  99504. * Disposes of th webVRCOntroller
  99505. */
  99506. dispose(): void;
  99507. }
  99508. }
  99509. declare module BABYLON {
  99510. /**
  99511. * The HemisphericLight simulates the ambient environment light,
  99512. * so the passed direction is the light reflection direction, not the incoming direction.
  99513. */
  99514. export class HemisphericLight extends Light {
  99515. /**
  99516. * The groundColor is the light in the opposite direction to the one specified during creation.
  99517. * 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.
  99518. */
  99519. groundColor: Color3;
  99520. /**
  99521. * The light reflection direction, not the incoming direction.
  99522. */
  99523. direction: Vector3;
  99524. /**
  99525. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  99526. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  99527. * The HemisphericLight can't cast shadows.
  99528. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99529. * @param name The friendly name of the light
  99530. * @param direction The direction of the light reflection
  99531. * @param scene The scene the light belongs to
  99532. */
  99533. constructor(name: string, direction: Vector3, scene: Scene);
  99534. protected _buildUniformLayout(): void;
  99535. /**
  99536. * Returns the string "HemisphericLight".
  99537. * @return The class name
  99538. */
  99539. getClassName(): string;
  99540. /**
  99541. * Sets the HemisphericLight direction towards the passed target (Vector3).
  99542. * Returns the updated direction.
  99543. * @param target The target the direction should point to
  99544. * @return The computed direction
  99545. */
  99546. setDirectionToTarget(target: Vector3): Vector3;
  99547. /**
  99548. * Returns the shadow generator associated to the light.
  99549. * @returns Always null for hemispheric lights because it does not support shadows.
  99550. */
  99551. getShadowGenerator(): Nullable<IShadowGenerator>;
  99552. /**
  99553. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  99554. * @param effect The effect to update
  99555. * @param lightIndex The index of the light in the effect to update
  99556. * @returns The hemispheric light
  99557. */
  99558. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  99559. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  99560. /**
  99561. * Computes the world matrix of the node
  99562. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  99563. * @param useWasUpdatedFlag defines a reserved property
  99564. * @returns the world matrix
  99565. */
  99566. computeWorldMatrix(): Matrix;
  99567. /**
  99568. * Returns the integer 3.
  99569. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99570. */
  99571. getTypeID(): number;
  99572. /**
  99573. * Prepares the list of defines specific to the light type.
  99574. * @param defines the list of defines
  99575. * @param lightIndex defines the index of the light for the effect
  99576. */
  99577. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99578. }
  99579. }
  99580. declare module BABYLON {
  99581. /** @hidden */
  99582. export var vrMultiviewToSingleviewPixelShader: {
  99583. name: string;
  99584. shader: string;
  99585. };
  99586. }
  99587. declare module BABYLON {
  99588. /**
  99589. * Renders to multiple views with a single draw call
  99590. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  99591. */
  99592. export class MultiviewRenderTarget extends RenderTargetTexture {
  99593. /**
  99594. * Creates a multiview render target
  99595. * @param scene scene used with the render target
  99596. * @param size the size of the render target (used for each view)
  99597. */
  99598. constructor(scene: Scene, size?: number | {
  99599. width: number;
  99600. height: number;
  99601. } | {
  99602. ratio: number;
  99603. });
  99604. /**
  99605. * @hidden
  99606. * @param faceIndex the face index, if its a cube texture
  99607. */
  99608. _bindFrameBuffer(faceIndex?: number): void;
  99609. /**
  99610. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  99611. * @returns the view count
  99612. */
  99613. getViewCount(): number;
  99614. }
  99615. }
  99616. declare module BABYLON {
  99617. interface Engine {
  99618. /**
  99619. * Creates a new multiview render target
  99620. * @param width defines the width of the texture
  99621. * @param height defines the height of the texture
  99622. * @returns the created multiview texture
  99623. */
  99624. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  99625. /**
  99626. * Binds a multiview framebuffer to be drawn to
  99627. * @param multiviewTexture texture to bind
  99628. */
  99629. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  99630. }
  99631. interface Camera {
  99632. /**
  99633. * @hidden
  99634. * 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)
  99635. */
  99636. _useMultiviewToSingleView: boolean;
  99637. /**
  99638. * @hidden
  99639. * 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)
  99640. */
  99641. _multiviewTexture: Nullable<RenderTargetTexture>;
  99642. /**
  99643. * @hidden
  99644. * ensures the multiview texture of the camera exists and has the specified width/height
  99645. * @param width height to set on the multiview texture
  99646. * @param height width to set on the multiview texture
  99647. */
  99648. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  99649. }
  99650. interface Scene {
  99651. /** @hidden */
  99652. _transformMatrixR: Matrix;
  99653. /** @hidden */
  99654. _multiviewSceneUbo: Nullable<UniformBuffer>;
  99655. /** @hidden */
  99656. _createMultiviewUbo(): void;
  99657. /** @hidden */
  99658. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  99659. /** @hidden */
  99660. _renderMultiviewToSingleView(camera: Camera): void;
  99661. }
  99662. }
  99663. declare module BABYLON {
  99664. /**
  99665. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  99666. * This will not be used for webXR as it supports displaying texture arrays directly
  99667. */
  99668. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  99669. /**
  99670. * Gets a string identifying the name of the class
  99671. * @returns "VRMultiviewToSingleviewPostProcess" string
  99672. */
  99673. getClassName(): string;
  99674. /**
  99675. * Initializes a VRMultiviewToSingleview
  99676. * @param name name of the post process
  99677. * @param camera camera to be applied to
  99678. * @param scaleFactor scaling factor to the size of the output texture
  99679. */
  99680. constructor(name: string, camera: Camera, scaleFactor: number);
  99681. }
  99682. }
  99683. declare module BABYLON {
  99684. /**
  99685. * Interface used to define additional presentation attributes
  99686. */
  99687. export interface IVRPresentationAttributes {
  99688. /**
  99689. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  99690. */
  99691. highRefreshRate: boolean;
  99692. /**
  99693. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  99694. */
  99695. foveationLevel: number;
  99696. }
  99697. interface Engine {
  99698. /** @hidden */
  99699. _vrDisplay: any;
  99700. /** @hidden */
  99701. _vrSupported: boolean;
  99702. /** @hidden */
  99703. _oldSize: Size;
  99704. /** @hidden */
  99705. _oldHardwareScaleFactor: number;
  99706. /** @hidden */
  99707. _vrExclusivePointerMode: boolean;
  99708. /** @hidden */
  99709. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  99710. /** @hidden */
  99711. _onVRDisplayPointerRestricted: () => void;
  99712. /** @hidden */
  99713. _onVRDisplayPointerUnrestricted: () => void;
  99714. /** @hidden */
  99715. _onVrDisplayConnect: Nullable<(display: any) => void>;
  99716. /** @hidden */
  99717. _onVrDisplayDisconnect: Nullable<() => void>;
  99718. /** @hidden */
  99719. _onVrDisplayPresentChange: Nullable<() => void>;
  99720. /**
  99721. * Observable signaled when VR display mode changes
  99722. */
  99723. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  99724. /**
  99725. * Observable signaled when VR request present is complete
  99726. */
  99727. onVRRequestPresentComplete: Observable<boolean>;
  99728. /**
  99729. * Observable signaled when VR request present starts
  99730. */
  99731. onVRRequestPresentStart: Observable<Engine>;
  99732. /**
  99733. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  99734. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  99735. */
  99736. isInVRExclusivePointerMode: boolean;
  99737. /**
  99738. * Gets a boolean indicating if a webVR device was detected
  99739. * @returns true if a webVR device was detected
  99740. */
  99741. isVRDevicePresent(): boolean;
  99742. /**
  99743. * Gets the current webVR device
  99744. * @returns the current webVR device (or null)
  99745. */
  99746. getVRDevice(): any;
  99747. /**
  99748. * Initializes a webVR display and starts listening to display change events
  99749. * The onVRDisplayChangedObservable will be notified upon these changes
  99750. * @returns A promise containing a VRDisplay and if vr is supported
  99751. */
  99752. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  99753. /** @hidden */
  99754. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  99755. /**
  99756. * Gets or sets the presentation attributes used to configure VR rendering
  99757. */
  99758. vrPresentationAttributes?: IVRPresentationAttributes;
  99759. /**
  99760. * Call this function to switch to webVR mode
  99761. * Will do nothing if webVR is not supported or if there is no webVR device
  99762. * @param options the webvr options provided to the camera. mainly used for multiview
  99763. * @see https://doc.babylonjs.com/how_to/webvr_camera
  99764. */
  99765. enableVR(options: WebVROptions): void;
  99766. /** @hidden */
  99767. _onVRFullScreenTriggered(): void;
  99768. }
  99769. }
  99770. declare module BABYLON {
  99771. /**
  99772. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  99773. * IMPORTANT!! The data is right-hand data.
  99774. * @export
  99775. * @interface DevicePose
  99776. */
  99777. export interface DevicePose {
  99778. /**
  99779. * The position of the device, values in array are [x,y,z].
  99780. */
  99781. readonly position: Nullable<Float32Array>;
  99782. /**
  99783. * The linearVelocity of the device, values in array are [x,y,z].
  99784. */
  99785. readonly linearVelocity: Nullable<Float32Array>;
  99786. /**
  99787. * The linearAcceleration of the device, values in array are [x,y,z].
  99788. */
  99789. readonly linearAcceleration: Nullable<Float32Array>;
  99790. /**
  99791. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  99792. */
  99793. readonly orientation: Nullable<Float32Array>;
  99794. /**
  99795. * The angularVelocity of the device, values in array are [x,y,z].
  99796. */
  99797. readonly angularVelocity: Nullable<Float32Array>;
  99798. /**
  99799. * The angularAcceleration of the device, values in array are [x,y,z].
  99800. */
  99801. readonly angularAcceleration: Nullable<Float32Array>;
  99802. }
  99803. /**
  99804. * Interface representing a pose controlled object in Babylon.
  99805. * A pose controlled object has both regular pose values as well as pose values
  99806. * from an external device such as a VR head mounted display
  99807. */
  99808. export interface PoseControlled {
  99809. /**
  99810. * The position of the object in babylon space.
  99811. */
  99812. position: Vector3;
  99813. /**
  99814. * The rotation quaternion of the object in babylon space.
  99815. */
  99816. rotationQuaternion: Quaternion;
  99817. /**
  99818. * The position of the device in babylon space.
  99819. */
  99820. devicePosition?: Vector3;
  99821. /**
  99822. * The rotation quaternion of the device in babylon space.
  99823. */
  99824. deviceRotationQuaternion: Quaternion;
  99825. /**
  99826. * The raw pose coming from the device.
  99827. */
  99828. rawPose: Nullable<DevicePose>;
  99829. /**
  99830. * The scale of the device to be used when translating from device space to babylon space.
  99831. */
  99832. deviceScaleFactor: number;
  99833. /**
  99834. * Updates the poseControlled values based on the input device pose.
  99835. * @param poseData the pose data to update the object with
  99836. */
  99837. updateFromDevice(poseData: DevicePose): void;
  99838. }
  99839. /**
  99840. * Set of options to customize the webVRCamera
  99841. */
  99842. export interface WebVROptions {
  99843. /**
  99844. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  99845. */
  99846. trackPosition?: boolean;
  99847. /**
  99848. * Sets the scale of the vrDevice in babylon space. (default: 1)
  99849. */
  99850. positionScale?: number;
  99851. /**
  99852. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  99853. */
  99854. displayName?: string;
  99855. /**
  99856. * Should the native controller meshes be initialized. (default: true)
  99857. */
  99858. controllerMeshes?: boolean;
  99859. /**
  99860. * Creating a default HemiLight only on controllers. (default: true)
  99861. */
  99862. defaultLightingOnControllers?: boolean;
  99863. /**
  99864. * If you don't want to use the default VR button of the helper. (default: false)
  99865. */
  99866. useCustomVRButton?: boolean;
  99867. /**
  99868. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  99869. */
  99870. customVRButton?: HTMLButtonElement;
  99871. /**
  99872. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  99873. */
  99874. rayLength?: number;
  99875. /**
  99876. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  99877. */
  99878. defaultHeight?: number;
  99879. /**
  99880. * If multiview should be used if availible (default: false)
  99881. */
  99882. useMultiview?: boolean;
  99883. }
  99884. /**
  99885. * This represents a WebVR camera.
  99886. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  99887. * @example https://doc.babylonjs.com/how_to/webvr_camera
  99888. */
  99889. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  99890. private webVROptions;
  99891. /**
  99892. * @hidden
  99893. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  99894. */
  99895. _vrDevice: any;
  99896. /**
  99897. * The rawPose of the vrDevice.
  99898. */
  99899. rawPose: Nullable<DevicePose>;
  99900. private _onVREnabled;
  99901. private _specsVersion;
  99902. private _attached;
  99903. private _frameData;
  99904. protected _descendants: Array<Node>;
  99905. private _deviceRoomPosition;
  99906. /** @hidden */
  99907. _deviceRoomRotationQuaternion: Quaternion;
  99908. private _standingMatrix;
  99909. /**
  99910. * Represents device position in babylon space.
  99911. */
  99912. devicePosition: Vector3;
  99913. /**
  99914. * Represents device rotation in babylon space.
  99915. */
  99916. deviceRotationQuaternion: Quaternion;
  99917. /**
  99918. * The scale of the device to be used when translating from device space to babylon space.
  99919. */
  99920. deviceScaleFactor: number;
  99921. private _deviceToWorld;
  99922. private _worldToDevice;
  99923. /**
  99924. * References to the webVR controllers for the vrDevice.
  99925. */
  99926. controllers: Array<WebVRController>;
  99927. /**
  99928. * Emits an event when a controller is attached.
  99929. */
  99930. onControllersAttachedObservable: Observable<WebVRController[]>;
  99931. /**
  99932. * Emits an event when a controller's mesh has been loaded;
  99933. */
  99934. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99935. /**
  99936. * Emits an event when the HMD's pose has been updated.
  99937. */
  99938. onPoseUpdatedFromDeviceObservable: Observable<any>;
  99939. private _poseSet;
  99940. /**
  99941. * If the rig cameras be used as parent instead of this camera.
  99942. */
  99943. rigParenting: boolean;
  99944. private _lightOnControllers;
  99945. private _defaultHeight?;
  99946. /**
  99947. * Instantiates a WebVRFreeCamera.
  99948. * @param name The name of the WebVRFreeCamera
  99949. * @param position The starting anchor position for the camera
  99950. * @param scene The scene the camera belongs to
  99951. * @param webVROptions a set of customizable options for the webVRCamera
  99952. */
  99953. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  99954. /**
  99955. * Gets the device distance from the ground in meters.
  99956. * @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.
  99957. */
  99958. deviceDistanceToRoomGround(): number;
  99959. /**
  99960. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  99961. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  99962. */
  99963. useStandingMatrix(callback?: (bool: boolean) => void): void;
  99964. /**
  99965. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  99966. * @returns A promise with a boolean set to if the standing matrix is supported.
  99967. */
  99968. useStandingMatrixAsync(): Promise<boolean>;
  99969. /**
  99970. * Disposes the camera
  99971. */
  99972. dispose(): void;
  99973. /**
  99974. * Gets a vrController by name.
  99975. * @param name The name of the controller to retreive
  99976. * @returns the controller matching the name specified or null if not found
  99977. */
  99978. getControllerByName(name: string): Nullable<WebVRController>;
  99979. private _leftController;
  99980. /**
  99981. * The controller corresponding to the users left hand.
  99982. */
  99983. get leftController(): Nullable<WebVRController>;
  99984. private _rightController;
  99985. /**
  99986. * The controller corresponding to the users right hand.
  99987. */
  99988. get rightController(): Nullable<WebVRController>;
  99989. /**
  99990. * Casts a ray forward from the vrCamera's gaze.
  99991. * @param length Length of the ray (default: 100)
  99992. * @returns the ray corresponding to the gaze
  99993. */
  99994. getForwardRay(length?: number): Ray;
  99995. /**
  99996. * @hidden
  99997. * Updates the camera based on device's frame data
  99998. */
  99999. _checkInputs(): void;
  100000. /**
  100001. * Updates the poseControlled values based on the input device pose.
  100002. * @param poseData Pose coming from the device
  100003. */
  100004. updateFromDevice(poseData: DevicePose): void;
  100005. private _htmlElementAttached;
  100006. private _detachIfAttached;
  100007. /**
  100008. * WebVR's attach control will start broadcasting frames to the device.
  100009. * Note that in certain browsers (chrome for example) this function must be called
  100010. * within a user-interaction callback. Example:
  100011. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  100012. *
  100013. * @param element html element to attach the vrDevice to
  100014. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  100015. */
  100016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100017. /**
  100018. * Detaches the camera from the html element and disables VR
  100019. *
  100020. * @param element html element to detach from
  100021. */
  100022. detachControl(element: HTMLElement): void;
  100023. /**
  100024. * @returns the name of this class
  100025. */
  100026. getClassName(): string;
  100027. /**
  100028. * Calls resetPose on the vrDisplay
  100029. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  100030. */
  100031. resetToCurrentRotation(): void;
  100032. /**
  100033. * @hidden
  100034. * Updates the rig cameras (left and right eye)
  100035. */
  100036. _updateRigCameras(): void;
  100037. private _workingVector;
  100038. private _oneVector;
  100039. private _workingMatrix;
  100040. private updateCacheCalled;
  100041. private _correctPositionIfNotTrackPosition;
  100042. /**
  100043. * @hidden
  100044. * Updates the cached values of the camera
  100045. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  100046. */
  100047. _updateCache(ignoreParentClass?: boolean): void;
  100048. /**
  100049. * @hidden
  100050. * Get current device position in babylon world
  100051. */
  100052. _computeDevicePosition(): void;
  100053. /**
  100054. * Updates the current device position and rotation in the babylon world
  100055. */
  100056. update(): void;
  100057. /**
  100058. * @hidden
  100059. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  100060. * @returns an identity matrix
  100061. */
  100062. _getViewMatrix(): Matrix;
  100063. private _tmpMatrix;
  100064. /**
  100065. * This function is called by the two RIG cameras.
  100066. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  100067. * @hidden
  100068. */
  100069. _getWebVRViewMatrix(): Matrix;
  100070. /** @hidden */
  100071. _getWebVRProjectionMatrix(): Matrix;
  100072. private _onGamepadConnectedObserver;
  100073. private _onGamepadDisconnectedObserver;
  100074. private _updateCacheWhenTrackingDisabledObserver;
  100075. /**
  100076. * Initializes the controllers and their meshes
  100077. */
  100078. initControllers(): void;
  100079. }
  100080. }
  100081. declare module BABYLON {
  100082. /**
  100083. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  100084. *
  100085. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  100086. *
  100087. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100088. */
  100089. export class MaterialHelper {
  100090. /**
  100091. * Bind the current view position to an effect.
  100092. * @param effect The effect to be bound
  100093. * @param scene The scene the eyes position is used from
  100094. * @param variableName name of the shader variable that will hold the eye position
  100095. */
  100096. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  100097. /**
  100098. * Helps preparing the defines values about the UVs in used in the effect.
  100099. * UVs are shared as much as we can accross channels in the shaders.
  100100. * @param texture The texture we are preparing the UVs for
  100101. * @param defines The defines to update
  100102. * @param key The channel key "diffuse", "specular"... used in the shader
  100103. */
  100104. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  100105. /**
  100106. * Binds a texture matrix value to its corrsponding uniform
  100107. * @param texture The texture to bind the matrix for
  100108. * @param uniformBuffer The uniform buffer receivin the data
  100109. * @param key The channel key "diffuse", "specular"... used in the shader
  100110. */
  100111. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  100112. /**
  100113. * Gets the current status of the fog (should it be enabled?)
  100114. * @param mesh defines the mesh to evaluate for fog support
  100115. * @param scene defines the hosting scene
  100116. * @returns true if fog must be enabled
  100117. */
  100118. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  100119. /**
  100120. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  100121. * @param mesh defines the current mesh
  100122. * @param scene defines the current scene
  100123. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  100124. * @param pointsCloud defines if point cloud rendering has to be turned on
  100125. * @param fogEnabled defines if fog has to be turned on
  100126. * @param alphaTest defines if alpha testing has to be turned on
  100127. * @param defines defines the current list of defines
  100128. */
  100129. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  100130. /**
  100131. * Helper used to prepare the list of defines associated with frame values for shader compilation
  100132. * @param scene defines the current scene
  100133. * @param engine defines the current engine
  100134. * @param defines specifies the list of active defines
  100135. * @param useInstances defines if instances have to be turned on
  100136. * @param useClipPlane defines if clip plane have to be turned on
  100137. * @param useInstances defines if instances have to be turned on
  100138. * @param useThinInstances defines if thin instances have to be turned on
  100139. */
  100140. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  100141. /**
  100142. * Prepares the defines for bones
  100143. * @param mesh The mesh containing the geometry data we will draw
  100144. * @param defines The defines to update
  100145. */
  100146. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  100147. /**
  100148. * Prepares the defines for morph targets
  100149. * @param mesh The mesh containing the geometry data we will draw
  100150. * @param defines The defines to update
  100151. */
  100152. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  100153. /**
  100154. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  100155. * @param mesh The mesh containing the geometry data we will draw
  100156. * @param defines The defines to update
  100157. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  100158. * @param useBones Precise whether bones should be used or not (override mesh info)
  100159. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  100160. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  100161. * @returns false if defines are considered not dirty and have not been checked
  100162. */
  100163. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  100164. /**
  100165. * Prepares the defines related to multiview
  100166. * @param scene The scene we are intending to draw
  100167. * @param defines The defines to update
  100168. */
  100169. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  100170. /**
  100171. * Prepares the defines related to the prepass
  100172. * @param scene The scene we are intending to draw
  100173. * @param defines The defines to update
  100174. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  100175. */
  100176. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  100177. /**
  100178. * Prepares the defines related to the light information passed in parameter
  100179. * @param scene The scene we are intending to draw
  100180. * @param mesh The mesh the effect is compiling for
  100181. * @param light The light the effect is compiling for
  100182. * @param lightIndex The index of the light
  100183. * @param defines The defines to update
  100184. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100185. * @param state Defines the current state regarding what is needed (normals, etc...)
  100186. */
  100187. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  100188. needNormals: boolean;
  100189. needRebuild: boolean;
  100190. shadowEnabled: boolean;
  100191. specularEnabled: boolean;
  100192. lightmapMode: boolean;
  100193. }): void;
  100194. /**
  100195. * Prepares the defines related to the light information passed in parameter
  100196. * @param scene The scene we are intending to draw
  100197. * @param mesh The mesh the effect is compiling for
  100198. * @param defines The defines to update
  100199. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100200. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  100201. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  100202. * @returns true if normals will be required for the rest of the effect
  100203. */
  100204. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  100205. /**
  100206. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  100207. * @param lightIndex defines the light index
  100208. * @param uniformsList The uniform list
  100209. * @param samplersList The sampler list
  100210. * @param projectedLightTexture defines if projected texture must be used
  100211. * @param uniformBuffersList defines an optional list of uniform buffers
  100212. */
  100213. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  100214. /**
  100215. * Prepares the uniforms and samplers list to be used in the effect
  100216. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  100217. * @param samplersList The sampler list
  100218. * @param defines The defines helping in the list generation
  100219. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  100220. */
  100221. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  100222. /**
  100223. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  100224. * @param defines The defines to update while falling back
  100225. * @param fallbacks The authorized effect fallbacks
  100226. * @param maxSimultaneousLights The maximum number of lights allowed
  100227. * @param rank the current rank of the Effect
  100228. * @returns The newly affected rank
  100229. */
  100230. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  100231. private static _TmpMorphInfluencers;
  100232. /**
  100233. * Prepares the list of attributes required for morph targets according to the effect defines.
  100234. * @param attribs The current list of supported attribs
  100235. * @param mesh The mesh to prepare the morph targets attributes for
  100236. * @param influencers The number of influencers
  100237. */
  100238. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  100239. /**
  100240. * Prepares the list of attributes required for morph targets according to the effect defines.
  100241. * @param attribs The current list of supported attribs
  100242. * @param mesh The mesh to prepare the morph targets attributes for
  100243. * @param defines The current Defines of the effect
  100244. */
  100245. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  100246. /**
  100247. * Prepares the list of attributes required for bones according to the effect defines.
  100248. * @param attribs The current list of supported attribs
  100249. * @param mesh The mesh to prepare the bones attributes for
  100250. * @param defines The current Defines of the effect
  100251. * @param fallbacks The current efffect fallback strategy
  100252. */
  100253. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  100254. /**
  100255. * Check and prepare the list of attributes required for instances according to the effect defines.
  100256. * @param attribs The current list of supported attribs
  100257. * @param defines The current MaterialDefines of the effect
  100258. */
  100259. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  100260. /**
  100261. * Add the list of attributes required for instances to the attribs array.
  100262. * @param attribs The current list of supported attribs
  100263. */
  100264. static PushAttributesForInstances(attribs: string[]): void;
  100265. /**
  100266. * Binds the light information to the effect.
  100267. * @param light The light containing the generator
  100268. * @param effect The effect we are binding the data to
  100269. * @param lightIndex The light index in the effect used to render
  100270. */
  100271. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  100272. /**
  100273. * Binds the lights information from the scene to the effect for the given mesh.
  100274. * @param light Light to bind
  100275. * @param lightIndex Light index
  100276. * @param scene The scene where the light belongs to
  100277. * @param effect The effect we are binding the data to
  100278. * @param useSpecular Defines if specular is supported
  100279. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100280. */
  100281. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  100282. /**
  100283. * Binds the lights information from the scene to the effect for the given mesh.
  100284. * @param scene The scene the lights belongs to
  100285. * @param mesh The mesh we are binding the information to render
  100286. * @param effect The effect we are binding the data to
  100287. * @param defines The generated defines for the effect
  100288. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  100289. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100290. */
  100291. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  100292. private static _tempFogColor;
  100293. /**
  100294. * Binds the fog information from the scene to the effect for the given mesh.
  100295. * @param scene The scene the lights belongs to
  100296. * @param mesh The mesh we are binding the information to render
  100297. * @param effect The effect we are binding the data to
  100298. * @param linearSpace Defines if the fog effect is applied in linear space
  100299. */
  100300. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  100301. /**
  100302. * Binds the bones information from the mesh to the effect.
  100303. * @param mesh The mesh we are binding the information to render
  100304. * @param effect The effect we are binding the data to
  100305. */
  100306. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  100307. /**
  100308. * Binds the morph targets information from the mesh to the effect.
  100309. * @param abstractMesh The mesh we are binding the information to render
  100310. * @param effect The effect we are binding the data to
  100311. */
  100312. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  100313. /**
  100314. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  100315. * @param defines The generated defines used in the effect
  100316. * @param effect The effect we are binding the data to
  100317. * @param scene The scene we are willing to render with logarithmic scale for
  100318. */
  100319. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  100320. /**
  100321. * Binds the clip plane information from the scene to the effect.
  100322. * @param scene The scene the clip plane information are extracted from
  100323. * @param effect The effect we are binding the data to
  100324. */
  100325. static BindClipPlane(effect: Effect, scene: Scene): void;
  100326. }
  100327. }
  100328. declare module BABYLON {
  100329. /**
  100330. * Block used to expose an input value
  100331. */
  100332. export class InputBlock extends NodeMaterialBlock {
  100333. private _mode;
  100334. private _associatedVariableName;
  100335. private _storedValue;
  100336. private _valueCallback;
  100337. private _type;
  100338. private _animationType;
  100339. /** Gets or set a value used to limit the range of float values */
  100340. min: number;
  100341. /** Gets or set a value used to limit the range of float values */
  100342. max: number;
  100343. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  100344. isBoolean: boolean;
  100345. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  100346. matrixMode: number;
  100347. /** @hidden */
  100348. _systemValue: Nullable<NodeMaterialSystemValues>;
  100349. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  100350. isConstant: boolean;
  100351. /** Gets or sets the group to use to display this block in the Inspector */
  100352. groupInInspector: string;
  100353. /** Gets an observable raised when the value is changed */
  100354. onValueChangedObservable: Observable<InputBlock>;
  100355. /**
  100356. * Gets or sets the connection point type (default is float)
  100357. */
  100358. get type(): NodeMaterialBlockConnectionPointTypes;
  100359. /**
  100360. * Creates a new InputBlock
  100361. * @param name defines the block name
  100362. * @param target defines the target of that block (Vertex by default)
  100363. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  100364. */
  100365. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  100366. /**
  100367. * Validates if a name is a reserve word.
  100368. * @param newName the new name to be given to the node.
  100369. * @returns false if the name is a reserve word, else true.
  100370. */
  100371. validateBlockName(newName: string): boolean;
  100372. /**
  100373. * Gets the output component
  100374. */
  100375. get output(): NodeMaterialConnectionPoint;
  100376. /**
  100377. * Set the source of this connection point to a vertex attribute
  100378. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  100379. * @returns the current connection point
  100380. */
  100381. setAsAttribute(attributeName?: string): InputBlock;
  100382. /**
  100383. * Set the source of this connection point to a system value
  100384. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  100385. * @returns the current connection point
  100386. */
  100387. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  100388. /**
  100389. * Gets or sets the value of that point.
  100390. * Please note that this value will be ignored if valueCallback is defined
  100391. */
  100392. get value(): any;
  100393. set value(value: any);
  100394. /**
  100395. * Gets or sets a callback used to get the value of that point.
  100396. * Please note that setting this value will force the connection point to ignore the value property
  100397. */
  100398. get valueCallback(): () => any;
  100399. set valueCallback(value: () => any);
  100400. /**
  100401. * Gets or sets the associated variable name in the shader
  100402. */
  100403. get associatedVariableName(): string;
  100404. set associatedVariableName(value: string);
  100405. /** Gets or sets the type of animation applied to the input */
  100406. get animationType(): AnimatedInputBlockTypes;
  100407. set animationType(value: AnimatedInputBlockTypes);
  100408. /**
  100409. * Gets a boolean indicating that this connection point not defined yet
  100410. */
  100411. get isUndefined(): boolean;
  100412. /**
  100413. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  100414. * In this case the connection point name must be the name of the uniform to use.
  100415. * Can only be set on inputs
  100416. */
  100417. get isUniform(): boolean;
  100418. set isUniform(value: boolean);
  100419. /**
  100420. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  100421. * In this case the connection point name must be the name of the attribute to use
  100422. * Can only be set on inputs
  100423. */
  100424. get isAttribute(): boolean;
  100425. set isAttribute(value: boolean);
  100426. /**
  100427. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  100428. * Can only be set on exit points
  100429. */
  100430. get isVarying(): boolean;
  100431. set isVarying(value: boolean);
  100432. /**
  100433. * Gets a boolean indicating that the current connection point is a system value
  100434. */
  100435. get isSystemValue(): boolean;
  100436. /**
  100437. * Gets or sets the current well known value or null if not defined as a system value
  100438. */
  100439. get systemValue(): Nullable<NodeMaterialSystemValues>;
  100440. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  100441. /**
  100442. * Gets the current class name
  100443. * @returns the class name
  100444. */
  100445. getClassName(): string;
  100446. /**
  100447. * Animate the input if animationType !== None
  100448. * @param scene defines the rendering scene
  100449. */
  100450. animate(scene: Scene): void;
  100451. private _emitDefine;
  100452. initialize(state: NodeMaterialBuildState): void;
  100453. /**
  100454. * Set the input block to its default value (based on its type)
  100455. */
  100456. setDefaultValue(): void;
  100457. private _emitConstant;
  100458. /** @hidden */
  100459. get _noContextSwitch(): boolean;
  100460. private _emit;
  100461. /** @hidden */
  100462. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  100463. /** @hidden */
  100464. _transmit(effect: Effect, scene: Scene): void;
  100465. protected _buildBlock(state: NodeMaterialBuildState): void;
  100466. protected _dumpPropertiesCode(): string;
  100467. dispose(): void;
  100468. serialize(): any;
  100469. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100470. }
  100471. }
  100472. declare module BABYLON {
  100473. /**
  100474. * Enum used to define the compatibility state between two connection points
  100475. */
  100476. export enum NodeMaterialConnectionPointCompatibilityStates {
  100477. /** Points are compatibles */
  100478. Compatible = 0,
  100479. /** Points are incompatible because of their types */
  100480. TypeIncompatible = 1,
  100481. /** Points are incompatible because of their targets (vertex vs fragment) */
  100482. TargetIncompatible = 2
  100483. }
  100484. /**
  100485. * Defines the direction of a connection point
  100486. */
  100487. export enum NodeMaterialConnectionPointDirection {
  100488. /** Input */
  100489. Input = 0,
  100490. /** Output */
  100491. Output = 1
  100492. }
  100493. /**
  100494. * Defines a connection point for a block
  100495. */
  100496. export class NodeMaterialConnectionPoint {
  100497. /** @hidden */
  100498. _ownerBlock: NodeMaterialBlock;
  100499. /** @hidden */
  100500. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  100501. private _endpoints;
  100502. private _associatedVariableName;
  100503. private _direction;
  100504. /** @hidden */
  100505. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100506. /** @hidden */
  100507. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100508. private _type;
  100509. /** @hidden */
  100510. _enforceAssociatedVariableName: boolean;
  100511. /** Gets the direction of the point */
  100512. get direction(): NodeMaterialConnectionPointDirection;
  100513. /** Indicates that this connection point needs dual validation before being connected to another point */
  100514. needDualDirectionValidation: boolean;
  100515. /**
  100516. * Gets or sets the additional types supported by this connection point
  100517. */
  100518. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100519. /**
  100520. * Gets or sets the additional types excluded by this connection point
  100521. */
  100522. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100523. /**
  100524. * Observable triggered when this point is connected
  100525. */
  100526. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  100527. /**
  100528. * Gets or sets the associated variable name in the shader
  100529. */
  100530. get associatedVariableName(): string;
  100531. set associatedVariableName(value: string);
  100532. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  100533. get innerType(): NodeMaterialBlockConnectionPointTypes;
  100534. /**
  100535. * Gets or sets the connection point type (default is float)
  100536. */
  100537. get type(): NodeMaterialBlockConnectionPointTypes;
  100538. set type(value: NodeMaterialBlockConnectionPointTypes);
  100539. /**
  100540. * Gets or sets the connection point name
  100541. */
  100542. name: string;
  100543. /**
  100544. * Gets or sets the connection point name
  100545. */
  100546. displayName: string;
  100547. /**
  100548. * Gets or sets a boolean indicating that this connection point can be omitted
  100549. */
  100550. isOptional: boolean;
  100551. /**
  100552. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  100553. */
  100554. isExposedOnFrame: boolean;
  100555. /**
  100556. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  100557. */
  100558. define: string;
  100559. /** @hidden */
  100560. _prioritizeVertex: boolean;
  100561. private _target;
  100562. /** Gets or sets the target of that connection point */
  100563. get target(): NodeMaterialBlockTargets;
  100564. set target(value: NodeMaterialBlockTargets);
  100565. /**
  100566. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  100567. */
  100568. get isConnected(): boolean;
  100569. /**
  100570. * Gets a boolean indicating that the current point is connected to an input block
  100571. */
  100572. get isConnectedToInputBlock(): boolean;
  100573. /**
  100574. * Gets a the connected input block (if any)
  100575. */
  100576. get connectInputBlock(): Nullable<InputBlock>;
  100577. /** Get the other side of the connection (if any) */
  100578. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  100579. /** Get the block that owns this connection point */
  100580. get ownerBlock(): NodeMaterialBlock;
  100581. /** Get the block connected on the other side of this connection (if any) */
  100582. get sourceBlock(): Nullable<NodeMaterialBlock>;
  100583. /** Get the block connected on the endpoints of this connection (if any) */
  100584. get connectedBlocks(): Array<NodeMaterialBlock>;
  100585. /** Gets the list of connected endpoints */
  100586. get endpoints(): NodeMaterialConnectionPoint[];
  100587. /** Gets a boolean indicating if that output point is connected to at least one input */
  100588. get hasEndpoints(): boolean;
  100589. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  100590. get isConnectedInVertexShader(): boolean;
  100591. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  100592. get isConnectedInFragmentShader(): boolean;
  100593. /**
  100594. * Creates a block suitable to be used as an input for this input point.
  100595. * If null is returned, a block based on the point type will be created.
  100596. * @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
  100597. */
  100598. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  100599. /**
  100600. * Creates a new connection point
  100601. * @param name defines the connection point name
  100602. * @param ownerBlock defines the block hosting this connection point
  100603. * @param direction defines the direction of the connection point
  100604. */
  100605. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  100606. /**
  100607. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  100608. * @returns the class name
  100609. */
  100610. getClassName(): string;
  100611. /**
  100612. * Gets a boolean indicating if the current point can be connected to another point
  100613. * @param connectionPoint defines the other connection point
  100614. * @returns a boolean
  100615. */
  100616. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  100617. /**
  100618. * Gets a number indicating if the current point can be connected to another point
  100619. * @param connectionPoint defines the other connection point
  100620. * @returns a number defining the compatibility state
  100621. */
  100622. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  100623. /**
  100624. * Connect this point to another connection point
  100625. * @param connectionPoint defines the other connection point
  100626. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  100627. * @returns the current connection point
  100628. */
  100629. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  100630. /**
  100631. * Disconnect this point from one of his endpoint
  100632. * @param endpoint defines the other connection point
  100633. * @returns the current connection point
  100634. */
  100635. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  100636. /**
  100637. * Serializes this point in a JSON representation
  100638. * @param isInput defines if the connection point is an input (default is true)
  100639. * @returns the serialized point object
  100640. */
  100641. serialize(isInput?: boolean): any;
  100642. /**
  100643. * Release resources
  100644. */
  100645. dispose(): void;
  100646. }
  100647. }
  100648. declare module BABYLON {
  100649. /**
  100650. * Enum used to define the material modes
  100651. */
  100652. export enum NodeMaterialModes {
  100653. /** Regular material */
  100654. Material = 0,
  100655. /** For post process */
  100656. PostProcess = 1,
  100657. /** For particle system */
  100658. Particle = 2
  100659. }
  100660. }
  100661. declare module BABYLON {
  100662. /**
  100663. * Block used to read a texture from a sampler
  100664. */
  100665. export class TextureBlock extends NodeMaterialBlock {
  100666. private _defineName;
  100667. private _linearDefineName;
  100668. private _gammaDefineName;
  100669. private _tempTextureRead;
  100670. private _samplerName;
  100671. private _transformedUVName;
  100672. private _textureTransformName;
  100673. private _textureInfoName;
  100674. private _mainUVName;
  100675. private _mainUVDefineName;
  100676. private _fragmentOnly;
  100677. /**
  100678. * Gets or sets the texture associated with the node
  100679. */
  100680. texture: Nullable<Texture>;
  100681. /**
  100682. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100683. */
  100684. convertToGammaSpace: boolean;
  100685. /**
  100686. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100687. */
  100688. convertToLinearSpace: boolean;
  100689. /**
  100690. * Create a new TextureBlock
  100691. * @param name defines the block name
  100692. */
  100693. constructor(name: string, fragmentOnly?: boolean);
  100694. /**
  100695. * Gets the current class name
  100696. * @returns the class name
  100697. */
  100698. getClassName(): string;
  100699. /**
  100700. * Gets the uv input component
  100701. */
  100702. get uv(): NodeMaterialConnectionPoint;
  100703. /**
  100704. * Gets the rgba output component
  100705. */
  100706. get rgba(): NodeMaterialConnectionPoint;
  100707. /**
  100708. * Gets the rgb output component
  100709. */
  100710. get rgb(): NodeMaterialConnectionPoint;
  100711. /**
  100712. * Gets the r output component
  100713. */
  100714. get r(): NodeMaterialConnectionPoint;
  100715. /**
  100716. * Gets the g output component
  100717. */
  100718. get g(): NodeMaterialConnectionPoint;
  100719. /**
  100720. * Gets the b output component
  100721. */
  100722. get b(): NodeMaterialConnectionPoint;
  100723. /**
  100724. * Gets the a output component
  100725. */
  100726. get a(): NodeMaterialConnectionPoint;
  100727. get target(): NodeMaterialBlockTargets;
  100728. autoConfigure(material: NodeMaterial): void;
  100729. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100730. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100731. isReady(): boolean;
  100732. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  100733. private get _isMixed();
  100734. private _injectVertexCode;
  100735. private _writeTextureRead;
  100736. private _writeOutput;
  100737. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100738. protected _dumpPropertiesCode(): string;
  100739. serialize(): any;
  100740. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100741. }
  100742. }
  100743. declare module BABYLON {
  100744. /** @hidden */
  100745. export var reflectionFunction: {
  100746. name: string;
  100747. shader: string;
  100748. };
  100749. }
  100750. declare module BABYLON {
  100751. /**
  100752. * Base block used to read a reflection texture from a sampler
  100753. */
  100754. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  100755. /** @hidden */
  100756. _define3DName: string;
  100757. /** @hidden */
  100758. _defineCubicName: string;
  100759. /** @hidden */
  100760. _defineExplicitName: string;
  100761. /** @hidden */
  100762. _defineProjectionName: string;
  100763. /** @hidden */
  100764. _defineLocalCubicName: string;
  100765. /** @hidden */
  100766. _defineSphericalName: string;
  100767. /** @hidden */
  100768. _definePlanarName: string;
  100769. /** @hidden */
  100770. _defineEquirectangularName: string;
  100771. /** @hidden */
  100772. _defineMirroredEquirectangularFixedName: string;
  100773. /** @hidden */
  100774. _defineEquirectangularFixedName: string;
  100775. /** @hidden */
  100776. _defineSkyboxName: string;
  100777. /** @hidden */
  100778. _defineOppositeZ: string;
  100779. /** @hidden */
  100780. _cubeSamplerName: string;
  100781. /** @hidden */
  100782. _2DSamplerName: string;
  100783. protected _positionUVWName: string;
  100784. protected _directionWName: string;
  100785. protected _reflectionVectorName: string;
  100786. /** @hidden */
  100787. _reflectionCoordsName: string;
  100788. /** @hidden */
  100789. _reflectionMatrixName: string;
  100790. protected _reflectionColorName: string;
  100791. /**
  100792. * Gets or sets the texture associated with the node
  100793. */
  100794. texture: Nullable<BaseTexture>;
  100795. /**
  100796. * Create a new ReflectionTextureBaseBlock
  100797. * @param name defines the block name
  100798. */
  100799. constructor(name: string);
  100800. /**
  100801. * Gets the current class name
  100802. * @returns the class name
  100803. */
  100804. getClassName(): string;
  100805. /**
  100806. * Gets the world position input component
  100807. */
  100808. abstract get position(): NodeMaterialConnectionPoint;
  100809. /**
  100810. * Gets the world position input component
  100811. */
  100812. abstract get worldPosition(): NodeMaterialConnectionPoint;
  100813. /**
  100814. * Gets the world normal input component
  100815. */
  100816. abstract get worldNormal(): NodeMaterialConnectionPoint;
  100817. /**
  100818. * Gets the world input component
  100819. */
  100820. abstract get world(): NodeMaterialConnectionPoint;
  100821. /**
  100822. * Gets the camera (or eye) position component
  100823. */
  100824. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  100825. /**
  100826. * Gets the view input component
  100827. */
  100828. abstract get view(): NodeMaterialConnectionPoint;
  100829. protected _getTexture(): Nullable<BaseTexture>;
  100830. autoConfigure(material: NodeMaterial): void;
  100831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100832. isReady(): boolean;
  100833. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  100834. /**
  100835. * Gets the code to inject in the vertex shader
  100836. * @param state current state of the node material building
  100837. * @returns the shader code
  100838. */
  100839. handleVertexSide(state: NodeMaterialBuildState): string;
  100840. /**
  100841. * Handles the inits for the fragment code path
  100842. * @param state node material build state
  100843. */
  100844. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  100845. /**
  100846. * Generates the reflection coords code for the fragment code path
  100847. * @param worldNormalVarName name of the world normal variable
  100848. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  100849. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  100850. * @returns the shader code
  100851. */
  100852. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  100853. /**
  100854. * Generates the reflection color code for the fragment code path
  100855. * @param lodVarName name of the lod variable
  100856. * @param swizzleLookupTexture swizzle to use for the final color variable
  100857. * @returns the shader code
  100858. */
  100859. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  100860. /**
  100861. * Generates the code corresponding to the connected output points
  100862. * @param state node material build state
  100863. * @param varName name of the variable to output
  100864. * @returns the shader code
  100865. */
  100866. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  100867. protected _buildBlock(state: NodeMaterialBuildState): this;
  100868. protected _dumpPropertiesCode(): string;
  100869. serialize(): any;
  100870. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100871. }
  100872. }
  100873. declare module BABYLON {
  100874. /**
  100875. * Defines a connection point to be used for points with a custom object type
  100876. */
  100877. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  100878. private _blockType;
  100879. private _blockName;
  100880. private _nameForCheking?;
  100881. /**
  100882. * Creates a new connection point
  100883. * @param name defines the connection point name
  100884. * @param ownerBlock defines the block hosting this connection point
  100885. * @param direction defines the direction of the connection point
  100886. */
  100887. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  100888. /**
  100889. * Gets a number indicating if the current point can be connected to another point
  100890. * @param connectionPoint defines the other connection point
  100891. * @returns a number defining the compatibility state
  100892. */
  100893. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  100894. /**
  100895. * Creates a block suitable to be used as an input for this input point.
  100896. * If null is returned, a block based on the point type will be created.
  100897. * @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
  100898. */
  100899. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  100900. }
  100901. }
  100902. declare module BABYLON {
  100903. /**
  100904. * Enum defining the type of properties that can be edited in the property pages in the NME
  100905. */
  100906. export enum PropertyTypeForEdition {
  100907. /** property is a boolean */
  100908. Boolean = 0,
  100909. /** property is a float */
  100910. Float = 1,
  100911. /** property is a Vector2 */
  100912. Vector2 = 2,
  100913. /** property is a list of values */
  100914. List = 3
  100915. }
  100916. /**
  100917. * Interface that defines an option in a variable of type list
  100918. */
  100919. export interface IEditablePropertyListOption {
  100920. /** label of the option */
  100921. "label": string;
  100922. /** value of the option */
  100923. "value": number;
  100924. }
  100925. /**
  100926. * Interface that defines the options available for an editable property
  100927. */
  100928. export interface IEditablePropertyOption {
  100929. /** min value */
  100930. "min"?: number;
  100931. /** max value */
  100932. "max"?: number;
  100933. /** notifiers: indicates which actions to take when the property is changed */
  100934. "notifiers"?: {
  100935. /** the material should be rebuilt */
  100936. "rebuild"?: boolean;
  100937. /** the preview should be updated */
  100938. "update"?: boolean;
  100939. };
  100940. /** list of the options for a variable of type list */
  100941. "options"?: IEditablePropertyListOption[];
  100942. }
  100943. /**
  100944. * Interface that describes an editable property
  100945. */
  100946. export interface IPropertyDescriptionForEdition {
  100947. /** name of the property */
  100948. "propertyName": string;
  100949. /** display name of the property */
  100950. "displayName": string;
  100951. /** type of the property */
  100952. "type": PropertyTypeForEdition;
  100953. /** group of the property - all properties with the same group value will be displayed in a specific section */
  100954. "groupName": string;
  100955. /** options for the property */
  100956. "options": IEditablePropertyOption;
  100957. }
  100958. /**
  100959. * Decorator that flags a property in a node material block as being editable
  100960. */
  100961. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  100962. }
  100963. declare module BABYLON {
  100964. /**
  100965. * Block used to implement the refraction part of the sub surface module of the PBR material
  100966. */
  100967. export class RefractionBlock extends NodeMaterialBlock {
  100968. /** @hidden */
  100969. _define3DName: string;
  100970. /** @hidden */
  100971. _refractionMatrixName: string;
  100972. /** @hidden */
  100973. _defineLODRefractionAlpha: string;
  100974. /** @hidden */
  100975. _defineLinearSpecularRefraction: string;
  100976. /** @hidden */
  100977. _defineOppositeZ: string;
  100978. /** @hidden */
  100979. _cubeSamplerName: string;
  100980. /** @hidden */
  100981. _2DSamplerName: string;
  100982. /** @hidden */
  100983. _vRefractionMicrosurfaceInfosName: string;
  100984. /** @hidden */
  100985. _vRefractionInfosName: string;
  100986. private _scene;
  100987. /**
  100988. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  100989. * Materials half opaque for instance using refraction could benefit from this control.
  100990. */
  100991. linkRefractionWithTransparency: boolean;
  100992. /**
  100993. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  100994. */
  100995. invertRefractionY: boolean;
  100996. /**
  100997. * Gets or sets the texture associated with the node
  100998. */
  100999. texture: Nullable<BaseTexture>;
  101000. /**
  101001. * Create a new RefractionBlock
  101002. * @param name defines the block name
  101003. */
  101004. constructor(name: string);
  101005. /**
  101006. * Gets the current class name
  101007. * @returns the class name
  101008. */
  101009. getClassName(): string;
  101010. /**
  101011. * Gets the intensity input component
  101012. */
  101013. get intensity(): NodeMaterialConnectionPoint;
  101014. /**
  101015. * Gets the index of refraction input component
  101016. */
  101017. get indexOfRefraction(): NodeMaterialConnectionPoint;
  101018. /**
  101019. * Gets the tint at distance input component
  101020. */
  101021. get tintAtDistance(): NodeMaterialConnectionPoint;
  101022. /**
  101023. * Gets the view input component
  101024. */
  101025. get view(): NodeMaterialConnectionPoint;
  101026. /**
  101027. * Gets the refraction object output component
  101028. */
  101029. get refraction(): NodeMaterialConnectionPoint;
  101030. /**
  101031. * Returns true if the block has a texture
  101032. */
  101033. get hasTexture(): boolean;
  101034. protected _getTexture(): Nullable<BaseTexture>;
  101035. autoConfigure(material: NodeMaterial): void;
  101036. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101037. isReady(): boolean;
  101038. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101039. /**
  101040. * Gets the main code of the block (fragment side)
  101041. * @param state current state of the node material building
  101042. * @returns the shader code
  101043. */
  101044. getCode(state: NodeMaterialBuildState): string;
  101045. protected _buildBlock(state: NodeMaterialBuildState): this;
  101046. protected _dumpPropertiesCode(): string;
  101047. serialize(): any;
  101048. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101049. }
  101050. }
  101051. declare module BABYLON {
  101052. /**
  101053. * Base block used as input for post process
  101054. */
  101055. export class CurrentScreenBlock extends NodeMaterialBlock {
  101056. private _samplerName;
  101057. private _linearDefineName;
  101058. private _gammaDefineName;
  101059. private _mainUVName;
  101060. private _tempTextureRead;
  101061. /**
  101062. * Gets or sets the texture associated with the node
  101063. */
  101064. texture: Nullable<BaseTexture>;
  101065. /**
  101066. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101067. */
  101068. convertToGammaSpace: boolean;
  101069. /**
  101070. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101071. */
  101072. convertToLinearSpace: boolean;
  101073. /**
  101074. * Create a new CurrentScreenBlock
  101075. * @param name defines the block name
  101076. */
  101077. constructor(name: string);
  101078. /**
  101079. * Gets the current class name
  101080. * @returns the class name
  101081. */
  101082. getClassName(): string;
  101083. /**
  101084. * Gets the uv input component
  101085. */
  101086. get uv(): NodeMaterialConnectionPoint;
  101087. /**
  101088. * Gets the rgba output component
  101089. */
  101090. get rgba(): NodeMaterialConnectionPoint;
  101091. /**
  101092. * Gets the rgb output component
  101093. */
  101094. get rgb(): NodeMaterialConnectionPoint;
  101095. /**
  101096. * Gets the r output component
  101097. */
  101098. get r(): NodeMaterialConnectionPoint;
  101099. /**
  101100. * Gets the g output component
  101101. */
  101102. get g(): NodeMaterialConnectionPoint;
  101103. /**
  101104. * Gets the b output component
  101105. */
  101106. get b(): NodeMaterialConnectionPoint;
  101107. /**
  101108. * Gets the a output component
  101109. */
  101110. get a(): NodeMaterialConnectionPoint;
  101111. /**
  101112. * Initialize the block and prepare the context for build
  101113. * @param state defines the state that will be used for the build
  101114. */
  101115. initialize(state: NodeMaterialBuildState): void;
  101116. get target(): NodeMaterialBlockTargets;
  101117. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101118. isReady(): boolean;
  101119. private _injectVertexCode;
  101120. private _writeTextureRead;
  101121. private _writeOutput;
  101122. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101123. serialize(): any;
  101124. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101125. }
  101126. }
  101127. declare module BABYLON {
  101128. /**
  101129. * Base block used for the particle texture
  101130. */
  101131. export class ParticleTextureBlock extends NodeMaterialBlock {
  101132. private _samplerName;
  101133. private _linearDefineName;
  101134. private _gammaDefineName;
  101135. private _tempTextureRead;
  101136. /**
  101137. * Gets or sets the texture associated with the node
  101138. */
  101139. texture: Nullable<BaseTexture>;
  101140. /**
  101141. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101142. */
  101143. convertToGammaSpace: boolean;
  101144. /**
  101145. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101146. */
  101147. convertToLinearSpace: boolean;
  101148. /**
  101149. * Create a new ParticleTextureBlock
  101150. * @param name defines the block name
  101151. */
  101152. constructor(name: string);
  101153. /**
  101154. * Gets the current class name
  101155. * @returns the class name
  101156. */
  101157. getClassName(): string;
  101158. /**
  101159. * Gets the uv input component
  101160. */
  101161. get uv(): NodeMaterialConnectionPoint;
  101162. /**
  101163. * Gets the rgba output component
  101164. */
  101165. get rgba(): NodeMaterialConnectionPoint;
  101166. /**
  101167. * Gets the rgb output component
  101168. */
  101169. get rgb(): NodeMaterialConnectionPoint;
  101170. /**
  101171. * Gets the r output component
  101172. */
  101173. get r(): NodeMaterialConnectionPoint;
  101174. /**
  101175. * Gets the g output component
  101176. */
  101177. get g(): NodeMaterialConnectionPoint;
  101178. /**
  101179. * Gets the b output component
  101180. */
  101181. get b(): NodeMaterialConnectionPoint;
  101182. /**
  101183. * Gets the a output component
  101184. */
  101185. get a(): NodeMaterialConnectionPoint;
  101186. /**
  101187. * Initialize the block and prepare the context for build
  101188. * @param state defines the state that will be used for the build
  101189. */
  101190. initialize(state: NodeMaterialBuildState): void;
  101191. autoConfigure(material: NodeMaterial): void;
  101192. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101193. isReady(): boolean;
  101194. private _writeOutput;
  101195. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101196. serialize(): any;
  101197. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101198. }
  101199. }
  101200. declare module BABYLON {
  101201. /**
  101202. * Class used to store shared data between 2 NodeMaterialBuildState
  101203. */
  101204. export class NodeMaterialBuildStateSharedData {
  101205. /**
  101206. * Gets the list of emitted varyings
  101207. */
  101208. temps: string[];
  101209. /**
  101210. * Gets the list of emitted varyings
  101211. */
  101212. varyings: string[];
  101213. /**
  101214. * Gets the varying declaration string
  101215. */
  101216. varyingDeclaration: string;
  101217. /**
  101218. * Input blocks
  101219. */
  101220. inputBlocks: InputBlock[];
  101221. /**
  101222. * Input blocks
  101223. */
  101224. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101225. /**
  101226. * Bindable blocks (Blocks that need to set data to the effect)
  101227. */
  101228. bindableBlocks: NodeMaterialBlock[];
  101229. /**
  101230. * List of blocks that can provide a compilation fallback
  101231. */
  101232. blocksWithFallbacks: NodeMaterialBlock[];
  101233. /**
  101234. * List of blocks that can provide a define update
  101235. */
  101236. blocksWithDefines: NodeMaterialBlock[];
  101237. /**
  101238. * List of blocks that can provide a repeatable content
  101239. */
  101240. repeatableContentBlocks: NodeMaterialBlock[];
  101241. /**
  101242. * List of blocks that can provide a dynamic list of uniforms
  101243. */
  101244. dynamicUniformBlocks: NodeMaterialBlock[];
  101245. /**
  101246. * List of blocks that can block the isReady function for the material
  101247. */
  101248. blockingBlocks: NodeMaterialBlock[];
  101249. /**
  101250. * Gets the list of animated inputs
  101251. */
  101252. animatedInputs: InputBlock[];
  101253. /**
  101254. * Build Id used to avoid multiple recompilations
  101255. */
  101256. buildId: number;
  101257. /** List of emitted variables */
  101258. variableNames: {
  101259. [key: string]: number;
  101260. };
  101261. /** List of emitted defines */
  101262. defineNames: {
  101263. [key: string]: number;
  101264. };
  101265. /** Should emit comments? */
  101266. emitComments: boolean;
  101267. /** Emit build activity */
  101268. verbose: boolean;
  101269. /** Gets or sets the hosting scene */
  101270. scene: Scene;
  101271. /**
  101272. * Gets the compilation hints emitted at compilation time
  101273. */
  101274. hints: {
  101275. needWorldViewMatrix: boolean;
  101276. needWorldViewProjectionMatrix: boolean;
  101277. needAlphaBlending: boolean;
  101278. needAlphaTesting: boolean;
  101279. };
  101280. /**
  101281. * List of compilation checks
  101282. */
  101283. checks: {
  101284. emitVertex: boolean;
  101285. emitFragment: boolean;
  101286. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  101287. };
  101288. /**
  101289. * Is vertex program allowed to be empty?
  101290. */
  101291. allowEmptyVertexProgram: boolean;
  101292. /** Creates a new shared data */
  101293. constructor();
  101294. /**
  101295. * Emits console errors and exceptions if there is a failing check
  101296. */
  101297. emitErrors(): void;
  101298. }
  101299. }
  101300. declare module BABYLON {
  101301. /**
  101302. * Class used to store node based material build state
  101303. */
  101304. export class NodeMaterialBuildState {
  101305. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  101306. supportUniformBuffers: boolean;
  101307. /**
  101308. * Gets the list of emitted attributes
  101309. */
  101310. attributes: string[];
  101311. /**
  101312. * Gets the list of emitted uniforms
  101313. */
  101314. uniforms: string[];
  101315. /**
  101316. * Gets the list of emitted constants
  101317. */
  101318. constants: string[];
  101319. /**
  101320. * Gets the list of emitted samplers
  101321. */
  101322. samplers: string[];
  101323. /**
  101324. * Gets the list of emitted functions
  101325. */
  101326. functions: {
  101327. [key: string]: string;
  101328. };
  101329. /**
  101330. * Gets the list of emitted extensions
  101331. */
  101332. extensions: {
  101333. [key: string]: string;
  101334. };
  101335. /**
  101336. * Gets the target of the compilation state
  101337. */
  101338. target: NodeMaterialBlockTargets;
  101339. /**
  101340. * Gets the list of emitted counters
  101341. */
  101342. counters: {
  101343. [key: string]: number;
  101344. };
  101345. /**
  101346. * Shared data between multiple NodeMaterialBuildState instances
  101347. */
  101348. sharedData: NodeMaterialBuildStateSharedData;
  101349. /** @hidden */
  101350. _vertexState: NodeMaterialBuildState;
  101351. /** @hidden */
  101352. _attributeDeclaration: string;
  101353. /** @hidden */
  101354. _uniformDeclaration: string;
  101355. /** @hidden */
  101356. _constantDeclaration: string;
  101357. /** @hidden */
  101358. _samplerDeclaration: string;
  101359. /** @hidden */
  101360. _varyingTransfer: string;
  101361. /** @hidden */
  101362. _injectAtEnd: string;
  101363. private _repeatableContentAnchorIndex;
  101364. /** @hidden */
  101365. _builtCompilationString: string;
  101366. /**
  101367. * Gets the emitted compilation strings
  101368. */
  101369. compilationString: string;
  101370. /**
  101371. * Finalize the compilation strings
  101372. * @param state defines the current compilation state
  101373. */
  101374. finalize(state: NodeMaterialBuildState): void;
  101375. /** @hidden */
  101376. get _repeatableContentAnchor(): string;
  101377. /** @hidden */
  101378. _getFreeVariableName(prefix: string): string;
  101379. /** @hidden */
  101380. _getFreeDefineName(prefix: string): string;
  101381. /** @hidden */
  101382. _excludeVariableName(name: string): void;
  101383. /** @hidden */
  101384. _emit2DSampler(name: string): void;
  101385. /** @hidden */
  101386. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  101387. /** @hidden */
  101388. _emitExtension(name: string, extension: string, define?: string): void;
  101389. /** @hidden */
  101390. _emitFunction(name: string, code: string, comments: string): void;
  101391. /** @hidden */
  101392. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  101393. replaceStrings?: {
  101394. search: RegExp;
  101395. replace: string;
  101396. }[];
  101397. repeatKey?: string;
  101398. }): string;
  101399. /** @hidden */
  101400. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  101401. repeatKey?: string;
  101402. removeAttributes?: boolean;
  101403. removeUniforms?: boolean;
  101404. removeVaryings?: boolean;
  101405. removeIfDef?: boolean;
  101406. replaceStrings?: {
  101407. search: RegExp;
  101408. replace: string;
  101409. }[];
  101410. }, storeKey?: string): void;
  101411. /** @hidden */
  101412. _registerTempVariable(name: string): boolean;
  101413. /** @hidden */
  101414. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  101415. /** @hidden */
  101416. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  101417. /** @hidden */
  101418. _emitFloat(value: number): string;
  101419. }
  101420. }
  101421. declare module BABYLON {
  101422. /**
  101423. * Helper class used to generate session unique ID
  101424. */
  101425. export class UniqueIdGenerator {
  101426. private static _UniqueIdCounter;
  101427. /**
  101428. * Gets an unique (relatively to the current scene) Id
  101429. */
  101430. static get UniqueId(): number;
  101431. }
  101432. }
  101433. declare module BABYLON {
  101434. /**
  101435. * Defines a block that can be used inside a node based material
  101436. */
  101437. export class NodeMaterialBlock {
  101438. private _buildId;
  101439. private _buildTarget;
  101440. private _target;
  101441. private _isFinalMerger;
  101442. private _isInput;
  101443. private _name;
  101444. protected _isUnique: boolean;
  101445. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  101446. inputsAreExclusive: boolean;
  101447. /** @hidden */
  101448. _codeVariableName: string;
  101449. /** @hidden */
  101450. _inputs: NodeMaterialConnectionPoint[];
  101451. /** @hidden */
  101452. _outputs: NodeMaterialConnectionPoint[];
  101453. /** @hidden */
  101454. _preparationId: number;
  101455. /**
  101456. * Gets the name of the block
  101457. */
  101458. get name(): string;
  101459. /**
  101460. * Sets the name of the block. Will check if the name is valid.
  101461. */
  101462. set name(newName: string);
  101463. /**
  101464. * Gets or sets the unique id of the node
  101465. */
  101466. uniqueId: number;
  101467. /**
  101468. * Gets or sets the comments associated with this block
  101469. */
  101470. comments: string;
  101471. /**
  101472. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  101473. */
  101474. get isUnique(): boolean;
  101475. /**
  101476. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  101477. */
  101478. get isFinalMerger(): boolean;
  101479. /**
  101480. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  101481. */
  101482. get isInput(): boolean;
  101483. /**
  101484. * Gets or sets the build Id
  101485. */
  101486. get buildId(): number;
  101487. set buildId(value: number);
  101488. /**
  101489. * Gets or sets the target of the block
  101490. */
  101491. get target(): NodeMaterialBlockTargets;
  101492. set target(value: NodeMaterialBlockTargets);
  101493. /**
  101494. * Gets the list of input points
  101495. */
  101496. get inputs(): NodeMaterialConnectionPoint[];
  101497. /** Gets the list of output points */
  101498. get outputs(): NodeMaterialConnectionPoint[];
  101499. /**
  101500. * Find an input by its name
  101501. * @param name defines the name of the input to look for
  101502. * @returns the input or null if not found
  101503. */
  101504. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101505. /**
  101506. * Find an output by its name
  101507. * @param name defines the name of the outputto look for
  101508. * @returns the output or null if not found
  101509. */
  101510. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101511. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  101512. visibleInInspector: boolean;
  101513. /**
  101514. * Creates a new NodeMaterialBlock
  101515. * @param name defines the block name
  101516. * @param target defines the target of that block (Vertex by default)
  101517. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  101518. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  101519. */
  101520. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  101521. /**
  101522. * Initialize the block and prepare the context for build
  101523. * @param state defines the state that will be used for the build
  101524. */
  101525. initialize(state: NodeMaterialBuildState): void;
  101526. /**
  101527. * Bind data to effect. Will only be called for blocks with isBindable === true
  101528. * @param effect defines the effect to bind data to
  101529. * @param nodeMaterial defines the hosting NodeMaterial
  101530. * @param mesh defines the mesh that will be rendered
  101531. * @param subMesh defines the submesh that will be rendered
  101532. */
  101533. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101534. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  101535. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  101536. protected _writeFloat(value: number): string;
  101537. /**
  101538. * Gets the current class name e.g. "NodeMaterialBlock"
  101539. * @returns the class name
  101540. */
  101541. getClassName(): string;
  101542. /**
  101543. * Register a new input. Must be called inside a block constructor
  101544. * @param name defines the connection point name
  101545. * @param type defines the connection point type
  101546. * @param isOptional defines a boolean indicating that this input can be omitted
  101547. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101548. * @param point an already created connection point. If not provided, create a new one
  101549. * @returns the current block
  101550. */
  101551. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  101552. /**
  101553. * Register a new output. Must be called inside a block constructor
  101554. * @param name defines the connection point name
  101555. * @param type defines the connection point type
  101556. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101557. * @param point an already created connection point. If not provided, create a new one
  101558. * @returns the current block
  101559. */
  101560. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  101561. /**
  101562. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  101563. * @param forOutput defines an optional connection point to check compatibility with
  101564. * @returns the first available input or null
  101565. */
  101566. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  101567. /**
  101568. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  101569. * @param forBlock defines an optional block to check compatibility with
  101570. * @returns the first available input or null
  101571. */
  101572. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  101573. /**
  101574. * Gets the sibling of the given output
  101575. * @param current defines the current output
  101576. * @returns the next output in the list or null
  101577. */
  101578. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  101579. /**
  101580. * Connect current block with another block
  101581. * @param other defines the block to connect with
  101582. * @param options define the various options to help pick the right connections
  101583. * @returns the current block
  101584. */
  101585. connectTo(other: NodeMaterialBlock, options?: {
  101586. input?: string;
  101587. output?: string;
  101588. outputSwizzle?: string;
  101589. }): this | undefined;
  101590. protected _buildBlock(state: NodeMaterialBuildState): void;
  101591. /**
  101592. * Add uniforms, samplers and uniform buffers at compilation time
  101593. * @param state defines the state to update
  101594. * @param nodeMaterial defines the node material requesting the update
  101595. * @param defines defines the material defines to update
  101596. * @param uniformBuffers defines the list of uniform buffer names
  101597. */
  101598. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  101599. /**
  101600. * Add potential fallbacks if shader compilation fails
  101601. * @param mesh defines the mesh to be rendered
  101602. * @param fallbacks defines the current prioritized list of fallbacks
  101603. */
  101604. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  101605. /**
  101606. * Initialize defines for shader compilation
  101607. * @param mesh defines the mesh to be rendered
  101608. * @param nodeMaterial defines the node material requesting the update
  101609. * @param defines defines the material defines to update
  101610. * @param useInstances specifies that instances should be used
  101611. */
  101612. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101613. /**
  101614. * Update defines for shader compilation
  101615. * @param mesh defines the mesh to be rendered
  101616. * @param nodeMaterial defines the node material requesting the update
  101617. * @param defines defines the material defines to update
  101618. * @param useInstances specifies that instances should be used
  101619. * @param subMesh defines which submesh to render
  101620. */
  101621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  101622. /**
  101623. * Lets the block try to connect some inputs automatically
  101624. * @param material defines the hosting NodeMaterial
  101625. */
  101626. autoConfigure(material: NodeMaterial): void;
  101627. /**
  101628. * Function called when a block is declared as repeatable content generator
  101629. * @param vertexShaderState defines the current compilation state for the vertex shader
  101630. * @param fragmentShaderState defines the current compilation state for the fragment shader
  101631. * @param mesh defines the mesh to be rendered
  101632. * @param defines defines the material defines to update
  101633. */
  101634. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  101635. /**
  101636. * Checks if the block is ready
  101637. * @param mesh defines the mesh to be rendered
  101638. * @param nodeMaterial defines the node material requesting the update
  101639. * @param defines defines the material defines to update
  101640. * @param useInstances specifies that instances should be used
  101641. * @returns true if the block is ready
  101642. */
  101643. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  101644. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  101645. private _processBuild;
  101646. /**
  101647. * Validates the new name for the block node.
  101648. * @param newName the new name to be given to the node.
  101649. * @returns false if the name is a reserve word, else true.
  101650. */
  101651. validateBlockName(newName: string): boolean;
  101652. /**
  101653. * Compile the current node and generate the shader code
  101654. * @param state defines the current compilation state (uniforms, samplers, current string)
  101655. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  101656. * @returns true if already built
  101657. */
  101658. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  101659. protected _inputRename(name: string): string;
  101660. protected _outputRename(name: string): string;
  101661. protected _dumpPropertiesCode(): string;
  101662. /** @hidden */
  101663. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  101664. /** @hidden */
  101665. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  101666. /**
  101667. * Clone the current block to a new identical block
  101668. * @param scene defines the hosting scene
  101669. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101670. * @returns a copy of the current block
  101671. */
  101672. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  101673. /**
  101674. * Serializes this block in a JSON representation
  101675. * @returns the serialized block object
  101676. */
  101677. serialize(): any;
  101678. /** @hidden */
  101679. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101680. private _deserializePortDisplayNamesAndExposedOnFrame;
  101681. /**
  101682. * Release resources
  101683. */
  101684. dispose(): void;
  101685. }
  101686. }
  101687. declare module BABYLON {
  101688. /**
  101689. * Base class of materials working in push mode in babylon JS
  101690. * @hidden
  101691. */
  101692. export class PushMaterial extends Material {
  101693. protected _activeEffect: Effect;
  101694. protected _normalMatrix: Matrix;
  101695. constructor(name: string, scene: Scene);
  101696. getEffect(): Effect;
  101697. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101698. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  101699. /**
  101700. * Binds the given world matrix to the active effect
  101701. *
  101702. * @param world the matrix to bind
  101703. */
  101704. bindOnlyWorldMatrix(world: Matrix): void;
  101705. /**
  101706. * Binds the given normal matrix to the active effect
  101707. *
  101708. * @param normalMatrix the matrix to bind
  101709. */
  101710. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101711. bind(world: Matrix, mesh?: Mesh): void;
  101712. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101713. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101714. }
  101715. }
  101716. declare module BABYLON {
  101717. /**
  101718. * Root class for all node material optimizers
  101719. */
  101720. export class NodeMaterialOptimizer {
  101721. /**
  101722. * Function used to optimize a NodeMaterial graph
  101723. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  101724. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  101725. */
  101726. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  101727. }
  101728. }
  101729. declare module BABYLON {
  101730. /**
  101731. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  101732. */
  101733. export class TransformBlock extends NodeMaterialBlock {
  101734. /**
  101735. * Defines the value to use to complement W value to transform it to a Vector4
  101736. */
  101737. complementW: number;
  101738. /**
  101739. * Defines the value to use to complement z value to transform it to a Vector4
  101740. */
  101741. complementZ: number;
  101742. /**
  101743. * Creates a new TransformBlock
  101744. * @param name defines the block name
  101745. */
  101746. constructor(name: string);
  101747. /**
  101748. * Gets the current class name
  101749. * @returns the class name
  101750. */
  101751. getClassName(): string;
  101752. /**
  101753. * Gets the vector input
  101754. */
  101755. get vector(): NodeMaterialConnectionPoint;
  101756. /**
  101757. * Gets the output component
  101758. */
  101759. get output(): NodeMaterialConnectionPoint;
  101760. /**
  101761. * Gets the xyz output component
  101762. */
  101763. get xyz(): NodeMaterialConnectionPoint;
  101764. /**
  101765. * Gets the matrix transform input
  101766. */
  101767. get transform(): NodeMaterialConnectionPoint;
  101768. protected _buildBlock(state: NodeMaterialBuildState): this;
  101769. /**
  101770. * Update defines for shader compilation
  101771. * @param mesh defines the mesh to be rendered
  101772. * @param nodeMaterial defines the node material requesting the update
  101773. * @param defines defines the material defines to update
  101774. * @param useInstances specifies that instances should be used
  101775. * @param subMesh defines which submesh to render
  101776. */
  101777. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  101778. serialize(): any;
  101779. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101780. protected _dumpPropertiesCode(): string;
  101781. }
  101782. }
  101783. declare module BABYLON {
  101784. /**
  101785. * Block used to output the vertex position
  101786. */
  101787. export class VertexOutputBlock extends NodeMaterialBlock {
  101788. /**
  101789. * Creates a new VertexOutputBlock
  101790. * @param name defines the block name
  101791. */
  101792. constructor(name: string);
  101793. /**
  101794. * Gets the current class name
  101795. * @returns the class name
  101796. */
  101797. getClassName(): string;
  101798. /**
  101799. * Gets the vector input component
  101800. */
  101801. get vector(): NodeMaterialConnectionPoint;
  101802. protected _buildBlock(state: NodeMaterialBuildState): this;
  101803. }
  101804. }
  101805. declare module BABYLON {
  101806. /**
  101807. * Block used to output the final color
  101808. */
  101809. export class FragmentOutputBlock extends NodeMaterialBlock {
  101810. /**
  101811. * Create a new FragmentOutputBlock
  101812. * @param name defines the block name
  101813. */
  101814. constructor(name: string);
  101815. /**
  101816. * Gets the current class name
  101817. * @returns the class name
  101818. */
  101819. getClassName(): string;
  101820. /**
  101821. * Gets the rgba input component
  101822. */
  101823. get rgba(): NodeMaterialConnectionPoint;
  101824. /**
  101825. * Gets the rgb input component
  101826. */
  101827. get rgb(): NodeMaterialConnectionPoint;
  101828. /**
  101829. * Gets the a input component
  101830. */
  101831. get a(): NodeMaterialConnectionPoint;
  101832. protected _buildBlock(state: NodeMaterialBuildState): this;
  101833. }
  101834. }
  101835. declare module BABYLON {
  101836. /**
  101837. * Block used for the particle ramp gradient section
  101838. */
  101839. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  101840. /**
  101841. * Create a new ParticleRampGradientBlock
  101842. * @param name defines the block name
  101843. */
  101844. constructor(name: string);
  101845. /**
  101846. * Gets the current class name
  101847. * @returns the class name
  101848. */
  101849. getClassName(): string;
  101850. /**
  101851. * Gets the color input component
  101852. */
  101853. get color(): NodeMaterialConnectionPoint;
  101854. /**
  101855. * Gets the rampColor output component
  101856. */
  101857. get rampColor(): NodeMaterialConnectionPoint;
  101858. /**
  101859. * Initialize the block and prepare the context for build
  101860. * @param state defines the state that will be used for the build
  101861. */
  101862. initialize(state: NodeMaterialBuildState): void;
  101863. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101864. }
  101865. }
  101866. declare module BABYLON {
  101867. /**
  101868. * Block used for the particle blend multiply section
  101869. */
  101870. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  101871. /**
  101872. * Create a new ParticleBlendMultiplyBlock
  101873. * @param name defines the block name
  101874. */
  101875. constructor(name: string);
  101876. /**
  101877. * Gets the current class name
  101878. * @returns the class name
  101879. */
  101880. getClassName(): string;
  101881. /**
  101882. * Gets the color input component
  101883. */
  101884. get color(): NodeMaterialConnectionPoint;
  101885. /**
  101886. * Gets the alphaTexture input component
  101887. */
  101888. get alphaTexture(): NodeMaterialConnectionPoint;
  101889. /**
  101890. * Gets the alphaColor input component
  101891. */
  101892. get alphaColor(): NodeMaterialConnectionPoint;
  101893. /**
  101894. * Gets the blendColor output component
  101895. */
  101896. get blendColor(): NodeMaterialConnectionPoint;
  101897. /**
  101898. * Initialize the block and prepare the context for build
  101899. * @param state defines the state that will be used for the build
  101900. */
  101901. initialize(state: NodeMaterialBuildState): void;
  101902. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101903. }
  101904. }
  101905. declare module BABYLON {
  101906. /**
  101907. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  101908. */
  101909. export class VectorMergerBlock extends NodeMaterialBlock {
  101910. /**
  101911. * Create a new VectorMergerBlock
  101912. * @param name defines the block name
  101913. */
  101914. constructor(name: string);
  101915. /**
  101916. * Gets the current class name
  101917. * @returns the class name
  101918. */
  101919. getClassName(): string;
  101920. /**
  101921. * Gets the xyz component (input)
  101922. */
  101923. get xyzIn(): NodeMaterialConnectionPoint;
  101924. /**
  101925. * Gets the xy component (input)
  101926. */
  101927. get xyIn(): NodeMaterialConnectionPoint;
  101928. /**
  101929. * Gets the x component (input)
  101930. */
  101931. get x(): NodeMaterialConnectionPoint;
  101932. /**
  101933. * Gets the y component (input)
  101934. */
  101935. get y(): NodeMaterialConnectionPoint;
  101936. /**
  101937. * Gets the z component (input)
  101938. */
  101939. get z(): NodeMaterialConnectionPoint;
  101940. /**
  101941. * Gets the w component (input)
  101942. */
  101943. get w(): NodeMaterialConnectionPoint;
  101944. /**
  101945. * Gets the xyzw component (output)
  101946. */
  101947. get xyzw(): NodeMaterialConnectionPoint;
  101948. /**
  101949. * Gets the xyz component (output)
  101950. */
  101951. get xyzOut(): NodeMaterialConnectionPoint;
  101952. /**
  101953. * Gets the xy component (output)
  101954. */
  101955. get xyOut(): NodeMaterialConnectionPoint;
  101956. /**
  101957. * Gets the xy component (output)
  101958. * @deprecated Please use xyOut instead.
  101959. */
  101960. get xy(): NodeMaterialConnectionPoint;
  101961. /**
  101962. * Gets the xyz component (output)
  101963. * @deprecated Please use xyzOut instead.
  101964. */
  101965. get xyz(): NodeMaterialConnectionPoint;
  101966. protected _buildBlock(state: NodeMaterialBuildState): this;
  101967. }
  101968. }
  101969. declare module BABYLON {
  101970. /**
  101971. * Block used to remap a float from a range to a new one
  101972. */
  101973. export class RemapBlock extends NodeMaterialBlock {
  101974. /**
  101975. * Gets or sets the source range
  101976. */
  101977. sourceRange: Vector2;
  101978. /**
  101979. * Gets or sets the target range
  101980. */
  101981. targetRange: Vector2;
  101982. /**
  101983. * Creates a new RemapBlock
  101984. * @param name defines the block name
  101985. */
  101986. constructor(name: string);
  101987. /**
  101988. * Gets the current class name
  101989. * @returns the class name
  101990. */
  101991. getClassName(): string;
  101992. /**
  101993. * Gets the input component
  101994. */
  101995. get input(): NodeMaterialConnectionPoint;
  101996. /**
  101997. * Gets the source min input component
  101998. */
  101999. get sourceMin(): NodeMaterialConnectionPoint;
  102000. /**
  102001. * Gets the source max input component
  102002. */
  102003. get sourceMax(): NodeMaterialConnectionPoint;
  102004. /**
  102005. * Gets the target min input component
  102006. */
  102007. get targetMin(): NodeMaterialConnectionPoint;
  102008. /**
  102009. * Gets the target max input component
  102010. */
  102011. get targetMax(): NodeMaterialConnectionPoint;
  102012. /**
  102013. * Gets the output component
  102014. */
  102015. get output(): NodeMaterialConnectionPoint;
  102016. protected _buildBlock(state: NodeMaterialBuildState): this;
  102017. protected _dumpPropertiesCode(): string;
  102018. serialize(): any;
  102019. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102020. }
  102021. }
  102022. declare module BABYLON {
  102023. /**
  102024. * Block used to multiply 2 values
  102025. */
  102026. export class MultiplyBlock extends NodeMaterialBlock {
  102027. /**
  102028. * Creates a new MultiplyBlock
  102029. * @param name defines the block name
  102030. */
  102031. constructor(name: string);
  102032. /**
  102033. * Gets the current class name
  102034. * @returns the class name
  102035. */
  102036. getClassName(): string;
  102037. /**
  102038. * Gets the left operand input component
  102039. */
  102040. get left(): NodeMaterialConnectionPoint;
  102041. /**
  102042. * Gets the right operand input component
  102043. */
  102044. get right(): NodeMaterialConnectionPoint;
  102045. /**
  102046. * Gets the output component
  102047. */
  102048. get output(): NodeMaterialConnectionPoint;
  102049. protected _buildBlock(state: NodeMaterialBuildState): this;
  102050. }
  102051. }
  102052. declare module BABYLON {
  102053. /**
  102054. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102055. */
  102056. export class ColorSplitterBlock extends NodeMaterialBlock {
  102057. /**
  102058. * Create a new ColorSplitterBlock
  102059. * @param name defines the block name
  102060. */
  102061. constructor(name: string);
  102062. /**
  102063. * Gets the current class name
  102064. * @returns the class name
  102065. */
  102066. getClassName(): string;
  102067. /**
  102068. * Gets the rgba component (input)
  102069. */
  102070. get rgba(): NodeMaterialConnectionPoint;
  102071. /**
  102072. * Gets the rgb component (input)
  102073. */
  102074. get rgbIn(): NodeMaterialConnectionPoint;
  102075. /**
  102076. * Gets the rgb component (output)
  102077. */
  102078. get rgbOut(): NodeMaterialConnectionPoint;
  102079. /**
  102080. * Gets the r component (output)
  102081. */
  102082. get r(): NodeMaterialConnectionPoint;
  102083. /**
  102084. * Gets the g component (output)
  102085. */
  102086. get g(): NodeMaterialConnectionPoint;
  102087. /**
  102088. * Gets the b component (output)
  102089. */
  102090. get b(): NodeMaterialConnectionPoint;
  102091. /**
  102092. * Gets the a component (output)
  102093. */
  102094. get a(): NodeMaterialConnectionPoint;
  102095. protected _inputRename(name: string): string;
  102096. protected _outputRename(name: string): string;
  102097. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102098. }
  102099. }
  102100. declare module BABYLON {
  102101. /**
  102102. * Interface used to configure the node material editor
  102103. */
  102104. export interface INodeMaterialEditorOptions {
  102105. /** Define the URl to load node editor script */
  102106. editorURL?: string;
  102107. }
  102108. /** @hidden */
  102109. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102110. NORMAL: boolean;
  102111. TANGENT: boolean;
  102112. UV1: boolean;
  102113. /** BONES */
  102114. NUM_BONE_INFLUENCERS: number;
  102115. BonesPerMesh: number;
  102116. BONETEXTURE: boolean;
  102117. /** MORPH TARGETS */
  102118. MORPHTARGETS: boolean;
  102119. MORPHTARGETS_NORMAL: boolean;
  102120. MORPHTARGETS_TANGENT: boolean;
  102121. MORPHTARGETS_UV: boolean;
  102122. NUM_MORPH_INFLUENCERS: number;
  102123. /** IMAGE PROCESSING */
  102124. IMAGEPROCESSING: boolean;
  102125. VIGNETTE: boolean;
  102126. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102127. VIGNETTEBLENDMODEOPAQUE: boolean;
  102128. TONEMAPPING: boolean;
  102129. TONEMAPPING_ACES: boolean;
  102130. CONTRAST: boolean;
  102131. EXPOSURE: boolean;
  102132. COLORCURVES: boolean;
  102133. COLORGRADING: boolean;
  102134. COLORGRADING3D: boolean;
  102135. SAMPLER3DGREENDEPTH: boolean;
  102136. SAMPLER3DBGRMAP: boolean;
  102137. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102138. /** MISC. */
  102139. BUMPDIRECTUV: number;
  102140. constructor();
  102141. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102142. }
  102143. /**
  102144. * Class used to configure NodeMaterial
  102145. */
  102146. export interface INodeMaterialOptions {
  102147. /**
  102148. * Defines if blocks should emit comments
  102149. */
  102150. emitComments: boolean;
  102151. }
  102152. /**
  102153. * Class used to create a node based material built by assembling shader blocks
  102154. */
  102155. export class NodeMaterial extends PushMaterial {
  102156. private static _BuildIdGenerator;
  102157. private _options;
  102158. private _vertexCompilationState;
  102159. private _fragmentCompilationState;
  102160. private _sharedData;
  102161. private _buildId;
  102162. private _buildWasSuccessful;
  102163. private _cachedWorldViewMatrix;
  102164. private _cachedWorldViewProjectionMatrix;
  102165. private _optimizers;
  102166. private _animationFrame;
  102167. /** Define the Url to load node editor script */
  102168. static EditorURL: string;
  102169. /** Define the Url to load snippets */
  102170. static SnippetUrl: string;
  102171. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102172. static IgnoreTexturesAtLoadTime: boolean;
  102173. private BJSNODEMATERIALEDITOR;
  102174. /** Get the inspector from bundle or global */
  102175. private _getGlobalNodeMaterialEditor;
  102176. /**
  102177. * Snippet ID if the material was created from the snippet server
  102178. */
  102179. snippetId: string;
  102180. /**
  102181. * Gets or sets data used by visual editor
  102182. * @see https://nme.babylonjs.com
  102183. */
  102184. editorData: any;
  102185. /**
  102186. * 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)
  102187. */
  102188. ignoreAlpha: boolean;
  102189. /**
  102190. * Defines the maximum number of lights that can be used in the material
  102191. */
  102192. maxSimultaneousLights: number;
  102193. /**
  102194. * Observable raised when the material is built
  102195. */
  102196. onBuildObservable: Observable<NodeMaterial>;
  102197. /**
  102198. * Gets or sets the root nodes of the material vertex shader
  102199. */
  102200. _vertexOutputNodes: NodeMaterialBlock[];
  102201. /**
  102202. * Gets or sets the root nodes of the material fragment (pixel) shader
  102203. */
  102204. _fragmentOutputNodes: NodeMaterialBlock[];
  102205. /** Gets or sets options to control the node material overall behavior */
  102206. get options(): INodeMaterialOptions;
  102207. set options(options: INodeMaterialOptions);
  102208. /**
  102209. * Default configuration related to image processing available in the standard Material.
  102210. */
  102211. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102212. /**
  102213. * Gets the image processing configuration used either in this material.
  102214. */
  102215. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102216. /**
  102217. * Sets the Default image processing configuration used either in the this material.
  102218. *
  102219. * If sets to null, the scene one is in use.
  102220. */
  102221. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102222. /**
  102223. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  102224. */
  102225. attachedBlocks: NodeMaterialBlock[];
  102226. /**
  102227. * Specifies the mode of the node material
  102228. * @hidden
  102229. */
  102230. _mode: NodeMaterialModes;
  102231. /**
  102232. * Gets the mode property
  102233. */
  102234. get mode(): NodeMaterialModes;
  102235. /**
  102236. * Create a new node based material
  102237. * @param name defines the material name
  102238. * @param scene defines the hosting scene
  102239. * @param options defines creation option
  102240. */
  102241. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  102242. /**
  102243. * Gets the current class name of the material e.g. "NodeMaterial"
  102244. * @returns the class name
  102245. */
  102246. getClassName(): string;
  102247. /**
  102248. * Keep track of the image processing observer to allow dispose and replace.
  102249. */
  102250. private _imageProcessingObserver;
  102251. /**
  102252. * Attaches a new image processing configuration to the Standard Material.
  102253. * @param configuration
  102254. */
  102255. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102256. /**
  102257. * Get a block by its name
  102258. * @param name defines the name of the block to retrieve
  102259. * @returns the required block or null if not found
  102260. */
  102261. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  102262. /**
  102263. * Get a block by its name
  102264. * @param predicate defines the predicate used to find the good candidate
  102265. * @returns the required block or null if not found
  102266. */
  102267. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  102268. /**
  102269. * Get an input block by its name
  102270. * @param predicate defines the predicate used to find the good candidate
  102271. * @returns the required input block or null if not found
  102272. */
  102273. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  102274. /**
  102275. * Gets the list of input blocks attached to this material
  102276. * @returns an array of InputBlocks
  102277. */
  102278. getInputBlocks(): InputBlock[];
  102279. /**
  102280. * Adds a new optimizer to the list of optimizers
  102281. * @param optimizer defines the optimizers to add
  102282. * @returns the current material
  102283. */
  102284. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102285. /**
  102286. * Remove an optimizer from the list of optimizers
  102287. * @param optimizer defines the optimizers to remove
  102288. * @returns the current material
  102289. */
  102290. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102291. /**
  102292. * Add a new block to the list of output nodes
  102293. * @param node defines the node to add
  102294. * @returns the current material
  102295. */
  102296. addOutputNode(node: NodeMaterialBlock): this;
  102297. /**
  102298. * Remove a block from the list of root nodes
  102299. * @param node defines the node to remove
  102300. * @returns the current material
  102301. */
  102302. removeOutputNode(node: NodeMaterialBlock): this;
  102303. private _addVertexOutputNode;
  102304. private _removeVertexOutputNode;
  102305. private _addFragmentOutputNode;
  102306. private _removeFragmentOutputNode;
  102307. /**
  102308. * Specifies if the material will require alpha blending
  102309. * @returns a boolean specifying if alpha blending is needed
  102310. */
  102311. needAlphaBlending(): boolean;
  102312. /**
  102313. * Specifies if this material should be rendered in alpha test mode
  102314. * @returns a boolean specifying if an alpha test is needed.
  102315. */
  102316. needAlphaTesting(): boolean;
  102317. private _initializeBlock;
  102318. private _resetDualBlocks;
  102319. /**
  102320. * Remove a block from the current node material
  102321. * @param block defines the block to remove
  102322. */
  102323. removeBlock(block: NodeMaterialBlock): void;
  102324. /**
  102325. * Build the material and generates the inner effect
  102326. * @param verbose defines if the build should log activity
  102327. */
  102328. build(verbose?: boolean): void;
  102329. /**
  102330. * Runs an otpimization phase to try to improve the shader code
  102331. */
  102332. optimize(): void;
  102333. private _prepareDefinesForAttributes;
  102334. /**
  102335. * Create a post process from the material
  102336. * @param camera The camera to apply the render pass to.
  102337. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102339. * @param engine The engine which the post process will be applied. (default: current engine)
  102340. * @param reusable If the post process can be reused on the same frame. (default: false)
  102341. * @param textureType Type of textures used when performing the post process. (default: 0)
  102342. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102343. * @returns the post process created
  102344. */
  102345. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  102346. /**
  102347. * Create the post process effect from the material
  102348. * @param postProcess The post process to create the effect for
  102349. */
  102350. createEffectForPostProcess(postProcess: PostProcess): void;
  102351. private _createEffectOrPostProcess;
  102352. private _createEffectForParticles;
  102353. /**
  102354. * Create the effect to be used as the custom effect for a particle system
  102355. * @param particleSystem Particle system to create the effect for
  102356. * @param onCompiled defines a function to call when the effect creation is successful
  102357. * @param onError defines a function to call when the effect creation has failed
  102358. */
  102359. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102360. private _processDefines;
  102361. /**
  102362. * Get if the submesh is ready to be used and all its information available.
  102363. * Child classes can use it to update shaders
  102364. * @param mesh defines the mesh to check
  102365. * @param subMesh defines which submesh to check
  102366. * @param useInstances specifies that instances should be used
  102367. * @returns a boolean indicating that the submesh is ready or not
  102368. */
  102369. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102370. /**
  102371. * Get a string representing the shaders built by the current node graph
  102372. */
  102373. get compiledShaders(): string;
  102374. /**
  102375. * Binds the world matrix to the material
  102376. * @param world defines the world transformation matrix
  102377. */
  102378. bindOnlyWorldMatrix(world: Matrix): void;
  102379. /**
  102380. * Binds the submesh to this material by preparing the effect and shader to draw
  102381. * @param world defines the world transformation matrix
  102382. * @param mesh defines the mesh containing the submesh
  102383. * @param subMesh defines the submesh to bind the material to
  102384. */
  102385. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102386. /**
  102387. * Gets the active textures from the material
  102388. * @returns an array of textures
  102389. */
  102390. getActiveTextures(): BaseTexture[];
  102391. /**
  102392. * Gets the list of texture blocks
  102393. * @returns an array of texture blocks
  102394. */
  102395. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102396. /**
  102397. * Specifies if the material uses a texture
  102398. * @param texture defines the texture to check against the material
  102399. * @returns a boolean specifying if the material uses the texture
  102400. */
  102401. hasTexture(texture: BaseTexture): boolean;
  102402. /**
  102403. * Disposes the material
  102404. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102405. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102406. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102407. */
  102408. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102409. /** Creates the node editor window. */
  102410. private _createNodeEditor;
  102411. /**
  102412. * Launch the node material editor
  102413. * @param config Define the configuration of the editor
  102414. * @return a promise fulfilled when the node editor is visible
  102415. */
  102416. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  102417. /**
  102418. * Clear the current material
  102419. */
  102420. clear(): void;
  102421. /**
  102422. * Clear the current material and set it to a default state
  102423. */
  102424. setToDefault(): void;
  102425. /**
  102426. * Clear the current material and set it to a default state for post process
  102427. */
  102428. setToDefaultPostProcess(): void;
  102429. /**
  102430. * Clear the current material and set it to a default state for particle
  102431. */
  102432. setToDefaultParticle(): void;
  102433. /**
  102434. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  102435. * @param url defines the url to load from
  102436. * @returns a promise that will fullfil when the material is fully loaded
  102437. */
  102438. loadAsync(url: string): Promise<void>;
  102439. private _gatherBlocks;
  102440. /**
  102441. * Generate a string containing the code declaration required to create an equivalent of this material
  102442. * @returns a string
  102443. */
  102444. generateCode(): string;
  102445. /**
  102446. * Serializes this material in a JSON representation
  102447. * @returns the serialized material object
  102448. */
  102449. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  102450. private _restoreConnections;
  102451. /**
  102452. * Clear the current graph and load a new one from a serialization object
  102453. * @param source defines the JSON representation of the material
  102454. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102455. * @param merge defines whether or not the source must be merged or replace the current content
  102456. */
  102457. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  102458. /**
  102459. * Makes a duplicate of the current material.
  102460. * @param name - name to use for the new material.
  102461. */
  102462. clone(name: string): NodeMaterial;
  102463. /**
  102464. * Creates a node material from parsed material data
  102465. * @param source defines the JSON representation of the material
  102466. * @param scene defines the hosting scene
  102467. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102468. * @returns a new node material
  102469. */
  102470. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  102471. /**
  102472. * Creates a node material from a snippet saved in a remote file
  102473. * @param name defines the name of the material to create
  102474. * @param url defines the url to load from
  102475. * @param scene defines the hosting scene
  102476. * @returns a promise that will resolve to the new node material
  102477. */
  102478. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  102479. /**
  102480. * Creates a node material from a snippet saved by the node material editor
  102481. * @param snippetId defines the snippet to load
  102482. * @param scene defines the hosting scene
  102483. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102484. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  102485. * @returns a promise that will resolve to the new node material
  102486. */
  102487. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  102488. /**
  102489. * Creates a new node material set to default basic configuration
  102490. * @param name defines the name of the material
  102491. * @param scene defines the hosting scene
  102492. * @returns a new NodeMaterial
  102493. */
  102494. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  102495. }
  102496. }
  102497. declare module BABYLON {
  102498. /**
  102499. * Size options for a post process
  102500. */
  102501. export type PostProcessOptions = {
  102502. width: number;
  102503. height: number;
  102504. };
  102505. /**
  102506. * PostProcess can be used to apply a shader to a texture after it has been rendered
  102507. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  102508. */
  102509. export class PostProcess {
  102510. /**
  102511. * Gets or sets the unique id of the post process
  102512. */
  102513. uniqueId: number;
  102514. /** Name of the PostProcess. */
  102515. name: string;
  102516. /**
  102517. * Width of the texture to apply the post process on
  102518. */
  102519. width: number;
  102520. /**
  102521. * Height of the texture to apply the post process on
  102522. */
  102523. height: number;
  102524. /**
  102525. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  102526. */
  102527. nodeMaterialSource: Nullable<NodeMaterial>;
  102528. /**
  102529. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  102530. * @hidden
  102531. */
  102532. _outputTexture: Nullable<InternalTexture>;
  102533. /**
  102534. * Sampling mode used by the shader
  102535. * See https://doc.babylonjs.com/classes/3.1/texture
  102536. */
  102537. renderTargetSamplingMode: number;
  102538. /**
  102539. * Clear color to use when screen clearing
  102540. */
  102541. clearColor: Color4;
  102542. /**
  102543. * If the buffer needs to be cleared before applying the post process. (default: true)
  102544. * Should be set to false if shader will overwrite all previous pixels.
  102545. */
  102546. autoClear: boolean;
  102547. /**
  102548. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  102549. */
  102550. alphaMode: number;
  102551. /**
  102552. * Sets the setAlphaBlendConstants of the babylon engine
  102553. */
  102554. alphaConstants: Color4;
  102555. /**
  102556. * Animations to be used for the post processing
  102557. */
  102558. animations: Animation[];
  102559. /**
  102560. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  102561. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  102562. */
  102563. enablePixelPerfectMode: boolean;
  102564. /**
  102565. * Force the postprocess to be applied without taking in account viewport
  102566. */
  102567. forceFullscreenViewport: boolean;
  102568. /**
  102569. * List of inspectable custom properties (used by the Inspector)
  102570. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102571. */
  102572. inspectableCustomProperties: IInspectable[];
  102573. /**
  102574. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  102575. *
  102576. * | Value | Type | Description |
  102577. * | ----- | ----------------------------------- | ----------- |
  102578. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  102579. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  102580. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  102581. *
  102582. */
  102583. scaleMode: number;
  102584. /**
  102585. * Force textures to be a power of two (default: false)
  102586. */
  102587. alwaysForcePOT: boolean;
  102588. private _samples;
  102589. /**
  102590. * Number of sample textures (default: 1)
  102591. */
  102592. get samples(): number;
  102593. set samples(n: number);
  102594. /**
  102595. * Modify the scale of the post process to be the same as the viewport (default: false)
  102596. */
  102597. adaptScaleToCurrentViewport: boolean;
  102598. private _camera;
  102599. protected _scene: Scene;
  102600. private _engine;
  102601. private _options;
  102602. private _reusable;
  102603. private _textureType;
  102604. private _textureFormat;
  102605. /**
  102606. * Smart array of input and output textures for the post process.
  102607. * @hidden
  102608. */
  102609. _textures: SmartArray<InternalTexture>;
  102610. /**
  102611. * The index in _textures that corresponds to the output texture.
  102612. * @hidden
  102613. */
  102614. _currentRenderTextureInd: number;
  102615. private _effect;
  102616. private _samplers;
  102617. private _fragmentUrl;
  102618. private _vertexUrl;
  102619. private _parameters;
  102620. private _scaleRatio;
  102621. protected _indexParameters: any;
  102622. private _shareOutputWithPostProcess;
  102623. private _texelSize;
  102624. private _forcedOutputTexture;
  102625. /**
  102626. * Returns the fragment url or shader name used in the post process.
  102627. * @returns the fragment url or name in the shader store.
  102628. */
  102629. getEffectName(): string;
  102630. /**
  102631. * An event triggered when the postprocess is activated.
  102632. */
  102633. onActivateObservable: Observable<Camera>;
  102634. private _onActivateObserver;
  102635. /**
  102636. * A function that is added to the onActivateObservable
  102637. */
  102638. set onActivate(callback: Nullable<(camera: Camera) => void>);
  102639. /**
  102640. * An event triggered when the postprocess changes its size.
  102641. */
  102642. onSizeChangedObservable: Observable<PostProcess>;
  102643. private _onSizeChangedObserver;
  102644. /**
  102645. * A function that is added to the onSizeChangedObservable
  102646. */
  102647. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  102648. /**
  102649. * An event triggered when the postprocess applies its effect.
  102650. */
  102651. onApplyObservable: Observable<Effect>;
  102652. private _onApplyObserver;
  102653. /**
  102654. * A function that is added to the onApplyObservable
  102655. */
  102656. set onApply(callback: (effect: Effect) => void);
  102657. /**
  102658. * An event triggered before rendering the postprocess
  102659. */
  102660. onBeforeRenderObservable: Observable<Effect>;
  102661. private _onBeforeRenderObserver;
  102662. /**
  102663. * A function that is added to the onBeforeRenderObservable
  102664. */
  102665. set onBeforeRender(callback: (effect: Effect) => void);
  102666. /**
  102667. * An event triggered after rendering the postprocess
  102668. */
  102669. onAfterRenderObservable: Observable<Effect>;
  102670. private _onAfterRenderObserver;
  102671. /**
  102672. * A function that is added to the onAfterRenderObservable
  102673. */
  102674. set onAfterRender(callback: (efect: Effect) => void);
  102675. /**
  102676. * 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
  102677. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  102678. */
  102679. get inputTexture(): InternalTexture;
  102680. set inputTexture(value: InternalTexture);
  102681. /**
  102682. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  102683. * the only way to unset it is to use this function to restore its internal state
  102684. */
  102685. restoreDefaultInputTexture(): void;
  102686. /**
  102687. * Gets the camera which post process is applied to.
  102688. * @returns The camera the post process is applied to.
  102689. */
  102690. getCamera(): Camera;
  102691. /**
  102692. * Gets the texel size of the postprocess.
  102693. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  102694. */
  102695. get texelSize(): Vector2;
  102696. /**
  102697. * Creates a new instance PostProcess
  102698. * @param name The name of the PostProcess.
  102699. * @param fragmentUrl The url of the fragment shader to be used.
  102700. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  102701. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  102702. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102703. * @param camera The camera to apply the render pass to.
  102704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102705. * @param engine The engine which the post process will be applied. (default: current engine)
  102706. * @param reusable If the post process can be reused on the same frame. (default: false)
  102707. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  102708. * @param textureType Type of textures used when performing the post process. (default: 0)
  102709. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  102710. * @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
  102711. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  102712. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102713. */
  102714. 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);
  102715. /**
  102716. * Gets a string identifying the name of the class
  102717. * @returns "PostProcess" string
  102718. */
  102719. getClassName(): string;
  102720. /**
  102721. * Gets the engine which this post process belongs to.
  102722. * @returns The engine the post process was enabled with.
  102723. */
  102724. getEngine(): Engine;
  102725. /**
  102726. * The effect that is created when initializing the post process.
  102727. * @returns The created effect corresponding the the postprocess.
  102728. */
  102729. getEffect(): Effect;
  102730. /**
  102731. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  102732. * @param postProcess The post process to share the output with.
  102733. * @returns This post process.
  102734. */
  102735. shareOutputWith(postProcess: PostProcess): PostProcess;
  102736. /**
  102737. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  102738. * This should be called if the post process that shares output with this post process is disabled/disposed.
  102739. */
  102740. useOwnOutput(): void;
  102741. /**
  102742. * Updates the effect with the current post process compile time values and recompiles the shader.
  102743. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  102744. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  102745. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  102746. * @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
  102747. * @param onCompiled Called when the shader has been compiled.
  102748. * @param onError Called if there is an error when compiling a shader.
  102749. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  102750. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  102751. */
  102752. 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;
  102753. /**
  102754. * The post process is reusable if it can be used multiple times within one frame.
  102755. * @returns If the post process is reusable
  102756. */
  102757. isReusable(): boolean;
  102758. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  102759. markTextureDirty(): void;
  102760. /**
  102761. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  102762. * 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.
  102763. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  102764. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  102765. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  102766. * @returns The target texture that was bound to be written to.
  102767. */
  102768. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  102769. /**
  102770. * If the post process is supported.
  102771. */
  102772. get isSupported(): boolean;
  102773. /**
  102774. * The aspect ratio of the output texture.
  102775. */
  102776. get aspectRatio(): number;
  102777. /**
  102778. * Get a value indicating if the post-process is ready to be used
  102779. * @returns true if the post-process is ready (shader is compiled)
  102780. */
  102781. isReady(): boolean;
  102782. /**
  102783. * Binds all textures and uniforms to the shader, this will be run on every pass.
  102784. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  102785. */
  102786. apply(): Nullable<Effect>;
  102787. private _disposeTextures;
  102788. /**
  102789. * Disposes the post process.
  102790. * @param camera The camera to dispose the post process on.
  102791. */
  102792. dispose(camera?: Camera): void;
  102793. /**
  102794. * Serializes the particle system to a JSON object
  102795. * @returns the JSON object
  102796. */
  102797. serialize(): any;
  102798. /**
  102799. * Creates a material from parsed material data
  102800. * @param parsedPostProcess defines parsed post process data
  102801. * @param scene defines the hosting scene
  102802. * @param rootUrl defines the root URL to use to load textures
  102803. * @returns a new post process
  102804. */
  102805. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  102806. }
  102807. }
  102808. declare module BABYLON {
  102809. /** @hidden */
  102810. export var kernelBlurVaryingDeclaration: {
  102811. name: string;
  102812. shader: string;
  102813. };
  102814. }
  102815. declare module BABYLON {
  102816. /** @hidden */
  102817. export var kernelBlurFragment: {
  102818. name: string;
  102819. shader: string;
  102820. };
  102821. }
  102822. declare module BABYLON {
  102823. /** @hidden */
  102824. export var kernelBlurFragment2: {
  102825. name: string;
  102826. shader: string;
  102827. };
  102828. }
  102829. declare module BABYLON {
  102830. /** @hidden */
  102831. export var kernelBlurPixelShader: {
  102832. name: string;
  102833. shader: string;
  102834. };
  102835. }
  102836. declare module BABYLON {
  102837. /** @hidden */
  102838. export var kernelBlurVertex: {
  102839. name: string;
  102840. shader: string;
  102841. };
  102842. }
  102843. declare module BABYLON {
  102844. /** @hidden */
  102845. export var kernelBlurVertexShader: {
  102846. name: string;
  102847. shader: string;
  102848. };
  102849. }
  102850. declare module BABYLON {
  102851. /**
  102852. * The Blur Post Process which blurs an image based on a kernel and direction.
  102853. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  102854. */
  102855. export class BlurPostProcess extends PostProcess {
  102856. private blockCompilation;
  102857. protected _kernel: number;
  102858. protected _idealKernel: number;
  102859. protected _packedFloat: boolean;
  102860. private _staticDefines;
  102861. /** The direction in which to blur the image. */
  102862. direction: Vector2;
  102863. /**
  102864. * Sets the length in pixels of the blur sample region
  102865. */
  102866. set kernel(v: number);
  102867. /**
  102868. * Gets the length in pixels of the blur sample region
  102869. */
  102870. get kernel(): number;
  102871. /**
  102872. * Sets wether or not the blur needs to unpack/repack floats
  102873. */
  102874. set packedFloat(v: boolean);
  102875. /**
  102876. * Gets wether or not the blur is unpacking/repacking floats
  102877. */
  102878. get packedFloat(): boolean;
  102879. /**
  102880. * Gets a string identifying the name of the class
  102881. * @returns "BlurPostProcess" string
  102882. */
  102883. getClassName(): string;
  102884. /**
  102885. * Creates a new instance BlurPostProcess
  102886. * @param name The name of the effect.
  102887. * @param direction The direction in which to blur the image.
  102888. * @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.
  102889. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102890. * @param camera The camera to apply the render pass to.
  102891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102892. * @param engine The engine which the post process will be applied. (default: current engine)
  102893. * @param reusable If the post process can be reused on the same frame. (default: false)
  102894. * @param textureType Type of textures used when performing the post process. (default: 0)
  102895. * @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)
  102896. */
  102897. 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);
  102898. /**
  102899. * Updates the effect with the current post process compile time values and recompiles the shader.
  102900. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  102901. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  102902. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  102903. * @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
  102904. * @param onCompiled Called when the shader has been compiled.
  102905. * @param onError Called if there is an error when compiling a shader.
  102906. */
  102907. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102908. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102909. /**
  102910. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  102911. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  102912. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  102913. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  102914. * The gaps between physical kernels are compensated for in the weighting of the samples
  102915. * @param idealKernel Ideal blur kernel.
  102916. * @return Nearest best kernel.
  102917. */
  102918. protected _nearestBestKernel(idealKernel: number): number;
  102919. /**
  102920. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  102921. * @param x The point on the Gaussian distribution to sample.
  102922. * @return the value of the Gaussian function at x.
  102923. */
  102924. protected _gaussianWeight(x: number): number;
  102925. /**
  102926. * Generates a string that can be used as a floating point number in GLSL.
  102927. * @param x Value to print.
  102928. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  102929. * @return GLSL float string.
  102930. */
  102931. protected _glslFloat(x: number, decimalFigures?: number): string;
  102932. /** @hidden */
  102933. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  102934. }
  102935. }
  102936. declare module BABYLON {
  102937. /**
  102938. * Mirror texture can be used to simulate the view from a mirror in a scene.
  102939. * It will dynamically be rendered every frame to adapt to the camera point of view.
  102940. * You can then easily use it as a reflectionTexture on a flat surface.
  102941. * In case the surface is not a plane, please consider relying on reflection probes.
  102942. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102943. */
  102944. export class MirrorTexture extends RenderTargetTexture {
  102945. private scene;
  102946. /**
  102947. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  102948. * 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.
  102949. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102950. */
  102951. mirrorPlane: Plane;
  102952. /**
  102953. * Define the blur ratio used to blur the reflection if needed.
  102954. */
  102955. set blurRatio(value: number);
  102956. get blurRatio(): number;
  102957. /**
  102958. * Define the adaptive blur kernel used to blur the reflection if needed.
  102959. * This will autocompute the closest best match for the `blurKernel`
  102960. */
  102961. set adaptiveBlurKernel(value: number);
  102962. /**
  102963. * Define the blur kernel used to blur the reflection if needed.
  102964. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102965. */
  102966. set blurKernel(value: number);
  102967. /**
  102968. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  102969. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102970. */
  102971. set blurKernelX(value: number);
  102972. get blurKernelX(): number;
  102973. /**
  102974. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  102975. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102976. */
  102977. set blurKernelY(value: number);
  102978. get blurKernelY(): number;
  102979. private _autoComputeBlurKernel;
  102980. protected _onRatioRescale(): void;
  102981. private _updateGammaSpace;
  102982. private _imageProcessingConfigChangeObserver;
  102983. private _transformMatrix;
  102984. private _mirrorMatrix;
  102985. private _savedViewMatrix;
  102986. private _blurX;
  102987. private _blurY;
  102988. private _adaptiveBlurKernel;
  102989. private _blurKernelX;
  102990. private _blurKernelY;
  102991. private _blurRatio;
  102992. /**
  102993. * Instantiates a Mirror Texture.
  102994. * Mirror texture can be used to simulate the view from a mirror in a scene.
  102995. * It will dynamically be rendered every frame to adapt to the camera point of view.
  102996. * You can then easily use it as a reflectionTexture on a flat surface.
  102997. * In case the surface is not a plane, please consider relying on reflection probes.
  102998. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102999. * @param name
  103000. * @param size
  103001. * @param scene
  103002. * @param generateMipMaps
  103003. * @param type
  103004. * @param samplingMode
  103005. * @param generateDepthBuffer
  103006. */
  103007. constructor(name: string, size: number | {
  103008. width: number;
  103009. height: number;
  103010. } | {
  103011. ratio: number;
  103012. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  103013. private _preparePostProcesses;
  103014. /**
  103015. * Clone the mirror texture.
  103016. * @returns the cloned texture
  103017. */
  103018. clone(): MirrorTexture;
  103019. /**
  103020. * Serialize the texture to a JSON representation you could use in Parse later on
  103021. * @returns the serialized JSON representation
  103022. */
  103023. serialize(): any;
  103024. /**
  103025. * Dispose the texture and release its associated resources.
  103026. */
  103027. dispose(): void;
  103028. }
  103029. }
  103030. declare module BABYLON {
  103031. /**
  103032. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103033. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103034. */
  103035. export class Texture extends BaseTexture {
  103036. /**
  103037. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  103038. */
  103039. static SerializeBuffers: boolean;
  103040. /** @hidden */
  103041. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  103042. /** @hidden */
  103043. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  103044. /** @hidden */
  103045. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  103046. /** nearest is mag = nearest and min = nearest and mip = linear */
  103047. static readonly NEAREST_SAMPLINGMODE: number;
  103048. /** nearest is mag = nearest and min = nearest and mip = linear */
  103049. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  103050. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103051. static readonly BILINEAR_SAMPLINGMODE: number;
  103052. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103053. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  103054. /** Trilinear is mag = linear and min = linear and mip = linear */
  103055. static readonly TRILINEAR_SAMPLINGMODE: number;
  103056. /** Trilinear is mag = linear and min = linear and mip = linear */
  103057. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  103058. /** mag = nearest and min = nearest and mip = nearest */
  103059. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  103060. /** mag = nearest and min = linear and mip = nearest */
  103061. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  103062. /** mag = nearest and min = linear and mip = linear */
  103063. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  103064. /** mag = nearest and min = linear and mip = none */
  103065. static readonly NEAREST_LINEAR: number;
  103066. /** mag = nearest and min = nearest and mip = none */
  103067. static readonly NEAREST_NEAREST: number;
  103068. /** mag = linear and min = nearest and mip = nearest */
  103069. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  103070. /** mag = linear and min = nearest and mip = linear */
  103071. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  103072. /** mag = linear and min = linear and mip = none */
  103073. static readonly LINEAR_LINEAR: number;
  103074. /** mag = linear and min = nearest and mip = none */
  103075. static readonly LINEAR_NEAREST: number;
  103076. /** Explicit coordinates mode */
  103077. static readonly EXPLICIT_MODE: number;
  103078. /** Spherical coordinates mode */
  103079. static readonly SPHERICAL_MODE: number;
  103080. /** Planar coordinates mode */
  103081. static readonly PLANAR_MODE: number;
  103082. /** Cubic coordinates mode */
  103083. static readonly CUBIC_MODE: number;
  103084. /** Projection coordinates mode */
  103085. static readonly PROJECTION_MODE: number;
  103086. /** Inverse Cubic coordinates mode */
  103087. static readonly SKYBOX_MODE: number;
  103088. /** Inverse Cubic coordinates mode */
  103089. static readonly INVCUBIC_MODE: number;
  103090. /** Equirectangular coordinates mode */
  103091. static readonly EQUIRECTANGULAR_MODE: number;
  103092. /** Equirectangular Fixed coordinates mode */
  103093. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  103094. /** Equirectangular Fixed Mirrored coordinates mode */
  103095. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  103096. /** Texture is not repeating outside of 0..1 UVs */
  103097. static readonly CLAMP_ADDRESSMODE: number;
  103098. /** Texture is repeating outside of 0..1 UVs */
  103099. static readonly WRAP_ADDRESSMODE: number;
  103100. /** Texture is repeating and mirrored */
  103101. static readonly MIRROR_ADDRESSMODE: number;
  103102. /**
  103103. * 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
  103104. */
  103105. static UseSerializedUrlIfAny: boolean;
  103106. /**
  103107. * Define the url of the texture.
  103108. */
  103109. url: Nullable<string>;
  103110. /**
  103111. * Define an offset on the texture to offset the u coordinates of the UVs
  103112. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103113. */
  103114. uOffset: number;
  103115. /**
  103116. * Define an offset on the texture to offset the v coordinates of the UVs
  103117. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103118. */
  103119. vOffset: number;
  103120. /**
  103121. * Define an offset on the texture to scale the u coordinates of the UVs
  103122. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103123. */
  103124. uScale: number;
  103125. /**
  103126. * Define an offset on the texture to scale the v coordinates of the UVs
  103127. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103128. */
  103129. vScale: number;
  103130. /**
  103131. * Define an offset on the texture to rotate around the u coordinates of the UVs
  103132. * @see https://doc.babylonjs.com/how_to/more_materials
  103133. */
  103134. uAng: number;
  103135. /**
  103136. * Define an offset on the texture to rotate around the v coordinates of the UVs
  103137. * @see https://doc.babylonjs.com/how_to/more_materials
  103138. */
  103139. vAng: number;
  103140. /**
  103141. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  103142. * @see https://doc.babylonjs.com/how_to/more_materials
  103143. */
  103144. wAng: number;
  103145. /**
  103146. * Defines the center of rotation (U)
  103147. */
  103148. uRotationCenter: number;
  103149. /**
  103150. * Defines the center of rotation (V)
  103151. */
  103152. vRotationCenter: number;
  103153. /**
  103154. * Defines the center of rotation (W)
  103155. */
  103156. wRotationCenter: number;
  103157. /**
  103158. * Are mip maps generated for this texture or not.
  103159. */
  103160. get noMipmap(): boolean;
  103161. /**
  103162. * List of inspectable custom properties (used by the Inspector)
  103163. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103164. */
  103165. inspectableCustomProperties: Nullable<IInspectable[]>;
  103166. private _noMipmap;
  103167. /** @hidden */
  103168. _invertY: boolean;
  103169. private _rowGenerationMatrix;
  103170. private _cachedTextureMatrix;
  103171. private _projectionModeMatrix;
  103172. private _t0;
  103173. private _t1;
  103174. private _t2;
  103175. private _cachedUOffset;
  103176. private _cachedVOffset;
  103177. private _cachedUScale;
  103178. private _cachedVScale;
  103179. private _cachedUAng;
  103180. private _cachedVAng;
  103181. private _cachedWAng;
  103182. private _cachedProjectionMatrixId;
  103183. private _cachedCoordinatesMode;
  103184. /** @hidden */
  103185. protected _initialSamplingMode: number;
  103186. /** @hidden */
  103187. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  103188. private _deleteBuffer;
  103189. protected _format: Nullable<number>;
  103190. private _delayedOnLoad;
  103191. private _delayedOnError;
  103192. private _mimeType?;
  103193. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  103194. get mimeType(): string | undefined;
  103195. /**
  103196. * Observable triggered once the texture has been loaded.
  103197. */
  103198. onLoadObservable: Observable<Texture>;
  103199. protected _isBlocking: boolean;
  103200. /**
  103201. * Is the texture preventing material to render while loading.
  103202. * If false, a default texture will be used instead of the loading one during the preparation step.
  103203. */
  103204. set isBlocking(value: boolean);
  103205. get isBlocking(): boolean;
  103206. /**
  103207. * Get the current sampling mode associated with the texture.
  103208. */
  103209. get samplingMode(): number;
  103210. /**
  103211. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  103212. */
  103213. get invertY(): boolean;
  103214. /**
  103215. * Instantiates a new texture.
  103216. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103217. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103218. * @param url defines the url of the picture to load as a texture
  103219. * @param sceneOrEngine defines the scene or engine the texture will belong to
  103220. * @param noMipmap defines if the texture will require mip maps or not
  103221. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  103222. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103223. * @param onLoad defines a callback triggered when the texture has been loaded
  103224. * @param onError defines a callback triggered when an error occurred during the loading session
  103225. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  103226. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  103227. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103228. * @param mimeType defines an optional mime type information
  103229. */
  103230. 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);
  103231. /**
  103232. * Update the url (and optional buffer) of this texture if url was null during construction.
  103233. * @param url the url of the texture
  103234. * @param buffer the buffer of the texture (defaults to null)
  103235. * @param onLoad callback called when the texture is loaded (defaults to null)
  103236. */
  103237. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  103238. /**
  103239. * Finish the loading sequence of a texture flagged as delayed load.
  103240. * @hidden
  103241. */
  103242. delayLoad(): void;
  103243. private _prepareRowForTextureGeneration;
  103244. /**
  103245. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  103246. * @returns the transform matrix of the texture.
  103247. */
  103248. getTextureMatrix(uBase?: number): Matrix;
  103249. /**
  103250. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  103251. * @returns The reflection texture transform
  103252. */
  103253. getReflectionTextureMatrix(): Matrix;
  103254. /**
  103255. * Clones the texture.
  103256. * @returns the cloned texture
  103257. */
  103258. clone(): Texture;
  103259. /**
  103260. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103261. * @returns The JSON representation of the texture
  103262. */
  103263. serialize(): any;
  103264. /**
  103265. * Get the current class name of the texture useful for serialization or dynamic coding.
  103266. * @returns "Texture"
  103267. */
  103268. getClassName(): string;
  103269. /**
  103270. * Dispose the texture and release its associated resources.
  103271. */
  103272. dispose(): void;
  103273. /**
  103274. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  103275. * @param parsedTexture Define the JSON representation of the texture
  103276. * @param scene Define the scene the parsed texture should be instantiated in
  103277. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  103278. * @returns The parsed texture if successful
  103279. */
  103280. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  103281. /**
  103282. * Creates a texture from its base 64 representation.
  103283. * @param data Define the base64 payload without the data: prefix
  103284. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103285. * @param scene Define the scene the texture should belong to
  103286. * @param noMipmap Forces the texture to not create mip map information if true
  103287. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103288. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103289. * @param onLoad define a callback triggered when the texture has been loaded
  103290. * @param onError define a callback triggered when an error occurred during the loading session
  103291. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103292. * @returns the created texture
  103293. */
  103294. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  103295. /**
  103296. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  103297. * @param data Define the base64 payload without the data: prefix
  103298. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103299. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  103300. * @param scene Define the scene the texture should belong to
  103301. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  103302. * @param noMipmap Forces the texture to not create mip map information if true
  103303. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103304. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103305. * @param onLoad define a callback triggered when the texture has been loaded
  103306. * @param onError define a callback triggered when an error occurred during the loading session
  103307. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103308. * @returns the created texture
  103309. */
  103310. 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;
  103311. }
  103312. }
  103313. declare module BABYLON {
  103314. /**
  103315. * PostProcessManager is used to manage one or more post processes or post process pipelines
  103316. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103317. */
  103318. export class PostProcessManager {
  103319. private _scene;
  103320. private _indexBuffer;
  103321. private _vertexBuffers;
  103322. /**
  103323. * Creates a new instance PostProcess
  103324. * @param scene The scene that the post process is associated with.
  103325. */
  103326. constructor(scene: Scene);
  103327. private _prepareBuffers;
  103328. private _buildIndexBuffer;
  103329. /**
  103330. * Rebuilds the vertex buffers of the manager.
  103331. * @hidden
  103332. */
  103333. _rebuild(): void;
  103334. /**
  103335. * Prepares a frame to be run through a post process.
  103336. * @param sourceTexture The input texture to the post procesess. (default: null)
  103337. * @param postProcesses An array of post processes to be run. (default: null)
  103338. * @returns True if the post processes were able to be run.
  103339. * @hidden
  103340. */
  103341. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  103342. /**
  103343. * Manually render a set of post processes to a texture.
  103344. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  103345. * @param postProcesses An array of post processes to be run.
  103346. * @param targetTexture The target texture to render to.
  103347. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  103348. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  103349. * @param lodLevel defines which lod of the texture to render to
  103350. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  103351. */
  103352. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  103353. /**
  103354. * Finalize the result of the output of the postprocesses.
  103355. * @param doNotPresent If true the result will not be displayed to the screen.
  103356. * @param targetTexture The target texture to render to.
  103357. * @param faceIndex The index of the face to bind the target texture to.
  103358. * @param postProcesses The array of post processes to render.
  103359. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  103360. * @hidden
  103361. */
  103362. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  103363. /**
  103364. * Disposes of the post process manager.
  103365. */
  103366. dispose(): void;
  103367. }
  103368. }
  103369. declare module BABYLON {
  103370. /**
  103371. * This Helps creating a texture that will be created from a camera in your scene.
  103372. * It is basically a dynamic texture that could be used to create special effects for instance.
  103373. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  103374. */
  103375. export class RenderTargetTexture extends Texture {
  103376. /**
  103377. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  103378. */
  103379. static readonly REFRESHRATE_RENDER_ONCE: number;
  103380. /**
  103381. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  103382. */
  103383. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  103384. /**
  103385. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  103386. * the central point of your effect and can save a lot of performances.
  103387. */
  103388. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  103389. /**
  103390. * Use this predicate to dynamically define the list of mesh you want to render.
  103391. * If set, the renderList property will be overwritten.
  103392. */
  103393. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  103394. private _renderList;
  103395. /**
  103396. * Use this list to define the list of mesh you want to render.
  103397. */
  103398. get renderList(): Nullable<Array<AbstractMesh>>;
  103399. set renderList(value: Nullable<Array<AbstractMesh>>);
  103400. /**
  103401. * Use this function to overload the renderList array at rendering time.
  103402. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  103403. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  103404. * the cube (if the RTT is a cube, else layerOrFace=0).
  103405. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  103406. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  103407. * hold dummy elements!
  103408. */
  103409. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  103410. private _hookArray;
  103411. /**
  103412. * Define if particles should be rendered in your texture.
  103413. */
  103414. renderParticles: boolean;
  103415. /**
  103416. * Define if sprites should be rendered in your texture.
  103417. */
  103418. renderSprites: boolean;
  103419. /**
  103420. * Define the camera used to render the texture.
  103421. */
  103422. activeCamera: Nullable<Camera>;
  103423. /**
  103424. * Override the mesh isReady function with your own one.
  103425. */
  103426. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  103427. /**
  103428. * Override the render function of the texture with your own one.
  103429. */
  103430. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  103431. /**
  103432. * Define if camera post processes should be use while rendering the texture.
  103433. */
  103434. useCameraPostProcesses: boolean;
  103435. /**
  103436. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  103437. */
  103438. ignoreCameraViewport: boolean;
  103439. private _postProcessManager;
  103440. private _postProcesses;
  103441. private _resizeObserver;
  103442. /**
  103443. * An event triggered when the texture is unbind.
  103444. */
  103445. onBeforeBindObservable: Observable<RenderTargetTexture>;
  103446. /**
  103447. * An event triggered when the texture is unbind.
  103448. */
  103449. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  103450. private _onAfterUnbindObserver;
  103451. /**
  103452. * Set a after unbind callback in the texture.
  103453. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  103454. */
  103455. set onAfterUnbind(callback: () => void);
  103456. /**
  103457. * An event triggered before rendering the texture
  103458. */
  103459. onBeforeRenderObservable: Observable<number>;
  103460. private _onBeforeRenderObserver;
  103461. /**
  103462. * Set a before render callback in the texture.
  103463. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  103464. */
  103465. set onBeforeRender(callback: (faceIndex: number) => void);
  103466. /**
  103467. * An event triggered after rendering the texture
  103468. */
  103469. onAfterRenderObservable: Observable<number>;
  103470. private _onAfterRenderObserver;
  103471. /**
  103472. * Set a after render callback in the texture.
  103473. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  103474. */
  103475. set onAfterRender(callback: (faceIndex: number) => void);
  103476. /**
  103477. * An event triggered after the texture clear
  103478. */
  103479. onClearObservable: Observable<Engine>;
  103480. private _onClearObserver;
  103481. /**
  103482. * Set a clear callback in the texture.
  103483. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  103484. */
  103485. set onClear(callback: (Engine: Engine) => void);
  103486. /**
  103487. * An event triggered when the texture is resized.
  103488. */
  103489. onResizeObservable: Observable<RenderTargetTexture>;
  103490. /**
  103491. * Define the clear color of the Render Target if it should be different from the scene.
  103492. */
  103493. clearColor: Color4;
  103494. protected _size: number | {
  103495. width: number;
  103496. height: number;
  103497. layers?: number;
  103498. };
  103499. protected _initialSizeParameter: number | {
  103500. width: number;
  103501. height: number;
  103502. } | {
  103503. ratio: number;
  103504. };
  103505. protected _sizeRatio: Nullable<number>;
  103506. /** @hidden */
  103507. _generateMipMaps: boolean;
  103508. protected _renderingManager: RenderingManager;
  103509. /** @hidden */
  103510. _waitingRenderList?: string[];
  103511. protected _doNotChangeAspectRatio: boolean;
  103512. protected _currentRefreshId: number;
  103513. protected _refreshRate: number;
  103514. protected _textureMatrix: Matrix;
  103515. protected _samples: number;
  103516. protected _renderTargetOptions: RenderTargetCreationOptions;
  103517. /**
  103518. * Gets render target creation options that were used.
  103519. */
  103520. get renderTargetOptions(): RenderTargetCreationOptions;
  103521. protected _onRatioRescale(): void;
  103522. /**
  103523. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  103524. * It must define where the camera used to render the texture is set
  103525. */
  103526. boundingBoxPosition: Vector3;
  103527. private _boundingBoxSize;
  103528. /**
  103529. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  103530. * When defined, the cubemap will switch to local mode
  103531. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  103532. * @example https://www.babylonjs-playground.com/#RNASML
  103533. */
  103534. set boundingBoxSize(value: Vector3);
  103535. get boundingBoxSize(): Vector3;
  103536. /**
  103537. * In case the RTT has been created with a depth texture, get the associated
  103538. * depth texture.
  103539. * Otherwise, return null.
  103540. */
  103541. get depthStencilTexture(): Nullable<InternalTexture>;
  103542. /**
  103543. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  103544. * or used a shadow, depth texture...
  103545. * @param name The friendly name of the texture
  103546. * @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)
  103547. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  103548. * @param generateMipMaps True if mip maps need to be generated after render.
  103549. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  103550. * @param type The type of the buffer in the RTT (int, half float, float...)
  103551. * @param isCube True if a cube texture needs to be created
  103552. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  103553. * @param generateDepthBuffer True to generate a depth buffer
  103554. * @param generateStencilBuffer True to generate a stencil buffer
  103555. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  103556. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  103557. * @param delayAllocation if the texture allocation should be delayed (default: false)
  103558. */
  103559. constructor(name: string, size: number | {
  103560. width: number;
  103561. height: number;
  103562. layers?: number;
  103563. } | {
  103564. ratio: number;
  103565. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  103566. /**
  103567. * Creates a depth stencil texture.
  103568. * This is only available in WebGL 2 or with the depth texture extension available.
  103569. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  103570. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  103571. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  103572. */
  103573. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  103574. private _processSizeParameter;
  103575. /**
  103576. * Define the number of samples to use in case of MSAA.
  103577. * It defaults to one meaning no MSAA has been enabled.
  103578. */
  103579. get samples(): number;
  103580. set samples(value: number);
  103581. /**
  103582. * Resets the refresh counter of the texture and start bak from scratch.
  103583. * Could be useful to regenerate the texture if it is setup to render only once.
  103584. */
  103585. resetRefreshCounter(): void;
  103586. /**
  103587. * Define the refresh rate of the texture or the rendering frequency.
  103588. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  103589. */
  103590. get refreshRate(): number;
  103591. set refreshRate(value: number);
  103592. /**
  103593. * Adds a post process to the render target rendering passes.
  103594. * @param postProcess define the post process to add
  103595. */
  103596. addPostProcess(postProcess: PostProcess): void;
  103597. /**
  103598. * Clear all the post processes attached to the render target
  103599. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  103600. */
  103601. clearPostProcesses(dispose?: boolean): void;
  103602. /**
  103603. * Remove one of the post process from the list of attached post processes to the texture
  103604. * @param postProcess define the post process to remove from the list
  103605. */
  103606. removePostProcess(postProcess: PostProcess): void;
  103607. /** @hidden */
  103608. _shouldRender(): boolean;
  103609. /**
  103610. * Gets the actual render size of the texture.
  103611. * @returns the width of the render size
  103612. */
  103613. getRenderSize(): number;
  103614. /**
  103615. * Gets the actual render width of the texture.
  103616. * @returns the width of the render size
  103617. */
  103618. getRenderWidth(): number;
  103619. /**
  103620. * Gets the actual render height of the texture.
  103621. * @returns the height of the render size
  103622. */
  103623. getRenderHeight(): number;
  103624. /**
  103625. * Gets the actual number of layers of the texture.
  103626. * @returns the number of layers
  103627. */
  103628. getRenderLayers(): number;
  103629. /**
  103630. * Get if the texture can be rescaled or not.
  103631. */
  103632. get canRescale(): boolean;
  103633. /**
  103634. * Resize the texture using a ratio.
  103635. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  103636. */
  103637. scale(ratio: number): void;
  103638. /**
  103639. * Get the texture reflection matrix used to rotate/transform the reflection.
  103640. * @returns the reflection matrix
  103641. */
  103642. getReflectionTextureMatrix(): Matrix;
  103643. /**
  103644. * Resize the texture to a new desired size.
  103645. * Be carrefull as it will recreate all the data in the new texture.
  103646. * @param size Define the new size. It can be:
  103647. * - a number for squared texture,
  103648. * - an object containing { width: number, height: number }
  103649. * - or an object containing a ratio { ratio: number }
  103650. */
  103651. resize(size: number | {
  103652. width: number;
  103653. height: number;
  103654. } | {
  103655. ratio: number;
  103656. }): void;
  103657. private _defaultRenderListPrepared;
  103658. /**
  103659. * Renders all the objects from the render list into the texture.
  103660. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  103661. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  103662. */
  103663. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  103664. private _bestReflectionRenderTargetDimension;
  103665. private _prepareRenderingManager;
  103666. /**
  103667. * @hidden
  103668. * @param faceIndex face index to bind to if this is a cubetexture
  103669. * @param layer defines the index of the texture to bind in the array
  103670. */
  103671. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  103672. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103673. private renderToTarget;
  103674. /**
  103675. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103676. * This allowed control for front to back rendering or reversly depending of the special needs.
  103677. *
  103678. * @param renderingGroupId The rendering group id corresponding to its index
  103679. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103680. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103681. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103682. */
  103683. 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;
  103684. /**
  103685. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103686. *
  103687. * @param renderingGroupId The rendering group id corresponding to its index
  103688. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103689. */
  103690. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  103691. /**
  103692. * Clones the texture.
  103693. * @returns the cloned texture
  103694. */
  103695. clone(): RenderTargetTexture;
  103696. /**
  103697. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103698. * @returns The JSON representation of the texture
  103699. */
  103700. serialize(): any;
  103701. /**
  103702. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  103703. */
  103704. disposeFramebufferObjects(): void;
  103705. /**
  103706. * Dispose the texture and release its associated resources.
  103707. */
  103708. dispose(): void;
  103709. /** @hidden */
  103710. _rebuild(): void;
  103711. /**
  103712. * Clear the info related to rendering groups preventing retention point in material dispose.
  103713. */
  103714. freeRenderingGroups(): void;
  103715. /**
  103716. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  103717. * @returns the view count
  103718. */
  103719. getViewCount(): number;
  103720. }
  103721. }
  103722. declare module BABYLON {
  103723. /**
  103724. * Class used to manipulate GUIDs
  103725. */
  103726. export class GUID {
  103727. /**
  103728. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103729. * Be aware Math.random() could cause collisions, but:
  103730. * "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"
  103731. * @returns a pseudo random id
  103732. */
  103733. static RandomId(): string;
  103734. }
  103735. }
  103736. declare module BABYLON {
  103737. /**
  103738. * Options to be used when creating a shadow depth material
  103739. */
  103740. export interface IIOptionShadowDepthMaterial {
  103741. /** Variables in the vertex shader code that need to have their names remapped.
  103742. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  103743. * "var_name" should be either: worldPos or vNormalW
  103744. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  103745. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  103746. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  103747. */
  103748. remappedVariables?: string[];
  103749. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  103750. standalone?: boolean;
  103751. }
  103752. /**
  103753. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  103754. */
  103755. export class ShadowDepthWrapper {
  103756. private _scene;
  103757. private _options?;
  103758. private _baseMaterial;
  103759. private _onEffectCreatedObserver;
  103760. private _subMeshToEffect;
  103761. private _subMeshToDepthEffect;
  103762. private _meshes;
  103763. /** @hidden */
  103764. _matriceNames: any;
  103765. /** Gets the standalone status of the wrapper */
  103766. get standalone(): boolean;
  103767. /** Gets the base material the wrapper is built upon */
  103768. get baseMaterial(): Material;
  103769. /**
  103770. * Instantiate a new shadow depth wrapper.
  103771. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  103772. * generate the shadow depth map. For more information, please refer to the documentation:
  103773. * https://doc.babylonjs.com/babylon101/shadows
  103774. * @param baseMaterial Material to wrap
  103775. * @param scene Define the scene the material belongs to
  103776. * @param options Options used to create the wrapper
  103777. */
  103778. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  103779. /**
  103780. * Gets the effect to use to generate the depth map
  103781. * @param subMesh subMesh to get the effect for
  103782. * @param shadowGenerator shadow generator to get the effect for
  103783. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  103784. */
  103785. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  103786. /**
  103787. * Specifies that the submesh is ready to be used for depth rendering
  103788. * @param subMesh submesh to check
  103789. * @param defines the list of defines to take into account when checking the effect
  103790. * @param shadowGenerator combined with subMesh, it defines the effect to check
  103791. * @param useInstances specifies that instances should be used
  103792. * @returns a boolean indicating that the submesh is ready or not
  103793. */
  103794. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  103795. /**
  103796. * Disposes the resources
  103797. */
  103798. dispose(): void;
  103799. private _makeEffect;
  103800. }
  103801. }
  103802. declare module BABYLON {
  103803. interface ThinEngine {
  103804. /**
  103805. * Unbind a list of render target textures from the webGL context
  103806. * This is used only when drawBuffer extension or webGL2 are active
  103807. * @param textures defines the render target textures to unbind
  103808. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103809. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103810. */
  103811. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103812. /**
  103813. * Create a multi render target texture
  103814. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103815. * @param size defines the size of the texture
  103816. * @param options defines the creation options
  103817. * @returns the cube texture as an InternalTexture
  103818. */
  103819. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103820. /**
  103821. * Update the sample count for a given multiple render target texture
  103822. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103823. * @param textures defines the textures to update
  103824. * @param samples defines the sample count to set
  103825. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103826. */
  103827. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103828. /**
  103829. * Select a subsets of attachments to draw to.
  103830. * @param attachments gl attachments
  103831. */
  103832. bindAttachments(attachments: number[]): void;
  103833. }
  103834. }
  103835. declare module BABYLON {
  103836. /**
  103837. * Creation options of the multi render target texture.
  103838. */
  103839. export interface IMultiRenderTargetOptions {
  103840. /**
  103841. * Define if the texture needs to create mip maps after render.
  103842. */
  103843. generateMipMaps?: boolean;
  103844. /**
  103845. * Define the types of all the draw buffers we want to create
  103846. */
  103847. types?: number[];
  103848. /**
  103849. * Define the sampling modes of all the draw buffers we want to create
  103850. */
  103851. samplingModes?: number[];
  103852. /**
  103853. * Define if a depth buffer is required
  103854. */
  103855. generateDepthBuffer?: boolean;
  103856. /**
  103857. * Define if a stencil buffer is required
  103858. */
  103859. generateStencilBuffer?: boolean;
  103860. /**
  103861. * Define if a depth texture is required instead of a depth buffer
  103862. */
  103863. generateDepthTexture?: boolean;
  103864. /**
  103865. * Define the number of desired draw buffers
  103866. */
  103867. textureCount?: number;
  103868. /**
  103869. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103870. */
  103871. doNotChangeAspectRatio?: boolean;
  103872. /**
  103873. * Define the default type of the buffers we are creating
  103874. */
  103875. defaultType?: number;
  103876. }
  103877. /**
  103878. * A multi render target, like a render target provides the ability to render to a texture.
  103879. * Unlike the render target, it can render to several draw buffers in one draw.
  103880. * This is specially interesting in deferred rendering or for any effects requiring more than
  103881. * just one color from a single pass.
  103882. */
  103883. export class MultiRenderTarget extends RenderTargetTexture {
  103884. private _internalTextures;
  103885. private _textures;
  103886. private _multiRenderTargetOptions;
  103887. private _count;
  103888. /**
  103889. * Get if draw buffers are currently supported by the used hardware and browser.
  103890. */
  103891. get isSupported(): boolean;
  103892. /**
  103893. * Get the list of textures generated by the multi render target.
  103894. */
  103895. get textures(): Texture[];
  103896. /**
  103897. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103898. */
  103899. get count(): number;
  103900. /**
  103901. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103902. */
  103903. get depthTexture(): Texture;
  103904. /**
  103905. * Set the wrapping mode on U of all the textures we are rendering to.
  103906. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103907. */
  103908. set wrapU(wrap: number);
  103909. /**
  103910. * Set the wrapping mode on V of all the textures we are rendering to.
  103911. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103912. */
  103913. set wrapV(wrap: number);
  103914. /**
  103915. * Instantiate a new multi render target texture.
  103916. * A multi render target, like a render target provides the ability to render to a texture.
  103917. * Unlike the render target, it can render to several draw buffers in one draw.
  103918. * This is specially interesting in deferred rendering or for any effects requiring more than
  103919. * just one color from a single pass.
  103920. * @param name Define the name of the texture
  103921. * @param size Define the size of the buffers to render to
  103922. * @param count Define the number of target we are rendering into
  103923. * @param scene Define the scene the texture belongs to
  103924. * @param options Define the options used to create the multi render target
  103925. */
  103926. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103927. /** @hidden */
  103928. _rebuild(): void;
  103929. private _createInternalTextures;
  103930. private _createTextures;
  103931. /**
  103932. * Define the number of samples used if MSAA is enabled.
  103933. */
  103934. get samples(): number;
  103935. set samples(value: number);
  103936. /**
  103937. * Resize all the textures in the multi render target.
  103938. * Be carrefull as it will recreate all the data in the new texture.
  103939. * @param size Define the new size
  103940. */
  103941. resize(size: any): void;
  103942. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103943. /**
  103944. * Dispose the render targets and their associated resources
  103945. */
  103946. dispose(): void;
  103947. /**
  103948. * Release all the underlying texture used as draw buffers.
  103949. */
  103950. releaseInternalTextures(): void;
  103951. }
  103952. }
  103953. declare module BABYLON {
  103954. /** @hidden */
  103955. export var imageProcessingPixelShader: {
  103956. name: string;
  103957. shader: string;
  103958. };
  103959. }
  103960. declare module BABYLON {
  103961. /**
  103962. * ImageProcessingPostProcess
  103963. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103964. */
  103965. export class ImageProcessingPostProcess extends PostProcess {
  103966. /**
  103967. * Default configuration related to image processing available in the PBR Material.
  103968. */
  103969. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103970. /**
  103971. * Gets the image processing configuration used either in this material.
  103972. */
  103973. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103974. /**
  103975. * Sets the Default image processing configuration used either in the this material.
  103976. *
  103977. * If sets to null, the scene one is in use.
  103978. */
  103979. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103980. /**
  103981. * Keep track of the image processing observer to allow dispose and replace.
  103982. */
  103983. private _imageProcessingObserver;
  103984. /**
  103985. * Attaches a new image processing configuration to the PBR Material.
  103986. * @param configuration
  103987. */
  103988. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103989. /**
  103990. * If the post process is supported.
  103991. */
  103992. get isSupported(): boolean;
  103993. /**
  103994. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103995. */
  103996. get colorCurves(): Nullable<ColorCurves>;
  103997. /**
  103998. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103999. */
  104000. set colorCurves(value: Nullable<ColorCurves>);
  104001. /**
  104002. * Gets wether the color curves effect is enabled.
  104003. */
  104004. get colorCurvesEnabled(): boolean;
  104005. /**
  104006. * Sets wether the color curves effect is enabled.
  104007. */
  104008. set colorCurvesEnabled(value: boolean);
  104009. /**
  104010. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104011. */
  104012. get colorGradingTexture(): Nullable<BaseTexture>;
  104013. /**
  104014. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104015. */
  104016. set colorGradingTexture(value: Nullable<BaseTexture>);
  104017. /**
  104018. * Gets wether the color grading effect is enabled.
  104019. */
  104020. get colorGradingEnabled(): boolean;
  104021. /**
  104022. * Gets wether the color grading effect is enabled.
  104023. */
  104024. set colorGradingEnabled(value: boolean);
  104025. /**
  104026. * Gets exposure used in the effect.
  104027. */
  104028. get exposure(): number;
  104029. /**
  104030. * Sets exposure used in the effect.
  104031. */
  104032. set exposure(value: number);
  104033. /**
  104034. * Gets wether tonemapping is enabled or not.
  104035. */
  104036. get toneMappingEnabled(): boolean;
  104037. /**
  104038. * Sets wether tonemapping is enabled or not
  104039. */
  104040. set toneMappingEnabled(value: boolean);
  104041. /**
  104042. * Gets the type of tone mapping effect.
  104043. */
  104044. get toneMappingType(): number;
  104045. /**
  104046. * Sets the type of tone mapping effect.
  104047. */
  104048. set toneMappingType(value: number);
  104049. /**
  104050. * Gets contrast used in the effect.
  104051. */
  104052. get contrast(): number;
  104053. /**
  104054. * Sets contrast used in the effect.
  104055. */
  104056. set contrast(value: number);
  104057. /**
  104058. * Gets Vignette stretch size.
  104059. */
  104060. get vignetteStretch(): number;
  104061. /**
  104062. * Sets Vignette stretch size.
  104063. */
  104064. set vignetteStretch(value: number);
  104065. /**
  104066. * Gets Vignette centre X Offset.
  104067. */
  104068. get vignetteCentreX(): number;
  104069. /**
  104070. * Sets Vignette centre X Offset.
  104071. */
  104072. set vignetteCentreX(value: number);
  104073. /**
  104074. * Gets Vignette centre Y Offset.
  104075. */
  104076. get vignetteCentreY(): number;
  104077. /**
  104078. * Sets Vignette centre Y Offset.
  104079. */
  104080. set vignetteCentreY(value: number);
  104081. /**
  104082. * Gets Vignette weight or intensity of the vignette effect.
  104083. */
  104084. get vignetteWeight(): number;
  104085. /**
  104086. * Sets Vignette weight or intensity of the vignette effect.
  104087. */
  104088. set vignetteWeight(value: number);
  104089. /**
  104090. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104091. * if vignetteEnabled is set to true.
  104092. */
  104093. get vignetteColor(): Color4;
  104094. /**
  104095. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104096. * if vignetteEnabled is set to true.
  104097. */
  104098. set vignetteColor(value: Color4);
  104099. /**
  104100. * Gets Camera field of view used by the Vignette effect.
  104101. */
  104102. get vignetteCameraFov(): number;
  104103. /**
  104104. * Sets Camera field of view used by the Vignette effect.
  104105. */
  104106. set vignetteCameraFov(value: number);
  104107. /**
  104108. * Gets the vignette blend mode allowing different kind of effect.
  104109. */
  104110. get vignetteBlendMode(): number;
  104111. /**
  104112. * Sets the vignette blend mode allowing different kind of effect.
  104113. */
  104114. set vignetteBlendMode(value: number);
  104115. /**
  104116. * Gets wether the vignette effect is enabled.
  104117. */
  104118. get vignetteEnabled(): boolean;
  104119. /**
  104120. * Sets wether the vignette effect is enabled.
  104121. */
  104122. set vignetteEnabled(value: boolean);
  104123. private _fromLinearSpace;
  104124. /**
  104125. * Gets wether the input of the processing is in Gamma or Linear Space.
  104126. */
  104127. get fromLinearSpace(): boolean;
  104128. /**
  104129. * Sets wether the input of the processing is in Gamma or Linear Space.
  104130. */
  104131. set fromLinearSpace(value: boolean);
  104132. /**
  104133. * Defines cache preventing GC.
  104134. */
  104135. private _defines;
  104136. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104137. /**
  104138. * "ImageProcessingPostProcess"
  104139. * @returns "ImageProcessingPostProcess"
  104140. */
  104141. getClassName(): string;
  104142. /**
  104143. * @hidden
  104144. */
  104145. _updateParameters(): void;
  104146. dispose(camera?: Camera): void;
  104147. }
  104148. }
  104149. declare module BABYLON {
  104150. /** @hidden */
  104151. export var fibonacci: {
  104152. name: string;
  104153. shader: string;
  104154. };
  104155. }
  104156. declare module BABYLON {
  104157. /** @hidden */
  104158. export var subSurfaceScatteringFunctions: {
  104159. name: string;
  104160. shader: string;
  104161. };
  104162. }
  104163. declare module BABYLON {
  104164. /** @hidden */
  104165. export var diffusionProfile: {
  104166. name: string;
  104167. shader: string;
  104168. };
  104169. }
  104170. declare module BABYLON {
  104171. /** @hidden */
  104172. export var subSurfaceScatteringPixelShader: {
  104173. name: string;
  104174. shader: string;
  104175. };
  104176. }
  104177. declare module BABYLON {
  104178. /**
  104179. * Sub surface scattering post process
  104180. */
  104181. export class SubSurfaceScatteringPostProcess extends PostProcess {
  104182. /**
  104183. * Gets a string identifying the name of the class
  104184. * @returns "SubSurfaceScatteringPostProcess" string
  104185. */
  104186. getClassName(): string;
  104187. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  104188. }
  104189. }
  104190. declare module BABYLON {
  104191. /**
  104192. * Interface for defining prepass effects in the prepass post-process pipeline
  104193. */
  104194. export interface PrePassEffectConfiguration {
  104195. /**
  104196. * Post process to attach for this effect
  104197. */
  104198. postProcess: PostProcess;
  104199. /**
  104200. * Is the effect enabled
  104201. */
  104202. enabled: boolean;
  104203. /**
  104204. * Disposes the effect configuration
  104205. */
  104206. dispose(): void;
  104207. /**
  104208. * Disposes the effect configuration
  104209. */
  104210. createPostProcess: () => PostProcess;
  104211. }
  104212. }
  104213. declare module BABYLON {
  104214. /**
  104215. * Contains all parameters needed for the prepass to perform
  104216. * screen space subsurface scattering
  104217. */
  104218. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  104219. private _ssDiffusionS;
  104220. private _ssFilterRadii;
  104221. private _ssDiffusionD;
  104222. /**
  104223. * Post process to attach for screen space subsurface scattering
  104224. */
  104225. postProcess: SubSurfaceScatteringPostProcess;
  104226. /**
  104227. * Diffusion profile color for subsurface scattering
  104228. */
  104229. get ssDiffusionS(): number[];
  104230. /**
  104231. * Diffusion profile max color channel value for subsurface scattering
  104232. */
  104233. get ssDiffusionD(): number[];
  104234. /**
  104235. * Diffusion profile filter radius for subsurface scattering
  104236. */
  104237. get ssFilterRadii(): number[];
  104238. /**
  104239. * Is subsurface enabled
  104240. */
  104241. enabled: boolean;
  104242. /**
  104243. * Diffusion profile colors for subsurface scattering
  104244. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  104245. * See ...
  104246. * Note that you can only store up to 5 of them
  104247. */
  104248. ssDiffusionProfileColors: Color3[];
  104249. /**
  104250. * Defines the ratio real world => scene units.
  104251. * Used for subsurface scattering
  104252. */
  104253. metersPerUnit: number;
  104254. private _scene;
  104255. /**
  104256. * Builds a subsurface configuration object
  104257. * @param scene The scene
  104258. */
  104259. constructor(scene: Scene);
  104260. /**
  104261. * Adds a new diffusion profile.
  104262. * Useful for more realistic subsurface scattering on diverse materials.
  104263. * @param color The color of the diffusion profile. Should be the average color of the material.
  104264. * @return The index of the diffusion profile for the material subsurface configuration
  104265. */
  104266. addDiffusionProfile(color: Color3): number;
  104267. /**
  104268. * Creates the sss post process
  104269. * @return The created post process
  104270. */
  104271. createPostProcess(): SubSurfaceScatteringPostProcess;
  104272. /**
  104273. * Deletes all diffusion profiles.
  104274. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  104275. */
  104276. clearAllDiffusionProfiles(): void;
  104277. /**
  104278. * Disposes this object
  104279. */
  104280. dispose(): void;
  104281. /**
  104282. * @hidden
  104283. * https://zero-radiance.github.io/post/sampling-diffusion/
  104284. *
  104285. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  104286. * ------------------------------------------------------------------------------------
  104287. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  104288. * PDF[r, phi, s] = r * R[r, phi, s]
  104289. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  104290. * ------------------------------------------------------------------------------------
  104291. * We importance sample the color channel with the widest scattering distance.
  104292. */
  104293. getDiffusionProfileParameters(color: Color3): number;
  104294. /**
  104295. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  104296. * 'u' is the random number (the value of the CDF): [0, 1).
  104297. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  104298. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  104299. */
  104300. private _sampleBurleyDiffusionProfile;
  104301. }
  104302. }
  104303. declare module BABYLON {
  104304. /**
  104305. * Renders a pre pass of the scene
  104306. * This means every mesh in the scene will be rendered to a render target texture
  104307. * And then this texture will be composited to the rendering canvas with post processes
  104308. * It is necessary for effects like subsurface scattering or deferred shading
  104309. */
  104310. export class PrePassRenderer {
  104311. /** @hidden */
  104312. static _SceneComponentInitialization: (scene: Scene) => void;
  104313. private _scene;
  104314. private _engine;
  104315. private _isDirty;
  104316. /**
  104317. * Number of textures in the multi render target texture where the scene is directly rendered
  104318. */
  104319. readonly mrtCount: number;
  104320. /**
  104321. * The render target where the scene is directly rendered
  104322. */
  104323. prePassRT: MultiRenderTarget;
  104324. private _mrtTypes;
  104325. private _multiRenderAttachments;
  104326. private _defaultAttachments;
  104327. private _clearAttachments;
  104328. private _postProcesses;
  104329. private readonly _clearColor;
  104330. /**
  104331. * Image processing post process for composition
  104332. */
  104333. imageProcessingPostProcess: ImageProcessingPostProcess;
  104334. /**
  104335. * Configuration for sub surface scattering post process
  104336. */
  104337. subSurfaceConfiguration: SubSurfaceConfiguration;
  104338. /**
  104339. * Should materials render their geometry on the MRT
  104340. */
  104341. materialsShouldRenderGeometry: boolean;
  104342. /**
  104343. * Should materials render the irradiance information on the MRT
  104344. */
  104345. materialsShouldRenderIrradiance: boolean;
  104346. private _enabled;
  104347. /**
  104348. * Indicates if the prepass is enabled
  104349. */
  104350. get enabled(): boolean;
  104351. /**
  104352. * How many samples are used for MSAA of the scene render target
  104353. */
  104354. get samples(): number;
  104355. set samples(n: number);
  104356. /**
  104357. * Instanciates a prepass renderer
  104358. * @param scene The scene
  104359. */
  104360. constructor(scene: Scene);
  104361. private _initializeAttachments;
  104362. private _createCompositionEffect;
  104363. /**
  104364. * Indicates if rendering a prepass is supported
  104365. */
  104366. get isSupported(): boolean;
  104367. /**
  104368. * Sets the proper output textures to draw in the engine.
  104369. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  104370. */
  104371. bindAttachmentsForEffect(effect: Effect): void;
  104372. /**
  104373. * @hidden
  104374. */
  104375. _beforeCameraDraw(): void;
  104376. /**
  104377. * @hidden
  104378. */
  104379. _afterCameraDraw(): void;
  104380. private _checkRTSize;
  104381. private _bindFrameBuffer;
  104382. /**
  104383. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  104384. */
  104385. clear(): void;
  104386. private _setState;
  104387. private _enable;
  104388. private _disable;
  104389. private _resetPostProcessChain;
  104390. private _bindPostProcessChain;
  104391. /**
  104392. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  104393. */
  104394. markAsDirty(): void;
  104395. private _update;
  104396. /**
  104397. * Disposes the prepass renderer.
  104398. */
  104399. dispose(): void;
  104400. }
  104401. }
  104402. declare module BABYLON {
  104403. /**
  104404. * Options for compiling materials.
  104405. */
  104406. export interface IMaterialCompilationOptions {
  104407. /**
  104408. * Defines whether clip planes are enabled.
  104409. */
  104410. clipPlane: boolean;
  104411. /**
  104412. * Defines whether instances are enabled.
  104413. */
  104414. useInstances: boolean;
  104415. }
  104416. /**
  104417. * Options passed when calling customShaderNameResolve
  104418. */
  104419. export interface ICustomShaderNameResolveOptions {
  104420. /**
  104421. * 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
  104422. */
  104423. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  104424. }
  104425. /**
  104426. * Base class for the main features of a material in Babylon.js
  104427. */
  104428. export class Material implements IAnimatable {
  104429. /**
  104430. * Returns the triangle fill mode
  104431. */
  104432. static readonly TriangleFillMode: number;
  104433. /**
  104434. * Returns the wireframe mode
  104435. */
  104436. static readonly WireFrameFillMode: number;
  104437. /**
  104438. * Returns the point fill mode
  104439. */
  104440. static readonly PointFillMode: number;
  104441. /**
  104442. * Returns the point list draw mode
  104443. */
  104444. static readonly PointListDrawMode: number;
  104445. /**
  104446. * Returns the line list draw mode
  104447. */
  104448. static readonly LineListDrawMode: number;
  104449. /**
  104450. * Returns the line loop draw mode
  104451. */
  104452. static readonly LineLoopDrawMode: number;
  104453. /**
  104454. * Returns the line strip draw mode
  104455. */
  104456. static readonly LineStripDrawMode: number;
  104457. /**
  104458. * Returns the triangle strip draw mode
  104459. */
  104460. static readonly TriangleStripDrawMode: number;
  104461. /**
  104462. * Returns the triangle fan draw mode
  104463. */
  104464. static readonly TriangleFanDrawMode: number;
  104465. /**
  104466. * Stores the clock-wise side orientation
  104467. */
  104468. static readonly ClockWiseSideOrientation: number;
  104469. /**
  104470. * Stores the counter clock-wise side orientation
  104471. */
  104472. static readonly CounterClockWiseSideOrientation: number;
  104473. /**
  104474. * The dirty texture flag value
  104475. */
  104476. static readonly TextureDirtyFlag: number;
  104477. /**
  104478. * The dirty light flag value
  104479. */
  104480. static readonly LightDirtyFlag: number;
  104481. /**
  104482. * The dirty fresnel flag value
  104483. */
  104484. static readonly FresnelDirtyFlag: number;
  104485. /**
  104486. * The dirty attribute flag value
  104487. */
  104488. static readonly AttributesDirtyFlag: number;
  104489. /**
  104490. * The dirty misc flag value
  104491. */
  104492. static readonly MiscDirtyFlag: number;
  104493. /**
  104494. * The all dirty flag value
  104495. */
  104496. static readonly AllDirtyFlag: number;
  104497. /**
  104498. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104499. */
  104500. static readonly MATERIAL_OPAQUE: number;
  104501. /**
  104502. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104503. */
  104504. static readonly MATERIAL_ALPHATEST: number;
  104505. /**
  104506. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104507. */
  104508. static readonly MATERIAL_ALPHABLEND: number;
  104509. /**
  104510. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104511. * They are also discarded below the alpha cutoff threshold to improve performances.
  104512. */
  104513. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  104514. /**
  104515. * The Whiteout method is used to blend normals.
  104516. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104517. */
  104518. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  104519. /**
  104520. * The Reoriented Normal Mapping method is used to blend normals.
  104521. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104522. */
  104523. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  104524. /**
  104525. * Custom callback helping to override the default shader used in the material.
  104526. */
  104527. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  104528. /**
  104529. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  104530. */
  104531. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  104532. /**
  104533. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  104534. * This means that the material can keep using a previous shader while a new one is being compiled.
  104535. * This is mostly used when shader parallel compilation is supported (true by default)
  104536. */
  104537. allowShaderHotSwapping: boolean;
  104538. /**
  104539. * The ID of the material
  104540. */
  104541. id: string;
  104542. /**
  104543. * Gets or sets the unique id of the material
  104544. */
  104545. uniqueId: number;
  104546. /**
  104547. * The name of the material
  104548. */
  104549. name: string;
  104550. /**
  104551. * Gets or sets user defined metadata
  104552. */
  104553. metadata: any;
  104554. /**
  104555. * For internal use only. Please do not use.
  104556. */
  104557. reservedDataStore: any;
  104558. /**
  104559. * Specifies if the ready state should be checked on each call
  104560. */
  104561. checkReadyOnEveryCall: boolean;
  104562. /**
  104563. * Specifies if the ready state should be checked once
  104564. */
  104565. checkReadyOnlyOnce: boolean;
  104566. /**
  104567. * The state of the material
  104568. */
  104569. state: string;
  104570. /**
  104571. * If the material can be rendered to several textures with MRT extension
  104572. */
  104573. get canRenderToMRT(): boolean;
  104574. /**
  104575. * The alpha value of the material
  104576. */
  104577. protected _alpha: number;
  104578. /**
  104579. * List of inspectable custom properties (used by the Inspector)
  104580. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104581. */
  104582. inspectableCustomProperties: IInspectable[];
  104583. /**
  104584. * Sets the alpha value of the material
  104585. */
  104586. set alpha(value: number);
  104587. /**
  104588. * Gets the alpha value of the material
  104589. */
  104590. get alpha(): number;
  104591. /**
  104592. * Specifies if back face culling is enabled
  104593. */
  104594. protected _backFaceCulling: boolean;
  104595. /**
  104596. * Sets the back-face culling state
  104597. */
  104598. set backFaceCulling(value: boolean);
  104599. /**
  104600. * Gets the back-face culling state
  104601. */
  104602. get backFaceCulling(): boolean;
  104603. /**
  104604. * Stores the value for side orientation
  104605. */
  104606. sideOrientation: number;
  104607. /**
  104608. * Callback triggered when the material is compiled
  104609. */
  104610. onCompiled: Nullable<(effect: Effect) => void>;
  104611. /**
  104612. * Callback triggered when an error occurs
  104613. */
  104614. onError: Nullable<(effect: Effect, errors: string) => void>;
  104615. /**
  104616. * Callback triggered to get the render target textures
  104617. */
  104618. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  104619. /**
  104620. * Gets a boolean indicating that current material needs to register RTT
  104621. */
  104622. get hasRenderTargetTextures(): boolean;
  104623. /**
  104624. * Specifies if the material should be serialized
  104625. */
  104626. doNotSerialize: boolean;
  104627. /**
  104628. * @hidden
  104629. */
  104630. _storeEffectOnSubMeshes: boolean;
  104631. /**
  104632. * Stores the animations for the material
  104633. */
  104634. animations: Nullable<Array<Animation>>;
  104635. /**
  104636. * An event triggered when the material is disposed
  104637. */
  104638. onDisposeObservable: Observable<Material>;
  104639. /**
  104640. * An observer which watches for dispose events
  104641. */
  104642. private _onDisposeObserver;
  104643. private _onUnBindObservable;
  104644. /**
  104645. * Called during a dispose event
  104646. */
  104647. set onDispose(callback: () => void);
  104648. private _onBindObservable;
  104649. /**
  104650. * An event triggered when the material is bound
  104651. */
  104652. get onBindObservable(): Observable<AbstractMesh>;
  104653. /**
  104654. * An observer which watches for bind events
  104655. */
  104656. private _onBindObserver;
  104657. /**
  104658. * Called during a bind event
  104659. */
  104660. set onBind(callback: (Mesh: AbstractMesh) => void);
  104661. /**
  104662. * An event triggered when the material is unbound
  104663. */
  104664. get onUnBindObservable(): Observable<Material>;
  104665. protected _onEffectCreatedObservable: Nullable<Observable<{
  104666. effect: Effect;
  104667. subMesh: Nullable<SubMesh>;
  104668. }>>;
  104669. /**
  104670. * An event triggered when the effect is (re)created
  104671. */
  104672. get onEffectCreatedObservable(): Observable<{
  104673. effect: Effect;
  104674. subMesh: Nullable<SubMesh>;
  104675. }>;
  104676. /**
  104677. * Stores the value of the alpha mode
  104678. */
  104679. private _alphaMode;
  104680. /**
  104681. * Sets the value of the alpha mode.
  104682. *
  104683. * | Value | Type | Description |
  104684. * | --- | --- | --- |
  104685. * | 0 | ALPHA_DISABLE | |
  104686. * | 1 | ALPHA_ADD | |
  104687. * | 2 | ALPHA_COMBINE | |
  104688. * | 3 | ALPHA_SUBTRACT | |
  104689. * | 4 | ALPHA_MULTIPLY | |
  104690. * | 5 | ALPHA_MAXIMIZED | |
  104691. * | 6 | ALPHA_ONEONE | |
  104692. * | 7 | ALPHA_PREMULTIPLIED | |
  104693. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  104694. * | 9 | ALPHA_INTERPOLATE | |
  104695. * | 10 | ALPHA_SCREENMODE | |
  104696. *
  104697. */
  104698. set alphaMode(value: number);
  104699. /**
  104700. * Gets the value of the alpha mode
  104701. */
  104702. get alphaMode(): number;
  104703. /**
  104704. * Stores the state of the need depth pre-pass value
  104705. */
  104706. private _needDepthPrePass;
  104707. /**
  104708. * Sets the need depth pre-pass value
  104709. */
  104710. set needDepthPrePass(value: boolean);
  104711. /**
  104712. * Gets the depth pre-pass value
  104713. */
  104714. get needDepthPrePass(): boolean;
  104715. /**
  104716. * Specifies if depth writing should be disabled
  104717. */
  104718. disableDepthWrite: boolean;
  104719. /**
  104720. * Specifies if color writing should be disabled
  104721. */
  104722. disableColorWrite: boolean;
  104723. /**
  104724. * Specifies if depth writing should be forced
  104725. */
  104726. forceDepthWrite: boolean;
  104727. /**
  104728. * Specifies the depth function that should be used. 0 means the default engine function
  104729. */
  104730. depthFunction: number;
  104731. /**
  104732. * Specifies if there should be a separate pass for culling
  104733. */
  104734. separateCullingPass: boolean;
  104735. /**
  104736. * Stores the state specifing if fog should be enabled
  104737. */
  104738. private _fogEnabled;
  104739. /**
  104740. * Sets the state for enabling fog
  104741. */
  104742. set fogEnabled(value: boolean);
  104743. /**
  104744. * Gets the value of the fog enabled state
  104745. */
  104746. get fogEnabled(): boolean;
  104747. /**
  104748. * Stores the size of points
  104749. */
  104750. pointSize: number;
  104751. /**
  104752. * Stores the z offset value
  104753. */
  104754. zOffset: number;
  104755. get wireframe(): boolean;
  104756. /**
  104757. * Sets the state of wireframe mode
  104758. */
  104759. set wireframe(value: boolean);
  104760. /**
  104761. * Gets the value specifying if point clouds are enabled
  104762. */
  104763. get pointsCloud(): boolean;
  104764. /**
  104765. * Sets the state of point cloud mode
  104766. */
  104767. set pointsCloud(value: boolean);
  104768. /**
  104769. * Gets the material fill mode
  104770. */
  104771. get fillMode(): number;
  104772. /**
  104773. * Sets the material fill mode
  104774. */
  104775. set fillMode(value: number);
  104776. /**
  104777. * @hidden
  104778. * Stores the effects for the material
  104779. */
  104780. _effect: Nullable<Effect>;
  104781. /**
  104782. * Specifies if uniform buffers should be used
  104783. */
  104784. private _useUBO;
  104785. /**
  104786. * Stores a reference to the scene
  104787. */
  104788. private _scene;
  104789. /**
  104790. * Stores the fill mode state
  104791. */
  104792. private _fillMode;
  104793. /**
  104794. * Specifies if the depth write state should be cached
  104795. */
  104796. private _cachedDepthWriteState;
  104797. /**
  104798. * Specifies if the color write state should be cached
  104799. */
  104800. private _cachedColorWriteState;
  104801. /**
  104802. * Specifies if the depth function state should be cached
  104803. */
  104804. private _cachedDepthFunctionState;
  104805. /**
  104806. * Stores the uniform buffer
  104807. */
  104808. protected _uniformBuffer: UniformBuffer;
  104809. /** @hidden */
  104810. _indexInSceneMaterialArray: number;
  104811. /** @hidden */
  104812. meshMap: Nullable<{
  104813. [id: string]: AbstractMesh | undefined;
  104814. }>;
  104815. /**
  104816. * Creates a material instance
  104817. * @param name defines the name of the material
  104818. * @param scene defines the scene to reference
  104819. * @param doNotAdd specifies if the material should be added to the scene
  104820. */
  104821. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  104822. /**
  104823. * Returns a string representation of the current material
  104824. * @param fullDetails defines a boolean indicating which levels of logging is desired
  104825. * @returns a string with material information
  104826. */
  104827. toString(fullDetails?: boolean): string;
  104828. /**
  104829. * Gets the class name of the material
  104830. * @returns a string with the class name of the material
  104831. */
  104832. getClassName(): string;
  104833. /**
  104834. * Specifies if updates for the material been locked
  104835. */
  104836. get isFrozen(): boolean;
  104837. /**
  104838. * Locks updates for the material
  104839. */
  104840. freeze(): void;
  104841. /**
  104842. * Unlocks updates for the material
  104843. */
  104844. unfreeze(): void;
  104845. /**
  104846. * Specifies if the material is ready to be used
  104847. * @param mesh defines the mesh to check
  104848. * @param useInstances specifies if instances should be used
  104849. * @returns a boolean indicating if the material is ready to be used
  104850. */
  104851. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  104852. /**
  104853. * Specifies that the submesh is ready to be used
  104854. * @param mesh defines the mesh to check
  104855. * @param subMesh defines which submesh to check
  104856. * @param useInstances specifies that instances should be used
  104857. * @returns a boolean indicating that the submesh is ready or not
  104858. */
  104859. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104860. /**
  104861. * Returns the material effect
  104862. * @returns the effect associated with the material
  104863. */
  104864. getEffect(): Nullable<Effect>;
  104865. /**
  104866. * Returns the current scene
  104867. * @returns a Scene
  104868. */
  104869. getScene(): Scene;
  104870. /**
  104871. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104872. */
  104873. protected _forceAlphaTest: boolean;
  104874. /**
  104875. * The transparency mode of the material.
  104876. */
  104877. protected _transparencyMode: Nullable<number>;
  104878. /**
  104879. * Gets the current transparency mode.
  104880. */
  104881. get transparencyMode(): Nullable<number>;
  104882. /**
  104883. * Sets the transparency mode of the material.
  104884. *
  104885. * | Value | Type | Description |
  104886. * | ----- | ----------------------------------- | ----------- |
  104887. * | 0 | OPAQUE | |
  104888. * | 1 | ALPHATEST | |
  104889. * | 2 | ALPHABLEND | |
  104890. * | 3 | ALPHATESTANDBLEND | |
  104891. *
  104892. */
  104893. set transparencyMode(value: Nullable<number>);
  104894. /**
  104895. * Returns true if alpha blending should be disabled.
  104896. */
  104897. protected get _disableAlphaBlending(): boolean;
  104898. /**
  104899. * Specifies whether or not this material should be rendered in alpha blend mode.
  104900. * @returns a boolean specifying if alpha blending is needed
  104901. */
  104902. needAlphaBlending(): boolean;
  104903. /**
  104904. * Specifies if the mesh will require alpha blending
  104905. * @param mesh defines the mesh to check
  104906. * @returns a boolean specifying if alpha blending is needed for the mesh
  104907. */
  104908. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  104909. /**
  104910. * Specifies whether or not this material should be rendered in alpha test mode.
  104911. * @returns a boolean specifying if an alpha test is needed.
  104912. */
  104913. needAlphaTesting(): boolean;
  104914. /**
  104915. * Specifies if material alpha testing should be turned on for the mesh
  104916. * @param mesh defines the mesh to check
  104917. */
  104918. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  104919. /**
  104920. * Gets the texture used for the alpha test
  104921. * @returns the texture to use for alpha testing
  104922. */
  104923. getAlphaTestTexture(): Nullable<BaseTexture>;
  104924. /**
  104925. * Marks the material to indicate that it needs to be re-calculated
  104926. */
  104927. markDirty(): void;
  104928. /** @hidden */
  104929. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  104930. /**
  104931. * Binds the material to the mesh
  104932. * @param world defines the world transformation matrix
  104933. * @param mesh defines the mesh to bind the material to
  104934. */
  104935. bind(world: Matrix, mesh?: Mesh): void;
  104936. /**
  104937. * Binds the submesh to the material
  104938. * @param world defines the world transformation matrix
  104939. * @param mesh defines the mesh containing the submesh
  104940. * @param subMesh defines the submesh to bind the material to
  104941. */
  104942. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104943. /**
  104944. * Binds the world matrix to the material
  104945. * @param world defines the world transformation matrix
  104946. */
  104947. bindOnlyWorldMatrix(world: Matrix): void;
  104948. /**
  104949. * Binds the scene's uniform buffer to the effect.
  104950. * @param effect defines the effect to bind to the scene uniform buffer
  104951. * @param sceneUbo defines the uniform buffer storing scene data
  104952. */
  104953. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  104954. /**
  104955. * Binds the view matrix to the effect
  104956. * @param effect defines the effect to bind the view matrix to
  104957. */
  104958. bindView(effect: Effect): void;
  104959. /**
  104960. * Binds the view projection matrix to the effect
  104961. * @param effect defines the effect to bind the view projection matrix to
  104962. */
  104963. bindViewProjection(effect: Effect): void;
  104964. /**
  104965. * Processes to execute after binding the material to a mesh
  104966. * @param mesh defines the rendered mesh
  104967. */
  104968. protected _afterBind(mesh?: Mesh): void;
  104969. /**
  104970. * Unbinds the material from the mesh
  104971. */
  104972. unbind(): void;
  104973. /**
  104974. * Gets the active textures from the material
  104975. * @returns an array of textures
  104976. */
  104977. getActiveTextures(): BaseTexture[];
  104978. /**
  104979. * Specifies if the material uses a texture
  104980. * @param texture defines the texture to check against the material
  104981. * @returns a boolean specifying if the material uses the texture
  104982. */
  104983. hasTexture(texture: BaseTexture): boolean;
  104984. /**
  104985. * Makes a duplicate of the material, and gives it a new name
  104986. * @param name defines the new name for the duplicated material
  104987. * @returns the cloned material
  104988. */
  104989. clone(name: string): Nullable<Material>;
  104990. /**
  104991. * Gets the meshes bound to the material
  104992. * @returns an array of meshes bound to the material
  104993. */
  104994. getBindedMeshes(): AbstractMesh[];
  104995. /**
  104996. * Force shader compilation
  104997. * @param mesh defines the mesh associated with this material
  104998. * @param onCompiled defines a function to execute once the material is compiled
  104999. * @param options defines the options to configure the compilation
  105000. * @param onError defines a function to execute if the material fails compiling
  105001. */
  105002. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  105003. /**
  105004. * Force shader compilation
  105005. * @param mesh defines the mesh that will use this material
  105006. * @param options defines additional options for compiling the shaders
  105007. * @returns a promise that resolves when the compilation completes
  105008. */
  105009. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  105010. private static readonly _AllDirtyCallBack;
  105011. private static readonly _ImageProcessingDirtyCallBack;
  105012. private static readonly _TextureDirtyCallBack;
  105013. private static readonly _FresnelDirtyCallBack;
  105014. private static readonly _MiscDirtyCallBack;
  105015. private static readonly _LightsDirtyCallBack;
  105016. private static readonly _AttributeDirtyCallBack;
  105017. private static _FresnelAndMiscDirtyCallBack;
  105018. private static _TextureAndMiscDirtyCallBack;
  105019. private static readonly _DirtyCallbackArray;
  105020. private static readonly _RunDirtyCallBacks;
  105021. /**
  105022. * Marks a define in the material to indicate that it needs to be re-computed
  105023. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  105024. */
  105025. markAsDirty(flag: number): void;
  105026. /**
  105027. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  105028. * @param func defines a function which checks material defines against the submeshes
  105029. */
  105030. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  105031. /**
  105032. * Indicates that the scene should check if the rendering now needs a prepass
  105033. */
  105034. protected _markScenePrePassDirty(): void;
  105035. /**
  105036. * Indicates that we need to re-calculated for all submeshes
  105037. */
  105038. protected _markAllSubMeshesAsAllDirty(): void;
  105039. /**
  105040. * Indicates that image processing needs to be re-calculated for all submeshes
  105041. */
  105042. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  105043. /**
  105044. * Indicates that textures need to be re-calculated for all submeshes
  105045. */
  105046. protected _markAllSubMeshesAsTexturesDirty(): void;
  105047. /**
  105048. * Indicates that fresnel needs to be re-calculated for all submeshes
  105049. */
  105050. protected _markAllSubMeshesAsFresnelDirty(): void;
  105051. /**
  105052. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  105053. */
  105054. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  105055. /**
  105056. * Indicates that lights need to be re-calculated for all submeshes
  105057. */
  105058. protected _markAllSubMeshesAsLightsDirty(): void;
  105059. /**
  105060. * Indicates that attributes need to be re-calculated for all submeshes
  105061. */
  105062. protected _markAllSubMeshesAsAttributesDirty(): void;
  105063. /**
  105064. * Indicates that misc needs to be re-calculated for all submeshes
  105065. */
  105066. protected _markAllSubMeshesAsMiscDirty(): void;
  105067. /**
  105068. * Indicates that textures and misc need to be re-calculated for all submeshes
  105069. */
  105070. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  105071. /**
  105072. * Sets the required values to the prepass renderer.
  105073. * @param prePassRenderer defines the prepass renderer to setup.
  105074. * @returns true if the pre pass is needed.
  105075. */
  105076. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  105077. /**
  105078. * Disposes the material
  105079. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105080. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105081. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  105082. */
  105083. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  105084. /** @hidden */
  105085. private releaseVertexArrayObject;
  105086. /**
  105087. * Serializes this material
  105088. * @returns the serialized material object
  105089. */
  105090. serialize(): any;
  105091. /**
  105092. * Creates a material from parsed material data
  105093. * @param parsedMaterial defines parsed material data
  105094. * @param scene defines the hosting scene
  105095. * @param rootUrl defines the root URL to use to load textures
  105096. * @returns a new material
  105097. */
  105098. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  105099. }
  105100. }
  105101. declare module BABYLON {
  105102. /**
  105103. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105104. * separate meshes. This can be use to improve performances.
  105105. * @see https://doc.babylonjs.com/how_to/multi_materials
  105106. */
  105107. export class MultiMaterial extends Material {
  105108. private _subMaterials;
  105109. /**
  105110. * Gets or Sets the list of Materials used within the multi material.
  105111. * They need to be ordered according to the submeshes order in the associated mesh
  105112. */
  105113. get subMaterials(): Nullable<Material>[];
  105114. set subMaterials(value: Nullable<Material>[]);
  105115. /**
  105116. * Function used to align with Node.getChildren()
  105117. * @returns the list of Materials used within the multi material
  105118. */
  105119. getChildren(): Nullable<Material>[];
  105120. /**
  105121. * Instantiates a new Multi Material
  105122. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105123. * separate meshes. This can be use to improve performances.
  105124. * @see https://doc.babylonjs.com/how_to/multi_materials
  105125. * @param name Define the name in the scene
  105126. * @param scene Define the scene the material belongs to
  105127. */
  105128. constructor(name: string, scene: Scene);
  105129. private _hookArray;
  105130. /**
  105131. * Get one of the submaterial by its index in the submaterials array
  105132. * @param index The index to look the sub material at
  105133. * @returns The Material if the index has been defined
  105134. */
  105135. getSubMaterial(index: number): Nullable<Material>;
  105136. /**
  105137. * Get the list of active textures for the whole sub materials list.
  105138. * @returns All the textures that will be used during the rendering
  105139. */
  105140. getActiveTextures(): BaseTexture[];
  105141. /**
  105142. * Gets the current class name of the material e.g. "MultiMaterial"
  105143. * Mainly use in serialization.
  105144. * @returns the class name
  105145. */
  105146. getClassName(): string;
  105147. /**
  105148. * Checks if the material is ready to render the requested sub mesh
  105149. * @param mesh Define the mesh the submesh belongs to
  105150. * @param subMesh Define the sub mesh to look readyness for
  105151. * @param useInstances Define whether or not the material is used with instances
  105152. * @returns true if ready, otherwise false
  105153. */
  105154. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105155. /**
  105156. * Clones the current material and its related sub materials
  105157. * @param name Define the name of the newly cloned material
  105158. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  105159. * @returns the cloned material
  105160. */
  105161. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  105162. /**
  105163. * Serializes the materials into a JSON representation.
  105164. * @returns the JSON representation
  105165. */
  105166. serialize(): any;
  105167. /**
  105168. * Dispose the material and release its associated resources
  105169. * @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)
  105170. * @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)
  105171. * @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)
  105172. */
  105173. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  105174. /**
  105175. * Creates a MultiMaterial from parsed MultiMaterial data.
  105176. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  105177. * @param scene defines the hosting scene
  105178. * @returns a new MultiMaterial
  105179. */
  105180. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  105181. }
  105182. }
  105183. declare module BABYLON {
  105184. /**
  105185. * Defines a subdivision inside a mesh
  105186. */
  105187. export class SubMesh implements ICullable {
  105188. /** the material index to use */
  105189. materialIndex: number;
  105190. /** vertex index start */
  105191. verticesStart: number;
  105192. /** vertices count */
  105193. verticesCount: number;
  105194. /** index start */
  105195. indexStart: number;
  105196. /** indices count */
  105197. indexCount: number;
  105198. /** @hidden */
  105199. _materialDefines: Nullable<MaterialDefines>;
  105200. /** @hidden */
  105201. _materialEffect: Nullable<Effect>;
  105202. /** @hidden */
  105203. _effectOverride: Nullable<Effect>;
  105204. /**
  105205. * Gets material defines used by the effect associated to the sub mesh
  105206. */
  105207. get materialDefines(): Nullable<MaterialDefines>;
  105208. /**
  105209. * Sets material defines used by the effect associated to the sub mesh
  105210. */
  105211. set materialDefines(defines: Nullable<MaterialDefines>);
  105212. /**
  105213. * Gets associated effect
  105214. */
  105215. get effect(): Nullable<Effect>;
  105216. /**
  105217. * Sets associated effect (effect used to render this submesh)
  105218. * @param effect defines the effect to associate with
  105219. * @param defines defines the set of defines used to compile this effect
  105220. */
  105221. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  105222. /** @hidden */
  105223. _linesIndexCount: number;
  105224. private _mesh;
  105225. private _renderingMesh;
  105226. private _boundingInfo;
  105227. private _linesIndexBuffer;
  105228. /** @hidden */
  105229. _lastColliderWorldVertices: Nullable<Vector3[]>;
  105230. /** @hidden */
  105231. _trianglePlanes: Plane[];
  105232. /** @hidden */
  105233. _lastColliderTransformMatrix: Nullable<Matrix>;
  105234. /** @hidden */
  105235. _renderId: number;
  105236. /** @hidden */
  105237. _alphaIndex: number;
  105238. /** @hidden */
  105239. _distanceToCamera: number;
  105240. /** @hidden */
  105241. _id: number;
  105242. private _currentMaterial;
  105243. /**
  105244. * Add a new submesh to a mesh
  105245. * @param materialIndex defines the material index to use
  105246. * @param verticesStart defines vertex index start
  105247. * @param verticesCount defines vertices count
  105248. * @param indexStart defines index start
  105249. * @param indexCount defines indices count
  105250. * @param mesh defines the parent mesh
  105251. * @param renderingMesh defines an optional rendering mesh
  105252. * @param createBoundingBox defines if bounding box should be created for this submesh
  105253. * @returns the new submesh
  105254. */
  105255. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  105256. /**
  105257. * Creates a new submesh
  105258. * @param materialIndex defines the material index to use
  105259. * @param verticesStart defines vertex index start
  105260. * @param verticesCount defines vertices count
  105261. * @param indexStart defines index start
  105262. * @param indexCount defines indices count
  105263. * @param mesh defines the parent mesh
  105264. * @param renderingMesh defines an optional rendering mesh
  105265. * @param createBoundingBox defines if bounding box should be created for this submesh
  105266. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  105267. */
  105268. constructor(
  105269. /** the material index to use */
  105270. materialIndex: number,
  105271. /** vertex index start */
  105272. verticesStart: number,
  105273. /** vertices count */
  105274. verticesCount: number,
  105275. /** index start */
  105276. indexStart: number,
  105277. /** indices count */
  105278. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  105279. /**
  105280. * Returns true if this submesh covers the entire parent mesh
  105281. * @ignorenaming
  105282. */
  105283. get IsGlobal(): boolean;
  105284. /**
  105285. * Returns the submesh BoudingInfo object
  105286. * @returns current bounding info (or mesh's one if the submesh is global)
  105287. */
  105288. getBoundingInfo(): BoundingInfo;
  105289. /**
  105290. * Sets the submesh BoundingInfo
  105291. * @param boundingInfo defines the new bounding info to use
  105292. * @returns the SubMesh
  105293. */
  105294. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  105295. /**
  105296. * Returns the mesh of the current submesh
  105297. * @return the parent mesh
  105298. */
  105299. getMesh(): AbstractMesh;
  105300. /**
  105301. * Returns the rendering mesh of the submesh
  105302. * @returns the rendering mesh (could be different from parent mesh)
  105303. */
  105304. getRenderingMesh(): Mesh;
  105305. /**
  105306. * Returns the replacement mesh of the submesh
  105307. * @returns the replacement mesh (could be different from parent mesh)
  105308. */
  105309. getReplacementMesh(): Nullable<AbstractMesh>;
  105310. /**
  105311. * Returns the effective mesh of the submesh
  105312. * @returns the effective mesh (could be different from parent mesh)
  105313. */
  105314. getEffectiveMesh(): AbstractMesh;
  105315. /**
  105316. * Returns the submesh material
  105317. * @returns null or the current material
  105318. */
  105319. getMaterial(): Nullable<Material>;
  105320. private _IsMultiMaterial;
  105321. /**
  105322. * Sets a new updated BoundingInfo object to the submesh
  105323. * @param data defines an optional position array to use to determine the bounding info
  105324. * @returns the SubMesh
  105325. */
  105326. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  105327. /** @hidden */
  105328. _checkCollision(collider: Collider): boolean;
  105329. /**
  105330. * Updates the submesh BoundingInfo
  105331. * @param world defines the world matrix to use to update the bounding info
  105332. * @returns the submesh
  105333. */
  105334. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  105335. /**
  105336. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  105337. * @param frustumPlanes defines the frustum planes
  105338. * @returns true if the submesh is intersecting with the frustum
  105339. */
  105340. isInFrustum(frustumPlanes: Plane[]): boolean;
  105341. /**
  105342. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  105343. * @param frustumPlanes defines the frustum planes
  105344. * @returns true if the submesh is inside the frustum
  105345. */
  105346. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  105347. /**
  105348. * Renders the submesh
  105349. * @param enableAlphaMode defines if alpha needs to be used
  105350. * @returns the submesh
  105351. */
  105352. render(enableAlphaMode: boolean): SubMesh;
  105353. /**
  105354. * @hidden
  105355. */
  105356. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  105357. /**
  105358. * Checks if the submesh intersects with a ray
  105359. * @param ray defines the ray to test
  105360. * @returns true is the passed ray intersects the submesh bounding box
  105361. */
  105362. canIntersects(ray: Ray): boolean;
  105363. /**
  105364. * Intersects current submesh with a ray
  105365. * @param ray defines the ray to test
  105366. * @param positions defines mesh's positions array
  105367. * @param indices defines mesh's indices array
  105368. * @param fastCheck defines if the first intersection will be used (and not the closest)
  105369. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105370. * @returns intersection info or null if no intersection
  105371. */
  105372. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  105373. /** @hidden */
  105374. private _intersectLines;
  105375. /** @hidden */
  105376. private _intersectUnIndexedLines;
  105377. /** @hidden */
  105378. private _intersectTriangles;
  105379. /** @hidden */
  105380. private _intersectUnIndexedTriangles;
  105381. /** @hidden */
  105382. _rebuild(): void;
  105383. /**
  105384. * Creates a new submesh from the passed mesh
  105385. * @param newMesh defines the new hosting mesh
  105386. * @param newRenderingMesh defines an optional rendering mesh
  105387. * @returns the new submesh
  105388. */
  105389. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  105390. /**
  105391. * Release associated resources
  105392. */
  105393. dispose(): void;
  105394. /**
  105395. * Gets the class name
  105396. * @returns the string "SubMesh".
  105397. */
  105398. getClassName(): string;
  105399. /**
  105400. * Creates a new submesh from indices data
  105401. * @param materialIndex the index of the main mesh material
  105402. * @param startIndex the index where to start the copy in the mesh indices array
  105403. * @param indexCount the number of indices to copy then from the startIndex
  105404. * @param mesh the main mesh to create the submesh from
  105405. * @param renderingMesh the optional rendering mesh
  105406. * @returns a new submesh
  105407. */
  105408. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  105409. }
  105410. }
  105411. declare module BABYLON {
  105412. /**
  105413. * Class used to represent data loading progression
  105414. */
  105415. export class SceneLoaderFlags {
  105416. private static _ForceFullSceneLoadingForIncremental;
  105417. private static _ShowLoadingScreen;
  105418. private static _CleanBoneMatrixWeights;
  105419. private static _loggingLevel;
  105420. /**
  105421. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105422. */
  105423. static get ForceFullSceneLoadingForIncremental(): boolean;
  105424. static set ForceFullSceneLoadingForIncremental(value: boolean);
  105425. /**
  105426. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105427. */
  105428. static get ShowLoadingScreen(): boolean;
  105429. static set ShowLoadingScreen(value: boolean);
  105430. /**
  105431. * Defines the current logging level (while loading the scene)
  105432. * @ignorenaming
  105433. */
  105434. static get loggingLevel(): number;
  105435. static set loggingLevel(value: number);
  105436. /**
  105437. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105438. */
  105439. static get CleanBoneMatrixWeights(): boolean;
  105440. static set CleanBoneMatrixWeights(value: boolean);
  105441. }
  105442. }
  105443. declare module BABYLON {
  105444. /**
  105445. * Class used to store geometry data (vertex buffers + index buffer)
  105446. */
  105447. export class Geometry implements IGetSetVerticesData {
  105448. /**
  105449. * Gets or sets the ID of the geometry
  105450. */
  105451. id: string;
  105452. /**
  105453. * Gets or sets the unique ID of the geometry
  105454. */
  105455. uniqueId: number;
  105456. /**
  105457. * Gets the delay loading state of the geometry (none by default which means not delayed)
  105458. */
  105459. delayLoadState: number;
  105460. /**
  105461. * Gets the file containing the data to load when running in delay load state
  105462. */
  105463. delayLoadingFile: Nullable<string>;
  105464. /**
  105465. * Callback called when the geometry is updated
  105466. */
  105467. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  105468. private _scene;
  105469. private _engine;
  105470. private _meshes;
  105471. private _totalVertices;
  105472. /** @hidden */
  105473. _indices: IndicesArray;
  105474. /** @hidden */
  105475. _vertexBuffers: {
  105476. [key: string]: VertexBuffer;
  105477. };
  105478. private _isDisposed;
  105479. private _extend;
  105480. private _boundingBias;
  105481. /** @hidden */
  105482. _delayInfo: Array<string>;
  105483. private _indexBuffer;
  105484. private _indexBufferIsUpdatable;
  105485. /** @hidden */
  105486. _boundingInfo: Nullable<BoundingInfo>;
  105487. /** @hidden */
  105488. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  105489. /** @hidden */
  105490. _softwareSkinningFrameId: number;
  105491. private _vertexArrayObjects;
  105492. private _updatable;
  105493. /** @hidden */
  105494. _positions: Nullable<Vector3[]>;
  105495. /**
  105496. * 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
  105497. */
  105498. get boundingBias(): Vector2;
  105499. /**
  105500. * 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
  105501. */
  105502. set boundingBias(value: Vector2);
  105503. /**
  105504. * Static function used to attach a new empty geometry to a mesh
  105505. * @param mesh defines the mesh to attach the geometry to
  105506. * @returns the new Geometry
  105507. */
  105508. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  105509. /** Get the list of meshes using this geometry */
  105510. get meshes(): Mesh[];
  105511. /**
  105512. * 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
  105513. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  105514. */
  105515. useBoundingInfoFromGeometry: boolean;
  105516. /**
  105517. * Creates a new geometry
  105518. * @param id defines the unique ID
  105519. * @param scene defines the hosting scene
  105520. * @param vertexData defines the VertexData used to get geometry data
  105521. * @param updatable defines if geometry must be updatable (false by default)
  105522. * @param mesh defines the mesh that will be associated with the geometry
  105523. */
  105524. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  105525. /**
  105526. * Gets the current extend of the geometry
  105527. */
  105528. get extend(): {
  105529. minimum: Vector3;
  105530. maximum: Vector3;
  105531. };
  105532. /**
  105533. * Gets the hosting scene
  105534. * @returns the hosting Scene
  105535. */
  105536. getScene(): Scene;
  105537. /**
  105538. * Gets the hosting engine
  105539. * @returns the hosting Engine
  105540. */
  105541. getEngine(): Engine;
  105542. /**
  105543. * Defines if the geometry is ready to use
  105544. * @returns true if the geometry is ready to be used
  105545. */
  105546. isReady(): boolean;
  105547. /**
  105548. * Gets a value indicating that the geometry should not be serialized
  105549. */
  105550. get doNotSerialize(): boolean;
  105551. /** @hidden */
  105552. _rebuild(): void;
  105553. /**
  105554. * Affects all geometry data in one call
  105555. * @param vertexData defines the geometry data
  105556. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  105557. */
  105558. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  105559. /**
  105560. * Set specific vertex data
  105561. * @param kind defines the data kind (Position, normal, etc...)
  105562. * @param data defines the vertex data to use
  105563. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  105564. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  105565. */
  105566. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  105567. /**
  105568. * Removes a specific vertex data
  105569. * @param kind defines the data kind (Position, normal, etc...)
  105570. */
  105571. removeVerticesData(kind: string): void;
  105572. /**
  105573. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  105574. * @param buffer defines the vertex buffer to use
  105575. * @param totalVertices defines the total number of vertices for position kind (could be null)
  105576. */
  105577. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  105578. /**
  105579. * Update a specific vertex buffer
  105580. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  105581. * It will do nothing if the buffer is not updatable
  105582. * @param kind defines the data kind (Position, normal, etc...)
  105583. * @param data defines the data to use
  105584. * @param offset defines the offset in the target buffer where to store the data
  105585. * @param useBytes set to true if the offset is in bytes
  105586. */
  105587. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  105588. /**
  105589. * Update a specific vertex buffer
  105590. * This function will create a new buffer if the current one is not updatable
  105591. * @param kind defines the data kind (Position, normal, etc...)
  105592. * @param data defines the data to use
  105593. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  105594. */
  105595. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  105596. private _updateBoundingInfo;
  105597. /** @hidden */
  105598. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  105599. /**
  105600. * Gets total number of vertices
  105601. * @returns the total number of vertices
  105602. */
  105603. getTotalVertices(): number;
  105604. /**
  105605. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  105606. * @param kind defines the data kind (Position, normal, etc...)
  105607. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105608. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105609. * @returns a float array containing vertex data
  105610. */
  105611. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105612. /**
  105613. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  105614. * @param kind defines the data kind (Position, normal, etc...)
  105615. * @returns true if the vertex buffer with the specified kind is updatable
  105616. */
  105617. isVertexBufferUpdatable(kind: string): boolean;
  105618. /**
  105619. * Gets a specific vertex buffer
  105620. * @param kind defines the data kind (Position, normal, etc...)
  105621. * @returns a VertexBuffer
  105622. */
  105623. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105624. /**
  105625. * Returns all vertex buffers
  105626. * @return an object holding all vertex buffers indexed by kind
  105627. */
  105628. getVertexBuffers(): Nullable<{
  105629. [key: string]: VertexBuffer;
  105630. }>;
  105631. /**
  105632. * Gets a boolean indicating if specific vertex buffer is present
  105633. * @param kind defines the data kind (Position, normal, etc...)
  105634. * @returns true if data is present
  105635. */
  105636. isVerticesDataPresent(kind: string): boolean;
  105637. /**
  105638. * Gets a list of all attached data kinds (Position, normal, etc...)
  105639. * @returns a list of string containing all kinds
  105640. */
  105641. getVerticesDataKinds(): string[];
  105642. /**
  105643. * Update index buffer
  105644. * @param indices defines the indices to store in the index buffer
  105645. * @param offset defines the offset in the target buffer where to store the data
  105646. * @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)
  105647. */
  105648. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  105649. /**
  105650. * Creates a new index buffer
  105651. * @param indices defines the indices to store in the index buffer
  105652. * @param totalVertices defines the total number of vertices (could be null)
  105653. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  105654. */
  105655. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  105656. /**
  105657. * Return the total number of indices
  105658. * @returns the total number of indices
  105659. */
  105660. getTotalIndices(): number;
  105661. /**
  105662. * Gets the index buffer array
  105663. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105664. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105665. * @returns the index buffer array
  105666. */
  105667. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105668. /**
  105669. * Gets the index buffer
  105670. * @return the index buffer
  105671. */
  105672. getIndexBuffer(): Nullable<DataBuffer>;
  105673. /** @hidden */
  105674. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  105675. /**
  105676. * Release the associated resources for a specific mesh
  105677. * @param mesh defines the source mesh
  105678. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  105679. */
  105680. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  105681. /**
  105682. * Apply current geometry to a given mesh
  105683. * @param mesh defines the mesh to apply geometry to
  105684. */
  105685. applyToMesh(mesh: Mesh): void;
  105686. private _updateExtend;
  105687. private _applyToMesh;
  105688. private notifyUpdate;
  105689. /**
  105690. * Load the geometry if it was flagged as delay loaded
  105691. * @param scene defines the hosting scene
  105692. * @param onLoaded defines a callback called when the geometry is loaded
  105693. */
  105694. load(scene: Scene, onLoaded?: () => void): void;
  105695. private _queueLoad;
  105696. /**
  105697. * Invert the geometry to move from a right handed system to a left handed one.
  105698. */
  105699. toLeftHanded(): void;
  105700. /** @hidden */
  105701. _resetPointsArrayCache(): void;
  105702. /** @hidden */
  105703. _generatePointsArray(): boolean;
  105704. /**
  105705. * Gets a value indicating if the geometry is disposed
  105706. * @returns true if the geometry was disposed
  105707. */
  105708. isDisposed(): boolean;
  105709. private _disposeVertexArrayObjects;
  105710. /**
  105711. * Free all associated resources
  105712. */
  105713. dispose(): void;
  105714. /**
  105715. * Clone the current geometry into a new geometry
  105716. * @param id defines the unique ID of the new geometry
  105717. * @returns a new geometry object
  105718. */
  105719. copy(id: string): Geometry;
  105720. /**
  105721. * Serialize the current geometry info (and not the vertices data) into a JSON object
  105722. * @return a JSON representation of the current geometry data (without the vertices data)
  105723. */
  105724. serialize(): any;
  105725. private toNumberArray;
  105726. /**
  105727. * Serialize all vertices data into a JSON oject
  105728. * @returns a JSON representation of the current geometry data
  105729. */
  105730. serializeVerticeData(): any;
  105731. /**
  105732. * Extracts a clone of a mesh geometry
  105733. * @param mesh defines the source mesh
  105734. * @param id defines the unique ID of the new geometry object
  105735. * @returns the new geometry object
  105736. */
  105737. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  105738. /**
  105739. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  105740. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  105741. * Be aware Math.random() could cause collisions, but:
  105742. * "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"
  105743. * @returns a string containing a new GUID
  105744. */
  105745. static RandomId(): string;
  105746. /** @hidden */
  105747. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  105748. private static _CleanMatricesWeights;
  105749. /**
  105750. * Create a new geometry from persisted data (Using .babylon file format)
  105751. * @param parsedVertexData defines the persisted data
  105752. * @param scene defines the hosting scene
  105753. * @param rootUrl defines the root url to use to load assets (like delayed data)
  105754. * @returns the new geometry object
  105755. */
  105756. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  105757. }
  105758. }
  105759. declare module BABYLON {
  105760. /**
  105761. * Define an interface for all classes that will get and set the data on vertices
  105762. */
  105763. export interface IGetSetVerticesData {
  105764. /**
  105765. * Gets a boolean indicating if specific vertex data is present
  105766. * @param kind defines the vertex data kind to use
  105767. * @returns true is data kind is present
  105768. */
  105769. isVerticesDataPresent(kind: string): boolean;
  105770. /**
  105771. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  105772. * @param kind defines the data kind (Position, normal, etc...)
  105773. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105774. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105775. * @returns a float array containing vertex data
  105776. */
  105777. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105778. /**
  105779. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105780. * @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.
  105781. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105782. * @returns the indices array or an empty array if the mesh has no geometry
  105783. */
  105784. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105785. /**
  105786. * Set specific vertex data
  105787. * @param kind defines the data kind (Position, normal, etc...)
  105788. * @param data defines the vertex data to use
  105789. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  105790. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  105791. */
  105792. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  105793. /**
  105794. * Update a specific associated vertex buffer
  105795. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105796. * - VertexBuffer.PositionKind
  105797. * - VertexBuffer.UVKind
  105798. * - VertexBuffer.UV2Kind
  105799. * - VertexBuffer.UV3Kind
  105800. * - VertexBuffer.UV4Kind
  105801. * - VertexBuffer.UV5Kind
  105802. * - VertexBuffer.UV6Kind
  105803. * - VertexBuffer.ColorKind
  105804. * - VertexBuffer.MatricesIndicesKind
  105805. * - VertexBuffer.MatricesIndicesExtraKind
  105806. * - VertexBuffer.MatricesWeightsKind
  105807. * - VertexBuffer.MatricesWeightsExtraKind
  105808. * @param data defines the data source
  105809. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105810. * @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)
  105811. */
  105812. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  105813. /**
  105814. * Creates a new index buffer
  105815. * @param indices defines the indices to store in the index buffer
  105816. * @param totalVertices defines the total number of vertices (could be null)
  105817. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  105818. */
  105819. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  105820. }
  105821. /**
  105822. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  105823. */
  105824. export class VertexData {
  105825. /**
  105826. * Mesh side orientation : usually the external or front surface
  105827. */
  105828. static readonly FRONTSIDE: number;
  105829. /**
  105830. * Mesh side orientation : usually the internal or back surface
  105831. */
  105832. static readonly BACKSIDE: number;
  105833. /**
  105834. * Mesh side orientation : both internal and external or front and back surfaces
  105835. */
  105836. static readonly DOUBLESIDE: number;
  105837. /**
  105838. * Mesh side orientation : by default, `FRONTSIDE`
  105839. */
  105840. static readonly DEFAULTSIDE: number;
  105841. /**
  105842. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  105843. */
  105844. positions: Nullable<FloatArray>;
  105845. /**
  105846. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  105847. */
  105848. normals: Nullable<FloatArray>;
  105849. /**
  105850. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  105851. */
  105852. tangents: Nullable<FloatArray>;
  105853. /**
  105854. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105855. */
  105856. uvs: Nullable<FloatArray>;
  105857. /**
  105858. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105859. */
  105860. uvs2: Nullable<FloatArray>;
  105861. /**
  105862. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105863. */
  105864. uvs3: Nullable<FloatArray>;
  105865. /**
  105866. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105867. */
  105868. uvs4: Nullable<FloatArray>;
  105869. /**
  105870. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105871. */
  105872. uvs5: Nullable<FloatArray>;
  105873. /**
  105874. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105875. */
  105876. uvs6: Nullable<FloatArray>;
  105877. /**
  105878. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  105879. */
  105880. colors: Nullable<FloatArray>;
  105881. /**
  105882. * 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).
  105883. */
  105884. matricesIndices: Nullable<FloatArray>;
  105885. /**
  105886. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  105887. */
  105888. matricesWeights: Nullable<FloatArray>;
  105889. /**
  105890. * An array extending the number of possible indices
  105891. */
  105892. matricesIndicesExtra: Nullable<FloatArray>;
  105893. /**
  105894. * An array extending the number of possible weights when the number of indices is extended
  105895. */
  105896. matricesWeightsExtra: Nullable<FloatArray>;
  105897. /**
  105898. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  105899. */
  105900. indices: Nullable<IndicesArray>;
  105901. /**
  105902. * Uses the passed data array to set the set the values for the specified kind of data
  105903. * @param data a linear array of floating numbers
  105904. * @param kind the type of data that is being set, eg positions, colors etc
  105905. */
  105906. set(data: FloatArray, kind: string): void;
  105907. /**
  105908. * Associates the vertexData to the passed Mesh.
  105909. * Sets it as updatable or not (default `false`)
  105910. * @param mesh the mesh the vertexData is applied to
  105911. * @param updatable when used and having the value true allows new data to update the vertexData
  105912. * @returns the VertexData
  105913. */
  105914. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  105915. /**
  105916. * Associates the vertexData to the passed Geometry.
  105917. * Sets it as updatable or not (default `false`)
  105918. * @param geometry the geometry the vertexData is applied to
  105919. * @param updatable when used and having the value true allows new data to update the vertexData
  105920. * @returns VertexData
  105921. */
  105922. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  105923. /**
  105924. * Updates the associated mesh
  105925. * @param mesh the mesh to be updated
  105926. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  105927. * @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
  105928. * @returns VertexData
  105929. */
  105930. updateMesh(mesh: Mesh): VertexData;
  105931. /**
  105932. * Updates the associated geometry
  105933. * @param geometry the geometry to be updated
  105934. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  105935. * @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
  105936. * @returns VertexData.
  105937. */
  105938. updateGeometry(geometry: Geometry): VertexData;
  105939. private _applyTo;
  105940. private _update;
  105941. /**
  105942. * Transforms each position and each normal of the vertexData according to the passed Matrix
  105943. * @param matrix the transforming matrix
  105944. * @returns the VertexData
  105945. */
  105946. transform(matrix: Matrix): VertexData;
  105947. /**
  105948. * Merges the passed VertexData into the current one
  105949. * @param other the VertexData to be merged into the current one
  105950. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  105951. * @returns the modified VertexData
  105952. */
  105953. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  105954. private _mergeElement;
  105955. private _validate;
  105956. /**
  105957. * Serializes the VertexData
  105958. * @returns a serialized object
  105959. */
  105960. serialize(): any;
  105961. /**
  105962. * Extracts the vertexData from a mesh
  105963. * @param mesh the mesh from which to extract the VertexData
  105964. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  105965. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  105966. * @returns the object VertexData associated to the passed mesh
  105967. */
  105968. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  105969. /**
  105970. * Extracts the vertexData from the geometry
  105971. * @param geometry the geometry from which to extract the VertexData
  105972. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  105973. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  105974. * @returns the object VertexData associated to the passed mesh
  105975. */
  105976. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  105977. private static _ExtractFrom;
  105978. /**
  105979. * Creates the VertexData for a Ribbon
  105980. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  105981. * * pathArray array of paths, each of which an array of successive Vector3
  105982. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  105983. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  105984. * * 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
  105985. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105986. * * 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)
  105987. * * 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)
  105988. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  105989. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  105990. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  105991. * @returns the VertexData of the ribbon
  105992. */
  105993. static CreateRibbon(options: {
  105994. pathArray: Vector3[][];
  105995. closeArray?: boolean;
  105996. closePath?: boolean;
  105997. offset?: number;
  105998. sideOrientation?: number;
  105999. frontUVs?: Vector4;
  106000. backUVs?: Vector4;
  106001. invertUV?: boolean;
  106002. uvs?: Vector2[];
  106003. colors?: Color4[];
  106004. }): VertexData;
  106005. /**
  106006. * Creates the VertexData for a box
  106007. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106008. * * size sets the width, height and depth of the box to the value of size, optional default 1
  106009. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  106010. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  106011. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  106012. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106013. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106014. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106015. * * 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)
  106016. * * 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)
  106017. * @returns the VertexData of the box
  106018. */
  106019. static CreateBox(options: {
  106020. size?: number;
  106021. width?: number;
  106022. height?: number;
  106023. depth?: number;
  106024. faceUV?: Vector4[];
  106025. faceColors?: Color4[];
  106026. sideOrientation?: number;
  106027. frontUVs?: Vector4;
  106028. backUVs?: Vector4;
  106029. }): VertexData;
  106030. /**
  106031. * Creates the VertexData for a tiled box
  106032. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106033. * * faceTiles sets the pattern, tile size and number of tiles for a face
  106034. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106035. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106036. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106037. * @returns the VertexData of the box
  106038. */
  106039. static CreateTiledBox(options: {
  106040. pattern?: number;
  106041. width?: number;
  106042. height?: number;
  106043. depth?: number;
  106044. tileSize?: number;
  106045. tileWidth?: number;
  106046. tileHeight?: number;
  106047. alignHorizontal?: number;
  106048. alignVertical?: number;
  106049. faceUV?: Vector4[];
  106050. faceColors?: Color4[];
  106051. sideOrientation?: number;
  106052. }): VertexData;
  106053. /**
  106054. * Creates the VertexData for a tiled plane
  106055. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106056. * * pattern a limited pattern arrangement depending on the number
  106057. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  106058. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  106059. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  106060. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106061. * * 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)
  106062. * * 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)
  106063. * @returns the VertexData of the tiled plane
  106064. */
  106065. static CreateTiledPlane(options: {
  106066. pattern?: number;
  106067. tileSize?: number;
  106068. tileWidth?: number;
  106069. tileHeight?: number;
  106070. size?: number;
  106071. width?: number;
  106072. height?: number;
  106073. alignHorizontal?: number;
  106074. alignVertical?: number;
  106075. sideOrientation?: number;
  106076. frontUVs?: Vector4;
  106077. backUVs?: Vector4;
  106078. }): VertexData;
  106079. /**
  106080. * Creates the VertexData for an ellipsoid, defaults to a sphere
  106081. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106082. * * segments sets the number of horizontal strips optional, default 32
  106083. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  106084. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  106085. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  106086. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  106087. * * 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
  106088. * * 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
  106089. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106090. * * 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)
  106091. * * 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)
  106092. * @returns the VertexData of the ellipsoid
  106093. */
  106094. static CreateSphere(options: {
  106095. segments?: number;
  106096. diameter?: number;
  106097. diameterX?: number;
  106098. diameterY?: number;
  106099. diameterZ?: number;
  106100. arc?: number;
  106101. slice?: number;
  106102. sideOrientation?: number;
  106103. frontUVs?: Vector4;
  106104. backUVs?: Vector4;
  106105. }): VertexData;
  106106. /**
  106107. * Creates the VertexData for a cylinder, cone or prism
  106108. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106109. * * height sets the height (y direction) of the cylinder, optional, default 2
  106110. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  106111. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  106112. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  106113. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106114. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  106115. * * 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
  106116. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106117. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106118. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  106119. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  106120. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106121. * * 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)
  106122. * * 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)
  106123. * @returns the VertexData of the cylinder, cone or prism
  106124. */
  106125. static CreateCylinder(options: {
  106126. height?: number;
  106127. diameterTop?: number;
  106128. diameterBottom?: number;
  106129. diameter?: number;
  106130. tessellation?: number;
  106131. subdivisions?: number;
  106132. arc?: number;
  106133. faceColors?: Color4[];
  106134. faceUV?: Vector4[];
  106135. hasRings?: boolean;
  106136. enclose?: boolean;
  106137. sideOrientation?: number;
  106138. frontUVs?: Vector4;
  106139. backUVs?: Vector4;
  106140. }): VertexData;
  106141. /**
  106142. * Creates the VertexData for a torus
  106143. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106144. * * diameter the diameter of the torus, optional default 1
  106145. * * thickness the diameter of the tube forming the torus, optional default 0.5
  106146. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106147. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106148. * * 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)
  106149. * * 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)
  106150. * @returns the VertexData of the torus
  106151. */
  106152. static CreateTorus(options: {
  106153. diameter?: number;
  106154. thickness?: number;
  106155. tessellation?: number;
  106156. sideOrientation?: number;
  106157. frontUVs?: Vector4;
  106158. backUVs?: Vector4;
  106159. }): VertexData;
  106160. /**
  106161. * Creates the VertexData of the LineSystem
  106162. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  106163. * - lines an array of lines, each line being an array of successive Vector3
  106164. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  106165. * @returns the VertexData of the LineSystem
  106166. */
  106167. static CreateLineSystem(options: {
  106168. lines: Vector3[][];
  106169. colors?: Nullable<Color4[][]>;
  106170. }): VertexData;
  106171. /**
  106172. * Create the VertexData for a DashedLines
  106173. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  106174. * - points an array successive Vector3
  106175. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  106176. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  106177. * - dashNb the intended total number of dashes, optional, default 200
  106178. * @returns the VertexData for the DashedLines
  106179. */
  106180. static CreateDashedLines(options: {
  106181. points: Vector3[];
  106182. dashSize?: number;
  106183. gapSize?: number;
  106184. dashNb?: number;
  106185. }): VertexData;
  106186. /**
  106187. * Creates the VertexData for a Ground
  106188. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106189. * - width the width (x direction) of the ground, optional, default 1
  106190. * - height the height (z direction) of the ground, optional, default 1
  106191. * - subdivisions the number of subdivisions per side, optional, default 1
  106192. * @returns the VertexData of the Ground
  106193. */
  106194. static CreateGround(options: {
  106195. width?: number;
  106196. height?: number;
  106197. subdivisions?: number;
  106198. subdivisionsX?: number;
  106199. subdivisionsY?: number;
  106200. }): VertexData;
  106201. /**
  106202. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  106203. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106204. * * xmin the ground minimum X coordinate, optional, default -1
  106205. * * zmin the ground minimum Z coordinate, optional, default -1
  106206. * * xmax the ground maximum X coordinate, optional, default 1
  106207. * * zmax the ground maximum Z coordinate, optional, default 1
  106208. * * 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}
  106209. * * 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}
  106210. * @returns the VertexData of the TiledGround
  106211. */
  106212. static CreateTiledGround(options: {
  106213. xmin: number;
  106214. zmin: number;
  106215. xmax: number;
  106216. zmax: number;
  106217. subdivisions?: {
  106218. w: number;
  106219. h: number;
  106220. };
  106221. precision?: {
  106222. w: number;
  106223. h: number;
  106224. };
  106225. }): VertexData;
  106226. /**
  106227. * Creates the VertexData of the Ground designed from a heightmap
  106228. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  106229. * * width the width (x direction) of the ground
  106230. * * height the height (z direction) of the ground
  106231. * * subdivisions the number of subdivisions per side
  106232. * * minHeight the minimum altitude on the ground, optional, default 0
  106233. * * maxHeight the maximum altitude on the ground, optional default 1
  106234. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  106235. * * buffer the array holding the image color data
  106236. * * bufferWidth the width of image
  106237. * * bufferHeight the height of image
  106238. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  106239. * @returns the VertexData of the Ground designed from a heightmap
  106240. */
  106241. static CreateGroundFromHeightMap(options: {
  106242. width: number;
  106243. height: number;
  106244. subdivisions: number;
  106245. minHeight: number;
  106246. maxHeight: number;
  106247. colorFilter: Color3;
  106248. buffer: Uint8Array;
  106249. bufferWidth: number;
  106250. bufferHeight: number;
  106251. alphaFilter: number;
  106252. }): VertexData;
  106253. /**
  106254. * Creates the VertexData for a Plane
  106255. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  106256. * * size sets the width and height of the plane to the value of size, optional default 1
  106257. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  106258. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  106259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106260. * * 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)
  106261. * * 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)
  106262. * @returns the VertexData of the box
  106263. */
  106264. static CreatePlane(options: {
  106265. size?: number;
  106266. width?: number;
  106267. height?: number;
  106268. sideOrientation?: number;
  106269. frontUVs?: Vector4;
  106270. backUVs?: Vector4;
  106271. }): VertexData;
  106272. /**
  106273. * Creates the VertexData of the Disc or regular Polygon
  106274. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  106275. * * radius the radius of the disc, optional default 0.5
  106276. * * tessellation the number of polygon sides, optional, default 64
  106277. * * 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
  106278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106279. * * 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)
  106280. * * 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)
  106281. * @returns the VertexData of the box
  106282. */
  106283. static CreateDisc(options: {
  106284. radius?: number;
  106285. tessellation?: number;
  106286. arc?: number;
  106287. sideOrientation?: number;
  106288. frontUVs?: Vector4;
  106289. backUVs?: Vector4;
  106290. }): VertexData;
  106291. /**
  106292. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  106293. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  106294. * @param polygon a mesh built from polygonTriangulation.build()
  106295. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106296. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106297. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106298. * @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)
  106299. * @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)
  106300. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  106301. * @returns the VertexData of the Polygon
  106302. */
  106303. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  106304. /**
  106305. * Creates the VertexData of the IcoSphere
  106306. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  106307. * * radius the radius of the IcoSphere, optional default 1
  106308. * * radiusX allows stretching in the x direction, optional, default radius
  106309. * * radiusY allows stretching in the y direction, optional, default radius
  106310. * * radiusZ allows stretching in the z direction, optional, default radius
  106311. * * flat when true creates a flat shaded mesh, optional, default true
  106312. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106313. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106314. * * 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)
  106315. * * 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)
  106316. * @returns the VertexData of the IcoSphere
  106317. */
  106318. static CreateIcoSphere(options: {
  106319. radius?: number;
  106320. radiusX?: number;
  106321. radiusY?: number;
  106322. radiusZ?: number;
  106323. flat?: boolean;
  106324. subdivisions?: number;
  106325. sideOrientation?: number;
  106326. frontUVs?: Vector4;
  106327. backUVs?: Vector4;
  106328. }): VertexData;
  106329. /**
  106330. * Creates the VertexData for a Polyhedron
  106331. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  106332. * * type provided types are:
  106333. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  106334. * * 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)
  106335. * * size the size of the IcoSphere, optional default 1
  106336. * * sizeX allows stretching in the x direction, optional, default size
  106337. * * sizeY allows stretching in the y direction, optional, default size
  106338. * * sizeZ allows stretching in the z direction, optional, default size
  106339. * * 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
  106340. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106341. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106342. * * flat when true creates a flat shaded mesh, optional, default true
  106343. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106344. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106345. * * 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)
  106346. * * 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)
  106347. * @returns the VertexData of the Polyhedron
  106348. */
  106349. static CreatePolyhedron(options: {
  106350. type?: number;
  106351. size?: number;
  106352. sizeX?: number;
  106353. sizeY?: number;
  106354. sizeZ?: number;
  106355. custom?: any;
  106356. faceUV?: Vector4[];
  106357. faceColors?: Color4[];
  106358. flat?: boolean;
  106359. sideOrientation?: number;
  106360. frontUVs?: Vector4;
  106361. backUVs?: Vector4;
  106362. }): VertexData;
  106363. /**
  106364. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  106365. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  106366. * @returns the VertexData of the Capsule
  106367. */
  106368. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  106369. /**
  106370. * Creates the VertexData for a TorusKnot
  106371. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  106372. * * radius the radius of the torus knot, optional, default 2
  106373. * * tube the thickness of the tube, optional, default 0.5
  106374. * * radialSegments the number of sides on each tube segments, optional, default 32
  106375. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  106376. * * p the number of windings around the z axis, optional, default 2
  106377. * * q the number of windings around the x axis, optional, default 3
  106378. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106379. * * 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)
  106380. * * 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)
  106381. * @returns the VertexData of the Torus Knot
  106382. */
  106383. static CreateTorusKnot(options: {
  106384. radius?: number;
  106385. tube?: number;
  106386. radialSegments?: number;
  106387. tubularSegments?: number;
  106388. p?: number;
  106389. q?: number;
  106390. sideOrientation?: number;
  106391. frontUVs?: Vector4;
  106392. backUVs?: Vector4;
  106393. }): VertexData;
  106394. /**
  106395. * Compute normals for given positions and indices
  106396. * @param positions an array of vertex positions, [...., x, y, z, ......]
  106397. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  106398. * @param normals an array of vertex normals, [...., x, y, z, ......]
  106399. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  106400. * * facetNormals : optional array of facet normals (vector3)
  106401. * * facetPositions : optional array of facet positions (vector3)
  106402. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  106403. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  106404. * * bInfo : optional bounding info, required for facetPartitioning computation
  106405. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  106406. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  106407. * * useRightHandedSystem: optional boolean to for right handed system computation
  106408. * * depthSort : optional boolean to enable the facet depth sort computation
  106409. * * distanceTo : optional Vector3 to compute the facet depth from this location
  106410. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  106411. */
  106412. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  106413. facetNormals?: any;
  106414. facetPositions?: any;
  106415. facetPartitioning?: any;
  106416. ratio?: number;
  106417. bInfo?: any;
  106418. bbSize?: Vector3;
  106419. subDiv?: any;
  106420. useRightHandedSystem?: boolean;
  106421. depthSort?: boolean;
  106422. distanceTo?: Vector3;
  106423. depthSortedFacets?: any;
  106424. }): void;
  106425. /** @hidden */
  106426. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  106427. /**
  106428. * Applies VertexData created from the imported parameters to the geometry
  106429. * @param parsedVertexData the parsed data from an imported file
  106430. * @param geometry the geometry to apply the VertexData to
  106431. */
  106432. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  106433. }
  106434. }
  106435. declare module BABYLON {
  106436. /**
  106437. * Defines a target to use with MorphTargetManager
  106438. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106439. */
  106440. export class MorphTarget implements IAnimatable {
  106441. /** defines the name of the target */
  106442. name: string;
  106443. /**
  106444. * Gets or sets the list of animations
  106445. */
  106446. animations: Animation[];
  106447. private _scene;
  106448. private _positions;
  106449. private _normals;
  106450. private _tangents;
  106451. private _uvs;
  106452. private _influence;
  106453. private _uniqueId;
  106454. /**
  106455. * Observable raised when the influence changes
  106456. */
  106457. onInfluenceChanged: Observable<boolean>;
  106458. /** @hidden */
  106459. _onDataLayoutChanged: Observable<void>;
  106460. /**
  106461. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  106462. */
  106463. get influence(): number;
  106464. set influence(influence: number);
  106465. /**
  106466. * Gets or sets the id of the morph Target
  106467. */
  106468. id: string;
  106469. private _animationPropertiesOverride;
  106470. /**
  106471. * Gets or sets the animation properties override
  106472. */
  106473. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106474. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106475. /**
  106476. * Creates a new MorphTarget
  106477. * @param name defines the name of the target
  106478. * @param influence defines the influence to use
  106479. * @param scene defines the scene the morphtarget belongs to
  106480. */
  106481. constructor(
  106482. /** defines the name of the target */
  106483. name: string, influence?: number, scene?: Nullable<Scene>);
  106484. /**
  106485. * Gets the unique ID of this manager
  106486. */
  106487. get uniqueId(): number;
  106488. /**
  106489. * Gets a boolean defining if the target contains position data
  106490. */
  106491. get hasPositions(): boolean;
  106492. /**
  106493. * Gets a boolean defining if the target contains normal data
  106494. */
  106495. get hasNormals(): boolean;
  106496. /**
  106497. * Gets a boolean defining if the target contains tangent data
  106498. */
  106499. get hasTangents(): boolean;
  106500. /**
  106501. * Gets a boolean defining if the target contains texture coordinates data
  106502. */
  106503. get hasUVs(): boolean;
  106504. /**
  106505. * Affects position data to this target
  106506. * @param data defines the position data to use
  106507. */
  106508. setPositions(data: Nullable<FloatArray>): void;
  106509. /**
  106510. * Gets the position data stored in this target
  106511. * @returns a FloatArray containing the position data (or null if not present)
  106512. */
  106513. getPositions(): Nullable<FloatArray>;
  106514. /**
  106515. * Affects normal data to this target
  106516. * @param data defines the normal data to use
  106517. */
  106518. setNormals(data: Nullable<FloatArray>): void;
  106519. /**
  106520. * Gets the normal data stored in this target
  106521. * @returns a FloatArray containing the normal data (or null if not present)
  106522. */
  106523. getNormals(): Nullable<FloatArray>;
  106524. /**
  106525. * Affects tangent data to this target
  106526. * @param data defines the tangent data to use
  106527. */
  106528. setTangents(data: Nullable<FloatArray>): void;
  106529. /**
  106530. * Gets the tangent data stored in this target
  106531. * @returns a FloatArray containing the tangent data (or null if not present)
  106532. */
  106533. getTangents(): Nullable<FloatArray>;
  106534. /**
  106535. * Affects texture coordinates data to this target
  106536. * @param data defines the texture coordinates data to use
  106537. */
  106538. setUVs(data: Nullable<FloatArray>): void;
  106539. /**
  106540. * Gets the texture coordinates data stored in this target
  106541. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  106542. */
  106543. getUVs(): Nullable<FloatArray>;
  106544. /**
  106545. * Clone the current target
  106546. * @returns a new MorphTarget
  106547. */
  106548. clone(): MorphTarget;
  106549. /**
  106550. * Serializes the current target into a Serialization object
  106551. * @returns the serialized object
  106552. */
  106553. serialize(): any;
  106554. /**
  106555. * Returns the string "MorphTarget"
  106556. * @returns "MorphTarget"
  106557. */
  106558. getClassName(): string;
  106559. /**
  106560. * Creates a new target from serialized data
  106561. * @param serializationObject defines the serialized data to use
  106562. * @returns a new MorphTarget
  106563. */
  106564. static Parse(serializationObject: any): MorphTarget;
  106565. /**
  106566. * Creates a MorphTarget from mesh data
  106567. * @param mesh defines the source mesh
  106568. * @param name defines the name to use for the new target
  106569. * @param influence defines the influence to attach to the target
  106570. * @returns a new MorphTarget
  106571. */
  106572. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  106573. }
  106574. }
  106575. declare module BABYLON {
  106576. /**
  106577. * This class is used to deform meshes using morphing between different targets
  106578. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106579. */
  106580. export class MorphTargetManager {
  106581. private _targets;
  106582. private _targetInfluenceChangedObservers;
  106583. private _targetDataLayoutChangedObservers;
  106584. private _activeTargets;
  106585. private _scene;
  106586. private _influences;
  106587. private _supportsNormals;
  106588. private _supportsTangents;
  106589. private _supportsUVs;
  106590. private _vertexCount;
  106591. private _uniqueId;
  106592. private _tempInfluences;
  106593. /**
  106594. * Gets or sets a boolean indicating if normals must be morphed
  106595. */
  106596. enableNormalMorphing: boolean;
  106597. /**
  106598. * Gets or sets a boolean indicating if tangents must be morphed
  106599. */
  106600. enableTangentMorphing: boolean;
  106601. /**
  106602. * Gets or sets a boolean indicating if UV must be morphed
  106603. */
  106604. enableUVMorphing: boolean;
  106605. /**
  106606. * Creates a new MorphTargetManager
  106607. * @param scene defines the current scene
  106608. */
  106609. constructor(scene?: Nullable<Scene>);
  106610. /**
  106611. * Gets the unique ID of this manager
  106612. */
  106613. get uniqueId(): number;
  106614. /**
  106615. * Gets the number of vertices handled by this manager
  106616. */
  106617. get vertexCount(): number;
  106618. /**
  106619. * Gets a boolean indicating if this manager supports morphing of normals
  106620. */
  106621. get supportsNormals(): boolean;
  106622. /**
  106623. * Gets a boolean indicating if this manager supports morphing of tangents
  106624. */
  106625. get supportsTangents(): boolean;
  106626. /**
  106627. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  106628. */
  106629. get supportsUVs(): boolean;
  106630. /**
  106631. * Gets the number of targets stored in this manager
  106632. */
  106633. get numTargets(): number;
  106634. /**
  106635. * Gets the number of influencers (ie. the number of targets with influences > 0)
  106636. */
  106637. get numInfluencers(): number;
  106638. /**
  106639. * Gets the list of influences (one per target)
  106640. */
  106641. get influences(): Float32Array;
  106642. /**
  106643. * Gets the active target at specified index. An active target is a target with an influence > 0
  106644. * @param index defines the index to check
  106645. * @returns the requested target
  106646. */
  106647. getActiveTarget(index: number): MorphTarget;
  106648. /**
  106649. * Gets the target at specified index
  106650. * @param index defines the index to check
  106651. * @returns the requested target
  106652. */
  106653. getTarget(index: number): MorphTarget;
  106654. /**
  106655. * Add a new target to this manager
  106656. * @param target defines the target to add
  106657. */
  106658. addTarget(target: MorphTarget): void;
  106659. /**
  106660. * Removes a target from the manager
  106661. * @param target defines the target to remove
  106662. */
  106663. removeTarget(target: MorphTarget): void;
  106664. /**
  106665. * Clone the current manager
  106666. * @returns a new MorphTargetManager
  106667. */
  106668. clone(): MorphTargetManager;
  106669. /**
  106670. * Serializes the current manager into a Serialization object
  106671. * @returns the serialized object
  106672. */
  106673. serialize(): any;
  106674. private _syncActiveTargets;
  106675. /**
  106676. * Syncrhonize the targets with all the meshes using this morph target manager
  106677. */
  106678. synchronize(): void;
  106679. /**
  106680. * Creates a new MorphTargetManager from serialized data
  106681. * @param serializationObject defines the serialized data
  106682. * @param scene defines the hosting scene
  106683. * @returns the new MorphTargetManager
  106684. */
  106685. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  106686. }
  106687. }
  106688. declare module BABYLON {
  106689. /**
  106690. * Class used to represent a specific level of detail of a mesh
  106691. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106692. */
  106693. export class MeshLODLevel {
  106694. /** Defines the distance where this level should start being displayed */
  106695. distance: number;
  106696. /** Defines the mesh to use to render this level */
  106697. mesh: Nullable<Mesh>;
  106698. /**
  106699. * Creates a new LOD level
  106700. * @param distance defines the distance where this level should star being displayed
  106701. * @param mesh defines the mesh to use to render this level
  106702. */
  106703. constructor(
  106704. /** Defines the distance where this level should start being displayed */
  106705. distance: number,
  106706. /** Defines the mesh to use to render this level */
  106707. mesh: Nullable<Mesh>);
  106708. }
  106709. }
  106710. declare module BABYLON {
  106711. /**
  106712. * Helper class used to generate a canvas to manipulate images
  106713. */
  106714. export class CanvasGenerator {
  106715. /**
  106716. * Create a new canvas (or offscreen canvas depending on the context)
  106717. * @param width defines the expected width
  106718. * @param height defines the expected height
  106719. * @return a new canvas or offscreen canvas
  106720. */
  106721. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  106722. }
  106723. }
  106724. declare module BABYLON {
  106725. /**
  106726. * Mesh representing the gorund
  106727. */
  106728. export class GroundMesh extends Mesh {
  106729. /** If octree should be generated */
  106730. generateOctree: boolean;
  106731. private _heightQuads;
  106732. /** @hidden */
  106733. _subdivisionsX: number;
  106734. /** @hidden */
  106735. _subdivisionsY: number;
  106736. /** @hidden */
  106737. _width: number;
  106738. /** @hidden */
  106739. _height: number;
  106740. /** @hidden */
  106741. _minX: number;
  106742. /** @hidden */
  106743. _maxX: number;
  106744. /** @hidden */
  106745. _minZ: number;
  106746. /** @hidden */
  106747. _maxZ: number;
  106748. constructor(name: string, scene: Scene);
  106749. /**
  106750. * "GroundMesh"
  106751. * @returns "GroundMesh"
  106752. */
  106753. getClassName(): string;
  106754. /**
  106755. * The minimum of x and y subdivisions
  106756. */
  106757. get subdivisions(): number;
  106758. /**
  106759. * X subdivisions
  106760. */
  106761. get subdivisionsX(): number;
  106762. /**
  106763. * Y subdivisions
  106764. */
  106765. get subdivisionsY(): number;
  106766. /**
  106767. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  106768. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  106769. * @param chunksCount the number of subdivisions for x and y
  106770. * @param octreeBlocksSize (Default: 32)
  106771. */
  106772. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  106773. /**
  106774. * Returns a height (y) value in the Worl system :
  106775. * the ground altitude at the coordinates (x, z) expressed in the World system.
  106776. * @param x x coordinate
  106777. * @param z z coordinate
  106778. * @returns the ground y position if (x, z) are outside the ground surface.
  106779. */
  106780. getHeightAtCoordinates(x: number, z: number): number;
  106781. /**
  106782. * Returns a normalized vector (Vector3) orthogonal to the ground
  106783. * at the ground coordinates (x, z) expressed in the World system.
  106784. * @param x x coordinate
  106785. * @param z z coordinate
  106786. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  106787. */
  106788. getNormalAtCoordinates(x: number, z: number): Vector3;
  106789. /**
  106790. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  106791. * at the ground coordinates (x, z) expressed in the World system.
  106792. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  106793. * @param x x coordinate
  106794. * @param z z coordinate
  106795. * @param ref vector to store the result
  106796. * @returns the GroundMesh.
  106797. */
  106798. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  106799. /**
  106800. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  106801. * if the ground has been updated.
  106802. * This can be used in the render loop.
  106803. * @returns the GroundMesh.
  106804. */
  106805. updateCoordinateHeights(): GroundMesh;
  106806. private _getFacetAt;
  106807. private _initHeightQuads;
  106808. private _computeHeightQuads;
  106809. /**
  106810. * Serializes this ground mesh
  106811. * @param serializationObject object to write serialization to
  106812. */
  106813. serialize(serializationObject: any): void;
  106814. /**
  106815. * Parses a serialized ground mesh
  106816. * @param parsedMesh the serialized mesh
  106817. * @param scene the scene to create the ground mesh in
  106818. * @returns the created ground mesh
  106819. */
  106820. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  106821. }
  106822. }
  106823. declare module BABYLON {
  106824. /**
  106825. * Interface for Physics-Joint data
  106826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106827. */
  106828. export interface PhysicsJointData {
  106829. /**
  106830. * The main pivot of the joint
  106831. */
  106832. mainPivot?: Vector3;
  106833. /**
  106834. * The connected pivot of the joint
  106835. */
  106836. connectedPivot?: Vector3;
  106837. /**
  106838. * The main axis of the joint
  106839. */
  106840. mainAxis?: Vector3;
  106841. /**
  106842. * The connected axis of the joint
  106843. */
  106844. connectedAxis?: Vector3;
  106845. /**
  106846. * The collision of the joint
  106847. */
  106848. collision?: boolean;
  106849. /**
  106850. * Native Oimo/Cannon/Energy data
  106851. */
  106852. nativeParams?: any;
  106853. }
  106854. /**
  106855. * This is a holder class for the physics joint created by the physics plugin
  106856. * It holds a set of functions to control the underlying joint
  106857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106858. */
  106859. export class PhysicsJoint {
  106860. /**
  106861. * The type of the physics joint
  106862. */
  106863. type: number;
  106864. /**
  106865. * The data for the physics joint
  106866. */
  106867. jointData: PhysicsJointData;
  106868. private _physicsJoint;
  106869. protected _physicsPlugin: IPhysicsEnginePlugin;
  106870. /**
  106871. * Initializes the physics joint
  106872. * @param type The type of the physics joint
  106873. * @param jointData The data for the physics joint
  106874. */
  106875. constructor(
  106876. /**
  106877. * The type of the physics joint
  106878. */
  106879. type: number,
  106880. /**
  106881. * The data for the physics joint
  106882. */
  106883. jointData: PhysicsJointData);
  106884. /**
  106885. * Gets the physics joint
  106886. */
  106887. get physicsJoint(): any;
  106888. /**
  106889. * Sets the physics joint
  106890. */
  106891. set physicsJoint(newJoint: any);
  106892. /**
  106893. * Sets the physics plugin
  106894. */
  106895. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  106896. /**
  106897. * Execute a function that is physics-plugin specific.
  106898. * @param {Function} func the function that will be executed.
  106899. * It accepts two parameters: the physics world and the physics joint
  106900. */
  106901. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  106902. /**
  106903. * Distance-Joint type
  106904. */
  106905. static DistanceJoint: number;
  106906. /**
  106907. * Hinge-Joint type
  106908. */
  106909. static HingeJoint: number;
  106910. /**
  106911. * Ball-and-Socket joint type
  106912. */
  106913. static BallAndSocketJoint: number;
  106914. /**
  106915. * Wheel-Joint type
  106916. */
  106917. static WheelJoint: number;
  106918. /**
  106919. * Slider-Joint type
  106920. */
  106921. static SliderJoint: number;
  106922. /**
  106923. * Prismatic-Joint type
  106924. */
  106925. static PrismaticJoint: number;
  106926. /**
  106927. * Universal-Joint type
  106928. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  106929. */
  106930. static UniversalJoint: number;
  106931. /**
  106932. * Hinge-Joint 2 type
  106933. */
  106934. static Hinge2Joint: number;
  106935. /**
  106936. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  106937. */
  106938. static PointToPointJoint: number;
  106939. /**
  106940. * Spring-Joint type
  106941. */
  106942. static SpringJoint: number;
  106943. /**
  106944. * Lock-Joint type
  106945. */
  106946. static LockJoint: number;
  106947. }
  106948. /**
  106949. * A class representing a physics distance joint
  106950. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106951. */
  106952. export class DistanceJoint extends PhysicsJoint {
  106953. /**
  106954. *
  106955. * @param jointData The data for the Distance-Joint
  106956. */
  106957. constructor(jointData: DistanceJointData);
  106958. /**
  106959. * Update the predefined distance.
  106960. * @param maxDistance The maximum preferred distance
  106961. * @param minDistance The minimum preferred distance
  106962. */
  106963. updateDistance(maxDistance: number, minDistance?: number): void;
  106964. }
  106965. /**
  106966. * Represents a Motor-Enabled Joint
  106967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106968. */
  106969. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  106970. /**
  106971. * Initializes the Motor-Enabled Joint
  106972. * @param type The type of the joint
  106973. * @param jointData The physica joint data for the joint
  106974. */
  106975. constructor(type: number, jointData: PhysicsJointData);
  106976. /**
  106977. * Set the motor values.
  106978. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106979. * @param force the force to apply
  106980. * @param maxForce max force for this motor.
  106981. */
  106982. setMotor(force?: number, maxForce?: number): void;
  106983. /**
  106984. * Set the motor's limits.
  106985. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106986. * @param upperLimit The upper limit of the motor
  106987. * @param lowerLimit The lower limit of the motor
  106988. */
  106989. setLimit(upperLimit: number, lowerLimit?: number): void;
  106990. }
  106991. /**
  106992. * This class represents a single physics Hinge-Joint
  106993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106994. */
  106995. export class HingeJoint extends MotorEnabledJoint {
  106996. /**
  106997. * Initializes the Hinge-Joint
  106998. * @param jointData The joint data for the Hinge-Joint
  106999. */
  107000. constructor(jointData: PhysicsJointData);
  107001. /**
  107002. * Set the motor values.
  107003. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107004. * @param {number} force the force to apply
  107005. * @param {number} maxForce max force for this motor.
  107006. */
  107007. setMotor(force?: number, maxForce?: number): void;
  107008. /**
  107009. * Set the motor's limits.
  107010. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107011. * @param upperLimit The upper limit of the motor
  107012. * @param lowerLimit The lower limit of the motor
  107013. */
  107014. setLimit(upperLimit: number, lowerLimit?: number): void;
  107015. }
  107016. /**
  107017. * This class represents a dual hinge physics joint (same as wheel joint)
  107018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107019. */
  107020. export class Hinge2Joint extends MotorEnabledJoint {
  107021. /**
  107022. * Initializes the Hinge2-Joint
  107023. * @param jointData The joint data for the Hinge2-Joint
  107024. */
  107025. constructor(jointData: PhysicsJointData);
  107026. /**
  107027. * Set the motor values.
  107028. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107029. * @param {number} targetSpeed the speed the motor is to reach
  107030. * @param {number} maxForce max force for this motor.
  107031. * @param {motorIndex} the motor's index, 0 or 1.
  107032. */
  107033. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  107034. /**
  107035. * Set the motor limits.
  107036. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107037. * @param {number} upperLimit the upper limit
  107038. * @param {number} lowerLimit lower limit
  107039. * @param {motorIndex} the motor's index, 0 or 1.
  107040. */
  107041. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107042. }
  107043. /**
  107044. * Interface for a motor enabled joint
  107045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107046. */
  107047. export interface IMotorEnabledJoint {
  107048. /**
  107049. * Physics joint
  107050. */
  107051. physicsJoint: any;
  107052. /**
  107053. * Sets the motor of the motor-enabled joint
  107054. * @param force The force of the motor
  107055. * @param maxForce The maximum force of the motor
  107056. * @param motorIndex The index of the motor
  107057. */
  107058. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  107059. /**
  107060. * Sets the limit of the motor
  107061. * @param upperLimit The upper limit of the motor
  107062. * @param lowerLimit The lower limit of the motor
  107063. * @param motorIndex The index of the motor
  107064. */
  107065. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107066. }
  107067. /**
  107068. * Joint data for a Distance-Joint
  107069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107070. */
  107071. export interface DistanceJointData extends PhysicsJointData {
  107072. /**
  107073. * Max distance the 2 joint objects can be apart
  107074. */
  107075. maxDistance: number;
  107076. }
  107077. /**
  107078. * Joint data from a spring joint
  107079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107080. */
  107081. export interface SpringJointData extends PhysicsJointData {
  107082. /**
  107083. * Length of the spring
  107084. */
  107085. length: number;
  107086. /**
  107087. * Stiffness of the spring
  107088. */
  107089. stiffness: number;
  107090. /**
  107091. * Damping of the spring
  107092. */
  107093. damping: number;
  107094. /** this callback will be called when applying the force to the impostors. */
  107095. forceApplicationCallback: () => void;
  107096. }
  107097. }
  107098. declare module BABYLON {
  107099. /**
  107100. * Holds the data for the raycast result
  107101. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107102. */
  107103. export class PhysicsRaycastResult {
  107104. private _hasHit;
  107105. private _hitDistance;
  107106. private _hitNormalWorld;
  107107. private _hitPointWorld;
  107108. private _rayFromWorld;
  107109. private _rayToWorld;
  107110. /**
  107111. * Gets if there was a hit
  107112. */
  107113. get hasHit(): boolean;
  107114. /**
  107115. * Gets the distance from the hit
  107116. */
  107117. get hitDistance(): number;
  107118. /**
  107119. * Gets the hit normal/direction in the world
  107120. */
  107121. get hitNormalWorld(): Vector3;
  107122. /**
  107123. * Gets the hit point in the world
  107124. */
  107125. get hitPointWorld(): Vector3;
  107126. /**
  107127. * Gets the ray "start point" of the ray in the world
  107128. */
  107129. get rayFromWorld(): Vector3;
  107130. /**
  107131. * Gets the ray "end point" of the ray in the world
  107132. */
  107133. get rayToWorld(): Vector3;
  107134. /**
  107135. * Sets the hit data (normal & point in world space)
  107136. * @param hitNormalWorld defines the normal in world space
  107137. * @param hitPointWorld defines the point in world space
  107138. */
  107139. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  107140. /**
  107141. * Sets the distance from the start point to the hit point
  107142. * @param distance
  107143. */
  107144. setHitDistance(distance: number): void;
  107145. /**
  107146. * Calculates the distance manually
  107147. */
  107148. calculateHitDistance(): void;
  107149. /**
  107150. * Resets all the values to default
  107151. * @param from The from point on world space
  107152. * @param to The to point on world space
  107153. */
  107154. reset(from?: Vector3, to?: Vector3): void;
  107155. }
  107156. /**
  107157. * Interface for the size containing width and height
  107158. */
  107159. interface IXYZ {
  107160. /**
  107161. * X
  107162. */
  107163. x: number;
  107164. /**
  107165. * Y
  107166. */
  107167. y: number;
  107168. /**
  107169. * Z
  107170. */
  107171. z: number;
  107172. }
  107173. }
  107174. declare module BABYLON {
  107175. /**
  107176. * Interface used to describe a physics joint
  107177. */
  107178. export interface PhysicsImpostorJoint {
  107179. /** Defines the main impostor to which the joint is linked */
  107180. mainImpostor: PhysicsImpostor;
  107181. /** Defines the impostor that is connected to the main impostor using this joint */
  107182. connectedImpostor: PhysicsImpostor;
  107183. /** Defines the joint itself */
  107184. joint: PhysicsJoint;
  107185. }
  107186. /** @hidden */
  107187. export interface IPhysicsEnginePlugin {
  107188. world: any;
  107189. name: string;
  107190. setGravity(gravity: Vector3): void;
  107191. setTimeStep(timeStep: number): void;
  107192. getTimeStep(): number;
  107193. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107194. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107195. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107196. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107197. removePhysicsBody(impostor: PhysicsImpostor): void;
  107198. generateJoint(joint: PhysicsImpostorJoint): void;
  107199. removeJoint(joint: PhysicsImpostorJoint): void;
  107200. isSupported(): boolean;
  107201. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107202. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107203. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107204. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107205. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107206. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107207. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107208. getBodyMass(impostor: PhysicsImpostor): number;
  107209. getBodyFriction(impostor: PhysicsImpostor): number;
  107210. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107211. getBodyRestitution(impostor: PhysicsImpostor): number;
  107212. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107213. getBodyPressure?(impostor: PhysicsImpostor): number;
  107214. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  107215. getBodyStiffness?(impostor: PhysicsImpostor): number;
  107216. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  107217. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  107218. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  107219. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  107220. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  107221. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107222. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107223. sleepBody(impostor: PhysicsImpostor): void;
  107224. wakeUpBody(impostor: PhysicsImpostor): void;
  107225. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107226. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107227. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  107228. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107229. getRadius(impostor: PhysicsImpostor): number;
  107230. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107231. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107232. dispose(): void;
  107233. }
  107234. /**
  107235. * Interface used to define a physics engine
  107236. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107237. */
  107238. export interface IPhysicsEngine {
  107239. /**
  107240. * Gets the gravity vector used by the simulation
  107241. */
  107242. gravity: Vector3;
  107243. /**
  107244. * Sets the gravity vector used by the simulation
  107245. * @param gravity defines the gravity vector to use
  107246. */
  107247. setGravity(gravity: Vector3): void;
  107248. /**
  107249. * Set the time step of the physics engine.
  107250. * Default is 1/60.
  107251. * To slow it down, enter 1/600 for example.
  107252. * To speed it up, 1/30
  107253. * @param newTimeStep the new timestep to apply to this world.
  107254. */
  107255. setTimeStep(newTimeStep: number): void;
  107256. /**
  107257. * Get the time step of the physics engine.
  107258. * @returns the current time step
  107259. */
  107260. getTimeStep(): number;
  107261. /**
  107262. * Set the sub time step of the physics engine.
  107263. * Default is 0 meaning there is no sub steps
  107264. * To increase physics resolution precision, set a small value (like 1 ms)
  107265. * @param subTimeStep defines the new sub timestep used for physics resolution.
  107266. */
  107267. setSubTimeStep(subTimeStep: number): void;
  107268. /**
  107269. * Get the sub time step of the physics engine.
  107270. * @returns the current sub time step
  107271. */
  107272. getSubTimeStep(): number;
  107273. /**
  107274. * Release all resources
  107275. */
  107276. dispose(): void;
  107277. /**
  107278. * Gets the name of the current physics plugin
  107279. * @returns the name of the plugin
  107280. */
  107281. getPhysicsPluginName(): string;
  107282. /**
  107283. * Adding a new impostor for the impostor tracking.
  107284. * This will be done by the impostor itself.
  107285. * @param impostor the impostor to add
  107286. */
  107287. addImpostor(impostor: PhysicsImpostor): void;
  107288. /**
  107289. * Remove an impostor from the engine.
  107290. * This impostor and its mesh will not longer be updated by the physics engine.
  107291. * @param impostor the impostor to remove
  107292. */
  107293. removeImpostor(impostor: PhysicsImpostor): void;
  107294. /**
  107295. * Add a joint to the physics engine
  107296. * @param mainImpostor defines the main impostor to which the joint is added.
  107297. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107298. * @param joint defines the joint that will connect both impostors.
  107299. */
  107300. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107301. /**
  107302. * Removes a joint from the simulation
  107303. * @param mainImpostor defines the impostor used with the joint
  107304. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107305. * @param joint defines the joint to remove
  107306. */
  107307. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107308. /**
  107309. * Gets the current plugin used to run the simulation
  107310. * @returns current plugin
  107311. */
  107312. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107313. /**
  107314. * Gets the list of physic impostors
  107315. * @returns an array of PhysicsImpostor
  107316. */
  107317. getImpostors(): Array<PhysicsImpostor>;
  107318. /**
  107319. * Gets the impostor for a physics enabled object
  107320. * @param object defines the object impersonated by the impostor
  107321. * @returns the PhysicsImpostor or null if not found
  107322. */
  107323. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107324. /**
  107325. * Gets the impostor for a physics body object
  107326. * @param body defines physics body used by the impostor
  107327. * @returns the PhysicsImpostor or null if not found
  107328. */
  107329. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107330. /**
  107331. * Does a raycast in the physics world
  107332. * @param from when should the ray start?
  107333. * @param to when should the ray end?
  107334. * @returns PhysicsRaycastResult
  107335. */
  107336. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107337. /**
  107338. * Called by the scene. No need to call it.
  107339. * @param delta defines the timespam between frames
  107340. */
  107341. _step(delta: number): void;
  107342. }
  107343. }
  107344. declare module BABYLON {
  107345. /**
  107346. * The interface for the physics imposter parameters
  107347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107348. */
  107349. export interface PhysicsImpostorParameters {
  107350. /**
  107351. * The mass of the physics imposter
  107352. */
  107353. mass: number;
  107354. /**
  107355. * The friction of the physics imposter
  107356. */
  107357. friction?: number;
  107358. /**
  107359. * The coefficient of restitution of the physics imposter
  107360. */
  107361. restitution?: number;
  107362. /**
  107363. * The native options of the physics imposter
  107364. */
  107365. nativeOptions?: any;
  107366. /**
  107367. * Specifies if the parent should be ignored
  107368. */
  107369. ignoreParent?: boolean;
  107370. /**
  107371. * Specifies if bi-directional transformations should be disabled
  107372. */
  107373. disableBidirectionalTransformation?: boolean;
  107374. /**
  107375. * The pressure inside the physics imposter, soft object only
  107376. */
  107377. pressure?: number;
  107378. /**
  107379. * The stiffness the physics imposter, soft object only
  107380. */
  107381. stiffness?: number;
  107382. /**
  107383. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  107384. */
  107385. velocityIterations?: number;
  107386. /**
  107387. * The number of iterations used in maintaining consistent vertex positions, soft object only
  107388. */
  107389. positionIterations?: number;
  107390. /**
  107391. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  107392. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  107393. * Add to fix multiple points
  107394. */
  107395. fixedPoints?: number;
  107396. /**
  107397. * The collision margin around a soft object
  107398. */
  107399. margin?: number;
  107400. /**
  107401. * The collision margin around a soft object
  107402. */
  107403. damping?: number;
  107404. /**
  107405. * The path for a rope based on an extrusion
  107406. */
  107407. path?: any;
  107408. /**
  107409. * The shape of an extrusion used for a rope based on an extrusion
  107410. */
  107411. shape?: any;
  107412. }
  107413. /**
  107414. * Interface for a physics-enabled object
  107415. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107416. */
  107417. export interface IPhysicsEnabledObject {
  107418. /**
  107419. * The position of the physics-enabled object
  107420. */
  107421. position: Vector3;
  107422. /**
  107423. * The rotation of the physics-enabled object
  107424. */
  107425. rotationQuaternion: Nullable<Quaternion>;
  107426. /**
  107427. * The scale of the physics-enabled object
  107428. */
  107429. scaling: Vector3;
  107430. /**
  107431. * The rotation of the physics-enabled object
  107432. */
  107433. rotation?: Vector3;
  107434. /**
  107435. * The parent of the physics-enabled object
  107436. */
  107437. parent?: any;
  107438. /**
  107439. * The bounding info of the physics-enabled object
  107440. * @returns The bounding info of the physics-enabled object
  107441. */
  107442. getBoundingInfo(): BoundingInfo;
  107443. /**
  107444. * Computes the world matrix
  107445. * @param force Specifies if the world matrix should be computed by force
  107446. * @returns A world matrix
  107447. */
  107448. computeWorldMatrix(force: boolean): Matrix;
  107449. /**
  107450. * Gets the world matrix
  107451. * @returns A world matrix
  107452. */
  107453. getWorldMatrix?(): Matrix;
  107454. /**
  107455. * Gets the child meshes
  107456. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  107457. * @returns An array of abstract meshes
  107458. */
  107459. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  107460. /**
  107461. * Gets the vertex data
  107462. * @param kind The type of vertex data
  107463. * @returns A nullable array of numbers, or a float32 array
  107464. */
  107465. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  107466. /**
  107467. * Gets the indices from the mesh
  107468. * @returns A nullable array of index arrays
  107469. */
  107470. getIndices?(): Nullable<IndicesArray>;
  107471. /**
  107472. * Gets the scene from the mesh
  107473. * @returns the indices array or null
  107474. */
  107475. getScene?(): Scene;
  107476. /**
  107477. * Gets the absolute position from the mesh
  107478. * @returns the absolute position
  107479. */
  107480. getAbsolutePosition(): Vector3;
  107481. /**
  107482. * Gets the absolute pivot point from the mesh
  107483. * @returns the absolute pivot point
  107484. */
  107485. getAbsolutePivotPoint(): Vector3;
  107486. /**
  107487. * Rotates the mesh
  107488. * @param axis The axis of rotation
  107489. * @param amount The amount of rotation
  107490. * @param space The space of the rotation
  107491. * @returns The rotation transform node
  107492. */
  107493. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107494. /**
  107495. * Translates the mesh
  107496. * @param axis The axis of translation
  107497. * @param distance The distance of translation
  107498. * @param space The space of the translation
  107499. * @returns The transform node
  107500. */
  107501. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107502. /**
  107503. * Sets the absolute position of the mesh
  107504. * @param absolutePosition The absolute position of the mesh
  107505. * @returns The transform node
  107506. */
  107507. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107508. /**
  107509. * Gets the class name of the mesh
  107510. * @returns The class name
  107511. */
  107512. getClassName(): string;
  107513. }
  107514. /**
  107515. * Represents a physics imposter
  107516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107517. */
  107518. export class PhysicsImpostor {
  107519. /**
  107520. * The physics-enabled object used as the physics imposter
  107521. */
  107522. object: IPhysicsEnabledObject;
  107523. /**
  107524. * The type of the physics imposter
  107525. */
  107526. type: number;
  107527. private _options;
  107528. private _scene?;
  107529. /**
  107530. * The default object size of the imposter
  107531. */
  107532. static DEFAULT_OBJECT_SIZE: Vector3;
  107533. /**
  107534. * The identity quaternion of the imposter
  107535. */
  107536. static IDENTITY_QUATERNION: Quaternion;
  107537. /** @hidden */
  107538. _pluginData: any;
  107539. private _physicsEngine;
  107540. private _physicsBody;
  107541. private _bodyUpdateRequired;
  107542. private _onBeforePhysicsStepCallbacks;
  107543. private _onAfterPhysicsStepCallbacks;
  107544. /** @hidden */
  107545. _onPhysicsCollideCallbacks: Array<{
  107546. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  107547. otherImpostors: Array<PhysicsImpostor>;
  107548. }>;
  107549. private _deltaPosition;
  107550. private _deltaRotation;
  107551. private _deltaRotationConjugated;
  107552. /** @hidden */
  107553. _isFromLine: boolean;
  107554. private _parent;
  107555. private _isDisposed;
  107556. private static _tmpVecs;
  107557. private static _tmpQuat;
  107558. /**
  107559. * Specifies if the physics imposter is disposed
  107560. */
  107561. get isDisposed(): boolean;
  107562. /**
  107563. * Gets the mass of the physics imposter
  107564. */
  107565. get mass(): number;
  107566. set mass(value: number);
  107567. /**
  107568. * Gets the coefficient of friction
  107569. */
  107570. get friction(): number;
  107571. /**
  107572. * Sets the coefficient of friction
  107573. */
  107574. set friction(value: number);
  107575. /**
  107576. * Gets the coefficient of restitution
  107577. */
  107578. get restitution(): number;
  107579. /**
  107580. * Sets the coefficient of restitution
  107581. */
  107582. set restitution(value: number);
  107583. /**
  107584. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  107585. */
  107586. get pressure(): number;
  107587. /**
  107588. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  107589. */
  107590. set pressure(value: number);
  107591. /**
  107592. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  107593. */
  107594. get stiffness(): number;
  107595. /**
  107596. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  107597. */
  107598. set stiffness(value: number);
  107599. /**
  107600. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  107601. */
  107602. get velocityIterations(): number;
  107603. /**
  107604. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  107605. */
  107606. set velocityIterations(value: number);
  107607. /**
  107608. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  107609. */
  107610. get positionIterations(): number;
  107611. /**
  107612. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  107613. */
  107614. set positionIterations(value: number);
  107615. /**
  107616. * The unique id of the physics imposter
  107617. * set by the physics engine when adding this impostor to the array
  107618. */
  107619. uniqueId: number;
  107620. /**
  107621. * @hidden
  107622. */
  107623. soft: boolean;
  107624. /**
  107625. * @hidden
  107626. */
  107627. segments: number;
  107628. private _joints;
  107629. /**
  107630. * Initializes the physics imposter
  107631. * @param object The physics-enabled object used as the physics imposter
  107632. * @param type The type of the physics imposter
  107633. * @param _options The options for the physics imposter
  107634. * @param _scene The Babylon scene
  107635. */
  107636. constructor(
  107637. /**
  107638. * The physics-enabled object used as the physics imposter
  107639. */
  107640. object: IPhysicsEnabledObject,
  107641. /**
  107642. * The type of the physics imposter
  107643. */
  107644. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  107645. /**
  107646. * This function will completly initialize this impostor.
  107647. * It will create a new body - but only if this mesh has no parent.
  107648. * If it has, this impostor will not be used other than to define the impostor
  107649. * of the child mesh.
  107650. * @hidden
  107651. */
  107652. _init(): void;
  107653. private _getPhysicsParent;
  107654. /**
  107655. * Should a new body be generated.
  107656. * @returns boolean specifying if body initialization is required
  107657. */
  107658. isBodyInitRequired(): boolean;
  107659. /**
  107660. * Sets the updated scaling
  107661. * @param updated Specifies if the scaling is updated
  107662. */
  107663. setScalingUpdated(): void;
  107664. /**
  107665. * Force a regeneration of this or the parent's impostor's body.
  107666. * Use under cautious - This will remove all joints already implemented.
  107667. */
  107668. forceUpdate(): void;
  107669. /**
  107670. * Gets the body that holds this impostor. Either its own, or its parent.
  107671. */
  107672. get physicsBody(): any;
  107673. /**
  107674. * Get the parent of the physics imposter
  107675. * @returns Physics imposter or null
  107676. */
  107677. get parent(): Nullable<PhysicsImpostor>;
  107678. /**
  107679. * Sets the parent of the physics imposter
  107680. */
  107681. set parent(value: Nullable<PhysicsImpostor>);
  107682. /**
  107683. * Set the physics body. Used mainly by the physics engine/plugin
  107684. */
  107685. set physicsBody(physicsBody: any);
  107686. /**
  107687. * Resets the update flags
  107688. */
  107689. resetUpdateFlags(): void;
  107690. /**
  107691. * Gets the object extend size
  107692. * @returns the object extend size
  107693. */
  107694. getObjectExtendSize(): Vector3;
  107695. /**
  107696. * Gets the object center
  107697. * @returns The object center
  107698. */
  107699. getObjectCenter(): Vector3;
  107700. /**
  107701. * Get a specific parameter from the options parameters
  107702. * @param paramName The object parameter name
  107703. * @returns The object parameter
  107704. */
  107705. getParam(paramName: string): any;
  107706. /**
  107707. * Sets a specific parameter in the options given to the physics plugin
  107708. * @param paramName The parameter name
  107709. * @param value The value of the parameter
  107710. */
  107711. setParam(paramName: string, value: number): void;
  107712. /**
  107713. * Specifically change the body's mass option. Won't recreate the physics body object
  107714. * @param mass The mass of the physics imposter
  107715. */
  107716. setMass(mass: number): void;
  107717. /**
  107718. * Gets the linear velocity
  107719. * @returns linear velocity or null
  107720. */
  107721. getLinearVelocity(): Nullable<Vector3>;
  107722. /**
  107723. * Sets the linear velocity
  107724. * @param velocity linear velocity or null
  107725. */
  107726. setLinearVelocity(velocity: Nullable<Vector3>): void;
  107727. /**
  107728. * Gets the angular velocity
  107729. * @returns angular velocity or null
  107730. */
  107731. getAngularVelocity(): Nullable<Vector3>;
  107732. /**
  107733. * Sets the angular velocity
  107734. * @param velocity The velocity or null
  107735. */
  107736. setAngularVelocity(velocity: Nullable<Vector3>): void;
  107737. /**
  107738. * Execute a function with the physics plugin native code
  107739. * Provide a function the will have two variables - the world object and the physics body object
  107740. * @param func The function to execute with the physics plugin native code
  107741. */
  107742. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  107743. /**
  107744. * Register a function that will be executed before the physics world is stepping forward
  107745. * @param func The function to execute before the physics world is stepped forward
  107746. */
  107747. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107748. /**
  107749. * Unregister a function that will be executed before the physics world is stepping forward
  107750. * @param func The function to execute before the physics world is stepped forward
  107751. */
  107752. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107753. /**
  107754. * Register a function that will be executed after the physics step
  107755. * @param func The function to execute after physics step
  107756. */
  107757. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107758. /**
  107759. * Unregisters a function that will be executed after the physics step
  107760. * @param func The function to execute after physics step
  107761. */
  107762. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107763. /**
  107764. * register a function that will be executed when this impostor collides against a different body
  107765. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  107766. * @param func Callback that is executed on collision
  107767. */
  107768. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  107769. /**
  107770. * Unregisters the physics imposter on contact
  107771. * @param collideAgainst The physics object to collide against
  107772. * @param func Callback to execute on collision
  107773. */
  107774. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  107775. private _tmpQuat;
  107776. private _tmpQuat2;
  107777. /**
  107778. * Get the parent rotation
  107779. * @returns The parent rotation
  107780. */
  107781. getParentsRotation(): Quaternion;
  107782. /**
  107783. * this function is executed by the physics engine.
  107784. */
  107785. beforeStep: () => void;
  107786. /**
  107787. * this function is executed by the physics engine
  107788. */
  107789. afterStep: () => void;
  107790. /**
  107791. * Legacy collision detection event support
  107792. */
  107793. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  107794. /**
  107795. * event and body object due to cannon's event-based architecture.
  107796. */
  107797. onCollide: (e: {
  107798. body: any;
  107799. }) => void;
  107800. /**
  107801. * Apply a force
  107802. * @param force The force to apply
  107803. * @param contactPoint The contact point for the force
  107804. * @returns The physics imposter
  107805. */
  107806. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  107807. /**
  107808. * Apply an impulse
  107809. * @param force The impulse force
  107810. * @param contactPoint The contact point for the impulse force
  107811. * @returns The physics imposter
  107812. */
  107813. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  107814. /**
  107815. * A help function to create a joint
  107816. * @param otherImpostor A physics imposter used to create a joint
  107817. * @param jointType The type of joint
  107818. * @param jointData The data for the joint
  107819. * @returns The physics imposter
  107820. */
  107821. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  107822. /**
  107823. * Add a joint to this impostor with a different impostor
  107824. * @param otherImpostor A physics imposter used to add a joint
  107825. * @param joint The joint to add
  107826. * @returns The physics imposter
  107827. */
  107828. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  107829. /**
  107830. * Add an anchor to a cloth impostor
  107831. * @param otherImpostor rigid impostor to anchor to
  107832. * @param width ratio across width from 0 to 1
  107833. * @param height ratio up height from 0 to 1
  107834. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107835. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  107836. * @returns impostor the soft imposter
  107837. */
  107838. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  107839. /**
  107840. * Add a hook to a rope impostor
  107841. * @param otherImpostor rigid impostor to anchor to
  107842. * @param length ratio across rope from 0 to 1
  107843. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  107844. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107845. * @returns impostor the rope imposter
  107846. */
  107847. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  107848. /**
  107849. * Will keep this body still, in a sleep mode.
  107850. * @returns the physics imposter
  107851. */
  107852. sleep(): PhysicsImpostor;
  107853. /**
  107854. * Wake the body up.
  107855. * @returns The physics imposter
  107856. */
  107857. wakeUp(): PhysicsImpostor;
  107858. /**
  107859. * Clones the physics imposter
  107860. * @param newObject The physics imposter clones to this physics-enabled object
  107861. * @returns A nullable physics imposter
  107862. */
  107863. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107864. /**
  107865. * Disposes the physics imposter
  107866. */
  107867. dispose(): void;
  107868. /**
  107869. * Sets the delta position
  107870. * @param position The delta position amount
  107871. */
  107872. setDeltaPosition(position: Vector3): void;
  107873. /**
  107874. * Sets the delta rotation
  107875. * @param rotation The delta rotation amount
  107876. */
  107877. setDeltaRotation(rotation: Quaternion): void;
  107878. /**
  107879. * Gets the box size of the physics imposter and stores the result in the input parameter
  107880. * @param result Stores the box size
  107881. * @returns The physics imposter
  107882. */
  107883. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  107884. /**
  107885. * Gets the radius of the physics imposter
  107886. * @returns Radius of the physics imposter
  107887. */
  107888. getRadius(): number;
  107889. /**
  107890. * Sync a bone with this impostor
  107891. * @param bone The bone to sync to the impostor.
  107892. * @param boneMesh The mesh that the bone is influencing.
  107893. * @param jointPivot The pivot of the joint / bone in local space.
  107894. * @param distToJoint Optional distance from the impostor to the joint.
  107895. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  107896. */
  107897. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  107898. /**
  107899. * Sync impostor to a bone
  107900. * @param bone The bone that the impostor will be synced to.
  107901. * @param boneMesh The mesh that the bone is influencing.
  107902. * @param jointPivot The pivot of the joint / bone in local space.
  107903. * @param distToJoint Optional distance from the impostor to the joint.
  107904. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  107905. * @param boneAxis Optional vector3 axis the bone is aligned with
  107906. */
  107907. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  107908. /**
  107909. * No-Imposter type
  107910. */
  107911. static NoImpostor: number;
  107912. /**
  107913. * Sphere-Imposter type
  107914. */
  107915. static SphereImpostor: number;
  107916. /**
  107917. * Box-Imposter type
  107918. */
  107919. static BoxImpostor: number;
  107920. /**
  107921. * Plane-Imposter type
  107922. */
  107923. static PlaneImpostor: number;
  107924. /**
  107925. * Mesh-imposter type
  107926. */
  107927. static MeshImpostor: number;
  107928. /**
  107929. * Capsule-Impostor type (Ammo.js plugin only)
  107930. */
  107931. static CapsuleImpostor: number;
  107932. /**
  107933. * Cylinder-Imposter type
  107934. */
  107935. static CylinderImpostor: number;
  107936. /**
  107937. * Particle-Imposter type
  107938. */
  107939. static ParticleImpostor: number;
  107940. /**
  107941. * Heightmap-Imposter type
  107942. */
  107943. static HeightmapImpostor: number;
  107944. /**
  107945. * ConvexHull-Impostor type (Ammo.js plugin only)
  107946. */
  107947. static ConvexHullImpostor: number;
  107948. /**
  107949. * Custom-Imposter type (Ammo.js plugin only)
  107950. */
  107951. static CustomImpostor: number;
  107952. /**
  107953. * Rope-Imposter type
  107954. */
  107955. static RopeImpostor: number;
  107956. /**
  107957. * Cloth-Imposter type
  107958. */
  107959. static ClothImpostor: number;
  107960. /**
  107961. * Softbody-Imposter type
  107962. */
  107963. static SoftbodyImpostor: number;
  107964. }
  107965. }
  107966. declare module BABYLON {
  107967. /**
  107968. * @hidden
  107969. **/
  107970. export class _CreationDataStorage {
  107971. closePath?: boolean;
  107972. closeArray?: boolean;
  107973. idx: number[];
  107974. dashSize: number;
  107975. gapSize: number;
  107976. path3D: Path3D;
  107977. pathArray: Vector3[][];
  107978. arc: number;
  107979. radius: number;
  107980. cap: number;
  107981. tessellation: number;
  107982. }
  107983. /**
  107984. * @hidden
  107985. **/
  107986. class _InstanceDataStorage {
  107987. visibleInstances: any;
  107988. batchCache: _InstancesBatch;
  107989. instancesBufferSize: number;
  107990. instancesBuffer: Nullable<Buffer>;
  107991. instancesData: Float32Array;
  107992. overridenInstanceCount: number;
  107993. isFrozen: boolean;
  107994. previousBatch: Nullable<_InstancesBatch>;
  107995. hardwareInstancedRendering: boolean;
  107996. sideOrientation: number;
  107997. manualUpdate: boolean;
  107998. }
  107999. /**
  108000. * @hidden
  108001. **/
  108002. export class _InstancesBatch {
  108003. mustReturn: boolean;
  108004. visibleInstances: Nullable<InstancedMesh[]>[];
  108005. renderSelf: boolean[];
  108006. hardwareInstancedRendering: boolean[];
  108007. }
  108008. /**
  108009. * @hidden
  108010. **/
  108011. class _ThinInstanceDataStorage {
  108012. instancesCount: number;
  108013. matrixBuffer: Nullable<Buffer>;
  108014. matrixBufferSize: number;
  108015. matrixData: Nullable<Float32Array>;
  108016. boundingVectors: Array<Vector3>;
  108017. worldMatrices: Nullable<Matrix[]>;
  108018. }
  108019. /**
  108020. * Class used to represent renderable models
  108021. */
  108022. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  108023. /**
  108024. * Mesh side orientation : usually the external or front surface
  108025. */
  108026. static readonly FRONTSIDE: number;
  108027. /**
  108028. * Mesh side orientation : usually the internal or back surface
  108029. */
  108030. static readonly BACKSIDE: number;
  108031. /**
  108032. * Mesh side orientation : both internal and external or front and back surfaces
  108033. */
  108034. static readonly DOUBLESIDE: number;
  108035. /**
  108036. * Mesh side orientation : by default, `FRONTSIDE`
  108037. */
  108038. static readonly DEFAULTSIDE: number;
  108039. /**
  108040. * Mesh cap setting : no cap
  108041. */
  108042. static readonly NO_CAP: number;
  108043. /**
  108044. * Mesh cap setting : one cap at the beginning of the mesh
  108045. */
  108046. static readonly CAP_START: number;
  108047. /**
  108048. * Mesh cap setting : one cap at the end of the mesh
  108049. */
  108050. static readonly CAP_END: number;
  108051. /**
  108052. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  108053. */
  108054. static readonly CAP_ALL: number;
  108055. /**
  108056. * Mesh pattern setting : no flip or rotate
  108057. */
  108058. static readonly NO_FLIP: number;
  108059. /**
  108060. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  108061. */
  108062. static readonly FLIP_TILE: number;
  108063. /**
  108064. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  108065. */
  108066. static readonly ROTATE_TILE: number;
  108067. /**
  108068. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  108069. */
  108070. static readonly FLIP_ROW: number;
  108071. /**
  108072. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  108073. */
  108074. static readonly ROTATE_ROW: number;
  108075. /**
  108076. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  108077. */
  108078. static readonly FLIP_N_ROTATE_TILE: number;
  108079. /**
  108080. * Mesh pattern setting : rotate pattern and rotate
  108081. */
  108082. static readonly FLIP_N_ROTATE_ROW: number;
  108083. /**
  108084. * Mesh tile positioning : part tiles same on left/right or top/bottom
  108085. */
  108086. static readonly CENTER: number;
  108087. /**
  108088. * Mesh tile positioning : part tiles on left
  108089. */
  108090. static readonly LEFT: number;
  108091. /**
  108092. * Mesh tile positioning : part tiles on right
  108093. */
  108094. static readonly RIGHT: number;
  108095. /**
  108096. * Mesh tile positioning : part tiles on top
  108097. */
  108098. static readonly TOP: number;
  108099. /**
  108100. * Mesh tile positioning : part tiles on bottom
  108101. */
  108102. static readonly BOTTOM: number;
  108103. /**
  108104. * Gets the default side orientation.
  108105. * @param orientation the orientation to value to attempt to get
  108106. * @returns the default orientation
  108107. * @hidden
  108108. */
  108109. static _GetDefaultSideOrientation(orientation?: number): number;
  108110. private _internalMeshDataInfo;
  108111. get computeBonesUsingShaders(): boolean;
  108112. set computeBonesUsingShaders(value: boolean);
  108113. /**
  108114. * An event triggered before rendering the mesh
  108115. */
  108116. get onBeforeRenderObservable(): Observable<Mesh>;
  108117. /**
  108118. * An event triggered before binding the mesh
  108119. */
  108120. get onBeforeBindObservable(): Observable<Mesh>;
  108121. /**
  108122. * An event triggered after rendering the mesh
  108123. */
  108124. get onAfterRenderObservable(): Observable<Mesh>;
  108125. /**
  108126. * An event triggered before drawing the mesh
  108127. */
  108128. get onBeforeDrawObservable(): Observable<Mesh>;
  108129. private _onBeforeDrawObserver;
  108130. /**
  108131. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  108132. */
  108133. set onBeforeDraw(callback: () => void);
  108134. get hasInstances(): boolean;
  108135. get hasThinInstances(): boolean;
  108136. /**
  108137. * Gets the delay loading state of the mesh (when delay loading is turned on)
  108138. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  108139. */
  108140. delayLoadState: number;
  108141. /**
  108142. * Gets the list of instances created from this mesh
  108143. * it is not supposed to be modified manually.
  108144. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  108145. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108146. */
  108147. instances: InstancedMesh[];
  108148. /**
  108149. * Gets the file containing delay loading data for this mesh
  108150. */
  108151. delayLoadingFile: string;
  108152. /** @hidden */
  108153. _binaryInfo: any;
  108154. /**
  108155. * User defined function used to change how LOD level selection is done
  108156. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108157. */
  108158. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  108159. /**
  108160. * Gets or sets the morph target manager
  108161. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  108162. */
  108163. get morphTargetManager(): Nullable<MorphTargetManager>;
  108164. set morphTargetManager(value: Nullable<MorphTargetManager>);
  108165. /** @hidden */
  108166. _creationDataStorage: Nullable<_CreationDataStorage>;
  108167. /** @hidden */
  108168. _geometry: Nullable<Geometry>;
  108169. /** @hidden */
  108170. _delayInfo: Array<string>;
  108171. /** @hidden */
  108172. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  108173. /** @hidden */
  108174. _instanceDataStorage: _InstanceDataStorage;
  108175. /** @hidden */
  108176. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  108177. private _effectiveMaterial;
  108178. /** @hidden */
  108179. _shouldGenerateFlatShading: boolean;
  108180. /** @hidden */
  108181. _originalBuilderSideOrientation: number;
  108182. /**
  108183. * Use this property to change the original side orientation defined at construction time
  108184. */
  108185. overrideMaterialSideOrientation: Nullable<number>;
  108186. /**
  108187. * Gets the source mesh (the one used to clone this one from)
  108188. */
  108189. get source(): Nullable<Mesh>;
  108190. /**
  108191. * Gets the list of clones of this mesh
  108192. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  108193. * Note that useClonedMeshMap=true is the default setting
  108194. */
  108195. get cloneMeshMap(): Nullable<{
  108196. [id: string]: Mesh | undefined;
  108197. }>;
  108198. /**
  108199. * Gets or sets a boolean indicating that this mesh does not use index buffer
  108200. */
  108201. get isUnIndexed(): boolean;
  108202. set isUnIndexed(value: boolean);
  108203. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  108204. get worldMatrixInstancedBuffer(): Float32Array;
  108205. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  108206. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  108207. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  108208. /**
  108209. * @constructor
  108210. * @param name The value used by scene.getMeshByName() to do a lookup.
  108211. * @param scene The scene to add this mesh to.
  108212. * @param parent The parent of this mesh, if it has one
  108213. * @param source An optional Mesh from which geometry is shared, cloned.
  108214. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  108215. * When false, achieved by calling a clone(), also passing False.
  108216. * This will make creation of children, recursive.
  108217. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  108218. */
  108219. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  108220. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  108221. doNotInstantiate: boolean;
  108222. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  108223. /**
  108224. * Gets the class name
  108225. * @returns the string "Mesh".
  108226. */
  108227. getClassName(): string;
  108228. /** @hidden */
  108229. get _isMesh(): boolean;
  108230. /**
  108231. * Returns a description of this mesh
  108232. * @param fullDetails define if full details about this mesh must be used
  108233. * @returns a descriptive string representing this mesh
  108234. */
  108235. toString(fullDetails?: boolean): string;
  108236. /** @hidden */
  108237. _unBindEffect(): void;
  108238. /**
  108239. * Gets a boolean indicating if this mesh has LOD
  108240. */
  108241. get hasLODLevels(): boolean;
  108242. /**
  108243. * Gets the list of MeshLODLevel associated with the current mesh
  108244. * @returns an array of MeshLODLevel
  108245. */
  108246. getLODLevels(): MeshLODLevel[];
  108247. private _sortLODLevels;
  108248. /**
  108249. * Add a mesh as LOD level triggered at the given distance.
  108250. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108251. * @param distance The distance from the center of the object to show this level
  108252. * @param mesh The mesh to be added as LOD level (can be null)
  108253. * @return This mesh (for chaining)
  108254. */
  108255. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  108256. /**
  108257. * Returns the LOD level mesh at the passed distance or null if not found.
  108258. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108259. * @param distance The distance from the center of the object to show this level
  108260. * @returns a Mesh or `null`
  108261. */
  108262. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  108263. /**
  108264. * Remove a mesh from the LOD array
  108265. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108266. * @param mesh defines the mesh to be removed
  108267. * @return This mesh (for chaining)
  108268. */
  108269. removeLODLevel(mesh: Mesh): Mesh;
  108270. /**
  108271. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  108272. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108273. * @param camera defines the camera to use to compute distance
  108274. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  108275. * @return This mesh (for chaining)
  108276. */
  108277. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  108278. /**
  108279. * Gets the mesh internal Geometry object
  108280. */
  108281. get geometry(): Nullable<Geometry>;
  108282. /**
  108283. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  108284. * @returns the total number of vertices
  108285. */
  108286. getTotalVertices(): number;
  108287. /**
  108288. * Returns the content of an associated vertex buffer
  108289. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108290. * - VertexBuffer.PositionKind
  108291. * - VertexBuffer.UVKind
  108292. * - VertexBuffer.UV2Kind
  108293. * - VertexBuffer.UV3Kind
  108294. * - VertexBuffer.UV4Kind
  108295. * - VertexBuffer.UV5Kind
  108296. * - VertexBuffer.UV6Kind
  108297. * - VertexBuffer.ColorKind
  108298. * - VertexBuffer.MatricesIndicesKind
  108299. * - VertexBuffer.MatricesIndicesExtraKind
  108300. * - VertexBuffer.MatricesWeightsKind
  108301. * - VertexBuffer.MatricesWeightsExtraKind
  108302. * @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
  108303. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  108304. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  108305. */
  108306. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  108307. /**
  108308. * Returns the mesh VertexBuffer object from the requested `kind`
  108309. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108310. * - VertexBuffer.PositionKind
  108311. * - VertexBuffer.NormalKind
  108312. * - VertexBuffer.UVKind
  108313. * - VertexBuffer.UV2Kind
  108314. * - VertexBuffer.UV3Kind
  108315. * - VertexBuffer.UV4Kind
  108316. * - VertexBuffer.UV5Kind
  108317. * - VertexBuffer.UV6Kind
  108318. * - VertexBuffer.ColorKind
  108319. * - VertexBuffer.MatricesIndicesKind
  108320. * - VertexBuffer.MatricesIndicesExtraKind
  108321. * - VertexBuffer.MatricesWeightsKind
  108322. * - VertexBuffer.MatricesWeightsExtraKind
  108323. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  108324. */
  108325. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  108326. /**
  108327. * Tests if a specific vertex buffer is associated with this mesh
  108328. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108329. * - VertexBuffer.PositionKind
  108330. * - VertexBuffer.NormalKind
  108331. * - VertexBuffer.UVKind
  108332. * - VertexBuffer.UV2Kind
  108333. * - VertexBuffer.UV3Kind
  108334. * - VertexBuffer.UV4Kind
  108335. * - VertexBuffer.UV5Kind
  108336. * - VertexBuffer.UV6Kind
  108337. * - VertexBuffer.ColorKind
  108338. * - VertexBuffer.MatricesIndicesKind
  108339. * - VertexBuffer.MatricesIndicesExtraKind
  108340. * - VertexBuffer.MatricesWeightsKind
  108341. * - VertexBuffer.MatricesWeightsExtraKind
  108342. * @returns a boolean
  108343. */
  108344. isVerticesDataPresent(kind: string): boolean;
  108345. /**
  108346. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  108347. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108348. * - VertexBuffer.PositionKind
  108349. * - VertexBuffer.UVKind
  108350. * - VertexBuffer.UV2Kind
  108351. * - VertexBuffer.UV3Kind
  108352. * - VertexBuffer.UV4Kind
  108353. * - VertexBuffer.UV5Kind
  108354. * - VertexBuffer.UV6Kind
  108355. * - VertexBuffer.ColorKind
  108356. * - VertexBuffer.MatricesIndicesKind
  108357. * - VertexBuffer.MatricesIndicesExtraKind
  108358. * - VertexBuffer.MatricesWeightsKind
  108359. * - VertexBuffer.MatricesWeightsExtraKind
  108360. * @returns a boolean
  108361. */
  108362. isVertexBufferUpdatable(kind: string): boolean;
  108363. /**
  108364. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  108365. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108366. * - VertexBuffer.PositionKind
  108367. * - VertexBuffer.NormalKind
  108368. * - VertexBuffer.UVKind
  108369. * - VertexBuffer.UV2Kind
  108370. * - VertexBuffer.UV3Kind
  108371. * - VertexBuffer.UV4Kind
  108372. * - VertexBuffer.UV5Kind
  108373. * - VertexBuffer.UV6Kind
  108374. * - VertexBuffer.ColorKind
  108375. * - VertexBuffer.MatricesIndicesKind
  108376. * - VertexBuffer.MatricesIndicesExtraKind
  108377. * - VertexBuffer.MatricesWeightsKind
  108378. * - VertexBuffer.MatricesWeightsExtraKind
  108379. * @returns an array of strings
  108380. */
  108381. getVerticesDataKinds(): string[];
  108382. /**
  108383. * Returns a positive integer : the total number of indices in this mesh geometry.
  108384. * @returns the numner of indices or zero if the mesh has no geometry.
  108385. */
  108386. getTotalIndices(): number;
  108387. /**
  108388. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  108389. * @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.
  108390. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  108391. * @returns the indices array or an empty array if the mesh has no geometry
  108392. */
  108393. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  108394. get isBlocked(): boolean;
  108395. /**
  108396. * Determine if the current mesh is ready to be rendered
  108397. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  108398. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  108399. * @returns true if all associated assets are ready (material, textures, shaders)
  108400. */
  108401. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  108402. /**
  108403. * 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.
  108404. */
  108405. get areNormalsFrozen(): boolean;
  108406. /**
  108407. * 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.
  108408. * @returns the current mesh
  108409. */
  108410. freezeNormals(): Mesh;
  108411. /**
  108412. * 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
  108413. * @returns the current mesh
  108414. */
  108415. unfreezeNormals(): Mesh;
  108416. /**
  108417. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  108418. */
  108419. set overridenInstanceCount(count: number);
  108420. /** @hidden */
  108421. _preActivate(): Mesh;
  108422. /** @hidden */
  108423. _preActivateForIntermediateRendering(renderId: number): Mesh;
  108424. /** @hidden */
  108425. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  108426. protected _afterComputeWorldMatrix(): void;
  108427. /** @hidden */
  108428. _postActivate(): void;
  108429. /**
  108430. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108431. * This means the mesh underlying bounding box and sphere are recomputed.
  108432. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108433. * @returns the current mesh
  108434. */
  108435. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  108436. /** @hidden */
  108437. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  108438. /**
  108439. * This function will subdivide the mesh into multiple submeshes
  108440. * @param count defines the expected number of submeshes
  108441. */
  108442. subdivide(count: number): void;
  108443. /**
  108444. * Copy a FloatArray into a specific associated vertex buffer
  108445. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108446. * - VertexBuffer.PositionKind
  108447. * - VertexBuffer.UVKind
  108448. * - VertexBuffer.UV2Kind
  108449. * - VertexBuffer.UV3Kind
  108450. * - VertexBuffer.UV4Kind
  108451. * - VertexBuffer.UV5Kind
  108452. * - VertexBuffer.UV6Kind
  108453. * - VertexBuffer.ColorKind
  108454. * - VertexBuffer.MatricesIndicesKind
  108455. * - VertexBuffer.MatricesIndicesExtraKind
  108456. * - VertexBuffer.MatricesWeightsKind
  108457. * - VertexBuffer.MatricesWeightsExtraKind
  108458. * @param data defines the data source
  108459. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108460. * @param stride defines the data stride size (can be null)
  108461. * @returns the current mesh
  108462. */
  108463. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108464. /**
  108465. * Delete a vertex buffer associated with this mesh
  108466. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  108467. * - VertexBuffer.PositionKind
  108468. * - VertexBuffer.UVKind
  108469. * - VertexBuffer.UV2Kind
  108470. * - VertexBuffer.UV3Kind
  108471. * - VertexBuffer.UV4Kind
  108472. * - VertexBuffer.UV5Kind
  108473. * - VertexBuffer.UV6Kind
  108474. * - VertexBuffer.ColorKind
  108475. * - VertexBuffer.MatricesIndicesKind
  108476. * - VertexBuffer.MatricesIndicesExtraKind
  108477. * - VertexBuffer.MatricesWeightsKind
  108478. * - VertexBuffer.MatricesWeightsExtraKind
  108479. */
  108480. removeVerticesData(kind: string): void;
  108481. /**
  108482. * Flags an associated vertex buffer as updatable
  108483. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  108484. * - VertexBuffer.PositionKind
  108485. * - VertexBuffer.UVKind
  108486. * - VertexBuffer.UV2Kind
  108487. * - VertexBuffer.UV3Kind
  108488. * - VertexBuffer.UV4Kind
  108489. * - VertexBuffer.UV5Kind
  108490. * - VertexBuffer.UV6Kind
  108491. * - VertexBuffer.ColorKind
  108492. * - VertexBuffer.MatricesIndicesKind
  108493. * - VertexBuffer.MatricesIndicesExtraKind
  108494. * - VertexBuffer.MatricesWeightsKind
  108495. * - VertexBuffer.MatricesWeightsExtraKind
  108496. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108497. */
  108498. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  108499. /**
  108500. * Sets the mesh global Vertex Buffer
  108501. * @param buffer defines the buffer to use
  108502. * @returns the current mesh
  108503. */
  108504. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  108505. /**
  108506. * Update a specific associated vertex buffer
  108507. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108508. * - VertexBuffer.PositionKind
  108509. * - VertexBuffer.UVKind
  108510. * - VertexBuffer.UV2Kind
  108511. * - VertexBuffer.UV3Kind
  108512. * - VertexBuffer.UV4Kind
  108513. * - VertexBuffer.UV5Kind
  108514. * - VertexBuffer.UV6Kind
  108515. * - VertexBuffer.ColorKind
  108516. * - VertexBuffer.MatricesIndicesKind
  108517. * - VertexBuffer.MatricesIndicesExtraKind
  108518. * - VertexBuffer.MatricesWeightsKind
  108519. * - VertexBuffer.MatricesWeightsExtraKind
  108520. * @param data defines the data source
  108521. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  108522. * @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)
  108523. * @returns the current mesh
  108524. */
  108525. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108526. /**
  108527. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  108528. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  108529. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  108530. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  108531. * @returns the current mesh
  108532. */
  108533. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  108534. /**
  108535. * Creates a un-shared specific occurence of the geometry for the mesh.
  108536. * @returns the current mesh
  108537. */
  108538. makeGeometryUnique(): Mesh;
  108539. /**
  108540. * Set the index buffer of this mesh
  108541. * @param indices defines the source data
  108542. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  108543. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  108544. * @returns the current mesh
  108545. */
  108546. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  108547. /**
  108548. * Update the current index buffer
  108549. * @param indices defines the source data
  108550. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  108551. * @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)
  108552. * @returns the current mesh
  108553. */
  108554. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  108555. /**
  108556. * Invert the geometry to move from a right handed system to a left handed one.
  108557. * @returns the current mesh
  108558. */
  108559. toLeftHanded(): Mesh;
  108560. /** @hidden */
  108561. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  108562. /** @hidden */
  108563. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  108564. /**
  108565. * Registers for this mesh a javascript function called just before the rendering process
  108566. * @param func defines the function to call before rendering this mesh
  108567. * @returns the current mesh
  108568. */
  108569. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  108570. /**
  108571. * Disposes a previously registered javascript function called before the rendering
  108572. * @param func defines the function to remove
  108573. * @returns the current mesh
  108574. */
  108575. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  108576. /**
  108577. * Registers for this mesh a javascript function called just after the rendering is complete
  108578. * @param func defines the function to call after rendering this mesh
  108579. * @returns the current mesh
  108580. */
  108581. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  108582. /**
  108583. * Disposes a previously registered javascript function called after the rendering.
  108584. * @param func defines the function to remove
  108585. * @returns the current mesh
  108586. */
  108587. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  108588. /** @hidden */
  108589. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  108590. /** @hidden */
  108591. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  108592. /** @hidden */
  108593. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  108594. /** @hidden */
  108595. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  108596. /** @hidden */
  108597. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  108598. /** @hidden */
  108599. _rebuild(): void;
  108600. /** @hidden */
  108601. _freeze(): void;
  108602. /** @hidden */
  108603. _unFreeze(): void;
  108604. /**
  108605. * 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
  108606. * @param subMesh defines the subMesh to render
  108607. * @param enableAlphaMode defines if alpha mode can be changed
  108608. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  108609. * @returns the current mesh
  108610. */
  108611. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  108612. private _onBeforeDraw;
  108613. /**
  108614. * Renormalize the mesh and patch it up if there are no weights
  108615. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  108616. * However in the case of zero weights then we set just a single influence to 1.
  108617. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  108618. */
  108619. cleanMatrixWeights(): void;
  108620. private normalizeSkinFourWeights;
  108621. private normalizeSkinWeightsAndExtra;
  108622. /**
  108623. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  108624. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  108625. * the user know there was an issue with importing the mesh
  108626. * @returns a validation object with skinned, valid and report string
  108627. */
  108628. validateSkinning(): {
  108629. skinned: boolean;
  108630. valid: boolean;
  108631. report: string;
  108632. };
  108633. /** @hidden */
  108634. _checkDelayState(): Mesh;
  108635. private _queueLoad;
  108636. /**
  108637. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  108638. * A mesh is in the frustum if its bounding box intersects the frustum
  108639. * @param frustumPlanes defines the frustum to test
  108640. * @returns true if the mesh is in the frustum planes
  108641. */
  108642. isInFrustum(frustumPlanes: Plane[]): boolean;
  108643. /**
  108644. * Sets the mesh material by the material or multiMaterial `id` property
  108645. * @param id is a string identifying the material or the multiMaterial
  108646. * @returns the current mesh
  108647. */
  108648. setMaterialByID(id: string): Mesh;
  108649. /**
  108650. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  108651. * @returns an array of IAnimatable
  108652. */
  108653. getAnimatables(): IAnimatable[];
  108654. /**
  108655. * Modifies the mesh geometry according to the passed transformation matrix.
  108656. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  108657. * The mesh normals are modified using the same transformation.
  108658. * Note that, under the hood, this method sets a new VertexBuffer each call.
  108659. * @param transform defines the transform matrix to use
  108660. * @see https://doc.babylonjs.com/resources/baking_transformations
  108661. * @returns the current mesh
  108662. */
  108663. bakeTransformIntoVertices(transform: Matrix): Mesh;
  108664. /**
  108665. * Modifies the mesh geometry according to its own current World Matrix.
  108666. * The mesh World Matrix is then reset.
  108667. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  108668. * Note that, under the hood, this method sets a new VertexBuffer each call.
  108669. * @see https://doc.babylonjs.com/resources/baking_transformations
  108670. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  108671. * @returns the current mesh
  108672. */
  108673. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  108674. /** @hidden */
  108675. get _positions(): Nullable<Vector3[]>;
  108676. /** @hidden */
  108677. _resetPointsArrayCache(): Mesh;
  108678. /** @hidden */
  108679. _generatePointsArray(): boolean;
  108680. /**
  108681. * Returns a new Mesh object generated from the current mesh properties.
  108682. * This method must not get confused with createInstance()
  108683. * @param name is a string, the name given to the new mesh
  108684. * @param newParent can be any Node object (default `null`)
  108685. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  108686. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  108687. * @returns a new mesh
  108688. */
  108689. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  108690. /**
  108691. * Releases resources associated with this mesh.
  108692. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108693. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108694. */
  108695. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108696. /** @hidden */
  108697. _disposeInstanceSpecificData(): void;
  108698. /** @hidden */
  108699. _disposeThinInstanceSpecificData(): void;
  108700. /**
  108701. * Modifies the mesh geometry according to a displacement map.
  108702. * 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.
  108703. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  108704. * @param url is a string, the URL from the image file is to be downloaded.
  108705. * @param minHeight is the lower limit of the displacement.
  108706. * @param maxHeight is the upper limit of the displacement.
  108707. * @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.
  108708. * @param uvOffset is an optional vector2 used to offset UV.
  108709. * @param uvScale is an optional vector2 used to scale UV.
  108710. * @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.
  108711. * @returns the Mesh.
  108712. */
  108713. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  108714. /**
  108715. * Modifies the mesh geometry according to a displacementMap buffer.
  108716. * 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.
  108717. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  108718. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  108719. * @param heightMapWidth is the width of the buffer image.
  108720. * @param heightMapHeight is the height of the buffer image.
  108721. * @param minHeight is the lower limit of the displacement.
  108722. * @param maxHeight is the upper limit of the displacement.
  108723. * @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.
  108724. * @param uvOffset is an optional vector2 used to offset UV.
  108725. * @param uvScale is an optional vector2 used to scale UV.
  108726. * @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.
  108727. * @returns the Mesh.
  108728. */
  108729. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  108730. /**
  108731. * Modify the mesh to get a flat shading rendering.
  108732. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  108733. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  108734. * @returns current mesh
  108735. */
  108736. convertToFlatShadedMesh(): Mesh;
  108737. /**
  108738. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  108739. * In other words, more vertices, no more indices and a single bigger VBO.
  108740. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  108741. * @returns current mesh
  108742. */
  108743. convertToUnIndexedMesh(): Mesh;
  108744. /**
  108745. * Inverses facet orientations.
  108746. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108747. * @param flipNormals will also inverts the normals
  108748. * @returns current mesh
  108749. */
  108750. flipFaces(flipNormals?: boolean): Mesh;
  108751. /**
  108752. * Increase the number of facets and hence vertices in a mesh
  108753. * Vertex normals are interpolated from existing vertex normals
  108754. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108755. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  108756. */
  108757. increaseVertices(numberPerEdge: number): void;
  108758. /**
  108759. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  108760. * This will undo any application of covertToFlatShadedMesh
  108761. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108762. */
  108763. forceSharedVertices(): void;
  108764. /** @hidden */
  108765. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  108766. /** @hidden */
  108767. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  108768. /**
  108769. * Creates a new InstancedMesh object from the mesh model.
  108770. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108771. * @param name defines the name of the new instance
  108772. * @returns a new InstancedMesh
  108773. */
  108774. createInstance(name: string): InstancedMesh;
  108775. /**
  108776. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  108777. * After this call, all the mesh instances have the same submeshes than the current mesh.
  108778. * @returns the current mesh
  108779. */
  108780. synchronizeInstances(): Mesh;
  108781. /**
  108782. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  108783. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  108784. * This should be used together with the simplification to avoid disappearing triangles.
  108785. * @param successCallback an optional success callback to be called after the optimization finished.
  108786. * @returns the current mesh
  108787. */
  108788. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  108789. /**
  108790. * Serialize current mesh
  108791. * @param serializationObject defines the object which will receive the serialization data
  108792. */
  108793. serialize(serializationObject: any): void;
  108794. /** @hidden */
  108795. _syncGeometryWithMorphTargetManager(): void;
  108796. /** @hidden */
  108797. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  108798. /**
  108799. * Returns a new Mesh object parsed from the source provided.
  108800. * @param parsedMesh is the source
  108801. * @param scene defines the hosting scene
  108802. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  108803. * @returns a new Mesh
  108804. */
  108805. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  108806. /**
  108807. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  108808. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108809. * @param name defines the name of the mesh to create
  108810. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  108811. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  108812. * @param closePath creates a seam between the first and the last points of each path of the path array
  108813. * @param offset is taken in account only if the `pathArray` is containing a single path
  108814. * @param scene defines the hosting scene
  108815. * @param updatable defines if the mesh must be flagged as updatable
  108816. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108817. * @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)
  108818. * @returns a new Mesh
  108819. */
  108820. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108821. /**
  108822. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  108823. * @param name defines the name of the mesh to create
  108824. * @param radius sets the radius size (float) of the polygon (default 0.5)
  108825. * @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
  108826. * @param scene defines the hosting scene
  108827. * @param updatable defines if the mesh must be flagged as updatable
  108828. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108829. * @returns a new Mesh
  108830. */
  108831. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  108832. /**
  108833. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  108834. * @param name defines the name of the mesh to create
  108835. * @param size sets the size (float) of each box side (default 1)
  108836. * @param scene defines the hosting scene
  108837. * @param updatable defines if the mesh must be flagged as updatable
  108838. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108839. * @returns a new Mesh
  108840. */
  108841. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  108842. /**
  108843. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  108844. * @param name defines the name of the mesh to create
  108845. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  108846. * @param diameter sets the diameter size (float) of the sphere (default 1)
  108847. * @param scene defines the hosting scene
  108848. * @param updatable defines if the mesh must be flagged as updatable
  108849. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108850. * @returns a new Mesh
  108851. */
  108852. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108853. /**
  108854. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  108855. * @param name defines the name of the mesh to create
  108856. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  108857. * @param diameter sets the diameter size (float) of the sphere (default 1)
  108858. * @param scene defines the hosting scene
  108859. * @returns a new Mesh
  108860. */
  108861. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  108862. /**
  108863. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  108864. * @param name defines the name of the mesh to create
  108865. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  108866. * @param diameterTop set the top cap diameter (floats, default 1)
  108867. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  108868. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  108869. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  108870. * @param scene defines the hosting scene
  108871. * @param updatable defines if the mesh must be flagged as updatable
  108872. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108873. * @returns a new Mesh
  108874. */
  108875. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  108876. /**
  108877. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  108878. * @param name defines the name of the mesh to create
  108879. * @param diameter sets the diameter size (float) of the torus (default 1)
  108880. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  108881. * @param tessellation sets the number of torus sides (postive integer, default 16)
  108882. * @param scene defines the hosting scene
  108883. * @param updatable defines if the mesh must be flagged as updatable
  108884. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108885. * @returns a new Mesh
  108886. */
  108887. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108888. /**
  108889. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  108890. * @param name defines the name of the mesh to create
  108891. * @param radius sets the global radius size (float) of the torus knot (default 2)
  108892. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  108893. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  108894. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  108895. * @param p the number of windings on X axis (positive integers, default 2)
  108896. * @param q the number of windings on Y axis (positive integers, default 3)
  108897. * @param scene defines the hosting scene
  108898. * @param updatable defines if the mesh must be flagged as updatable
  108899. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108900. * @returns a new Mesh
  108901. */
  108902. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108903. /**
  108904. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  108905. * @param name defines the name of the mesh to create
  108906. * @param points is an array successive Vector3
  108907. * @param scene defines the hosting scene
  108908. * @param updatable defines if the mesh must be flagged as updatable
  108909. * @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).
  108910. * @returns a new Mesh
  108911. */
  108912. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  108913. /**
  108914. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  108915. * @param name defines the name of the mesh to create
  108916. * @param points is an array successive Vector3
  108917. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  108918. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  108919. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  108920. * @param scene defines the hosting scene
  108921. * @param updatable defines if the mesh must be flagged as updatable
  108922. * @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)
  108923. * @returns a new Mesh
  108924. */
  108925. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  108926. /**
  108927. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  108928. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  108929. * 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.
  108930. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108931. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108932. * Remember you can only change the shape positions, not their number when updating a polygon.
  108933. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  108934. * @param name defines the name of the mesh to create
  108935. * @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
  108936. * @param scene defines the hosting scene
  108937. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  108938. * @param updatable defines if the mesh must be flagged as updatable
  108939. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108940. * @param earcutInjection can be used to inject your own earcut reference
  108941. * @returns a new Mesh
  108942. */
  108943. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  108944. /**
  108945. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  108946. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  108947. * @param name defines the name of the mesh to create
  108948. * @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
  108949. * @param depth defines the height of extrusion
  108950. * @param scene defines the hosting scene
  108951. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  108952. * @param updatable defines if the mesh must be flagged as updatable
  108953. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108954. * @param earcutInjection can be used to inject your own earcut reference
  108955. * @returns a new Mesh
  108956. */
  108957. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  108958. /**
  108959. * Creates an extruded shape mesh.
  108960. * 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
  108961. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108962. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108963. * @param name defines the name of the mesh to create
  108964. * @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
  108965. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  108966. * @param scale is the value to scale the shape
  108967. * @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
  108968. * @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
  108969. * @param scene defines the hosting scene
  108970. * @param updatable defines if the mesh must be flagged as updatable
  108971. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108972. * @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)
  108973. * @returns a new Mesh
  108974. */
  108975. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108976. /**
  108977. * Creates an custom extruded shape mesh.
  108978. * The custom extrusion is a parametric shape.
  108979. * It has no predefined shape. Its final shape will depend on the input parameters.
  108980. * Please consider using the same method from the MeshBuilder class instead
  108981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108982. * @param name defines the name of the mesh to create
  108983. * @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
  108984. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  108985. * @param scaleFunction is a custom Javascript function called on each path point
  108986. * @param rotationFunction is a custom Javascript function called on each path point
  108987. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108988. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  108989. * @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
  108990. * @param scene defines the hosting scene
  108991. * @param updatable defines if the mesh must be flagged as updatable
  108992. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108993. * @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)
  108994. * @returns a new Mesh
  108995. */
  108996. 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;
  108997. /**
  108998. * Creates lathe mesh.
  108999. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  109000. * Please consider using the same method from the MeshBuilder class instead
  109001. * @param name defines the name of the mesh to create
  109002. * @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
  109003. * @param radius is the radius value of the lathe
  109004. * @param tessellation is the side number of the lathe.
  109005. * @param scene defines the hosting scene
  109006. * @param updatable defines if the mesh must be flagged as updatable
  109007. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109008. * @returns a new Mesh
  109009. */
  109010. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109011. /**
  109012. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  109013. * @param name defines the name of the mesh to create
  109014. * @param size sets the size (float) of both sides of the plane at once (default 1)
  109015. * @param scene defines the hosting scene
  109016. * @param updatable defines if the mesh must be flagged as updatable
  109017. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109018. * @returns a new Mesh
  109019. */
  109020. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109021. /**
  109022. * Creates a ground mesh.
  109023. * Please consider using the same method from the MeshBuilder class instead
  109024. * @param name defines the name of the mesh to create
  109025. * @param width set the width of the ground
  109026. * @param height set the height of the ground
  109027. * @param subdivisions sets the number of subdivisions per side
  109028. * @param scene defines the hosting scene
  109029. * @param updatable defines if the mesh must be flagged as updatable
  109030. * @returns a new Mesh
  109031. */
  109032. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  109033. /**
  109034. * Creates a tiled ground mesh.
  109035. * Please consider using the same method from the MeshBuilder class instead
  109036. * @param name defines the name of the mesh to create
  109037. * @param xmin set the ground minimum X coordinate
  109038. * @param zmin set the ground minimum Y coordinate
  109039. * @param xmax set the ground maximum X coordinate
  109040. * @param zmax set the ground maximum Z coordinate
  109041. * @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
  109042. * @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
  109043. * @param scene defines the hosting scene
  109044. * @param updatable defines if the mesh must be flagged as updatable
  109045. * @returns a new Mesh
  109046. */
  109047. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  109048. w: number;
  109049. h: number;
  109050. }, precision: {
  109051. w: number;
  109052. h: number;
  109053. }, scene: Scene, updatable?: boolean): Mesh;
  109054. /**
  109055. * Creates a ground mesh from a height map.
  109056. * Please consider using the same method from the MeshBuilder class instead
  109057. * @see https://doc.babylonjs.com/babylon101/height_map
  109058. * @param name defines the name of the mesh to create
  109059. * @param url sets the URL of the height map image resource
  109060. * @param width set the ground width size
  109061. * @param height set the ground height size
  109062. * @param subdivisions sets the number of subdivision per side
  109063. * @param minHeight is the minimum altitude on the ground
  109064. * @param maxHeight is the maximum altitude on the ground
  109065. * @param scene defines the hosting scene
  109066. * @param updatable defines if the mesh must be flagged as updatable
  109067. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  109068. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109069. * @returns a new Mesh
  109070. */
  109071. 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;
  109072. /**
  109073. * Creates a tube mesh.
  109074. * The tube is a parametric shape.
  109075. * It has no predefined shape. Its final shape will depend on the input parameters.
  109076. * Please consider using the same method from the MeshBuilder class instead
  109077. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109078. * @param name defines the name of the mesh to create
  109079. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  109080. * @param radius sets the tube radius size
  109081. * @param tessellation is the number of sides on the tubular surface
  109082. * @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
  109083. * @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
  109084. * @param scene defines the hosting scene
  109085. * @param updatable defines if the mesh must be flagged as updatable
  109086. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109087. * @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)
  109088. * @returns a new Mesh
  109089. */
  109090. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  109091. (i: number, distance: number): number;
  109092. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109093. /**
  109094. * Creates a polyhedron mesh.
  109095. * Please consider using the same method from the MeshBuilder class instead.
  109096. * * 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
  109097. * * The parameter `size` (positive float, default 1) sets the polygon size
  109098. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109099. * * 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`
  109100. * * 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
  109101. * * 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)`)
  109102. * * 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
  109103. * * 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
  109104. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109105. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109107. * @param name defines the name of the mesh to create
  109108. * @param options defines the options used to create the mesh
  109109. * @param scene defines the hosting scene
  109110. * @returns a new Mesh
  109111. */
  109112. static CreatePolyhedron(name: string, options: {
  109113. type?: number;
  109114. size?: number;
  109115. sizeX?: number;
  109116. sizeY?: number;
  109117. sizeZ?: number;
  109118. custom?: any;
  109119. faceUV?: Vector4[];
  109120. faceColors?: Color4[];
  109121. updatable?: boolean;
  109122. sideOrientation?: number;
  109123. }, scene: Scene): Mesh;
  109124. /**
  109125. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109126. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109127. * * 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`)
  109128. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109129. * * 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
  109130. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109131. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109133. * @param name defines the name of the mesh
  109134. * @param options defines the options used to create the mesh
  109135. * @param scene defines the hosting scene
  109136. * @returns a new Mesh
  109137. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109138. */
  109139. static CreateIcoSphere(name: string, options: {
  109140. radius?: number;
  109141. flat?: boolean;
  109142. subdivisions?: number;
  109143. sideOrientation?: number;
  109144. updatable?: boolean;
  109145. }, scene: Scene): Mesh;
  109146. /**
  109147. * Creates a decal mesh.
  109148. * Please consider using the same method from the MeshBuilder class instead.
  109149. * A decal is a mesh usually applied as a model onto the surface of another mesh
  109150. * @param name defines the name of the mesh
  109151. * @param sourceMesh defines the mesh receiving the decal
  109152. * @param position sets the position of the decal in world coordinates
  109153. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  109154. * @param size sets the decal scaling
  109155. * @param angle sets the angle to rotate the decal
  109156. * @returns a new Mesh
  109157. */
  109158. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  109159. /** Creates a Capsule Mesh
  109160. * @param name defines the name of the mesh.
  109161. * @param options the constructors options used to shape the mesh.
  109162. * @param scene defines the scene the mesh is scoped to.
  109163. * @returns the capsule mesh
  109164. * @see https://doc.babylonjs.com/how_to/capsule_shape
  109165. */
  109166. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  109167. /**
  109168. * Prepare internal position array for software CPU skinning
  109169. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  109170. */
  109171. setPositionsForCPUSkinning(): Float32Array;
  109172. /**
  109173. * Prepare internal normal array for software CPU skinning
  109174. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  109175. */
  109176. setNormalsForCPUSkinning(): Float32Array;
  109177. /**
  109178. * Updates the vertex buffer by applying transformation from the bones
  109179. * @param skeleton defines the skeleton to apply to current mesh
  109180. * @returns the current mesh
  109181. */
  109182. applySkeleton(skeleton: Skeleton): Mesh;
  109183. /**
  109184. * 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
  109185. * @param meshes defines the list of meshes to scan
  109186. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  109187. */
  109188. static MinMax(meshes: AbstractMesh[]): {
  109189. min: Vector3;
  109190. max: Vector3;
  109191. };
  109192. /**
  109193. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  109194. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  109195. * @returns a vector3
  109196. */
  109197. static Center(meshesOrMinMaxVector: {
  109198. min: Vector3;
  109199. max: Vector3;
  109200. } | AbstractMesh[]): Vector3;
  109201. /**
  109202. * Merge the array of meshes into a single mesh for performance reasons.
  109203. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  109204. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  109205. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  109206. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  109207. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  109208. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  109209. * @returns a new mesh
  109210. */
  109211. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  109212. /** @hidden */
  109213. addInstance(instance: InstancedMesh): void;
  109214. /** @hidden */
  109215. removeInstance(instance: InstancedMesh): void;
  109216. }
  109217. }
  109218. declare module BABYLON {
  109219. /**
  109220. * This is the base class of all the camera used in the application.
  109221. * @see https://doc.babylonjs.com/features/cameras
  109222. */
  109223. export class Camera extends Node {
  109224. /** @hidden */
  109225. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  109226. /**
  109227. * This is the default projection mode used by the cameras.
  109228. * It helps recreating a feeling of perspective and better appreciate depth.
  109229. * This is the best way to simulate real life cameras.
  109230. */
  109231. static readonly PERSPECTIVE_CAMERA: number;
  109232. /**
  109233. * This helps creating camera with an orthographic mode.
  109234. * 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.
  109235. */
  109236. static readonly ORTHOGRAPHIC_CAMERA: number;
  109237. /**
  109238. * This is the default FOV mode for perspective cameras.
  109239. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  109240. */
  109241. static readonly FOVMODE_VERTICAL_FIXED: number;
  109242. /**
  109243. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  109244. */
  109245. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  109246. /**
  109247. * This specifies ther is no need for a camera rig.
  109248. * Basically only one eye is rendered corresponding to the camera.
  109249. */
  109250. static readonly RIG_MODE_NONE: number;
  109251. /**
  109252. * Simulates a camera Rig with one blue eye and one red eye.
  109253. * This can be use with 3d blue and red glasses.
  109254. */
  109255. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  109256. /**
  109257. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  109258. */
  109259. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  109260. /**
  109261. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  109262. */
  109263. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  109264. /**
  109265. * Defines that both eyes of the camera will be rendered over under each other.
  109266. */
  109267. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  109268. /**
  109269. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  109270. */
  109271. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  109272. /**
  109273. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  109274. */
  109275. static readonly RIG_MODE_VR: number;
  109276. /**
  109277. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  109278. */
  109279. static readonly RIG_MODE_WEBVR: number;
  109280. /**
  109281. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  109282. */
  109283. static readonly RIG_MODE_CUSTOM: number;
  109284. /**
  109285. * Defines if by default attaching controls should prevent the default javascript event to continue.
  109286. */
  109287. static ForceAttachControlToAlwaysPreventDefault: boolean;
  109288. /**
  109289. * Define the input manager associated with the camera.
  109290. */
  109291. inputs: CameraInputsManager<Camera>;
  109292. /** @hidden */
  109293. _position: Vector3;
  109294. /**
  109295. * Define the current local position of the camera in the scene
  109296. */
  109297. get position(): Vector3;
  109298. set position(newPosition: Vector3);
  109299. protected _upVector: Vector3;
  109300. /**
  109301. * The vector the camera should consider as up.
  109302. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  109303. */
  109304. set upVector(vec: Vector3);
  109305. get upVector(): Vector3;
  109306. /**
  109307. * Define the current limit on the left side for an orthographic camera
  109308. * In scene unit
  109309. */
  109310. orthoLeft: Nullable<number>;
  109311. /**
  109312. * Define the current limit on the right side for an orthographic camera
  109313. * In scene unit
  109314. */
  109315. orthoRight: Nullable<number>;
  109316. /**
  109317. * Define the current limit on the bottom side for an orthographic camera
  109318. * In scene unit
  109319. */
  109320. orthoBottom: Nullable<number>;
  109321. /**
  109322. * Define the current limit on the top side for an orthographic camera
  109323. * In scene unit
  109324. */
  109325. orthoTop: Nullable<number>;
  109326. /**
  109327. * Field Of View is set in Radians. (default is 0.8)
  109328. */
  109329. fov: number;
  109330. /**
  109331. * Define the minimum distance the camera can see from.
  109332. * This is important to note that the depth buffer are not infinite and the closer it starts
  109333. * the more your scene might encounter depth fighting issue.
  109334. */
  109335. minZ: number;
  109336. /**
  109337. * Define the maximum distance the camera can see to.
  109338. * This is important to note that the depth buffer are not infinite and the further it end
  109339. * the more your scene might encounter depth fighting issue.
  109340. */
  109341. maxZ: number;
  109342. /**
  109343. * Define the default inertia of the camera.
  109344. * This helps giving a smooth feeling to the camera movement.
  109345. */
  109346. inertia: number;
  109347. /**
  109348. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  109349. */
  109350. mode: number;
  109351. /**
  109352. * Define whether the camera is intermediate.
  109353. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  109354. */
  109355. isIntermediate: boolean;
  109356. /**
  109357. * Define the viewport of the camera.
  109358. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  109359. */
  109360. viewport: Viewport;
  109361. /**
  109362. * Restricts the camera to viewing objects with the same layerMask.
  109363. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  109364. */
  109365. layerMask: number;
  109366. /**
  109367. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  109368. */
  109369. fovMode: number;
  109370. /**
  109371. * Rig mode of the camera.
  109372. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  109373. * This is normally controlled byt the camera themselves as internal use.
  109374. */
  109375. cameraRigMode: number;
  109376. /**
  109377. * Defines the distance between both "eyes" in case of a RIG
  109378. */
  109379. interaxialDistance: number;
  109380. /**
  109381. * Defines if stereoscopic rendering is done side by side or over under.
  109382. */
  109383. isStereoscopicSideBySide: boolean;
  109384. /**
  109385. * 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
  109386. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  109387. * else in the scene. (Eg. security camera)
  109388. *
  109389. * 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)
  109390. */
  109391. customRenderTargets: RenderTargetTexture[];
  109392. /**
  109393. * When set, the camera will render to this render target instead of the default canvas
  109394. *
  109395. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  109396. */
  109397. outputRenderTarget: Nullable<RenderTargetTexture>;
  109398. /**
  109399. * Observable triggered when the camera view matrix has changed.
  109400. */
  109401. onViewMatrixChangedObservable: Observable<Camera>;
  109402. /**
  109403. * Observable triggered when the camera Projection matrix has changed.
  109404. */
  109405. onProjectionMatrixChangedObservable: Observable<Camera>;
  109406. /**
  109407. * Observable triggered when the inputs have been processed.
  109408. */
  109409. onAfterCheckInputsObservable: Observable<Camera>;
  109410. /**
  109411. * Observable triggered when reset has been called and applied to the camera.
  109412. */
  109413. onRestoreStateObservable: Observable<Camera>;
  109414. /**
  109415. * Is this camera a part of a rig system?
  109416. */
  109417. isRigCamera: boolean;
  109418. /**
  109419. * If isRigCamera set to true this will be set with the parent camera.
  109420. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  109421. */
  109422. rigParent?: Camera;
  109423. /** @hidden */
  109424. _cameraRigParams: any;
  109425. /** @hidden */
  109426. _rigCameras: Camera[];
  109427. /** @hidden */
  109428. _rigPostProcess: Nullable<PostProcess>;
  109429. protected _webvrViewMatrix: Matrix;
  109430. /** @hidden */
  109431. _skipRendering: boolean;
  109432. /** @hidden */
  109433. _projectionMatrix: Matrix;
  109434. /** @hidden */
  109435. _postProcesses: Nullable<PostProcess>[];
  109436. /** @hidden */
  109437. _activeMeshes: SmartArray<AbstractMesh>;
  109438. protected _globalPosition: Vector3;
  109439. /** @hidden */
  109440. _computedViewMatrix: Matrix;
  109441. private _doNotComputeProjectionMatrix;
  109442. private _transformMatrix;
  109443. private _frustumPlanes;
  109444. private _refreshFrustumPlanes;
  109445. private _storedFov;
  109446. private _stateStored;
  109447. /**
  109448. * Instantiates a new camera object.
  109449. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  109450. * @see https://doc.babylonjs.com/features/cameras
  109451. * @param name Defines the name of the camera in the scene
  109452. * @param position Defines the position of the camera
  109453. * @param scene Defines the scene the camera belongs too
  109454. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  109455. */
  109456. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109457. /**
  109458. * Store current camera state (fov, position, etc..)
  109459. * @returns the camera
  109460. */
  109461. storeState(): Camera;
  109462. /**
  109463. * Restores the camera state values if it has been stored. You must call storeState() first
  109464. */
  109465. protected _restoreStateValues(): boolean;
  109466. /**
  109467. * Restored camera state. You must call storeState() first.
  109468. * @returns true if restored and false otherwise
  109469. */
  109470. restoreState(): boolean;
  109471. /**
  109472. * Gets the class name of the camera.
  109473. * @returns the class name
  109474. */
  109475. getClassName(): string;
  109476. /** @hidden */
  109477. readonly _isCamera: boolean;
  109478. /**
  109479. * Gets a string representation of the camera useful for debug purpose.
  109480. * @param fullDetails Defines that a more verboe level of logging is required
  109481. * @returns the string representation
  109482. */
  109483. toString(fullDetails?: boolean): string;
  109484. /**
  109485. * Gets the current world space position of the camera.
  109486. */
  109487. get globalPosition(): Vector3;
  109488. /**
  109489. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  109490. * @returns the active meshe list
  109491. */
  109492. getActiveMeshes(): SmartArray<AbstractMesh>;
  109493. /**
  109494. * Check whether a mesh is part of the current active mesh list of the camera
  109495. * @param mesh Defines the mesh to check
  109496. * @returns true if active, false otherwise
  109497. */
  109498. isActiveMesh(mesh: Mesh): boolean;
  109499. /**
  109500. * Is this camera ready to be used/rendered
  109501. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  109502. * @return true if the camera is ready
  109503. */
  109504. isReady(completeCheck?: boolean): boolean;
  109505. /** @hidden */
  109506. _initCache(): void;
  109507. /** @hidden */
  109508. _updateCache(ignoreParentClass?: boolean): void;
  109509. /** @hidden */
  109510. _isSynchronized(): boolean;
  109511. /** @hidden */
  109512. _isSynchronizedViewMatrix(): boolean;
  109513. /** @hidden */
  109514. _isSynchronizedProjectionMatrix(): boolean;
  109515. /**
  109516. * Attach the input controls to a specific dom element to get the input from.
  109517. * @param element Defines the element the controls should be listened from
  109518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109519. */
  109520. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109521. /**
  109522. * Detach the current controls from the specified dom element.
  109523. * @param element Defines the element to stop listening the inputs from
  109524. */
  109525. detachControl(element: HTMLElement): void;
  109526. /**
  109527. * Update the camera state according to the different inputs gathered during the frame.
  109528. */
  109529. update(): void;
  109530. /** @hidden */
  109531. _checkInputs(): void;
  109532. /** @hidden */
  109533. get rigCameras(): Camera[];
  109534. /**
  109535. * Gets the post process used by the rig cameras
  109536. */
  109537. get rigPostProcess(): Nullable<PostProcess>;
  109538. /**
  109539. * Internal, gets the first post proces.
  109540. * @returns the first post process to be run on this camera.
  109541. */
  109542. _getFirstPostProcess(): Nullable<PostProcess>;
  109543. private _cascadePostProcessesToRigCams;
  109544. /**
  109545. * Attach a post process to the camera.
  109546. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109547. * @param postProcess The post process to attach to the camera
  109548. * @param insertAt The position of the post process in case several of them are in use in the scene
  109549. * @returns the position the post process has been inserted at
  109550. */
  109551. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  109552. /**
  109553. * Detach a post process to the camera.
  109554. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109555. * @param postProcess The post process to detach from the camera
  109556. */
  109557. detachPostProcess(postProcess: PostProcess): void;
  109558. /**
  109559. * Gets the current world matrix of the camera
  109560. */
  109561. getWorldMatrix(): Matrix;
  109562. /** @hidden */
  109563. _getViewMatrix(): Matrix;
  109564. /**
  109565. * Gets the current view matrix of the camera.
  109566. * @param force forces the camera to recompute the matrix without looking at the cached state
  109567. * @returns the view matrix
  109568. */
  109569. getViewMatrix(force?: boolean): Matrix;
  109570. /**
  109571. * Freeze the projection matrix.
  109572. * It will prevent the cache check of the camera projection compute and can speed up perf
  109573. * if no parameter of the camera are meant to change
  109574. * @param projection Defines manually a projection if necessary
  109575. */
  109576. freezeProjectionMatrix(projection?: Matrix): void;
  109577. /**
  109578. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  109579. */
  109580. unfreezeProjectionMatrix(): void;
  109581. /**
  109582. * Gets the current projection matrix of the camera.
  109583. * @param force forces the camera to recompute the matrix without looking at the cached state
  109584. * @returns the projection matrix
  109585. */
  109586. getProjectionMatrix(force?: boolean): Matrix;
  109587. /**
  109588. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  109589. * @returns a Matrix
  109590. */
  109591. getTransformationMatrix(): Matrix;
  109592. private _updateFrustumPlanes;
  109593. /**
  109594. * Checks if a cullable object (mesh...) is in the camera frustum
  109595. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  109596. * @param target The object to check
  109597. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  109598. * @returns true if the object is in frustum otherwise false
  109599. */
  109600. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  109601. /**
  109602. * Checks if a cullable object (mesh...) is in the camera frustum
  109603. * Unlike isInFrustum this cheks the full bounding box
  109604. * @param target The object to check
  109605. * @returns true if the object is in frustum otherwise false
  109606. */
  109607. isCompletelyInFrustum(target: ICullable): boolean;
  109608. /**
  109609. * Gets a ray in the forward direction from the camera.
  109610. * @param length Defines the length of the ray to create
  109611. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  109612. * @param origin Defines the start point of the ray which defaults to the camera position
  109613. * @returns the forward ray
  109614. */
  109615. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  109616. /**
  109617. * Gets a ray in the forward direction from the camera.
  109618. * @param refRay the ray to (re)use when setting the values
  109619. * @param length Defines the length of the ray to create
  109620. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  109621. * @param origin Defines the start point of the ray which defaults to the camera position
  109622. * @returns the forward ray
  109623. */
  109624. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  109625. /**
  109626. * Releases resources associated with this node.
  109627. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109628. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109629. */
  109630. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109631. /** @hidden */
  109632. _isLeftCamera: boolean;
  109633. /**
  109634. * Gets the left camera of a rig setup in case of Rigged Camera
  109635. */
  109636. get isLeftCamera(): boolean;
  109637. /** @hidden */
  109638. _isRightCamera: boolean;
  109639. /**
  109640. * Gets the right camera of a rig setup in case of Rigged Camera
  109641. */
  109642. get isRightCamera(): boolean;
  109643. /**
  109644. * Gets the left camera of a rig setup in case of Rigged Camera
  109645. */
  109646. get leftCamera(): Nullable<FreeCamera>;
  109647. /**
  109648. * Gets the right camera of a rig setup in case of Rigged Camera
  109649. */
  109650. get rightCamera(): Nullable<FreeCamera>;
  109651. /**
  109652. * Gets the left camera target of a rig setup in case of Rigged Camera
  109653. * @returns the target position
  109654. */
  109655. getLeftTarget(): Nullable<Vector3>;
  109656. /**
  109657. * Gets the right camera target of a rig setup in case of Rigged Camera
  109658. * @returns the target position
  109659. */
  109660. getRightTarget(): Nullable<Vector3>;
  109661. /**
  109662. * @hidden
  109663. */
  109664. setCameraRigMode(mode: number, rigParams: any): void;
  109665. /** @hidden */
  109666. static _setStereoscopicRigMode(camera: Camera): void;
  109667. /** @hidden */
  109668. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  109669. /** @hidden */
  109670. static _setVRRigMode(camera: Camera, rigParams: any): void;
  109671. /** @hidden */
  109672. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  109673. /** @hidden */
  109674. _getVRProjectionMatrix(): Matrix;
  109675. protected _updateCameraRotationMatrix(): void;
  109676. protected _updateWebVRCameraRotationMatrix(): void;
  109677. /**
  109678. * This function MUST be overwritten by the different WebVR cameras available.
  109679. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  109680. * @hidden
  109681. */
  109682. _getWebVRProjectionMatrix(): Matrix;
  109683. /**
  109684. * This function MUST be overwritten by the different WebVR cameras available.
  109685. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  109686. * @hidden
  109687. */
  109688. _getWebVRViewMatrix(): Matrix;
  109689. /** @hidden */
  109690. setCameraRigParameter(name: string, value: any): void;
  109691. /**
  109692. * needs to be overridden by children so sub has required properties to be copied
  109693. * @hidden
  109694. */
  109695. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  109696. /**
  109697. * May need to be overridden by children
  109698. * @hidden
  109699. */
  109700. _updateRigCameras(): void;
  109701. /** @hidden */
  109702. _setupInputs(): void;
  109703. /**
  109704. * Serialiaze the camera setup to a json represention
  109705. * @returns the JSON representation
  109706. */
  109707. serialize(): any;
  109708. /**
  109709. * Clones the current camera.
  109710. * @param name The cloned camera name
  109711. * @returns the cloned camera
  109712. */
  109713. clone(name: string): Camera;
  109714. /**
  109715. * Gets the direction of the camera relative to a given local axis.
  109716. * @param localAxis Defines the reference axis to provide a relative direction.
  109717. * @return the direction
  109718. */
  109719. getDirection(localAxis: Vector3): Vector3;
  109720. /**
  109721. * Returns the current camera absolute rotation
  109722. */
  109723. get absoluteRotation(): Quaternion;
  109724. /**
  109725. * Gets the direction of the camera relative to a given local axis into a passed vector.
  109726. * @param localAxis Defines the reference axis to provide a relative direction.
  109727. * @param result Defines the vector to store the result in
  109728. */
  109729. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  109730. /**
  109731. * Gets a camera constructor for a given camera type
  109732. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  109733. * @param name The name of the camera the result will be able to instantiate
  109734. * @param scene The scene the result will construct the camera in
  109735. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  109736. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  109737. * @returns a factory method to construc the camera
  109738. */
  109739. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  109740. /**
  109741. * Compute the world matrix of the camera.
  109742. * @returns the camera world matrix
  109743. */
  109744. computeWorldMatrix(): Matrix;
  109745. /**
  109746. * Parse a JSON and creates the camera from the parsed information
  109747. * @param parsedCamera The JSON to parse
  109748. * @param scene The scene to instantiate the camera in
  109749. * @returns the newly constructed camera
  109750. */
  109751. static Parse(parsedCamera: any, scene: Scene): Camera;
  109752. }
  109753. }
  109754. declare module BABYLON {
  109755. /**
  109756. * Class containing static functions to help procedurally build meshes
  109757. */
  109758. export class DiscBuilder {
  109759. /**
  109760. * Creates a plane polygonal mesh. By default, this is a disc
  109761. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109762. * * 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
  109763. * * 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
  109764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109767. * @param name defines the name of the mesh
  109768. * @param options defines the options used to create the mesh
  109769. * @param scene defines the hosting scene
  109770. * @returns the plane polygonal mesh
  109771. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109772. */
  109773. static CreateDisc(name: string, options: {
  109774. radius?: number;
  109775. tessellation?: number;
  109776. arc?: number;
  109777. updatable?: boolean;
  109778. sideOrientation?: number;
  109779. frontUVs?: Vector4;
  109780. backUVs?: Vector4;
  109781. }, scene?: Nullable<Scene>): Mesh;
  109782. }
  109783. }
  109784. declare module BABYLON {
  109785. /**
  109786. * Options to be used when creating a FresnelParameters.
  109787. */
  109788. export type IFresnelParametersCreationOptions = {
  109789. /**
  109790. * Define the color used on edges (grazing angle)
  109791. */
  109792. leftColor?: Color3;
  109793. /**
  109794. * Define the color used on center
  109795. */
  109796. rightColor?: Color3;
  109797. /**
  109798. * Define bias applied to computed fresnel term
  109799. */
  109800. bias?: number;
  109801. /**
  109802. * Defined the power exponent applied to fresnel term
  109803. */
  109804. power?: number;
  109805. /**
  109806. * Define if the fresnel effect is enable or not.
  109807. */
  109808. isEnabled?: boolean;
  109809. };
  109810. /**
  109811. * Serialized format for FresnelParameters.
  109812. */
  109813. export type IFresnelParametersSerialized = {
  109814. /**
  109815. * Define the color used on edges (grazing angle) [as an array]
  109816. */
  109817. leftColor: number[];
  109818. /**
  109819. * Define the color used on center [as an array]
  109820. */
  109821. rightColor: number[];
  109822. /**
  109823. * Define bias applied to computed fresnel term
  109824. */
  109825. bias: number;
  109826. /**
  109827. * Defined the power exponent applied to fresnel term
  109828. */
  109829. power?: number;
  109830. /**
  109831. * Define if the fresnel effect is enable or not.
  109832. */
  109833. isEnabled: boolean;
  109834. };
  109835. /**
  109836. * This represents all the required information to add a fresnel effect on a material:
  109837. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109838. */
  109839. export class FresnelParameters {
  109840. private _isEnabled;
  109841. /**
  109842. * Define if the fresnel effect is enable or not.
  109843. */
  109844. get isEnabled(): boolean;
  109845. set isEnabled(value: boolean);
  109846. /**
  109847. * Define the color used on edges (grazing angle)
  109848. */
  109849. leftColor: Color3;
  109850. /**
  109851. * Define the color used on center
  109852. */
  109853. rightColor: Color3;
  109854. /**
  109855. * Define bias applied to computed fresnel term
  109856. */
  109857. bias: number;
  109858. /**
  109859. * Defined the power exponent applied to fresnel term
  109860. */
  109861. power: number;
  109862. /**
  109863. * Creates a new FresnelParameters object.
  109864. *
  109865. * @param options provide your own settings to optionally to override defaults
  109866. */
  109867. constructor(options?: IFresnelParametersCreationOptions);
  109868. /**
  109869. * Clones the current fresnel and its valuues
  109870. * @returns a clone fresnel configuration
  109871. */
  109872. clone(): FresnelParameters;
  109873. /**
  109874. * Determines equality between FresnelParameters objects
  109875. * @param otherFresnelParameters defines the second operand
  109876. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  109877. */
  109878. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  109879. /**
  109880. * Serializes the current fresnel parameters to a JSON representation.
  109881. * @return the JSON serialization
  109882. */
  109883. serialize(): IFresnelParametersSerialized;
  109884. /**
  109885. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  109886. * @param parsedFresnelParameters Define the JSON representation
  109887. * @returns the parsed parameters
  109888. */
  109889. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  109890. }
  109891. }
  109892. declare module BABYLON {
  109893. /**
  109894. * This groups all the flags used to control the materials channel.
  109895. */
  109896. export class MaterialFlags {
  109897. private static _DiffuseTextureEnabled;
  109898. /**
  109899. * Are diffuse textures enabled in the application.
  109900. */
  109901. static get DiffuseTextureEnabled(): boolean;
  109902. static set DiffuseTextureEnabled(value: boolean);
  109903. private static _DetailTextureEnabled;
  109904. /**
  109905. * Are detail textures enabled in the application.
  109906. */
  109907. static get DetailTextureEnabled(): boolean;
  109908. static set DetailTextureEnabled(value: boolean);
  109909. private static _AmbientTextureEnabled;
  109910. /**
  109911. * Are ambient textures enabled in the application.
  109912. */
  109913. static get AmbientTextureEnabled(): boolean;
  109914. static set AmbientTextureEnabled(value: boolean);
  109915. private static _OpacityTextureEnabled;
  109916. /**
  109917. * Are opacity textures enabled in the application.
  109918. */
  109919. static get OpacityTextureEnabled(): boolean;
  109920. static set OpacityTextureEnabled(value: boolean);
  109921. private static _ReflectionTextureEnabled;
  109922. /**
  109923. * Are reflection textures enabled in the application.
  109924. */
  109925. static get ReflectionTextureEnabled(): boolean;
  109926. static set ReflectionTextureEnabled(value: boolean);
  109927. private static _EmissiveTextureEnabled;
  109928. /**
  109929. * Are emissive textures enabled in the application.
  109930. */
  109931. static get EmissiveTextureEnabled(): boolean;
  109932. static set EmissiveTextureEnabled(value: boolean);
  109933. private static _SpecularTextureEnabled;
  109934. /**
  109935. * Are specular textures enabled in the application.
  109936. */
  109937. static get SpecularTextureEnabled(): boolean;
  109938. static set SpecularTextureEnabled(value: boolean);
  109939. private static _BumpTextureEnabled;
  109940. /**
  109941. * Are bump textures enabled in the application.
  109942. */
  109943. static get BumpTextureEnabled(): boolean;
  109944. static set BumpTextureEnabled(value: boolean);
  109945. private static _LightmapTextureEnabled;
  109946. /**
  109947. * Are lightmap textures enabled in the application.
  109948. */
  109949. static get LightmapTextureEnabled(): boolean;
  109950. static set LightmapTextureEnabled(value: boolean);
  109951. private static _RefractionTextureEnabled;
  109952. /**
  109953. * Are refraction textures enabled in the application.
  109954. */
  109955. static get RefractionTextureEnabled(): boolean;
  109956. static set RefractionTextureEnabled(value: boolean);
  109957. private static _ColorGradingTextureEnabled;
  109958. /**
  109959. * Are color grading textures enabled in the application.
  109960. */
  109961. static get ColorGradingTextureEnabled(): boolean;
  109962. static set ColorGradingTextureEnabled(value: boolean);
  109963. private static _FresnelEnabled;
  109964. /**
  109965. * Are fresnels enabled in the application.
  109966. */
  109967. static get FresnelEnabled(): boolean;
  109968. static set FresnelEnabled(value: boolean);
  109969. private static _ClearCoatTextureEnabled;
  109970. /**
  109971. * Are clear coat textures enabled in the application.
  109972. */
  109973. static get ClearCoatTextureEnabled(): boolean;
  109974. static set ClearCoatTextureEnabled(value: boolean);
  109975. private static _ClearCoatBumpTextureEnabled;
  109976. /**
  109977. * Are clear coat bump textures enabled in the application.
  109978. */
  109979. static get ClearCoatBumpTextureEnabled(): boolean;
  109980. static set ClearCoatBumpTextureEnabled(value: boolean);
  109981. private static _ClearCoatTintTextureEnabled;
  109982. /**
  109983. * Are clear coat tint textures enabled in the application.
  109984. */
  109985. static get ClearCoatTintTextureEnabled(): boolean;
  109986. static set ClearCoatTintTextureEnabled(value: boolean);
  109987. private static _SheenTextureEnabled;
  109988. /**
  109989. * Are sheen textures enabled in the application.
  109990. */
  109991. static get SheenTextureEnabled(): boolean;
  109992. static set SheenTextureEnabled(value: boolean);
  109993. private static _AnisotropicTextureEnabled;
  109994. /**
  109995. * Are anisotropic textures enabled in the application.
  109996. */
  109997. static get AnisotropicTextureEnabled(): boolean;
  109998. static set AnisotropicTextureEnabled(value: boolean);
  109999. private static _ThicknessTextureEnabled;
  110000. /**
  110001. * Are thickness textures enabled in the application.
  110002. */
  110003. static get ThicknessTextureEnabled(): boolean;
  110004. static set ThicknessTextureEnabled(value: boolean);
  110005. }
  110006. }
  110007. declare module BABYLON {
  110008. /** @hidden */
  110009. export var defaultFragmentDeclaration: {
  110010. name: string;
  110011. shader: string;
  110012. };
  110013. }
  110014. declare module BABYLON {
  110015. /** @hidden */
  110016. export var defaultUboDeclaration: {
  110017. name: string;
  110018. shader: string;
  110019. };
  110020. }
  110021. declare module BABYLON {
  110022. /** @hidden */
  110023. export var prePassDeclaration: {
  110024. name: string;
  110025. shader: string;
  110026. };
  110027. }
  110028. declare module BABYLON {
  110029. /** @hidden */
  110030. export var lightFragmentDeclaration: {
  110031. name: string;
  110032. shader: string;
  110033. };
  110034. }
  110035. declare module BABYLON {
  110036. /** @hidden */
  110037. export var lightUboDeclaration: {
  110038. name: string;
  110039. shader: string;
  110040. };
  110041. }
  110042. declare module BABYLON {
  110043. /** @hidden */
  110044. export var lightsFragmentFunctions: {
  110045. name: string;
  110046. shader: string;
  110047. };
  110048. }
  110049. declare module BABYLON {
  110050. /** @hidden */
  110051. export var shadowsFragmentFunctions: {
  110052. name: string;
  110053. shader: string;
  110054. };
  110055. }
  110056. declare module BABYLON {
  110057. /** @hidden */
  110058. export var fresnelFunction: {
  110059. name: string;
  110060. shader: string;
  110061. };
  110062. }
  110063. declare module BABYLON {
  110064. /** @hidden */
  110065. export var bumpFragmentMainFunctions: {
  110066. name: string;
  110067. shader: string;
  110068. };
  110069. }
  110070. declare module BABYLON {
  110071. /** @hidden */
  110072. export var bumpFragmentFunctions: {
  110073. name: string;
  110074. shader: string;
  110075. };
  110076. }
  110077. declare module BABYLON {
  110078. /** @hidden */
  110079. export var logDepthDeclaration: {
  110080. name: string;
  110081. shader: string;
  110082. };
  110083. }
  110084. declare module BABYLON {
  110085. /** @hidden */
  110086. export var bumpFragment: {
  110087. name: string;
  110088. shader: string;
  110089. };
  110090. }
  110091. declare module BABYLON {
  110092. /** @hidden */
  110093. export var depthPrePass: {
  110094. name: string;
  110095. shader: string;
  110096. };
  110097. }
  110098. declare module BABYLON {
  110099. /** @hidden */
  110100. export var lightFragment: {
  110101. name: string;
  110102. shader: string;
  110103. };
  110104. }
  110105. declare module BABYLON {
  110106. /** @hidden */
  110107. export var logDepthFragment: {
  110108. name: string;
  110109. shader: string;
  110110. };
  110111. }
  110112. declare module BABYLON {
  110113. /** @hidden */
  110114. export var defaultPixelShader: {
  110115. name: string;
  110116. shader: string;
  110117. };
  110118. }
  110119. declare module BABYLON {
  110120. /** @hidden */
  110121. export var defaultVertexDeclaration: {
  110122. name: string;
  110123. shader: string;
  110124. };
  110125. }
  110126. declare module BABYLON {
  110127. /** @hidden */
  110128. export var bumpVertexDeclaration: {
  110129. name: string;
  110130. shader: string;
  110131. };
  110132. }
  110133. declare module BABYLON {
  110134. /** @hidden */
  110135. export var bumpVertex: {
  110136. name: string;
  110137. shader: string;
  110138. };
  110139. }
  110140. declare module BABYLON {
  110141. /** @hidden */
  110142. export var fogVertex: {
  110143. name: string;
  110144. shader: string;
  110145. };
  110146. }
  110147. declare module BABYLON {
  110148. /** @hidden */
  110149. export var shadowsVertex: {
  110150. name: string;
  110151. shader: string;
  110152. };
  110153. }
  110154. declare module BABYLON {
  110155. /** @hidden */
  110156. export var pointCloudVertex: {
  110157. name: string;
  110158. shader: string;
  110159. };
  110160. }
  110161. declare module BABYLON {
  110162. /** @hidden */
  110163. export var logDepthVertex: {
  110164. name: string;
  110165. shader: string;
  110166. };
  110167. }
  110168. declare module BABYLON {
  110169. /** @hidden */
  110170. export var defaultVertexShader: {
  110171. name: string;
  110172. shader: string;
  110173. };
  110174. }
  110175. declare module BABYLON {
  110176. /**
  110177. * @hidden
  110178. */
  110179. export interface IMaterialDetailMapDefines {
  110180. DETAIL: boolean;
  110181. DETAILDIRECTUV: number;
  110182. DETAIL_NORMALBLENDMETHOD: number;
  110183. /** @hidden */
  110184. _areTexturesDirty: boolean;
  110185. }
  110186. /**
  110187. * Define the code related to the detail map parameters of a material
  110188. *
  110189. * Inspired from:
  110190. * 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
  110191. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  110192. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  110193. */
  110194. export class DetailMapConfiguration {
  110195. private _texture;
  110196. /**
  110197. * The detail texture of the material.
  110198. */
  110199. texture: Nullable<BaseTexture>;
  110200. /**
  110201. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  110202. * Bigger values mean stronger blending
  110203. */
  110204. diffuseBlendLevel: number;
  110205. /**
  110206. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  110207. * Bigger values mean stronger blending. Only used with PBR materials
  110208. */
  110209. roughnessBlendLevel: number;
  110210. /**
  110211. * Defines how strong the bump effect from the detail map is
  110212. * Bigger values mean stronger effect
  110213. */
  110214. bumpLevel: number;
  110215. private _normalBlendMethod;
  110216. /**
  110217. * The method used to blend the bump and detail normals together
  110218. */
  110219. normalBlendMethod: number;
  110220. private _isEnabled;
  110221. /**
  110222. * Enable or disable the detail map on this material
  110223. */
  110224. isEnabled: boolean;
  110225. /** @hidden */
  110226. private _internalMarkAllSubMeshesAsTexturesDirty;
  110227. /** @hidden */
  110228. _markAllSubMeshesAsTexturesDirty(): void;
  110229. /**
  110230. * Instantiate a new detail map
  110231. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110232. */
  110233. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110234. /**
  110235. * Gets whether the submesh is ready to be used or not.
  110236. * @param defines the list of "defines" to update.
  110237. * @param scene defines the scene the material belongs to.
  110238. * @returns - boolean indicating that the submesh is ready or not.
  110239. */
  110240. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  110241. /**
  110242. * Update the defines for detail map usage
  110243. * @param defines the list of "defines" to update.
  110244. * @param scene defines the scene the material belongs to.
  110245. */
  110246. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  110247. /**
  110248. * Binds the material data.
  110249. * @param uniformBuffer defines the Uniform buffer to fill in.
  110250. * @param scene defines the scene the material belongs to.
  110251. * @param isFrozen defines whether the material is frozen or not.
  110252. */
  110253. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110254. /**
  110255. * Checks to see if a texture is used in the material.
  110256. * @param texture - Base texture to use.
  110257. * @returns - Boolean specifying if a texture is used in the material.
  110258. */
  110259. hasTexture(texture: BaseTexture): boolean;
  110260. /**
  110261. * Returns an array of the actively used textures.
  110262. * @param activeTextures Array of BaseTextures
  110263. */
  110264. getActiveTextures(activeTextures: BaseTexture[]): void;
  110265. /**
  110266. * Returns the animatable textures.
  110267. * @param animatables Array of animatable textures.
  110268. */
  110269. getAnimatables(animatables: IAnimatable[]): void;
  110270. /**
  110271. * Disposes the resources of the material.
  110272. * @param forceDisposeTextures - Forces the disposal of all textures.
  110273. */
  110274. dispose(forceDisposeTextures?: boolean): void;
  110275. /**
  110276. * Get the current class name useful for serialization or dynamic coding.
  110277. * @returns "DetailMap"
  110278. */
  110279. getClassName(): string;
  110280. /**
  110281. * Add the required uniforms to the current list.
  110282. * @param uniforms defines the current uniform list.
  110283. */
  110284. static AddUniforms(uniforms: string[]): void;
  110285. /**
  110286. * Add the required samplers to the current list.
  110287. * @param samplers defines the current sampler list.
  110288. */
  110289. static AddSamplers(samplers: string[]): void;
  110290. /**
  110291. * Add the required uniforms to the current buffer.
  110292. * @param uniformBuffer defines the current uniform buffer.
  110293. */
  110294. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110295. /**
  110296. * Makes a duplicate of the current instance into another one.
  110297. * @param detailMap define the instance where to copy the info
  110298. */
  110299. copyTo(detailMap: DetailMapConfiguration): void;
  110300. /**
  110301. * Serializes this detail map instance
  110302. * @returns - An object with the serialized instance.
  110303. */
  110304. serialize(): any;
  110305. /**
  110306. * Parses a detail map setting from a serialized object.
  110307. * @param source - Serialized object.
  110308. * @param scene Defines the scene we are parsing for
  110309. * @param rootUrl Defines the rootUrl to load from
  110310. */
  110311. parse(source: any, scene: Scene, rootUrl: string): void;
  110312. }
  110313. }
  110314. declare module BABYLON {
  110315. /** @hidden */
  110316. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  110317. MAINUV1: boolean;
  110318. MAINUV2: boolean;
  110319. DIFFUSE: boolean;
  110320. DIFFUSEDIRECTUV: number;
  110321. DETAIL: boolean;
  110322. DETAILDIRECTUV: number;
  110323. DETAIL_NORMALBLENDMETHOD: number;
  110324. AMBIENT: boolean;
  110325. AMBIENTDIRECTUV: number;
  110326. OPACITY: boolean;
  110327. OPACITYDIRECTUV: number;
  110328. OPACITYRGB: boolean;
  110329. REFLECTION: boolean;
  110330. EMISSIVE: boolean;
  110331. EMISSIVEDIRECTUV: number;
  110332. SPECULAR: boolean;
  110333. SPECULARDIRECTUV: number;
  110334. BUMP: boolean;
  110335. BUMPDIRECTUV: number;
  110336. PARALLAX: boolean;
  110337. PARALLAXOCCLUSION: boolean;
  110338. SPECULAROVERALPHA: boolean;
  110339. CLIPPLANE: boolean;
  110340. CLIPPLANE2: boolean;
  110341. CLIPPLANE3: boolean;
  110342. CLIPPLANE4: boolean;
  110343. CLIPPLANE5: boolean;
  110344. CLIPPLANE6: boolean;
  110345. ALPHATEST: boolean;
  110346. DEPTHPREPASS: boolean;
  110347. ALPHAFROMDIFFUSE: boolean;
  110348. POINTSIZE: boolean;
  110349. FOG: boolean;
  110350. SPECULARTERM: boolean;
  110351. DIFFUSEFRESNEL: boolean;
  110352. OPACITYFRESNEL: boolean;
  110353. REFLECTIONFRESNEL: boolean;
  110354. REFRACTIONFRESNEL: boolean;
  110355. EMISSIVEFRESNEL: boolean;
  110356. FRESNEL: boolean;
  110357. NORMAL: boolean;
  110358. UV1: boolean;
  110359. UV2: boolean;
  110360. VERTEXCOLOR: boolean;
  110361. VERTEXALPHA: boolean;
  110362. NUM_BONE_INFLUENCERS: number;
  110363. BonesPerMesh: number;
  110364. BONETEXTURE: boolean;
  110365. INSTANCES: boolean;
  110366. THIN_INSTANCES: boolean;
  110367. GLOSSINESS: boolean;
  110368. ROUGHNESS: boolean;
  110369. EMISSIVEASILLUMINATION: boolean;
  110370. LINKEMISSIVEWITHDIFFUSE: boolean;
  110371. REFLECTIONFRESNELFROMSPECULAR: boolean;
  110372. LIGHTMAP: boolean;
  110373. LIGHTMAPDIRECTUV: number;
  110374. OBJECTSPACE_NORMALMAP: boolean;
  110375. USELIGHTMAPASSHADOWMAP: boolean;
  110376. REFLECTIONMAP_3D: boolean;
  110377. REFLECTIONMAP_SPHERICAL: boolean;
  110378. REFLECTIONMAP_PLANAR: boolean;
  110379. REFLECTIONMAP_CUBIC: boolean;
  110380. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110381. REFLECTIONMAP_PROJECTION: boolean;
  110382. REFLECTIONMAP_SKYBOX: boolean;
  110383. REFLECTIONMAP_EXPLICIT: boolean;
  110384. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110385. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110386. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110387. INVERTCUBICMAP: boolean;
  110388. LOGARITHMICDEPTH: boolean;
  110389. REFRACTION: boolean;
  110390. REFRACTIONMAP_3D: boolean;
  110391. REFLECTIONOVERALPHA: boolean;
  110392. TWOSIDEDLIGHTING: boolean;
  110393. SHADOWFLOAT: boolean;
  110394. MORPHTARGETS: boolean;
  110395. MORPHTARGETS_NORMAL: boolean;
  110396. MORPHTARGETS_TANGENT: boolean;
  110397. MORPHTARGETS_UV: boolean;
  110398. NUM_MORPH_INFLUENCERS: number;
  110399. NONUNIFORMSCALING: boolean;
  110400. PREMULTIPLYALPHA: boolean;
  110401. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  110402. ALPHABLEND: boolean;
  110403. PREPASS: boolean;
  110404. SCENE_MRT_COUNT: number;
  110405. RGBDLIGHTMAP: boolean;
  110406. RGBDREFLECTION: boolean;
  110407. RGBDREFRACTION: boolean;
  110408. IMAGEPROCESSING: boolean;
  110409. VIGNETTE: boolean;
  110410. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110411. VIGNETTEBLENDMODEOPAQUE: boolean;
  110412. TONEMAPPING: boolean;
  110413. TONEMAPPING_ACES: boolean;
  110414. CONTRAST: boolean;
  110415. COLORCURVES: boolean;
  110416. COLORGRADING: boolean;
  110417. COLORGRADING3D: boolean;
  110418. SAMPLER3DGREENDEPTH: boolean;
  110419. SAMPLER3DBGRMAP: boolean;
  110420. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110421. MULTIVIEW: boolean;
  110422. /**
  110423. * If the reflection texture on this material is in linear color space
  110424. * @hidden
  110425. */
  110426. IS_REFLECTION_LINEAR: boolean;
  110427. /**
  110428. * If the refraction texture on this material is in linear color space
  110429. * @hidden
  110430. */
  110431. IS_REFRACTION_LINEAR: boolean;
  110432. EXPOSURE: boolean;
  110433. constructor();
  110434. setReflectionMode(modeToEnable: string): void;
  110435. }
  110436. /**
  110437. * This is the default material used in Babylon. It is the best trade off between quality
  110438. * and performances.
  110439. * @see https://doc.babylonjs.com/babylon101/materials
  110440. */
  110441. export class StandardMaterial extends PushMaterial {
  110442. private _diffuseTexture;
  110443. /**
  110444. * The basic texture of the material as viewed under a light.
  110445. */
  110446. diffuseTexture: Nullable<BaseTexture>;
  110447. private _ambientTexture;
  110448. /**
  110449. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  110450. */
  110451. ambientTexture: Nullable<BaseTexture>;
  110452. private _opacityTexture;
  110453. /**
  110454. * Define the transparency of the material from a texture.
  110455. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  110456. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  110457. */
  110458. opacityTexture: Nullable<BaseTexture>;
  110459. private _reflectionTexture;
  110460. /**
  110461. * Define the texture used to display the reflection.
  110462. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110463. */
  110464. reflectionTexture: Nullable<BaseTexture>;
  110465. private _emissiveTexture;
  110466. /**
  110467. * Define texture of the material as if self lit.
  110468. * This will be mixed in the final result even in the absence of light.
  110469. */
  110470. emissiveTexture: Nullable<BaseTexture>;
  110471. private _specularTexture;
  110472. /**
  110473. * Define how the color and intensity of the highlight given by the light in the material.
  110474. */
  110475. specularTexture: Nullable<BaseTexture>;
  110476. private _bumpTexture;
  110477. /**
  110478. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  110479. * 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.
  110480. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  110481. */
  110482. bumpTexture: Nullable<BaseTexture>;
  110483. private _lightmapTexture;
  110484. /**
  110485. * Complex lighting can be computationally expensive to compute at runtime.
  110486. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  110487. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  110488. */
  110489. lightmapTexture: Nullable<BaseTexture>;
  110490. private _refractionTexture;
  110491. /**
  110492. * Define the texture used to display the refraction.
  110493. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110494. */
  110495. refractionTexture: Nullable<BaseTexture>;
  110496. /**
  110497. * The color of the material lit by the environmental background lighting.
  110498. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  110499. */
  110500. ambientColor: Color3;
  110501. /**
  110502. * The basic color of the material as viewed under a light.
  110503. */
  110504. diffuseColor: Color3;
  110505. /**
  110506. * Define how the color and intensity of the highlight given by the light in the material.
  110507. */
  110508. specularColor: Color3;
  110509. /**
  110510. * Define the color of the material as if self lit.
  110511. * This will be mixed in the final result even in the absence of light.
  110512. */
  110513. emissiveColor: Color3;
  110514. /**
  110515. * Defines how sharp are the highlights in the material.
  110516. * The bigger the value the sharper giving a more glossy feeling to the result.
  110517. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  110518. */
  110519. specularPower: number;
  110520. private _useAlphaFromDiffuseTexture;
  110521. /**
  110522. * Does the transparency come from the diffuse texture alpha channel.
  110523. */
  110524. useAlphaFromDiffuseTexture: boolean;
  110525. private _useEmissiveAsIllumination;
  110526. /**
  110527. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  110528. */
  110529. useEmissiveAsIllumination: boolean;
  110530. private _linkEmissiveWithDiffuse;
  110531. /**
  110532. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  110533. * the emissive level when the final color is close to one.
  110534. */
  110535. linkEmissiveWithDiffuse: boolean;
  110536. private _useSpecularOverAlpha;
  110537. /**
  110538. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  110539. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110540. */
  110541. useSpecularOverAlpha: boolean;
  110542. private _useReflectionOverAlpha;
  110543. /**
  110544. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110545. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110546. */
  110547. useReflectionOverAlpha: boolean;
  110548. private _disableLighting;
  110549. /**
  110550. * Does lights from the scene impacts this material.
  110551. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  110552. */
  110553. disableLighting: boolean;
  110554. private _useObjectSpaceNormalMap;
  110555. /**
  110556. * Allows using an object space normal map (instead of tangent space).
  110557. */
  110558. useObjectSpaceNormalMap: boolean;
  110559. private _useParallax;
  110560. /**
  110561. * Is parallax enabled or not.
  110562. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  110563. */
  110564. useParallax: boolean;
  110565. private _useParallaxOcclusion;
  110566. /**
  110567. * Is parallax occlusion enabled or not.
  110568. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  110569. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  110570. */
  110571. useParallaxOcclusion: boolean;
  110572. /**
  110573. * 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.
  110574. */
  110575. parallaxScaleBias: number;
  110576. private _roughness;
  110577. /**
  110578. * Helps to define how blurry the reflections should appears in the material.
  110579. */
  110580. roughness: number;
  110581. /**
  110582. * In case of refraction, define the value of the index of refraction.
  110583. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110584. */
  110585. indexOfRefraction: number;
  110586. /**
  110587. * Invert the refraction texture alongside the y axis.
  110588. * It can be useful with procedural textures or probe for instance.
  110589. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110590. */
  110591. invertRefractionY: boolean;
  110592. /**
  110593. * Defines the alpha limits in alpha test mode.
  110594. */
  110595. alphaCutOff: number;
  110596. private _useLightmapAsShadowmap;
  110597. /**
  110598. * In case of light mapping, define whether the map contains light or shadow informations.
  110599. */
  110600. useLightmapAsShadowmap: boolean;
  110601. private _diffuseFresnelParameters;
  110602. /**
  110603. * Define the diffuse fresnel parameters of the material.
  110604. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110605. */
  110606. diffuseFresnelParameters: FresnelParameters;
  110607. private _opacityFresnelParameters;
  110608. /**
  110609. * Define the opacity fresnel parameters of the material.
  110610. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110611. */
  110612. opacityFresnelParameters: FresnelParameters;
  110613. private _reflectionFresnelParameters;
  110614. /**
  110615. * Define the reflection fresnel parameters of the material.
  110616. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110617. */
  110618. reflectionFresnelParameters: FresnelParameters;
  110619. private _refractionFresnelParameters;
  110620. /**
  110621. * Define the refraction fresnel parameters of the material.
  110622. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110623. */
  110624. refractionFresnelParameters: FresnelParameters;
  110625. private _emissiveFresnelParameters;
  110626. /**
  110627. * Define the emissive fresnel parameters of the material.
  110628. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110629. */
  110630. emissiveFresnelParameters: FresnelParameters;
  110631. private _useReflectionFresnelFromSpecular;
  110632. /**
  110633. * If true automatically deducts the fresnels values from the material specularity.
  110634. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110635. */
  110636. useReflectionFresnelFromSpecular: boolean;
  110637. private _useGlossinessFromSpecularMapAlpha;
  110638. /**
  110639. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  110640. */
  110641. useGlossinessFromSpecularMapAlpha: boolean;
  110642. private _maxSimultaneousLights;
  110643. /**
  110644. * Defines the maximum number of lights that can be used in the material
  110645. */
  110646. maxSimultaneousLights: number;
  110647. private _invertNormalMapX;
  110648. /**
  110649. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  110650. */
  110651. invertNormalMapX: boolean;
  110652. private _invertNormalMapY;
  110653. /**
  110654. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  110655. */
  110656. invertNormalMapY: boolean;
  110657. private _twoSidedLighting;
  110658. /**
  110659. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110660. */
  110661. twoSidedLighting: boolean;
  110662. /**
  110663. * Default configuration related to image processing available in the standard Material.
  110664. */
  110665. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110666. /**
  110667. * Gets the image processing configuration used either in this material.
  110668. */
  110669. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  110670. /**
  110671. * Sets the Default image processing configuration used either in the this material.
  110672. *
  110673. * If sets to null, the scene one is in use.
  110674. */
  110675. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  110676. /**
  110677. * Keep track of the image processing observer to allow dispose and replace.
  110678. */
  110679. private _imageProcessingObserver;
  110680. /**
  110681. * Attaches a new image processing configuration to the Standard Material.
  110682. * @param configuration
  110683. */
  110684. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110685. /**
  110686. * Gets wether the color curves effect is enabled.
  110687. */
  110688. get cameraColorCurvesEnabled(): boolean;
  110689. /**
  110690. * Sets wether the color curves effect is enabled.
  110691. */
  110692. set cameraColorCurvesEnabled(value: boolean);
  110693. /**
  110694. * Gets wether the color grading effect is enabled.
  110695. */
  110696. get cameraColorGradingEnabled(): boolean;
  110697. /**
  110698. * Gets wether the color grading effect is enabled.
  110699. */
  110700. set cameraColorGradingEnabled(value: boolean);
  110701. /**
  110702. * Gets wether tonemapping is enabled or not.
  110703. */
  110704. get cameraToneMappingEnabled(): boolean;
  110705. /**
  110706. * Sets wether tonemapping is enabled or not
  110707. */
  110708. set cameraToneMappingEnabled(value: boolean);
  110709. /**
  110710. * The camera exposure used on this material.
  110711. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110712. * This corresponds to a photographic exposure.
  110713. */
  110714. get cameraExposure(): number;
  110715. /**
  110716. * The camera exposure used on this material.
  110717. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110718. * This corresponds to a photographic exposure.
  110719. */
  110720. set cameraExposure(value: number);
  110721. /**
  110722. * Gets The camera contrast used on this material.
  110723. */
  110724. get cameraContrast(): number;
  110725. /**
  110726. * Sets The camera contrast used on this material.
  110727. */
  110728. set cameraContrast(value: number);
  110729. /**
  110730. * Gets the Color Grading 2D Lookup Texture.
  110731. */
  110732. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  110733. /**
  110734. * Sets the Color Grading 2D Lookup Texture.
  110735. */
  110736. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  110737. /**
  110738. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110739. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110740. * 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;
  110741. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110742. */
  110743. get cameraColorCurves(): Nullable<ColorCurves>;
  110744. /**
  110745. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110746. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110747. * 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;
  110748. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110749. */
  110750. set cameraColorCurves(value: Nullable<ColorCurves>);
  110751. /**
  110752. * Can this material render to several textures at once
  110753. */
  110754. get canRenderToMRT(): boolean;
  110755. /**
  110756. * Defines the detail map parameters for the material.
  110757. */
  110758. readonly detailMap: DetailMapConfiguration;
  110759. protected _renderTargets: SmartArray<RenderTargetTexture>;
  110760. protected _worldViewProjectionMatrix: Matrix;
  110761. protected _globalAmbientColor: Color3;
  110762. protected _useLogarithmicDepth: boolean;
  110763. protected _rebuildInParallel: boolean;
  110764. /**
  110765. * Instantiates a new standard material.
  110766. * This is the default material used in Babylon. It is the best trade off between quality
  110767. * and performances.
  110768. * @see https://doc.babylonjs.com/babylon101/materials
  110769. * @param name Define the name of the material in the scene
  110770. * @param scene Define the scene the material belong to
  110771. */
  110772. constructor(name: string, scene: Scene);
  110773. /**
  110774. * Gets a boolean indicating that current material needs to register RTT
  110775. */
  110776. get hasRenderTargetTextures(): boolean;
  110777. /**
  110778. * Gets the current class name of the material e.g. "StandardMaterial"
  110779. * Mainly use in serialization.
  110780. * @returns the class name
  110781. */
  110782. getClassName(): string;
  110783. /**
  110784. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  110785. * You can try switching to logarithmic depth.
  110786. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  110787. */
  110788. get useLogarithmicDepth(): boolean;
  110789. set useLogarithmicDepth(value: boolean);
  110790. /**
  110791. * Specifies if the material will require alpha blending
  110792. * @returns a boolean specifying if alpha blending is needed
  110793. */
  110794. needAlphaBlending(): boolean;
  110795. /**
  110796. * Specifies if this material should be rendered in alpha test mode
  110797. * @returns a boolean specifying if an alpha test is needed.
  110798. */
  110799. needAlphaTesting(): boolean;
  110800. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  110801. /**
  110802. * Get the texture used for alpha test purpose.
  110803. * @returns the diffuse texture in case of the standard material.
  110804. */
  110805. getAlphaTestTexture(): Nullable<BaseTexture>;
  110806. /**
  110807. * Get if the submesh is ready to be used and all its information available.
  110808. * Child classes can use it to update shaders
  110809. * @param mesh defines the mesh to check
  110810. * @param subMesh defines which submesh to check
  110811. * @param useInstances specifies that instances should be used
  110812. * @returns a boolean indicating that the submesh is ready or not
  110813. */
  110814. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110815. /**
  110816. * Builds the material UBO layouts.
  110817. * Used internally during the effect preparation.
  110818. */
  110819. buildUniformLayout(): void;
  110820. /**
  110821. * Unbinds the material from the mesh
  110822. */
  110823. unbind(): void;
  110824. /**
  110825. * Binds the submesh to this material by preparing the effect and shader to draw
  110826. * @param world defines the world transformation matrix
  110827. * @param mesh defines the mesh containing the submesh
  110828. * @param subMesh defines the submesh to bind the material to
  110829. */
  110830. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110831. /**
  110832. * Get the list of animatables in the material.
  110833. * @returns the list of animatables object used in the material
  110834. */
  110835. getAnimatables(): IAnimatable[];
  110836. /**
  110837. * Gets the active textures from the material
  110838. * @returns an array of textures
  110839. */
  110840. getActiveTextures(): BaseTexture[];
  110841. /**
  110842. * Specifies if the material uses a texture
  110843. * @param texture defines the texture to check against the material
  110844. * @returns a boolean specifying if the material uses the texture
  110845. */
  110846. hasTexture(texture: BaseTexture): boolean;
  110847. /**
  110848. * Disposes the material
  110849. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110850. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110851. */
  110852. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110853. /**
  110854. * Makes a duplicate of the material, and gives it a new name
  110855. * @param name defines the new name for the duplicated material
  110856. * @returns the cloned material
  110857. */
  110858. clone(name: string): StandardMaterial;
  110859. /**
  110860. * Serializes this material in a JSON representation
  110861. * @returns the serialized material object
  110862. */
  110863. serialize(): any;
  110864. /**
  110865. * Creates a standard material from parsed material data
  110866. * @param source defines the JSON representation of the material
  110867. * @param scene defines the hosting scene
  110868. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  110869. * @returns a new standard material
  110870. */
  110871. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  110872. /**
  110873. * Are diffuse textures enabled in the application.
  110874. */
  110875. static get DiffuseTextureEnabled(): boolean;
  110876. static set DiffuseTextureEnabled(value: boolean);
  110877. /**
  110878. * Are detail textures enabled in the application.
  110879. */
  110880. static get DetailTextureEnabled(): boolean;
  110881. static set DetailTextureEnabled(value: boolean);
  110882. /**
  110883. * Are ambient textures enabled in the application.
  110884. */
  110885. static get AmbientTextureEnabled(): boolean;
  110886. static set AmbientTextureEnabled(value: boolean);
  110887. /**
  110888. * Are opacity textures enabled in the application.
  110889. */
  110890. static get OpacityTextureEnabled(): boolean;
  110891. static set OpacityTextureEnabled(value: boolean);
  110892. /**
  110893. * Are reflection textures enabled in the application.
  110894. */
  110895. static get ReflectionTextureEnabled(): boolean;
  110896. static set ReflectionTextureEnabled(value: boolean);
  110897. /**
  110898. * Are emissive textures enabled in the application.
  110899. */
  110900. static get EmissiveTextureEnabled(): boolean;
  110901. static set EmissiveTextureEnabled(value: boolean);
  110902. /**
  110903. * Are specular textures enabled in the application.
  110904. */
  110905. static get SpecularTextureEnabled(): boolean;
  110906. static set SpecularTextureEnabled(value: boolean);
  110907. /**
  110908. * Are bump textures enabled in the application.
  110909. */
  110910. static get BumpTextureEnabled(): boolean;
  110911. static set BumpTextureEnabled(value: boolean);
  110912. /**
  110913. * Are lightmap textures enabled in the application.
  110914. */
  110915. static get LightmapTextureEnabled(): boolean;
  110916. static set LightmapTextureEnabled(value: boolean);
  110917. /**
  110918. * Are refraction textures enabled in the application.
  110919. */
  110920. static get RefractionTextureEnabled(): boolean;
  110921. static set RefractionTextureEnabled(value: boolean);
  110922. /**
  110923. * Are color grading textures enabled in the application.
  110924. */
  110925. static get ColorGradingTextureEnabled(): boolean;
  110926. static set ColorGradingTextureEnabled(value: boolean);
  110927. /**
  110928. * Are fresnels enabled in the application.
  110929. */
  110930. static get FresnelEnabled(): boolean;
  110931. static set FresnelEnabled(value: boolean);
  110932. }
  110933. }
  110934. declare module BABYLON {
  110935. /**
  110936. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  110937. *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.
  110938. * The SPS is also a particle system. It provides some methods to manage the particles.
  110939. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  110940. *
  110941. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  110942. */
  110943. export class SolidParticleSystem implements IDisposable {
  110944. /**
  110945. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  110946. * Example : var p = SPS.particles[i];
  110947. */
  110948. particles: SolidParticle[];
  110949. /**
  110950. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  110951. */
  110952. nbParticles: number;
  110953. /**
  110954. * If the particles must ever face the camera (default false). Useful for planar particles.
  110955. */
  110956. billboard: boolean;
  110957. /**
  110958. * Recompute normals when adding a shape
  110959. */
  110960. recomputeNormals: boolean;
  110961. /**
  110962. * This a counter ofr your own usage. It's not set by any SPS functions.
  110963. */
  110964. counter: number;
  110965. /**
  110966. * The SPS name. This name is also given to the underlying mesh.
  110967. */
  110968. name: string;
  110969. /**
  110970. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  110971. */
  110972. mesh: Mesh;
  110973. /**
  110974. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  110975. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  110976. */
  110977. vars: any;
  110978. /**
  110979. * This array is populated when the SPS is set as 'pickable'.
  110980. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  110981. * Each element of this array is an object `{idx: int, faceId: int}`.
  110982. * `idx` is the picked particle index in the `SPS.particles` array
  110983. * `faceId` is the picked face index counted within this particle.
  110984. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  110985. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  110986. * Use the method SPS.pickedParticle(pickingInfo) instead.
  110987. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  110988. */
  110989. pickedParticles: {
  110990. idx: number;
  110991. faceId: number;
  110992. }[];
  110993. /**
  110994. * This array is populated when the SPS is set as 'pickable'
  110995. * Each key of this array is a submesh index.
  110996. * Each element of this array is a second array defined like this :
  110997. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  110998. * Each element of this second array is an object `{idx: int, faceId: int}`.
  110999. * `idx` is the picked particle index in the `SPS.particles` array
  111000. * `faceId` is the picked face index counted within this particle.
  111001. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  111002. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111003. */
  111004. pickedBySubMesh: {
  111005. idx: number;
  111006. faceId: number;
  111007. }[][];
  111008. /**
  111009. * This array is populated when `enableDepthSort` is set to true.
  111010. * Each element of this array is an instance of the class DepthSortedParticle.
  111011. */
  111012. depthSortedParticles: DepthSortedParticle[];
  111013. /**
  111014. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  111015. * @hidden
  111016. */
  111017. _bSphereOnly: boolean;
  111018. /**
  111019. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  111020. * @hidden
  111021. */
  111022. _bSphereRadiusFactor: number;
  111023. private _scene;
  111024. private _positions;
  111025. private _indices;
  111026. private _normals;
  111027. private _colors;
  111028. private _uvs;
  111029. private _indices32;
  111030. private _positions32;
  111031. private _normals32;
  111032. private _fixedNormal32;
  111033. private _colors32;
  111034. private _uvs32;
  111035. private _index;
  111036. private _updatable;
  111037. private _pickable;
  111038. private _isVisibilityBoxLocked;
  111039. private _alwaysVisible;
  111040. private _depthSort;
  111041. private _expandable;
  111042. private _shapeCounter;
  111043. private _copy;
  111044. private _color;
  111045. private _computeParticleColor;
  111046. private _computeParticleTexture;
  111047. private _computeParticleRotation;
  111048. private _computeParticleVertex;
  111049. private _computeBoundingBox;
  111050. private _depthSortParticles;
  111051. private _camera;
  111052. private _mustUnrotateFixedNormals;
  111053. private _particlesIntersect;
  111054. private _needs32Bits;
  111055. private _isNotBuilt;
  111056. private _lastParticleId;
  111057. private _idxOfId;
  111058. private _multimaterialEnabled;
  111059. private _useModelMaterial;
  111060. private _indicesByMaterial;
  111061. private _materialIndexes;
  111062. private _depthSortFunction;
  111063. private _materialSortFunction;
  111064. private _materials;
  111065. private _multimaterial;
  111066. private _materialIndexesById;
  111067. private _defaultMaterial;
  111068. private _autoUpdateSubMeshes;
  111069. private _tmpVertex;
  111070. /**
  111071. * Creates a SPS (Solid Particle System) object.
  111072. * @param name (String) is the SPS name, this will be the underlying mesh name.
  111073. * @param scene (Scene) is the scene in which the SPS is added.
  111074. * @param options defines the options of the sps e.g.
  111075. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  111076. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  111077. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  111078. * * 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.
  111079. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  111080. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  111081. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  111082. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  111083. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  111084. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  111085. */
  111086. constructor(name: string, scene: Scene, options?: {
  111087. updatable?: boolean;
  111088. isPickable?: boolean;
  111089. enableDepthSort?: boolean;
  111090. particleIntersection?: boolean;
  111091. boundingSphereOnly?: boolean;
  111092. bSphereRadiusFactor?: number;
  111093. expandable?: boolean;
  111094. useModelMaterial?: boolean;
  111095. enableMultiMaterial?: boolean;
  111096. });
  111097. /**
  111098. * Builds the SPS underlying mesh. Returns a standard Mesh.
  111099. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  111100. * @returns the created mesh
  111101. */
  111102. buildMesh(): Mesh;
  111103. /**
  111104. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  111105. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  111106. * Thus the particles generated from `digest()` have their property `position` set yet.
  111107. * @param mesh ( Mesh ) is the mesh to be digested
  111108. * @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
  111109. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  111110. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  111111. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111112. * @returns the current SPS
  111113. */
  111114. digest(mesh: Mesh, options?: {
  111115. facetNb?: number;
  111116. number?: number;
  111117. delta?: number;
  111118. storage?: [];
  111119. }): SolidParticleSystem;
  111120. /**
  111121. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  111122. * @hidden
  111123. */
  111124. private _unrotateFixedNormals;
  111125. /**
  111126. * Resets the temporary working copy particle
  111127. * @hidden
  111128. */
  111129. private _resetCopy;
  111130. /**
  111131. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  111132. * @param p the current index in the positions array to be updated
  111133. * @param ind the current index in the indices array
  111134. * @param shape a Vector3 array, the shape geometry
  111135. * @param positions the positions array to be updated
  111136. * @param meshInd the shape indices array
  111137. * @param indices the indices array to be updated
  111138. * @param meshUV the shape uv array
  111139. * @param uvs the uv array to be updated
  111140. * @param meshCol the shape color array
  111141. * @param colors the color array to be updated
  111142. * @param meshNor the shape normals array
  111143. * @param normals the normals array to be updated
  111144. * @param idx the particle index
  111145. * @param idxInShape the particle index in its shape
  111146. * @param options the addShape() method passed options
  111147. * @model the particle model
  111148. * @hidden
  111149. */
  111150. private _meshBuilder;
  111151. /**
  111152. * Returns a shape Vector3 array from positions float array
  111153. * @param positions float array
  111154. * @returns a vector3 array
  111155. * @hidden
  111156. */
  111157. private _posToShape;
  111158. /**
  111159. * Returns a shapeUV array from a float uvs (array deep copy)
  111160. * @param uvs as a float array
  111161. * @returns a shapeUV array
  111162. * @hidden
  111163. */
  111164. private _uvsToShapeUV;
  111165. /**
  111166. * Adds a new particle object in the particles array
  111167. * @param idx particle index in particles array
  111168. * @param id particle id
  111169. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  111170. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  111171. * @param model particle ModelShape object
  111172. * @param shapeId model shape identifier
  111173. * @param idxInShape index of the particle in the current model
  111174. * @param bInfo model bounding info object
  111175. * @param storage target storage array, if any
  111176. * @hidden
  111177. */
  111178. private _addParticle;
  111179. /**
  111180. * Adds some particles to the SPS from the model shape. Returns the shape id.
  111181. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  111182. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  111183. * @param nb (positive integer) the number of particles to be created from this model
  111184. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  111185. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  111186. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111187. * @returns the number of shapes in the system
  111188. */
  111189. addShape(mesh: Mesh, nb: number, options?: {
  111190. positionFunction?: any;
  111191. vertexFunction?: any;
  111192. storage?: [];
  111193. }): number;
  111194. /**
  111195. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  111196. * @hidden
  111197. */
  111198. private _rebuildParticle;
  111199. /**
  111200. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  111201. * @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.
  111202. * @returns the SPS.
  111203. */
  111204. rebuildMesh(reset?: boolean): SolidParticleSystem;
  111205. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  111206. * Returns an array with the removed particles.
  111207. * 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.
  111208. * The SPS can't be empty so at least one particle needs to remain in place.
  111209. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  111210. * @param start index of the first particle to remove
  111211. * @param end index of the last particle to remove (included)
  111212. * @returns an array populated with the removed particles
  111213. */
  111214. removeParticles(start: number, end: number): SolidParticle[];
  111215. /**
  111216. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  111217. * @param solidParticleArray an array populated with Solid Particles objects
  111218. * @returns the SPS
  111219. */
  111220. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  111221. /**
  111222. * Creates a new particle and modifies the SPS mesh geometry :
  111223. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  111224. * - calls _addParticle() to populate the particle array
  111225. * factorized code from addShape() and insertParticlesFromArray()
  111226. * @param idx particle index in the particles array
  111227. * @param i particle index in its shape
  111228. * @param modelShape particle ModelShape object
  111229. * @param shape shape vertex array
  111230. * @param meshInd shape indices array
  111231. * @param meshUV shape uv array
  111232. * @param meshCol shape color array
  111233. * @param meshNor shape normals array
  111234. * @param bbInfo shape bounding info
  111235. * @param storage target particle storage
  111236. * @options addShape() passed options
  111237. * @hidden
  111238. */
  111239. private _insertNewParticle;
  111240. /**
  111241. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  111242. * This method calls `updateParticle()` for each particle of the SPS.
  111243. * For an animated SPS, it is usually called within the render loop.
  111244. * 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.
  111245. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  111246. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  111247. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  111248. * @returns the SPS.
  111249. */
  111250. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  111251. /**
  111252. * Disposes the SPS.
  111253. */
  111254. dispose(): void;
  111255. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  111256. * idx is the particle index in the SPS
  111257. * faceId is the picked face index counted within this particle.
  111258. * Returns null if the pickInfo can't identify a picked particle.
  111259. * @param pickingInfo (PickingInfo object)
  111260. * @returns {idx: number, faceId: number} or null
  111261. */
  111262. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  111263. idx: number;
  111264. faceId: number;
  111265. }>;
  111266. /**
  111267. * Returns a SolidParticle object from its identifier : particle.id
  111268. * @param id (integer) the particle Id
  111269. * @returns the searched particle or null if not found in the SPS.
  111270. */
  111271. getParticleById(id: number): Nullable<SolidParticle>;
  111272. /**
  111273. * Returns a new array populated with the particles having the passed shapeId.
  111274. * @param shapeId (integer) the shape identifier
  111275. * @returns a new solid particle array
  111276. */
  111277. getParticlesByShapeId(shapeId: number): SolidParticle[];
  111278. /**
  111279. * Populates the passed array "ref" with the particles having the passed shapeId.
  111280. * @param shapeId the shape identifier
  111281. * @returns the SPS
  111282. * @param ref
  111283. */
  111284. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  111285. /**
  111286. * Computes the required SubMeshes according the materials assigned to the particles.
  111287. * @returns the solid particle system.
  111288. * Does nothing if called before the SPS mesh is built.
  111289. */
  111290. computeSubMeshes(): SolidParticleSystem;
  111291. /**
  111292. * Sorts the solid particles by material when MultiMaterial is enabled.
  111293. * Updates the indices32 array.
  111294. * Updates the indicesByMaterial array.
  111295. * Updates the mesh indices array.
  111296. * @returns the SPS
  111297. * @hidden
  111298. */
  111299. private _sortParticlesByMaterial;
  111300. /**
  111301. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  111302. * @hidden
  111303. */
  111304. private _setMaterialIndexesById;
  111305. /**
  111306. * Returns an array with unique values of Materials from the passed array
  111307. * @param array the material array to be checked and filtered
  111308. * @hidden
  111309. */
  111310. private _filterUniqueMaterialId;
  111311. /**
  111312. * Sets a new Standard Material as _defaultMaterial if not already set.
  111313. * @hidden
  111314. */
  111315. private _setDefaultMaterial;
  111316. /**
  111317. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  111318. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111319. * @returns the SPS.
  111320. */
  111321. refreshVisibleSize(): SolidParticleSystem;
  111322. /**
  111323. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  111324. * @param size the size (float) of the visibility box
  111325. * note : this doesn't lock the SPS mesh bounding box.
  111326. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111327. */
  111328. setVisibilityBox(size: number): void;
  111329. /**
  111330. * Gets whether the SPS as always visible or not
  111331. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111332. */
  111333. get isAlwaysVisible(): boolean;
  111334. /**
  111335. * Sets the SPS as always visible or not
  111336. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111337. */
  111338. set isAlwaysVisible(val: boolean);
  111339. /**
  111340. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111341. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111342. */
  111343. set isVisibilityBoxLocked(val: boolean);
  111344. /**
  111345. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111346. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111347. */
  111348. get isVisibilityBoxLocked(): boolean;
  111349. /**
  111350. * Tells to `setParticles()` to compute the particle rotations or not.
  111351. * Default value : true. The SPS is faster when it's set to false.
  111352. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111353. */
  111354. set computeParticleRotation(val: boolean);
  111355. /**
  111356. * Tells to `setParticles()` to compute the particle colors or not.
  111357. * Default value : true. The SPS is faster when it's set to false.
  111358. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111359. */
  111360. set computeParticleColor(val: boolean);
  111361. set computeParticleTexture(val: boolean);
  111362. /**
  111363. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  111364. * Default value : false. The SPS is faster when it's set to false.
  111365. * Note : the particle custom vertex positions aren't stored values.
  111366. */
  111367. set computeParticleVertex(val: boolean);
  111368. /**
  111369. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  111370. */
  111371. set computeBoundingBox(val: boolean);
  111372. /**
  111373. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  111374. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111375. * Default : `true`
  111376. */
  111377. set depthSortParticles(val: boolean);
  111378. /**
  111379. * Gets if `setParticles()` computes the particle rotations or not.
  111380. * Default value : true. The SPS is faster when it's set to false.
  111381. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111382. */
  111383. get computeParticleRotation(): boolean;
  111384. /**
  111385. * Gets if `setParticles()` computes the particle colors or not.
  111386. * Default value : true. The SPS is faster when it's set to false.
  111387. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111388. */
  111389. get computeParticleColor(): boolean;
  111390. /**
  111391. * Gets if `setParticles()` computes the particle textures or not.
  111392. * Default value : true. The SPS is faster when it's set to false.
  111393. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  111394. */
  111395. get computeParticleTexture(): boolean;
  111396. /**
  111397. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  111398. * Default value : false. The SPS is faster when it's set to false.
  111399. * Note : the particle custom vertex positions aren't stored values.
  111400. */
  111401. get computeParticleVertex(): boolean;
  111402. /**
  111403. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  111404. */
  111405. get computeBoundingBox(): boolean;
  111406. /**
  111407. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  111408. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111409. * Default : `true`
  111410. */
  111411. get depthSortParticles(): boolean;
  111412. /**
  111413. * Gets if the SPS is created as expandable at construction time.
  111414. * Default : `false`
  111415. */
  111416. get expandable(): boolean;
  111417. /**
  111418. * Gets if the SPS supports the Multi Materials
  111419. */
  111420. get multimaterialEnabled(): boolean;
  111421. /**
  111422. * Gets if the SPS uses the model materials for its own multimaterial.
  111423. */
  111424. get useModelMaterial(): boolean;
  111425. /**
  111426. * The SPS used material array.
  111427. */
  111428. get materials(): Material[];
  111429. /**
  111430. * Sets the SPS MultiMaterial from the passed materials.
  111431. * Note : the passed array is internally copied and not used then by reference.
  111432. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  111433. */
  111434. setMultiMaterial(materials: Material[]): void;
  111435. /**
  111436. * The SPS computed multimaterial object
  111437. */
  111438. get multimaterial(): MultiMaterial;
  111439. set multimaterial(mm: MultiMaterial);
  111440. /**
  111441. * If the subMeshes must be updated on the next call to setParticles()
  111442. */
  111443. get autoUpdateSubMeshes(): boolean;
  111444. set autoUpdateSubMeshes(val: boolean);
  111445. /**
  111446. * This function does nothing. It may be overwritten to set all the particle first values.
  111447. * The SPS doesn't call this function, you may have to call it by your own.
  111448. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111449. */
  111450. initParticles(): void;
  111451. /**
  111452. * This function does nothing. It may be overwritten to recycle a particle.
  111453. * The SPS doesn't call this function, you may have to call it by your own.
  111454. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111455. * @param particle The particle to recycle
  111456. * @returns the recycled particle
  111457. */
  111458. recycleParticle(particle: SolidParticle): SolidParticle;
  111459. /**
  111460. * Updates a particle : this function should be overwritten by the user.
  111461. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  111462. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111463. * @example : just set a particle position or velocity and recycle conditions
  111464. * @param particle The particle to update
  111465. * @returns the updated particle
  111466. */
  111467. updateParticle(particle: SolidParticle): SolidParticle;
  111468. /**
  111469. * Updates a vertex of a particle : it can be overwritten by the user.
  111470. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  111471. * @param particle the current particle
  111472. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  111473. * @param pt the index of the current vertex in the particle shape
  111474. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  111475. * @example : just set a vertex particle position or color
  111476. * @returns the sps
  111477. */
  111478. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  111479. /**
  111480. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  111481. * This does nothing and may be overwritten by the user.
  111482. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111483. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111484. * @param update the boolean update value actually passed to setParticles()
  111485. */
  111486. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111487. /**
  111488. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  111489. * This will be passed three parameters.
  111490. * This does nothing and may be overwritten by the user.
  111491. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111492. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111493. * @param update the boolean update value actually passed to setParticles()
  111494. */
  111495. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111496. }
  111497. }
  111498. declare module BABYLON {
  111499. /**
  111500. * Represents one particle of a solid particle system.
  111501. */
  111502. export class SolidParticle {
  111503. /**
  111504. * particle global index
  111505. */
  111506. idx: number;
  111507. /**
  111508. * particle identifier
  111509. */
  111510. id: number;
  111511. /**
  111512. * The color of the particle
  111513. */
  111514. color: Nullable<Color4>;
  111515. /**
  111516. * The world space position of the particle.
  111517. */
  111518. position: Vector3;
  111519. /**
  111520. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  111521. */
  111522. rotation: Vector3;
  111523. /**
  111524. * The world space rotation quaternion of the particle.
  111525. */
  111526. rotationQuaternion: Nullable<Quaternion>;
  111527. /**
  111528. * The scaling of the particle.
  111529. */
  111530. scaling: Vector3;
  111531. /**
  111532. * The uvs of the particle.
  111533. */
  111534. uvs: Vector4;
  111535. /**
  111536. * The current speed of the particle.
  111537. */
  111538. velocity: Vector3;
  111539. /**
  111540. * The pivot point in the particle local space.
  111541. */
  111542. pivot: Vector3;
  111543. /**
  111544. * Must the particle be translated from its pivot point in its local space ?
  111545. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  111546. * Default : false
  111547. */
  111548. translateFromPivot: boolean;
  111549. /**
  111550. * Is the particle active or not ?
  111551. */
  111552. alive: boolean;
  111553. /**
  111554. * Is the particle visible or not ?
  111555. */
  111556. isVisible: boolean;
  111557. /**
  111558. * Index of this particle in the global "positions" array (Internal use)
  111559. * @hidden
  111560. */
  111561. _pos: number;
  111562. /**
  111563. * @hidden Index of this particle in the global "indices" array (Internal use)
  111564. */
  111565. _ind: number;
  111566. /**
  111567. * @hidden ModelShape of this particle (Internal use)
  111568. */
  111569. _model: ModelShape;
  111570. /**
  111571. * ModelShape id of this particle
  111572. */
  111573. shapeId: number;
  111574. /**
  111575. * Index of the particle in its shape id
  111576. */
  111577. idxInShape: number;
  111578. /**
  111579. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  111580. */
  111581. _modelBoundingInfo: BoundingInfo;
  111582. /**
  111583. * @hidden Particle BoundingInfo object (Internal use)
  111584. */
  111585. _boundingInfo: BoundingInfo;
  111586. /**
  111587. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  111588. */
  111589. _sps: SolidParticleSystem;
  111590. /**
  111591. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  111592. */
  111593. _stillInvisible: boolean;
  111594. /**
  111595. * @hidden Last computed particle rotation matrix
  111596. */
  111597. _rotationMatrix: number[];
  111598. /**
  111599. * Parent particle Id, if any.
  111600. * Default null.
  111601. */
  111602. parentId: Nullable<number>;
  111603. /**
  111604. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  111605. */
  111606. materialIndex: Nullable<number>;
  111607. /**
  111608. * Custom object or properties.
  111609. */
  111610. props: Nullable<any>;
  111611. /**
  111612. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  111613. * The possible values are :
  111614. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  111615. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111616. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  111617. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  111618. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111619. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  111620. * */
  111621. cullingStrategy: number;
  111622. /**
  111623. * @hidden Internal global position in the SPS.
  111624. */
  111625. _globalPosition: Vector3;
  111626. /**
  111627. * Creates a Solid Particle object.
  111628. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  111629. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  111630. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  111631. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  111632. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  111633. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  111634. * @param shapeId (integer) is the model shape identifier in the SPS.
  111635. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  111636. * @param sps defines the sps it is associated to
  111637. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  111638. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  111639. */
  111640. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  111641. /**
  111642. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  111643. * @param target the particle target
  111644. * @returns the current particle
  111645. */
  111646. copyToRef(target: SolidParticle): SolidParticle;
  111647. /**
  111648. * Legacy support, changed scale to scaling
  111649. */
  111650. get scale(): Vector3;
  111651. /**
  111652. * Legacy support, changed scale to scaling
  111653. */
  111654. set scale(scale: Vector3);
  111655. /**
  111656. * Legacy support, changed quaternion to rotationQuaternion
  111657. */
  111658. get quaternion(): Nullable<Quaternion>;
  111659. /**
  111660. * Legacy support, changed quaternion to rotationQuaternion
  111661. */
  111662. set quaternion(q: Nullable<Quaternion>);
  111663. /**
  111664. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  111665. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  111666. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  111667. * @returns true if it intersects
  111668. */
  111669. intersectsMesh(target: Mesh | SolidParticle): boolean;
  111670. /**
  111671. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  111672. * A particle is in the frustum if its bounding box intersects the frustum
  111673. * @param frustumPlanes defines the frustum to test
  111674. * @returns true if the particle is in the frustum planes
  111675. */
  111676. isInFrustum(frustumPlanes: Plane[]): boolean;
  111677. /**
  111678. * get the rotation matrix of the particle
  111679. * @hidden
  111680. */
  111681. getRotationMatrix(m: Matrix): void;
  111682. }
  111683. /**
  111684. * Represents the shape of the model used by one particle of a solid particle system.
  111685. * SPS internal tool, don't use it manually.
  111686. */
  111687. export class ModelShape {
  111688. /**
  111689. * The shape id
  111690. * @hidden
  111691. */
  111692. shapeID: number;
  111693. /**
  111694. * flat array of model positions (internal use)
  111695. * @hidden
  111696. */
  111697. _shape: Vector3[];
  111698. /**
  111699. * flat array of model UVs (internal use)
  111700. * @hidden
  111701. */
  111702. _shapeUV: number[];
  111703. /**
  111704. * color array of the model
  111705. * @hidden
  111706. */
  111707. _shapeColors: number[];
  111708. /**
  111709. * indices array of the model
  111710. * @hidden
  111711. */
  111712. _indices: number[];
  111713. /**
  111714. * normals array of the model
  111715. * @hidden
  111716. */
  111717. _normals: number[];
  111718. /**
  111719. * length of the shape in the model indices array (internal use)
  111720. * @hidden
  111721. */
  111722. _indicesLength: number;
  111723. /**
  111724. * Custom position function (internal use)
  111725. * @hidden
  111726. */
  111727. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  111728. /**
  111729. * Custom vertex function (internal use)
  111730. * @hidden
  111731. */
  111732. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  111733. /**
  111734. * Model material (internal use)
  111735. * @hidden
  111736. */
  111737. _material: Nullable<Material>;
  111738. /**
  111739. * 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.
  111740. * SPS internal tool, don't use it manually.
  111741. * @hidden
  111742. */
  111743. 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>);
  111744. }
  111745. /**
  111746. * Represents a Depth Sorted Particle in the solid particle system.
  111747. * @hidden
  111748. */
  111749. export class DepthSortedParticle {
  111750. /**
  111751. * Particle index
  111752. */
  111753. idx: number;
  111754. /**
  111755. * Index of the particle in the "indices" array
  111756. */
  111757. ind: number;
  111758. /**
  111759. * Length of the particle shape in the "indices" array
  111760. */
  111761. indicesLength: number;
  111762. /**
  111763. * Squared distance from the particle to the camera
  111764. */
  111765. sqDistance: number;
  111766. /**
  111767. * Material index when used with MultiMaterials
  111768. */
  111769. materialIndex: number;
  111770. /**
  111771. * Creates a new sorted particle
  111772. * @param materialIndex
  111773. */
  111774. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  111775. }
  111776. /**
  111777. * Represents a solid particle vertex
  111778. */
  111779. export class SolidParticleVertex {
  111780. /**
  111781. * Vertex position
  111782. */
  111783. position: Vector3;
  111784. /**
  111785. * Vertex color
  111786. */
  111787. color: Color4;
  111788. /**
  111789. * Vertex UV
  111790. */
  111791. uv: Vector2;
  111792. /**
  111793. * Creates a new solid particle vertex
  111794. */
  111795. constructor();
  111796. /** Vertex x coordinate */
  111797. get x(): number;
  111798. set x(val: number);
  111799. /** Vertex y coordinate */
  111800. get y(): number;
  111801. set y(val: number);
  111802. /** Vertex z coordinate */
  111803. get z(): number;
  111804. set z(val: number);
  111805. }
  111806. }
  111807. declare module BABYLON {
  111808. /**
  111809. * @hidden
  111810. */
  111811. export class _MeshCollisionData {
  111812. _checkCollisions: boolean;
  111813. _collisionMask: number;
  111814. _collisionGroup: number;
  111815. _surroundingMeshes: Nullable<AbstractMesh[]>;
  111816. _collider: Nullable<Collider>;
  111817. _oldPositionForCollisions: Vector3;
  111818. _diffPositionForCollisions: Vector3;
  111819. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  111820. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  111821. _collisionResponse: boolean;
  111822. }
  111823. }
  111824. declare module BABYLON {
  111825. /** @hidden */
  111826. class _FacetDataStorage {
  111827. facetPositions: Vector3[];
  111828. facetNormals: Vector3[];
  111829. facetPartitioning: number[][];
  111830. facetNb: number;
  111831. partitioningSubdivisions: number;
  111832. partitioningBBoxRatio: number;
  111833. facetDataEnabled: boolean;
  111834. facetParameters: any;
  111835. bbSize: Vector3;
  111836. subDiv: {
  111837. max: number;
  111838. X: number;
  111839. Y: number;
  111840. Z: number;
  111841. };
  111842. facetDepthSort: boolean;
  111843. facetDepthSortEnabled: boolean;
  111844. depthSortedIndices: IndicesArray;
  111845. depthSortedFacets: {
  111846. ind: number;
  111847. sqDistance: number;
  111848. }[];
  111849. facetDepthSortFunction: (f1: {
  111850. ind: number;
  111851. sqDistance: number;
  111852. }, f2: {
  111853. ind: number;
  111854. sqDistance: number;
  111855. }) => number;
  111856. facetDepthSortFrom: Vector3;
  111857. facetDepthSortOrigin: Vector3;
  111858. invertedMatrix: Matrix;
  111859. }
  111860. /**
  111861. * @hidden
  111862. **/
  111863. class _InternalAbstractMeshDataInfo {
  111864. _hasVertexAlpha: boolean;
  111865. _useVertexColors: boolean;
  111866. _numBoneInfluencers: number;
  111867. _applyFog: boolean;
  111868. _receiveShadows: boolean;
  111869. _facetData: _FacetDataStorage;
  111870. _visibility: number;
  111871. _skeleton: Nullable<Skeleton>;
  111872. _layerMask: number;
  111873. _computeBonesUsingShaders: boolean;
  111874. _isActive: boolean;
  111875. _onlyForInstances: boolean;
  111876. _isActiveIntermediate: boolean;
  111877. _onlyForInstancesIntermediate: boolean;
  111878. _actAsRegularMesh: boolean;
  111879. }
  111880. /**
  111881. * Class used to store all common mesh properties
  111882. */
  111883. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  111884. /** No occlusion */
  111885. static OCCLUSION_TYPE_NONE: number;
  111886. /** Occlusion set to optimisitic */
  111887. static OCCLUSION_TYPE_OPTIMISTIC: number;
  111888. /** Occlusion set to strict */
  111889. static OCCLUSION_TYPE_STRICT: number;
  111890. /** Use an accurante occlusion algorithm */
  111891. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  111892. /** Use a conservative occlusion algorithm */
  111893. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  111894. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  111895. * Test order :
  111896. * Is the bounding sphere outside the frustum ?
  111897. * If not, are the bounding box vertices outside the frustum ?
  111898. * It not, then the cullable object is in the frustum.
  111899. */
  111900. static readonly CULLINGSTRATEGY_STANDARD: number;
  111901. /** Culling strategy : Bounding Sphere Only.
  111902. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  111903. * It's also less accurate than the standard because some not visible objects can still be selected.
  111904. * Test : is the bounding sphere outside the frustum ?
  111905. * If not, then the cullable object is in the frustum.
  111906. */
  111907. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  111908. /** Culling strategy : Optimistic Inclusion.
  111909. * This in an inclusion test first, then the standard exclusion test.
  111910. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  111911. * 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.
  111912. * Anyway, it's as accurate as the standard strategy.
  111913. * Test :
  111914. * Is the cullable object bounding sphere center in the frustum ?
  111915. * If not, apply the default culling strategy.
  111916. */
  111917. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  111918. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  111919. * This in an inclusion test first, then the bounding sphere only exclusion test.
  111920. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  111921. * 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.
  111922. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  111923. * Test :
  111924. * Is the cullable object bounding sphere center in the frustum ?
  111925. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  111926. */
  111927. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  111928. /**
  111929. * No billboard
  111930. */
  111931. static get BILLBOARDMODE_NONE(): number;
  111932. /** Billboard on X axis */
  111933. static get BILLBOARDMODE_X(): number;
  111934. /** Billboard on Y axis */
  111935. static get BILLBOARDMODE_Y(): number;
  111936. /** Billboard on Z axis */
  111937. static get BILLBOARDMODE_Z(): number;
  111938. /** Billboard on all axes */
  111939. static get BILLBOARDMODE_ALL(): number;
  111940. /** Billboard on using position instead of orientation */
  111941. static get BILLBOARDMODE_USE_POSITION(): number;
  111942. /** @hidden */
  111943. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  111944. /**
  111945. * The culling strategy to use to check whether the mesh must be rendered or not.
  111946. * This value can be changed at any time and will be used on the next render mesh selection.
  111947. * The possible values are :
  111948. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  111949. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111950. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  111951. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  111952. * Please read each static variable documentation to get details about the culling process.
  111953. * */
  111954. cullingStrategy: number;
  111955. /**
  111956. * Gets the number of facets in the mesh
  111957. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  111958. */
  111959. get facetNb(): number;
  111960. /**
  111961. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  111962. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  111963. */
  111964. get partitioningSubdivisions(): number;
  111965. set partitioningSubdivisions(nb: number);
  111966. /**
  111967. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  111968. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  111969. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  111970. */
  111971. get partitioningBBoxRatio(): number;
  111972. set partitioningBBoxRatio(ratio: number);
  111973. /**
  111974. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  111975. * Works only for updatable meshes.
  111976. * Doesn't work with multi-materials
  111977. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  111978. */
  111979. get mustDepthSortFacets(): boolean;
  111980. set mustDepthSortFacets(sort: boolean);
  111981. /**
  111982. * The location (Vector3) where the facet depth sort must be computed from.
  111983. * By default, the active camera position.
  111984. * Used only when facet depth sort is enabled
  111985. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  111986. */
  111987. get facetDepthSortFrom(): Vector3;
  111988. set facetDepthSortFrom(location: Vector3);
  111989. /**
  111990. * gets a boolean indicating if facetData is enabled
  111991. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  111992. */
  111993. get isFacetDataEnabled(): boolean;
  111994. /** @hidden */
  111995. _updateNonUniformScalingState(value: boolean): boolean;
  111996. /**
  111997. * An event triggered when this mesh collides with another one
  111998. */
  111999. onCollideObservable: Observable<AbstractMesh>;
  112000. /** Set a function to call when this mesh collides with another one */
  112001. set onCollide(callback: () => void);
  112002. /**
  112003. * An event triggered when the collision's position changes
  112004. */
  112005. onCollisionPositionChangeObservable: Observable<Vector3>;
  112006. /** Set a function to call when the collision's position changes */
  112007. set onCollisionPositionChange(callback: () => void);
  112008. /**
  112009. * An event triggered when material is changed
  112010. */
  112011. onMaterialChangedObservable: Observable<AbstractMesh>;
  112012. /**
  112013. * Gets or sets the orientation for POV movement & rotation
  112014. */
  112015. definedFacingForward: boolean;
  112016. /** @hidden */
  112017. _occlusionQuery: Nullable<WebGLQuery>;
  112018. /** @hidden */
  112019. _renderingGroup: Nullable<RenderingGroup>;
  112020. /**
  112021. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112022. */
  112023. get visibility(): number;
  112024. /**
  112025. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112026. */
  112027. set visibility(value: number);
  112028. /** Gets or sets the alpha index used to sort transparent meshes
  112029. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  112030. */
  112031. alphaIndex: number;
  112032. /**
  112033. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  112034. */
  112035. isVisible: boolean;
  112036. /**
  112037. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  112038. */
  112039. isPickable: boolean;
  112040. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  112041. showSubMeshesBoundingBox: boolean;
  112042. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  112043. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112044. */
  112045. isBlocker: boolean;
  112046. /**
  112047. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  112048. */
  112049. enablePointerMoveEvents: boolean;
  112050. private _renderingGroupId;
  112051. /**
  112052. * Specifies the rendering group id for this mesh (0 by default)
  112053. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  112054. */
  112055. get renderingGroupId(): number;
  112056. set renderingGroupId(value: number);
  112057. private _material;
  112058. /** Gets or sets current material */
  112059. get material(): Nullable<Material>;
  112060. set material(value: Nullable<Material>);
  112061. /**
  112062. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  112063. * @see https://doc.babylonjs.com/babylon101/shadows
  112064. */
  112065. get receiveShadows(): boolean;
  112066. set receiveShadows(value: boolean);
  112067. /** Defines color to use when rendering outline */
  112068. outlineColor: Color3;
  112069. /** Define width to use when rendering outline */
  112070. outlineWidth: number;
  112071. /** Defines color to use when rendering overlay */
  112072. overlayColor: Color3;
  112073. /** Defines alpha to use when rendering overlay */
  112074. overlayAlpha: number;
  112075. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  112076. get hasVertexAlpha(): boolean;
  112077. set hasVertexAlpha(value: boolean);
  112078. /** 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) */
  112079. get useVertexColors(): boolean;
  112080. set useVertexColors(value: boolean);
  112081. /**
  112082. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  112083. */
  112084. get computeBonesUsingShaders(): boolean;
  112085. set computeBonesUsingShaders(value: boolean);
  112086. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  112087. get numBoneInfluencers(): number;
  112088. set numBoneInfluencers(value: number);
  112089. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  112090. get applyFog(): boolean;
  112091. set applyFog(value: boolean);
  112092. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  112093. useOctreeForRenderingSelection: boolean;
  112094. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  112095. useOctreeForPicking: boolean;
  112096. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  112097. useOctreeForCollisions: boolean;
  112098. /**
  112099. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  112100. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  112101. */
  112102. get layerMask(): number;
  112103. set layerMask(value: number);
  112104. /**
  112105. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  112106. */
  112107. alwaysSelectAsActiveMesh: boolean;
  112108. /**
  112109. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  112110. */
  112111. doNotSyncBoundingInfo: boolean;
  112112. /**
  112113. * Gets or sets the current action manager
  112114. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112115. */
  112116. actionManager: Nullable<AbstractActionManager>;
  112117. private _meshCollisionData;
  112118. /**
  112119. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  112120. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112121. */
  112122. ellipsoid: Vector3;
  112123. /**
  112124. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  112125. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112126. */
  112127. ellipsoidOffset: Vector3;
  112128. /**
  112129. * Gets or sets a collision mask used to mask collisions (default is -1).
  112130. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112131. */
  112132. get collisionMask(): number;
  112133. set collisionMask(mask: number);
  112134. /**
  112135. * Gets or sets a collision response flag (default is true).
  112136. * when collisionResponse is false, events are still triggered but colliding entity has no response
  112137. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  112138. * to respond to the collision.
  112139. */
  112140. get collisionResponse(): boolean;
  112141. set collisionResponse(response: boolean);
  112142. /**
  112143. * Gets or sets the current collision group mask (-1 by default).
  112144. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112145. */
  112146. get collisionGroup(): number;
  112147. set collisionGroup(mask: number);
  112148. /**
  112149. * Gets or sets current surrounding meshes (null by default).
  112150. *
  112151. * By default collision detection is tested against every mesh in the scene.
  112152. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  112153. * meshes will be tested for the collision.
  112154. *
  112155. * Note: if set to an empty array no collision will happen when this mesh is moved.
  112156. */
  112157. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  112158. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  112159. /**
  112160. * Defines edge width used when edgesRenderer is enabled
  112161. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112162. */
  112163. edgesWidth: number;
  112164. /**
  112165. * Defines edge color used when edgesRenderer is enabled
  112166. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112167. */
  112168. edgesColor: Color4;
  112169. /** @hidden */
  112170. _edgesRenderer: Nullable<IEdgesRenderer>;
  112171. /** @hidden */
  112172. _masterMesh: Nullable<AbstractMesh>;
  112173. /** @hidden */
  112174. _boundingInfo: Nullable<BoundingInfo>;
  112175. /** @hidden */
  112176. _renderId: number;
  112177. /**
  112178. * Gets or sets the list of subMeshes
  112179. * @see https://doc.babylonjs.com/how_to/multi_materials
  112180. */
  112181. subMeshes: SubMesh[];
  112182. /** @hidden */
  112183. _intersectionsInProgress: AbstractMesh[];
  112184. /** @hidden */
  112185. _unIndexed: boolean;
  112186. /** @hidden */
  112187. _lightSources: Light[];
  112188. /** Gets the list of lights affecting that mesh */
  112189. get lightSources(): Light[];
  112190. /** @hidden */
  112191. get _positions(): Nullable<Vector3[]>;
  112192. /** @hidden */
  112193. _waitingData: {
  112194. lods: Nullable<any>;
  112195. actions: Nullable<any>;
  112196. freezeWorldMatrix: Nullable<boolean>;
  112197. };
  112198. /** @hidden */
  112199. _bonesTransformMatrices: Nullable<Float32Array>;
  112200. /** @hidden */
  112201. _transformMatrixTexture: Nullable<RawTexture>;
  112202. /**
  112203. * Gets or sets a skeleton to apply skining transformations
  112204. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  112205. */
  112206. set skeleton(value: Nullable<Skeleton>);
  112207. get skeleton(): Nullable<Skeleton>;
  112208. /**
  112209. * An event triggered when the mesh is rebuilt.
  112210. */
  112211. onRebuildObservable: Observable<AbstractMesh>;
  112212. /**
  112213. * Creates a new AbstractMesh
  112214. * @param name defines the name of the mesh
  112215. * @param scene defines the hosting scene
  112216. */
  112217. constructor(name: string, scene?: Nullable<Scene>);
  112218. /**
  112219. * Returns the string "AbstractMesh"
  112220. * @returns "AbstractMesh"
  112221. */
  112222. getClassName(): string;
  112223. /**
  112224. * Gets a string representation of the current mesh
  112225. * @param fullDetails defines a boolean indicating if full details must be included
  112226. * @returns a string representation of the current mesh
  112227. */
  112228. toString(fullDetails?: boolean): string;
  112229. /**
  112230. * @hidden
  112231. */
  112232. protected _getEffectiveParent(): Nullable<Node>;
  112233. /** @hidden */
  112234. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112235. /** @hidden */
  112236. _rebuild(): void;
  112237. /** @hidden */
  112238. _resyncLightSources(): void;
  112239. /** @hidden */
  112240. _resyncLightSource(light: Light): void;
  112241. /** @hidden */
  112242. _unBindEffect(): void;
  112243. /** @hidden */
  112244. _removeLightSource(light: Light, dispose: boolean): void;
  112245. private _markSubMeshesAsDirty;
  112246. /** @hidden */
  112247. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  112248. /** @hidden */
  112249. _markSubMeshesAsAttributesDirty(): void;
  112250. /** @hidden */
  112251. _markSubMeshesAsMiscDirty(): void;
  112252. /**
  112253. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  112254. */
  112255. get scaling(): Vector3;
  112256. set scaling(newScaling: Vector3);
  112257. /**
  112258. * Returns true if the mesh is blocked. Implemented by child classes
  112259. */
  112260. get isBlocked(): boolean;
  112261. /**
  112262. * Returns the mesh itself by default. Implemented by child classes
  112263. * @param camera defines the camera to use to pick the right LOD level
  112264. * @returns the currentAbstractMesh
  112265. */
  112266. getLOD(camera: Camera): Nullable<AbstractMesh>;
  112267. /**
  112268. * Returns 0 by default. Implemented by child classes
  112269. * @returns an integer
  112270. */
  112271. getTotalVertices(): number;
  112272. /**
  112273. * Returns a positive integer : the total number of indices in this mesh geometry.
  112274. * @returns the numner of indices or zero if the mesh has no geometry.
  112275. */
  112276. getTotalIndices(): number;
  112277. /**
  112278. * Returns null by default. Implemented by child classes
  112279. * @returns null
  112280. */
  112281. getIndices(): Nullable<IndicesArray>;
  112282. /**
  112283. * Returns the array of the requested vertex data kind. Implemented by child classes
  112284. * @param kind defines the vertex data kind to use
  112285. * @returns null
  112286. */
  112287. getVerticesData(kind: string): Nullable<FloatArray>;
  112288. /**
  112289. * Sets the vertex data of the mesh geometry for the requested `kind`.
  112290. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  112291. * Note that a new underlying VertexBuffer object is created each call.
  112292. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  112293. * @param kind defines vertex data kind:
  112294. * * VertexBuffer.PositionKind
  112295. * * VertexBuffer.UVKind
  112296. * * VertexBuffer.UV2Kind
  112297. * * VertexBuffer.UV3Kind
  112298. * * VertexBuffer.UV4Kind
  112299. * * VertexBuffer.UV5Kind
  112300. * * VertexBuffer.UV6Kind
  112301. * * VertexBuffer.ColorKind
  112302. * * VertexBuffer.MatricesIndicesKind
  112303. * * VertexBuffer.MatricesIndicesExtraKind
  112304. * * VertexBuffer.MatricesWeightsKind
  112305. * * VertexBuffer.MatricesWeightsExtraKind
  112306. * @param data defines the data source
  112307. * @param updatable defines if the data must be flagged as updatable (or static)
  112308. * @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
  112309. * @returns the current mesh
  112310. */
  112311. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  112312. /**
  112313. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  112314. * If the mesh has no geometry, it is simply returned as it is.
  112315. * @param kind defines vertex data kind:
  112316. * * VertexBuffer.PositionKind
  112317. * * VertexBuffer.UVKind
  112318. * * VertexBuffer.UV2Kind
  112319. * * VertexBuffer.UV3Kind
  112320. * * VertexBuffer.UV4Kind
  112321. * * VertexBuffer.UV5Kind
  112322. * * VertexBuffer.UV6Kind
  112323. * * VertexBuffer.ColorKind
  112324. * * VertexBuffer.MatricesIndicesKind
  112325. * * VertexBuffer.MatricesIndicesExtraKind
  112326. * * VertexBuffer.MatricesWeightsKind
  112327. * * VertexBuffer.MatricesWeightsExtraKind
  112328. * @param data defines the data source
  112329. * @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
  112330. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  112331. * @returns the current mesh
  112332. */
  112333. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  112334. /**
  112335. * Sets the mesh indices,
  112336. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  112337. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  112338. * @param totalVertices Defines the total number of vertices
  112339. * @returns the current mesh
  112340. */
  112341. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  112342. /**
  112343. * Gets a boolean indicating if specific vertex data is present
  112344. * @param kind defines the vertex data kind to use
  112345. * @returns true is data kind is present
  112346. */
  112347. isVerticesDataPresent(kind: string): boolean;
  112348. /**
  112349. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  112350. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  112351. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  112352. * @returns a BoundingInfo
  112353. */
  112354. getBoundingInfo(): BoundingInfo;
  112355. /**
  112356. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  112357. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  112358. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  112359. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  112360. * @returns the current mesh
  112361. */
  112362. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  112363. /**
  112364. * Overwrite the current bounding info
  112365. * @param boundingInfo defines the new bounding info
  112366. * @returns the current mesh
  112367. */
  112368. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  112369. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  112370. get useBones(): boolean;
  112371. /** @hidden */
  112372. _preActivate(): void;
  112373. /** @hidden */
  112374. _preActivateForIntermediateRendering(renderId: number): void;
  112375. /** @hidden */
  112376. _activate(renderId: number, intermediateRendering: boolean): boolean;
  112377. /** @hidden */
  112378. _postActivate(): void;
  112379. /** @hidden */
  112380. _freeze(): void;
  112381. /** @hidden */
  112382. _unFreeze(): void;
  112383. /**
  112384. * Gets the current world matrix
  112385. * @returns a Matrix
  112386. */
  112387. getWorldMatrix(): Matrix;
  112388. /** @hidden */
  112389. _getWorldMatrixDeterminant(): number;
  112390. /**
  112391. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  112392. */
  112393. get isAnInstance(): boolean;
  112394. /**
  112395. * Gets a boolean indicating if this mesh has instances
  112396. */
  112397. get hasInstances(): boolean;
  112398. /**
  112399. * Gets a boolean indicating if this mesh has thin instances
  112400. */
  112401. get hasThinInstances(): boolean;
  112402. /**
  112403. * Perform relative position change from the point of view of behind the front of the mesh.
  112404. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112405. * Supports definition of mesh facing forward or backward
  112406. * @param amountRight defines the distance on the right axis
  112407. * @param amountUp defines the distance on the up axis
  112408. * @param amountForward defines the distance on the forward axis
  112409. * @returns the current mesh
  112410. */
  112411. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  112412. /**
  112413. * Calculate relative position change from the point of view of behind the front of the mesh.
  112414. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112415. * Supports definition of mesh facing forward or backward
  112416. * @param amountRight defines the distance on the right axis
  112417. * @param amountUp defines the distance on the up axis
  112418. * @param amountForward defines the distance on the forward axis
  112419. * @returns the new displacement vector
  112420. */
  112421. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  112422. /**
  112423. * Perform relative rotation change from the point of view of behind the front of the mesh.
  112424. * Supports definition of mesh facing forward or backward
  112425. * @param flipBack defines the flip
  112426. * @param twirlClockwise defines the twirl
  112427. * @param tiltRight defines the tilt
  112428. * @returns the current mesh
  112429. */
  112430. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  112431. /**
  112432. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  112433. * Supports definition of mesh facing forward or backward.
  112434. * @param flipBack defines the flip
  112435. * @param twirlClockwise defines the twirl
  112436. * @param tiltRight defines the tilt
  112437. * @returns the new rotation vector
  112438. */
  112439. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  112440. /**
  112441. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  112442. * This means the mesh underlying bounding box and sphere are recomputed.
  112443. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  112444. * @returns the current mesh
  112445. */
  112446. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  112447. /** @hidden */
  112448. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  112449. /** @hidden */
  112450. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  112451. /** @hidden */
  112452. _updateBoundingInfo(): AbstractMesh;
  112453. /** @hidden */
  112454. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  112455. /** @hidden */
  112456. protected _afterComputeWorldMatrix(): void;
  112457. /** @hidden */
  112458. get _effectiveMesh(): AbstractMesh;
  112459. /**
  112460. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  112461. * A mesh is in the frustum if its bounding box intersects the frustum
  112462. * @param frustumPlanes defines the frustum to test
  112463. * @returns true if the mesh is in the frustum planes
  112464. */
  112465. isInFrustum(frustumPlanes: Plane[]): boolean;
  112466. /**
  112467. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  112468. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  112469. * @param frustumPlanes defines the frustum to test
  112470. * @returns true if the mesh is completely in the frustum planes
  112471. */
  112472. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  112473. /**
  112474. * True if the mesh intersects another mesh or a SolidParticle object
  112475. * @param mesh defines a target mesh or SolidParticle to test
  112476. * @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)
  112477. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  112478. * @returns true if there is an intersection
  112479. */
  112480. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  112481. /**
  112482. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  112483. * @param point defines the point to test
  112484. * @returns true if there is an intersection
  112485. */
  112486. intersectsPoint(point: Vector3): boolean;
  112487. /**
  112488. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  112489. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112490. */
  112491. get checkCollisions(): boolean;
  112492. set checkCollisions(collisionEnabled: boolean);
  112493. /**
  112494. * Gets Collider object used to compute collisions (not physics)
  112495. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112496. */
  112497. get collider(): Nullable<Collider>;
  112498. /**
  112499. * Move the mesh using collision engine
  112500. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112501. * @param displacement defines the requested displacement vector
  112502. * @returns the current mesh
  112503. */
  112504. moveWithCollisions(displacement: Vector3): AbstractMesh;
  112505. private _onCollisionPositionChange;
  112506. /** @hidden */
  112507. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  112508. /** @hidden */
  112509. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  112510. /** @hidden */
  112511. _checkCollision(collider: Collider): AbstractMesh;
  112512. /** @hidden */
  112513. _generatePointsArray(): boolean;
  112514. /**
  112515. * Checks if the passed Ray intersects with the mesh
  112516. * @param ray defines the ray to use
  112517. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  112518. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  112519. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  112520. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  112521. * @returns the picking info
  112522. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  112523. */
  112524. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  112525. /**
  112526. * Clones the current mesh
  112527. * @param name defines the mesh name
  112528. * @param newParent defines the new mesh parent
  112529. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  112530. * @returns the new mesh
  112531. */
  112532. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  112533. /**
  112534. * Disposes all the submeshes of the current meshnp
  112535. * @returns the current mesh
  112536. */
  112537. releaseSubMeshes(): AbstractMesh;
  112538. /**
  112539. * Releases resources associated with this abstract mesh.
  112540. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112541. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112542. */
  112543. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112544. /**
  112545. * Adds the passed mesh as a child to the current mesh
  112546. * @param mesh defines the child mesh
  112547. * @returns the current mesh
  112548. */
  112549. addChild(mesh: AbstractMesh): AbstractMesh;
  112550. /**
  112551. * Removes the passed mesh from the current mesh children list
  112552. * @param mesh defines the child mesh
  112553. * @returns the current mesh
  112554. */
  112555. removeChild(mesh: AbstractMesh): AbstractMesh;
  112556. /** @hidden */
  112557. private _initFacetData;
  112558. /**
  112559. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  112560. * This method can be called within the render loop.
  112561. * 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
  112562. * @returns the current mesh
  112563. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112564. */
  112565. updateFacetData(): AbstractMesh;
  112566. /**
  112567. * Returns the facetLocalNormals array.
  112568. * The normals are expressed in the mesh local spac
  112569. * @returns an array of Vector3
  112570. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112571. */
  112572. getFacetLocalNormals(): Vector3[];
  112573. /**
  112574. * Returns the facetLocalPositions array.
  112575. * The facet positions are expressed in the mesh local space
  112576. * @returns an array of Vector3
  112577. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112578. */
  112579. getFacetLocalPositions(): Vector3[];
  112580. /**
  112581. * Returns the facetLocalPartioning array
  112582. * @returns an array of array of numbers
  112583. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112584. */
  112585. getFacetLocalPartitioning(): number[][];
  112586. /**
  112587. * Returns the i-th facet position in the world system.
  112588. * This method allocates a new Vector3 per call
  112589. * @param i defines the facet index
  112590. * @returns a new Vector3
  112591. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112592. */
  112593. getFacetPosition(i: number): Vector3;
  112594. /**
  112595. * Sets the reference Vector3 with the i-th facet position in the world system
  112596. * @param i defines the facet index
  112597. * @param ref defines the target vector
  112598. * @returns the current mesh
  112599. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112600. */
  112601. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  112602. /**
  112603. * Returns the i-th facet normal in the world system.
  112604. * This method allocates a new Vector3 per call
  112605. * @param i defines the facet index
  112606. * @returns a new Vector3
  112607. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112608. */
  112609. getFacetNormal(i: number): Vector3;
  112610. /**
  112611. * Sets the reference Vector3 with the i-th facet normal in the world system
  112612. * @param i defines the facet index
  112613. * @param ref defines the target vector
  112614. * @returns the current mesh
  112615. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112616. */
  112617. getFacetNormalToRef(i: number, ref: Vector3): this;
  112618. /**
  112619. * 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)
  112620. * @param x defines x coordinate
  112621. * @param y defines y coordinate
  112622. * @param z defines z coordinate
  112623. * @returns the array of facet indexes
  112624. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112625. */
  112626. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  112627. /**
  112628. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  112629. * @param projected sets as the (x,y,z) world projection on the facet
  112630. * @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
  112631. * @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
  112632. * @param x defines x coordinate
  112633. * @param y defines y coordinate
  112634. * @param z defines z coordinate
  112635. * @returns the face index if found (or null instead)
  112636. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112637. */
  112638. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  112639. /**
  112640. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  112641. * @param projected sets as the (x,y,z) local projection on the facet
  112642. * @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
  112643. * @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
  112644. * @param x defines x coordinate
  112645. * @param y defines y coordinate
  112646. * @param z defines z coordinate
  112647. * @returns the face index if found (or null instead)
  112648. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112649. */
  112650. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  112651. /**
  112652. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  112653. * @returns the parameters
  112654. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112655. */
  112656. getFacetDataParameters(): any;
  112657. /**
  112658. * Disables the feature FacetData and frees the related memory
  112659. * @returns the current mesh
  112660. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112661. */
  112662. disableFacetData(): AbstractMesh;
  112663. /**
  112664. * Updates the AbstractMesh indices array
  112665. * @param indices defines the data source
  112666. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  112667. * @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)
  112668. * @returns the current mesh
  112669. */
  112670. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  112671. /**
  112672. * Creates new normals data for the mesh
  112673. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  112674. * @returns the current mesh
  112675. */
  112676. createNormals(updatable: boolean): AbstractMesh;
  112677. /**
  112678. * Align the mesh with a normal
  112679. * @param normal defines the normal to use
  112680. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  112681. * @returns the current mesh
  112682. */
  112683. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  112684. /** @hidden */
  112685. _checkOcclusionQuery(): boolean;
  112686. /**
  112687. * Disables the mesh edge rendering mode
  112688. * @returns the currentAbstractMesh
  112689. */
  112690. disableEdgesRendering(): AbstractMesh;
  112691. /**
  112692. * Enables the edge rendering mode on the mesh.
  112693. * This mode makes the mesh edges visible
  112694. * @param epsilon defines the maximal distance between two angles to detect a face
  112695. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  112696. * @returns the currentAbstractMesh
  112697. * @see https://www.babylonjs-playground.com/#19O9TU#0
  112698. */
  112699. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  112700. /**
  112701. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  112702. * @returns an array of particle systems in the scene that use the mesh as an emitter
  112703. */
  112704. getConnectedParticleSystems(): IParticleSystem[];
  112705. }
  112706. }
  112707. declare module BABYLON {
  112708. /**
  112709. * Interface used to define ActionEvent
  112710. */
  112711. export interface IActionEvent {
  112712. /** The mesh or sprite that triggered the action */
  112713. source: any;
  112714. /** The X mouse cursor position at the time of the event */
  112715. pointerX: number;
  112716. /** The Y mouse cursor position at the time of the event */
  112717. pointerY: number;
  112718. /** The mesh that is currently pointed at (can be null) */
  112719. meshUnderPointer: Nullable<AbstractMesh>;
  112720. /** the original (browser) event that triggered the ActionEvent */
  112721. sourceEvent?: any;
  112722. /** additional data for the event */
  112723. additionalData?: any;
  112724. }
  112725. /**
  112726. * ActionEvent is the event being sent when an action is triggered.
  112727. */
  112728. export class ActionEvent implements IActionEvent {
  112729. /** The mesh or sprite that triggered the action */
  112730. source: any;
  112731. /** The X mouse cursor position at the time of the event */
  112732. pointerX: number;
  112733. /** The Y mouse cursor position at the time of the event */
  112734. pointerY: number;
  112735. /** The mesh that is currently pointed at (can be null) */
  112736. meshUnderPointer: Nullable<AbstractMesh>;
  112737. /** the original (browser) event that triggered the ActionEvent */
  112738. sourceEvent?: any;
  112739. /** additional data for the event */
  112740. additionalData?: any;
  112741. /**
  112742. * Creates a new ActionEvent
  112743. * @param source The mesh or sprite that triggered the action
  112744. * @param pointerX The X mouse cursor position at the time of the event
  112745. * @param pointerY The Y mouse cursor position at the time of the event
  112746. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  112747. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  112748. * @param additionalData additional data for the event
  112749. */
  112750. constructor(
  112751. /** The mesh or sprite that triggered the action */
  112752. source: any,
  112753. /** The X mouse cursor position at the time of the event */
  112754. pointerX: number,
  112755. /** The Y mouse cursor position at the time of the event */
  112756. pointerY: number,
  112757. /** The mesh that is currently pointed at (can be null) */
  112758. meshUnderPointer: Nullable<AbstractMesh>,
  112759. /** the original (browser) event that triggered the ActionEvent */
  112760. sourceEvent?: any,
  112761. /** additional data for the event */
  112762. additionalData?: any);
  112763. /**
  112764. * Helper function to auto-create an ActionEvent from a source mesh.
  112765. * @param source The source mesh that triggered the event
  112766. * @param evt The original (browser) event
  112767. * @param additionalData additional data for the event
  112768. * @returns the new ActionEvent
  112769. */
  112770. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  112771. /**
  112772. * Helper function to auto-create an ActionEvent from a source sprite
  112773. * @param source The source sprite that triggered the event
  112774. * @param scene Scene associated with the sprite
  112775. * @param evt The original (browser) event
  112776. * @param additionalData additional data for the event
  112777. * @returns the new ActionEvent
  112778. */
  112779. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  112780. /**
  112781. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  112782. * @param scene the scene where the event occurred
  112783. * @param evt The original (browser) event
  112784. * @returns the new ActionEvent
  112785. */
  112786. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  112787. /**
  112788. * Helper function to auto-create an ActionEvent from a primitive
  112789. * @param prim defines the target primitive
  112790. * @param pointerPos defines the pointer position
  112791. * @param evt The original (browser) event
  112792. * @param additionalData additional data for the event
  112793. * @returns the new ActionEvent
  112794. */
  112795. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  112796. }
  112797. }
  112798. declare module BABYLON {
  112799. /**
  112800. * Abstract class used to decouple action Manager from scene and meshes.
  112801. * Do not instantiate.
  112802. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112803. */
  112804. export abstract class AbstractActionManager implements IDisposable {
  112805. /** Gets the list of active triggers */
  112806. static Triggers: {
  112807. [key: string]: number;
  112808. };
  112809. /** Gets the cursor to use when hovering items */
  112810. hoverCursor: string;
  112811. /** Gets the list of actions */
  112812. actions: IAction[];
  112813. /**
  112814. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  112815. */
  112816. isRecursive: boolean;
  112817. /**
  112818. * Releases all associated resources
  112819. */
  112820. abstract dispose(): void;
  112821. /**
  112822. * Does this action manager has pointer triggers
  112823. */
  112824. abstract get hasPointerTriggers(): boolean;
  112825. /**
  112826. * Does this action manager has pick triggers
  112827. */
  112828. abstract get hasPickTriggers(): boolean;
  112829. /**
  112830. * Process a specific trigger
  112831. * @param trigger defines the trigger to process
  112832. * @param evt defines the event details to be processed
  112833. */
  112834. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  112835. /**
  112836. * Does this action manager handles actions of any of the given triggers
  112837. * @param triggers defines the triggers to be tested
  112838. * @return a boolean indicating whether one (or more) of the triggers is handled
  112839. */
  112840. abstract hasSpecificTriggers(triggers: number[]): boolean;
  112841. /**
  112842. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  112843. * speed.
  112844. * @param triggerA defines the trigger to be tested
  112845. * @param triggerB defines the trigger to be tested
  112846. * @return a boolean indicating whether one (or more) of the triggers is handled
  112847. */
  112848. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  112849. /**
  112850. * Does this action manager handles actions of a given trigger
  112851. * @param trigger defines the trigger to be tested
  112852. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  112853. * @return whether the trigger is handled
  112854. */
  112855. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  112856. /**
  112857. * Serialize this manager to a JSON object
  112858. * @param name defines the property name to store this manager
  112859. * @returns a JSON representation of this manager
  112860. */
  112861. abstract serialize(name: string): any;
  112862. /**
  112863. * Registers an action to this action manager
  112864. * @param action defines the action to be registered
  112865. * @return the action amended (prepared) after registration
  112866. */
  112867. abstract registerAction(action: IAction): Nullable<IAction>;
  112868. /**
  112869. * Unregisters an action to this action manager
  112870. * @param action defines the action to be unregistered
  112871. * @return a boolean indicating whether the action has been unregistered
  112872. */
  112873. abstract unregisterAction(action: IAction): Boolean;
  112874. /**
  112875. * Does exist one action manager with at least one trigger
  112876. **/
  112877. static get HasTriggers(): boolean;
  112878. /**
  112879. * Does exist one action manager with at least one pick trigger
  112880. **/
  112881. static get HasPickTriggers(): boolean;
  112882. /**
  112883. * Does exist one action manager that handles actions of a given trigger
  112884. * @param trigger defines the trigger to be tested
  112885. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  112886. **/
  112887. static HasSpecificTrigger(trigger: number): boolean;
  112888. }
  112889. }
  112890. declare module BABYLON {
  112891. /**
  112892. * Defines how a node can be built from a string name.
  112893. */
  112894. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  112895. /**
  112896. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  112897. */
  112898. export class Node implements IBehaviorAware<Node> {
  112899. /** @hidden */
  112900. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  112901. private static _NodeConstructors;
  112902. /**
  112903. * Add a new node constructor
  112904. * @param type defines the type name of the node to construct
  112905. * @param constructorFunc defines the constructor function
  112906. */
  112907. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  112908. /**
  112909. * Returns a node constructor based on type name
  112910. * @param type defines the type name
  112911. * @param name defines the new node name
  112912. * @param scene defines the hosting scene
  112913. * @param options defines optional options to transmit to constructors
  112914. * @returns the new constructor or null
  112915. */
  112916. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  112917. /**
  112918. * Gets or sets the name of the node
  112919. */
  112920. name: string;
  112921. /**
  112922. * Gets or sets the id of the node
  112923. */
  112924. id: string;
  112925. /**
  112926. * Gets or sets the unique id of the node
  112927. */
  112928. uniqueId: number;
  112929. /**
  112930. * Gets or sets a string used to store user defined state for the node
  112931. */
  112932. state: string;
  112933. /**
  112934. * Gets or sets an object used to store user defined information for the node
  112935. */
  112936. metadata: any;
  112937. /**
  112938. * For internal use only. Please do not use.
  112939. */
  112940. reservedDataStore: any;
  112941. /**
  112942. * List of inspectable custom properties (used by the Inspector)
  112943. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  112944. */
  112945. inspectableCustomProperties: IInspectable[];
  112946. private _doNotSerialize;
  112947. /**
  112948. * Gets or sets a boolean used to define if the node must be serialized
  112949. */
  112950. get doNotSerialize(): boolean;
  112951. set doNotSerialize(value: boolean);
  112952. /** @hidden */
  112953. _isDisposed: boolean;
  112954. /**
  112955. * Gets a list of Animations associated with the node
  112956. */
  112957. animations: Animation[];
  112958. protected _ranges: {
  112959. [name: string]: Nullable<AnimationRange>;
  112960. };
  112961. /**
  112962. * Callback raised when the node is ready to be used
  112963. */
  112964. onReady: Nullable<(node: Node) => void>;
  112965. private _isEnabled;
  112966. private _isParentEnabled;
  112967. private _isReady;
  112968. /** @hidden */
  112969. _currentRenderId: number;
  112970. private _parentUpdateId;
  112971. /** @hidden */
  112972. _childUpdateId: number;
  112973. /** @hidden */
  112974. _waitingParentId: Nullable<string>;
  112975. /** @hidden */
  112976. _scene: Scene;
  112977. /** @hidden */
  112978. _cache: any;
  112979. private _parentNode;
  112980. private _children;
  112981. /** @hidden */
  112982. _worldMatrix: Matrix;
  112983. /** @hidden */
  112984. _worldMatrixDeterminant: number;
  112985. /** @hidden */
  112986. _worldMatrixDeterminantIsDirty: boolean;
  112987. /** @hidden */
  112988. private _sceneRootNodesIndex;
  112989. /**
  112990. * Gets a boolean indicating if the node has been disposed
  112991. * @returns true if the node was disposed
  112992. */
  112993. isDisposed(): boolean;
  112994. /**
  112995. * Gets or sets the parent of the node (without keeping the current position in the scene)
  112996. * @see https://doc.babylonjs.com/how_to/parenting
  112997. */
  112998. set parent(parent: Nullable<Node>);
  112999. get parent(): Nullable<Node>;
  113000. /** @hidden */
  113001. _addToSceneRootNodes(): void;
  113002. /** @hidden */
  113003. _removeFromSceneRootNodes(): void;
  113004. private _animationPropertiesOverride;
  113005. /**
  113006. * Gets or sets the animation properties override
  113007. */
  113008. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  113009. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  113010. /**
  113011. * Gets a string identifying the name of the class
  113012. * @returns "Node" string
  113013. */
  113014. getClassName(): string;
  113015. /** @hidden */
  113016. readonly _isNode: boolean;
  113017. /**
  113018. * An event triggered when the mesh is disposed
  113019. */
  113020. onDisposeObservable: Observable<Node>;
  113021. private _onDisposeObserver;
  113022. /**
  113023. * Sets a callback that will be raised when the node will be disposed
  113024. */
  113025. set onDispose(callback: () => void);
  113026. /**
  113027. * Creates a new Node
  113028. * @param name the name and id to be given to this node
  113029. * @param scene the scene this node will be added to
  113030. */
  113031. constructor(name: string, scene?: Nullable<Scene>);
  113032. /**
  113033. * Gets the scene of the node
  113034. * @returns a scene
  113035. */
  113036. getScene(): Scene;
  113037. /**
  113038. * Gets the engine of the node
  113039. * @returns a Engine
  113040. */
  113041. getEngine(): Engine;
  113042. private _behaviors;
  113043. /**
  113044. * Attach a behavior to the node
  113045. * @see https://doc.babylonjs.com/features/behaviour
  113046. * @param behavior defines the behavior to attach
  113047. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  113048. * @returns the current Node
  113049. */
  113050. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  113051. /**
  113052. * Remove an attached behavior
  113053. * @see https://doc.babylonjs.com/features/behaviour
  113054. * @param behavior defines the behavior to attach
  113055. * @returns the current Node
  113056. */
  113057. removeBehavior(behavior: Behavior<Node>): Node;
  113058. /**
  113059. * Gets the list of attached behaviors
  113060. * @see https://doc.babylonjs.com/features/behaviour
  113061. */
  113062. get behaviors(): Behavior<Node>[];
  113063. /**
  113064. * Gets an attached behavior by name
  113065. * @param name defines the name of the behavior to look for
  113066. * @see https://doc.babylonjs.com/features/behaviour
  113067. * @returns null if behavior was not found else the requested behavior
  113068. */
  113069. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  113070. /**
  113071. * Returns the latest update of the World matrix
  113072. * @returns a Matrix
  113073. */
  113074. getWorldMatrix(): Matrix;
  113075. /** @hidden */
  113076. _getWorldMatrixDeterminant(): number;
  113077. /**
  113078. * Returns directly the latest state of the mesh World matrix.
  113079. * A Matrix is returned.
  113080. */
  113081. get worldMatrixFromCache(): Matrix;
  113082. /** @hidden */
  113083. _initCache(): void;
  113084. /** @hidden */
  113085. updateCache(force?: boolean): void;
  113086. /** @hidden */
  113087. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  113088. /** @hidden */
  113089. _updateCache(ignoreParentClass?: boolean): void;
  113090. /** @hidden */
  113091. _isSynchronized(): boolean;
  113092. /** @hidden */
  113093. _markSyncedWithParent(): void;
  113094. /** @hidden */
  113095. isSynchronizedWithParent(): boolean;
  113096. /** @hidden */
  113097. isSynchronized(): boolean;
  113098. /**
  113099. * Is this node ready to be used/rendered
  113100. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113101. * @return true if the node is ready
  113102. */
  113103. isReady(completeCheck?: boolean): boolean;
  113104. /**
  113105. * Is this node enabled?
  113106. * 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
  113107. * @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
  113108. * @return whether this node (and its parent) is enabled
  113109. */
  113110. isEnabled(checkAncestors?: boolean): boolean;
  113111. /** @hidden */
  113112. protected _syncParentEnabledState(): void;
  113113. /**
  113114. * Set the enabled state of this node
  113115. * @param value defines the new enabled state
  113116. */
  113117. setEnabled(value: boolean): void;
  113118. /**
  113119. * Is this node a descendant of the given node?
  113120. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  113121. * @param ancestor defines the parent node to inspect
  113122. * @returns a boolean indicating if this node is a descendant of the given node
  113123. */
  113124. isDescendantOf(ancestor: Node): boolean;
  113125. /** @hidden */
  113126. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  113127. /**
  113128. * Will return all nodes that have this node as ascendant
  113129. * @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
  113130. * @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
  113131. * @return all children nodes of all types
  113132. */
  113133. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  113134. /**
  113135. * Get all child-meshes of this node
  113136. * @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)
  113137. * @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
  113138. * @returns an array of AbstractMesh
  113139. */
  113140. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  113141. /**
  113142. * Get all direct children of this node
  113143. * @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
  113144. * @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)
  113145. * @returns an array of Node
  113146. */
  113147. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  113148. /** @hidden */
  113149. _setReady(state: boolean): void;
  113150. /**
  113151. * Get an animation by name
  113152. * @param name defines the name of the animation to look for
  113153. * @returns null if not found else the requested animation
  113154. */
  113155. getAnimationByName(name: string): Nullable<Animation>;
  113156. /**
  113157. * Creates an animation range for this node
  113158. * @param name defines the name of the range
  113159. * @param from defines the starting key
  113160. * @param to defines the end key
  113161. */
  113162. createAnimationRange(name: string, from: number, to: number): void;
  113163. /**
  113164. * Delete a specific animation range
  113165. * @param name defines the name of the range to delete
  113166. * @param deleteFrames defines if animation frames from the range must be deleted as well
  113167. */
  113168. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  113169. /**
  113170. * Get an animation range by name
  113171. * @param name defines the name of the animation range to look for
  113172. * @returns null if not found else the requested animation range
  113173. */
  113174. getAnimationRange(name: string): Nullable<AnimationRange>;
  113175. /**
  113176. * Gets the list of all animation ranges defined on this node
  113177. * @returns an array
  113178. */
  113179. getAnimationRanges(): Nullable<AnimationRange>[];
  113180. /**
  113181. * Will start the animation sequence
  113182. * @param name defines the range frames for animation sequence
  113183. * @param loop defines if the animation should loop (false by default)
  113184. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  113185. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  113186. * @returns the object created for this animation. If range does not exist, it will return null
  113187. */
  113188. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  113189. /**
  113190. * Serialize animation ranges into a JSON compatible object
  113191. * @returns serialization object
  113192. */
  113193. serializeAnimationRanges(): any;
  113194. /**
  113195. * Computes the world matrix of the node
  113196. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  113197. * @returns the world matrix
  113198. */
  113199. computeWorldMatrix(force?: boolean): Matrix;
  113200. /**
  113201. * Releases resources associated with this node.
  113202. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113203. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113204. */
  113205. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113206. /**
  113207. * Parse animation range data from a serialization object and store them into a given node
  113208. * @param node defines where to store the animation ranges
  113209. * @param parsedNode defines the serialization object to read data from
  113210. * @param scene defines the hosting scene
  113211. */
  113212. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  113213. /**
  113214. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  113215. * @param includeDescendants Include bounding info from descendants as well (true by default)
  113216. * @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
  113217. * @returns the new bounding vectors
  113218. */
  113219. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  113220. min: Vector3;
  113221. max: Vector3;
  113222. };
  113223. }
  113224. }
  113225. declare module BABYLON {
  113226. /**
  113227. * @hidden
  113228. */
  113229. export class _IAnimationState {
  113230. key: number;
  113231. repeatCount: number;
  113232. workValue?: any;
  113233. loopMode?: number;
  113234. offsetValue?: any;
  113235. highLimitValue?: any;
  113236. }
  113237. /**
  113238. * Class used to store any kind of animation
  113239. */
  113240. export class Animation {
  113241. /**Name of the animation */
  113242. name: string;
  113243. /**Property to animate */
  113244. targetProperty: string;
  113245. /**The frames per second of the animation */
  113246. framePerSecond: number;
  113247. /**The data type of the animation */
  113248. dataType: number;
  113249. /**The loop mode of the animation */
  113250. loopMode?: number | undefined;
  113251. /**Specifies if blending should be enabled */
  113252. enableBlending?: boolean | undefined;
  113253. /**
  113254. * Use matrix interpolation instead of using direct key value when animating matrices
  113255. */
  113256. static AllowMatricesInterpolation: boolean;
  113257. /**
  113258. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  113259. */
  113260. static AllowMatrixDecomposeForInterpolation: boolean;
  113261. /** Define the Url to load snippets */
  113262. static SnippetUrl: string;
  113263. /** Snippet ID if the animation was created from the snippet server */
  113264. snippetId: string;
  113265. /**
  113266. * Stores the key frames of the animation
  113267. */
  113268. private _keys;
  113269. /**
  113270. * Stores the easing function of the animation
  113271. */
  113272. private _easingFunction;
  113273. /**
  113274. * @hidden Internal use only
  113275. */
  113276. _runtimeAnimations: RuntimeAnimation[];
  113277. /**
  113278. * The set of event that will be linked to this animation
  113279. */
  113280. private _events;
  113281. /**
  113282. * Stores an array of target property paths
  113283. */
  113284. targetPropertyPath: string[];
  113285. /**
  113286. * Stores the blending speed of the animation
  113287. */
  113288. blendingSpeed: number;
  113289. /**
  113290. * Stores the animation ranges for the animation
  113291. */
  113292. private _ranges;
  113293. /**
  113294. * @hidden Internal use
  113295. */
  113296. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  113297. /**
  113298. * Sets up an animation
  113299. * @param property The property to animate
  113300. * @param animationType The animation type to apply
  113301. * @param framePerSecond The frames per second of the animation
  113302. * @param easingFunction The easing function used in the animation
  113303. * @returns The created animation
  113304. */
  113305. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  113306. /**
  113307. * Create and start an animation on a node
  113308. * @param name defines the name of the global animation that will be run on all nodes
  113309. * @param node defines the root node where the animation will take place
  113310. * @param targetProperty defines property to animate
  113311. * @param framePerSecond defines the number of frame per second yo use
  113312. * @param totalFrame defines the number of frames in total
  113313. * @param from defines the initial value
  113314. * @param to defines the final value
  113315. * @param loopMode defines which loop mode you want to use (off by default)
  113316. * @param easingFunction defines the easing function to use (linear by default)
  113317. * @param onAnimationEnd defines the callback to call when animation end
  113318. * @returns the animatable created for this animation
  113319. */
  113320. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113321. /**
  113322. * Create and start an animation on a node and its descendants
  113323. * @param name defines the name of the global animation that will be run on all nodes
  113324. * @param node defines the root node where the animation will take place
  113325. * @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
  113326. * @param targetProperty defines property to animate
  113327. * @param framePerSecond defines the number of frame per second to use
  113328. * @param totalFrame defines the number of frames in total
  113329. * @param from defines the initial value
  113330. * @param to defines the final value
  113331. * @param loopMode defines which loop mode you want to use (off by default)
  113332. * @param easingFunction defines the easing function to use (linear by default)
  113333. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  113334. * @returns the list of animatables created for all nodes
  113335. * @example https://www.babylonjs-playground.com/#MH0VLI
  113336. */
  113337. 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[]>;
  113338. /**
  113339. * Creates a new animation, merges it with the existing animations and starts it
  113340. * @param name Name of the animation
  113341. * @param node Node which contains the scene that begins the animations
  113342. * @param targetProperty Specifies which property to animate
  113343. * @param framePerSecond The frames per second of the animation
  113344. * @param totalFrame The total number of frames
  113345. * @param from The frame at the beginning of the animation
  113346. * @param to The frame at the end of the animation
  113347. * @param loopMode Specifies the loop mode of the animation
  113348. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  113349. * @param onAnimationEnd Callback to run once the animation is complete
  113350. * @returns Nullable animation
  113351. */
  113352. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113353. /**
  113354. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  113355. * @param sourceAnimation defines the Animation containing keyframes to convert
  113356. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  113357. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  113358. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  113359. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  113360. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  113361. */
  113362. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  113363. /**
  113364. * Transition property of an host to the target Value
  113365. * @param property The property to transition
  113366. * @param targetValue The target Value of the property
  113367. * @param host The object where the property to animate belongs
  113368. * @param scene Scene used to run the animation
  113369. * @param frameRate Framerate (in frame/s) to use
  113370. * @param transition The transition type we want to use
  113371. * @param duration The duration of the animation, in milliseconds
  113372. * @param onAnimationEnd Callback trigger at the end of the animation
  113373. * @returns Nullable animation
  113374. */
  113375. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  113376. /**
  113377. * Return the array of runtime animations currently using this animation
  113378. */
  113379. get runtimeAnimations(): RuntimeAnimation[];
  113380. /**
  113381. * Specifies if any of the runtime animations are currently running
  113382. */
  113383. get hasRunningRuntimeAnimations(): boolean;
  113384. /**
  113385. * Initializes the animation
  113386. * @param name Name of the animation
  113387. * @param targetProperty Property to animate
  113388. * @param framePerSecond The frames per second of the animation
  113389. * @param dataType The data type of the animation
  113390. * @param loopMode The loop mode of the animation
  113391. * @param enableBlending Specifies if blending should be enabled
  113392. */
  113393. constructor(
  113394. /**Name of the animation */
  113395. name: string,
  113396. /**Property to animate */
  113397. targetProperty: string,
  113398. /**The frames per second of the animation */
  113399. framePerSecond: number,
  113400. /**The data type of the animation */
  113401. dataType: number,
  113402. /**The loop mode of the animation */
  113403. loopMode?: number | undefined,
  113404. /**Specifies if blending should be enabled */
  113405. enableBlending?: boolean | undefined);
  113406. /**
  113407. * Converts the animation to a string
  113408. * @param fullDetails support for multiple levels of logging within scene loading
  113409. * @returns String form of the animation
  113410. */
  113411. toString(fullDetails?: boolean): string;
  113412. /**
  113413. * Add an event to this animation
  113414. * @param event Event to add
  113415. */
  113416. addEvent(event: AnimationEvent): void;
  113417. /**
  113418. * Remove all events found at the given frame
  113419. * @param frame The frame to remove events from
  113420. */
  113421. removeEvents(frame: number): void;
  113422. /**
  113423. * Retrieves all the events from the animation
  113424. * @returns Events from the animation
  113425. */
  113426. getEvents(): AnimationEvent[];
  113427. /**
  113428. * Creates an animation range
  113429. * @param name Name of the animation range
  113430. * @param from Starting frame of the animation range
  113431. * @param to Ending frame of the animation
  113432. */
  113433. createRange(name: string, from: number, to: number): void;
  113434. /**
  113435. * Deletes an animation range by name
  113436. * @param name Name of the animation range to delete
  113437. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  113438. */
  113439. deleteRange(name: string, deleteFrames?: boolean): void;
  113440. /**
  113441. * Gets the animation range by name, or null if not defined
  113442. * @param name Name of the animation range
  113443. * @returns Nullable animation range
  113444. */
  113445. getRange(name: string): Nullable<AnimationRange>;
  113446. /**
  113447. * Gets the key frames from the animation
  113448. * @returns The key frames of the animation
  113449. */
  113450. getKeys(): Array<IAnimationKey>;
  113451. /**
  113452. * Gets the highest frame rate of the animation
  113453. * @returns Highest frame rate of the animation
  113454. */
  113455. getHighestFrame(): number;
  113456. /**
  113457. * Gets the easing function of the animation
  113458. * @returns Easing function of the animation
  113459. */
  113460. getEasingFunction(): IEasingFunction;
  113461. /**
  113462. * Sets the easing function of the animation
  113463. * @param easingFunction A custom mathematical formula for animation
  113464. */
  113465. setEasingFunction(easingFunction: EasingFunction): void;
  113466. /**
  113467. * Interpolates a scalar linearly
  113468. * @param startValue Start value of the animation curve
  113469. * @param endValue End value of the animation curve
  113470. * @param gradient Scalar amount to interpolate
  113471. * @returns Interpolated scalar value
  113472. */
  113473. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  113474. /**
  113475. * Interpolates a scalar cubically
  113476. * @param startValue Start value of the animation curve
  113477. * @param outTangent End tangent of the animation
  113478. * @param endValue End value of the animation curve
  113479. * @param inTangent Start tangent of the animation curve
  113480. * @param gradient Scalar amount to interpolate
  113481. * @returns Interpolated scalar value
  113482. */
  113483. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  113484. /**
  113485. * Interpolates a quaternion using a spherical linear interpolation
  113486. * @param startValue Start value of the animation curve
  113487. * @param endValue End value of the animation curve
  113488. * @param gradient Scalar amount to interpolate
  113489. * @returns Interpolated quaternion value
  113490. */
  113491. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  113492. /**
  113493. * Interpolates a quaternion cubically
  113494. * @param startValue Start value of the animation curve
  113495. * @param outTangent End tangent of the animation curve
  113496. * @param endValue End value of the animation curve
  113497. * @param inTangent Start tangent of the animation curve
  113498. * @param gradient Scalar amount to interpolate
  113499. * @returns Interpolated quaternion value
  113500. */
  113501. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  113502. /**
  113503. * Interpolates a Vector3 linearl
  113504. * @param startValue Start value of the animation curve
  113505. * @param endValue End value of the animation curve
  113506. * @param gradient Scalar amount to interpolate
  113507. * @returns Interpolated scalar value
  113508. */
  113509. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  113510. /**
  113511. * Interpolates a Vector3 cubically
  113512. * @param startValue Start value of the animation curve
  113513. * @param outTangent End tangent of the animation
  113514. * @param endValue End value of the animation curve
  113515. * @param inTangent Start tangent of the animation curve
  113516. * @param gradient Scalar amount to interpolate
  113517. * @returns InterpolatedVector3 value
  113518. */
  113519. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  113520. /**
  113521. * Interpolates a Vector2 linearly
  113522. * @param startValue Start value of the animation curve
  113523. * @param endValue End value of the animation curve
  113524. * @param gradient Scalar amount to interpolate
  113525. * @returns Interpolated Vector2 value
  113526. */
  113527. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  113528. /**
  113529. * Interpolates a Vector2 cubically
  113530. * @param startValue Start value of the animation curve
  113531. * @param outTangent End tangent of the animation
  113532. * @param endValue End value of the animation curve
  113533. * @param inTangent Start tangent of the animation curve
  113534. * @param gradient Scalar amount to interpolate
  113535. * @returns Interpolated Vector2 value
  113536. */
  113537. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  113538. /**
  113539. * Interpolates a size linearly
  113540. * @param startValue Start value of the animation curve
  113541. * @param endValue End value of the animation curve
  113542. * @param gradient Scalar amount to interpolate
  113543. * @returns Interpolated Size value
  113544. */
  113545. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  113546. /**
  113547. * Interpolates a Color3 linearly
  113548. * @param startValue Start value of the animation curve
  113549. * @param endValue End value of the animation curve
  113550. * @param gradient Scalar amount to interpolate
  113551. * @returns Interpolated Color3 value
  113552. */
  113553. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  113554. /**
  113555. * Interpolates a Color4 linearly
  113556. * @param startValue Start value of the animation curve
  113557. * @param endValue End value of the animation curve
  113558. * @param gradient Scalar amount to interpolate
  113559. * @returns Interpolated Color3 value
  113560. */
  113561. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  113562. /**
  113563. * @hidden Internal use only
  113564. */
  113565. _getKeyValue(value: any): any;
  113566. /**
  113567. * @hidden Internal use only
  113568. */
  113569. _interpolate(currentFrame: number, state: _IAnimationState): any;
  113570. /**
  113571. * Defines the function to use to interpolate matrices
  113572. * @param startValue defines the start matrix
  113573. * @param endValue defines the end matrix
  113574. * @param gradient defines the gradient between both matrices
  113575. * @param result defines an optional target matrix where to store the interpolation
  113576. * @returns the interpolated matrix
  113577. */
  113578. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  113579. /**
  113580. * Makes a copy of the animation
  113581. * @returns Cloned animation
  113582. */
  113583. clone(): Animation;
  113584. /**
  113585. * Sets the key frames of the animation
  113586. * @param values The animation key frames to set
  113587. */
  113588. setKeys(values: Array<IAnimationKey>): void;
  113589. /**
  113590. * Serializes the animation to an object
  113591. * @returns Serialized object
  113592. */
  113593. serialize(): any;
  113594. /**
  113595. * Float animation type
  113596. */
  113597. static readonly ANIMATIONTYPE_FLOAT: number;
  113598. /**
  113599. * Vector3 animation type
  113600. */
  113601. static readonly ANIMATIONTYPE_VECTOR3: number;
  113602. /**
  113603. * Quaternion animation type
  113604. */
  113605. static readonly ANIMATIONTYPE_QUATERNION: number;
  113606. /**
  113607. * Matrix animation type
  113608. */
  113609. static readonly ANIMATIONTYPE_MATRIX: number;
  113610. /**
  113611. * Color3 animation type
  113612. */
  113613. static readonly ANIMATIONTYPE_COLOR3: number;
  113614. /**
  113615. * Color3 animation type
  113616. */
  113617. static readonly ANIMATIONTYPE_COLOR4: number;
  113618. /**
  113619. * Vector2 animation type
  113620. */
  113621. static readonly ANIMATIONTYPE_VECTOR2: number;
  113622. /**
  113623. * Size animation type
  113624. */
  113625. static readonly ANIMATIONTYPE_SIZE: number;
  113626. /**
  113627. * Relative Loop Mode
  113628. */
  113629. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  113630. /**
  113631. * Cycle Loop Mode
  113632. */
  113633. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  113634. /**
  113635. * Constant Loop Mode
  113636. */
  113637. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  113638. /** @hidden */
  113639. static _UniversalLerp(left: any, right: any, amount: number): any;
  113640. /**
  113641. * Parses an animation object and creates an animation
  113642. * @param parsedAnimation Parsed animation object
  113643. * @returns Animation object
  113644. */
  113645. static Parse(parsedAnimation: any): Animation;
  113646. /**
  113647. * Appends the serialized animations from the source animations
  113648. * @param source Source containing the animations
  113649. * @param destination Target to store the animations
  113650. */
  113651. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  113652. /**
  113653. * Creates a new animation or an array of animations from a snippet saved in a remote file
  113654. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  113655. * @param url defines the url to load from
  113656. * @returns a promise that will resolve to the new animation or an array of animations
  113657. */
  113658. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  113659. /**
  113660. * Creates an animation or an array of animations from a snippet saved by the Inspector
  113661. * @param snippetId defines the snippet to load
  113662. * @returns a promise that will resolve to the new animation or a new array of animations
  113663. */
  113664. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  113665. }
  113666. }
  113667. declare module BABYLON {
  113668. /**
  113669. * Interface containing an array of animations
  113670. */
  113671. export interface IAnimatable {
  113672. /**
  113673. * Array of animations
  113674. */
  113675. animations: Nullable<Array<Animation>>;
  113676. }
  113677. }
  113678. declare module BABYLON {
  113679. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  113680. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113681. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113682. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113683. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113684. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113685. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113686. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113687. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113688. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113689. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113690. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113691. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113692. /**
  113693. * Decorator used to define property that can be serialized as reference to a camera
  113694. * @param sourceName defines the name of the property to decorate
  113695. */
  113696. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113697. /**
  113698. * Class used to help serialization objects
  113699. */
  113700. export class SerializationHelper {
  113701. /** @hidden */
  113702. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  113703. /** @hidden */
  113704. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  113705. /** @hidden */
  113706. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  113707. /** @hidden */
  113708. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  113709. /**
  113710. * Appends the serialized animations from the source animations
  113711. * @param source Source containing the animations
  113712. * @param destination Target to store the animations
  113713. */
  113714. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  113715. /**
  113716. * Static function used to serialized a specific entity
  113717. * @param entity defines the entity to serialize
  113718. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  113719. * @returns a JSON compatible object representing the serialization of the entity
  113720. */
  113721. static Serialize<T>(entity: T, serializationObject?: any): any;
  113722. /**
  113723. * Creates a new entity from a serialization data object
  113724. * @param creationFunction defines a function used to instanciated the new entity
  113725. * @param source defines the source serialization data
  113726. * @param scene defines the hosting scene
  113727. * @param rootUrl defines the root url for resources
  113728. * @returns a new entity
  113729. */
  113730. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  113731. /**
  113732. * Clones an object
  113733. * @param creationFunction defines the function used to instanciate the new object
  113734. * @param source defines the source object
  113735. * @returns the cloned object
  113736. */
  113737. static Clone<T>(creationFunction: () => T, source: T): T;
  113738. /**
  113739. * Instanciates a new object based on a source one (some data will be shared between both object)
  113740. * @param creationFunction defines the function used to instanciate the new object
  113741. * @param source defines the source object
  113742. * @returns the new object
  113743. */
  113744. static Instanciate<T>(creationFunction: () => T, source: T): T;
  113745. }
  113746. }
  113747. declare module BABYLON {
  113748. /**
  113749. * Base class of all the textures in babylon.
  113750. * It groups all the common properties the materials, post process, lights... might need
  113751. * in order to make a correct use of the texture.
  113752. */
  113753. export class BaseTexture implements IAnimatable {
  113754. /**
  113755. * Default anisotropic filtering level for the application.
  113756. * It is set to 4 as a good tradeoff between perf and quality.
  113757. */
  113758. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  113759. /**
  113760. * Gets or sets the unique id of the texture
  113761. */
  113762. uniqueId: number;
  113763. /**
  113764. * Define the name of the texture.
  113765. */
  113766. name: string;
  113767. /**
  113768. * Gets or sets an object used to store user defined information.
  113769. */
  113770. metadata: any;
  113771. /**
  113772. * For internal use only. Please do not use.
  113773. */
  113774. reservedDataStore: any;
  113775. private _hasAlpha;
  113776. /**
  113777. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  113778. */
  113779. set hasAlpha(value: boolean);
  113780. get hasAlpha(): boolean;
  113781. /**
  113782. * Defines if the alpha value should be determined via the rgb values.
  113783. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  113784. */
  113785. getAlphaFromRGB: boolean;
  113786. /**
  113787. * Intensity or strength of the texture.
  113788. * It is commonly used by materials to fine tune the intensity of the texture
  113789. */
  113790. level: number;
  113791. /**
  113792. * Define the UV chanel to use starting from 0 and defaulting to 0.
  113793. * This is part of the texture as textures usually maps to one uv set.
  113794. */
  113795. coordinatesIndex: number;
  113796. protected _coordinatesMode: number;
  113797. /**
  113798. * How a texture is mapped.
  113799. *
  113800. * | Value | Type | Description |
  113801. * | ----- | ----------------------------------- | ----------- |
  113802. * | 0 | EXPLICIT_MODE | |
  113803. * | 1 | SPHERICAL_MODE | |
  113804. * | 2 | PLANAR_MODE | |
  113805. * | 3 | CUBIC_MODE | |
  113806. * | 4 | PROJECTION_MODE | |
  113807. * | 5 | SKYBOX_MODE | |
  113808. * | 6 | INVCUBIC_MODE | |
  113809. * | 7 | EQUIRECTANGULAR_MODE | |
  113810. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  113811. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  113812. */
  113813. set coordinatesMode(value: number);
  113814. get coordinatesMode(): number;
  113815. private _wrapU;
  113816. /**
  113817. * | Value | Type | Description |
  113818. * | ----- | ------------------ | ----------- |
  113819. * | 0 | CLAMP_ADDRESSMODE | |
  113820. * | 1 | WRAP_ADDRESSMODE | |
  113821. * | 2 | MIRROR_ADDRESSMODE | |
  113822. */
  113823. get wrapU(): number;
  113824. set wrapU(value: number);
  113825. private _wrapV;
  113826. /**
  113827. * | Value | Type | Description |
  113828. * | ----- | ------------------ | ----------- |
  113829. * | 0 | CLAMP_ADDRESSMODE | |
  113830. * | 1 | WRAP_ADDRESSMODE | |
  113831. * | 2 | MIRROR_ADDRESSMODE | |
  113832. */
  113833. get wrapV(): number;
  113834. set wrapV(value: number);
  113835. /**
  113836. * | Value | Type | Description |
  113837. * | ----- | ------------------ | ----------- |
  113838. * | 0 | CLAMP_ADDRESSMODE | |
  113839. * | 1 | WRAP_ADDRESSMODE | |
  113840. * | 2 | MIRROR_ADDRESSMODE | |
  113841. */
  113842. wrapR: number;
  113843. /**
  113844. * With compliant hardware and browser (supporting anisotropic filtering)
  113845. * this defines the level of anisotropic filtering in the texture.
  113846. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  113847. */
  113848. anisotropicFilteringLevel: number;
  113849. /**
  113850. * Define if the texture is a cube texture or if false a 2d texture.
  113851. */
  113852. get isCube(): boolean;
  113853. set isCube(value: boolean);
  113854. /**
  113855. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  113856. */
  113857. get is3D(): boolean;
  113858. set is3D(value: boolean);
  113859. /**
  113860. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  113861. */
  113862. get is2DArray(): boolean;
  113863. set is2DArray(value: boolean);
  113864. private _gammaSpace;
  113865. /**
  113866. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  113867. * HDR texture are usually stored in linear space.
  113868. * This only impacts the PBR and Background materials
  113869. */
  113870. get gammaSpace(): boolean;
  113871. set gammaSpace(gamma: boolean);
  113872. /**
  113873. * Gets or sets whether or not the texture contains RGBD data.
  113874. */
  113875. get isRGBD(): boolean;
  113876. set isRGBD(value: boolean);
  113877. /**
  113878. * Is Z inverted in the texture (useful in a cube texture).
  113879. */
  113880. invertZ: boolean;
  113881. /**
  113882. * Are mip maps generated for this texture or not.
  113883. */
  113884. get noMipmap(): boolean;
  113885. /**
  113886. * @hidden
  113887. */
  113888. lodLevelInAlpha: boolean;
  113889. /**
  113890. * With prefiltered texture, defined the offset used during the prefiltering steps.
  113891. */
  113892. get lodGenerationOffset(): number;
  113893. set lodGenerationOffset(value: number);
  113894. /**
  113895. * With prefiltered texture, defined the scale used during the prefiltering steps.
  113896. */
  113897. get lodGenerationScale(): number;
  113898. set lodGenerationScale(value: number);
  113899. /**
  113900. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  113901. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  113902. * average roughness values.
  113903. */
  113904. get linearSpecularLOD(): boolean;
  113905. set linearSpecularLOD(value: boolean);
  113906. /**
  113907. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  113908. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  113909. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  113910. */
  113911. get irradianceTexture(): Nullable<BaseTexture>;
  113912. set irradianceTexture(value: Nullable<BaseTexture>);
  113913. /**
  113914. * Define if the texture is a render target.
  113915. */
  113916. isRenderTarget: boolean;
  113917. /**
  113918. * Define the unique id of the texture in the scene.
  113919. */
  113920. get uid(): string;
  113921. /** @hidden */
  113922. _prefiltered: boolean;
  113923. /**
  113924. * Return a string representation of the texture.
  113925. * @returns the texture as a string
  113926. */
  113927. toString(): string;
  113928. /**
  113929. * Get the class name of the texture.
  113930. * @returns "BaseTexture"
  113931. */
  113932. getClassName(): string;
  113933. /**
  113934. * Define the list of animation attached to the texture.
  113935. */
  113936. animations: Animation[];
  113937. /**
  113938. * An event triggered when the texture is disposed.
  113939. */
  113940. onDisposeObservable: Observable<BaseTexture>;
  113941. private _onDisposeObserver;
  113942. /**
  113943. * Callback triggered when the texture has been disposed.
  113944. * Kept for back compatibility, you can use the onDisposeObservable instead.
  113945. */
  113946. set onDispose(callback: () => void);
  113947. /**
  113948. * Define the current state of the loading sequence when in delayed load mode.
  113949. */
  113950. delayLoadState: number;
  113951. protected _scene: Nullable<Scene>;
  113952. protected _engine: Nullable<ThinEngine>;
  113953. /** @hidden */
  113954. _texture: Nullable<InternalTexture>;
  113955. private _uid;
  113956. /**
  113957. * Define if the texture is preventinga material to render or not.
  113958. * If not and the texture is not ready, the engine will use a default black texture instead.
  113959. */
  113960. get isBlocking(): boolean;
  113961. /**
  113962. * Instantiates a new BaseTexture.
  113963. * Base class of all the textures in babylon.
  113964. * It groups all the common properties the materials, post process, lights... might need
  113965. * in order to make a correct use of the texture.
  113966. * @param sceneOrEngine Define the scene or engine the texture blongs to
  113967. */
  113968. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  113969. /**
  113970. * Get the scene the texture belongs to.
  113971. * @returns the scene or null if undefined
  113972. */
  113973. getScene(): Nullable<Scene>;
  113974. /** @hidden */
  113975. protected _getEngine(): Nullable<ThinEngine>;
  113976. /**
  113977. * Get the texture transform matrix used to offset tile the texture for istance.
  113978. * @returns the transformation matrix
  113979. */
  113980. getTextureMatrix(): Matrix;
  113981. /**
  113982. * Get the texture reflection matrix used to rotate/transform the reflection.
  113983. * @returns the reflection matrix
  113984. */
  113985. getReflectionTextureMatrix(): Matrix;
  113986. /**
  113987. * Get the underlying lower level texture from Babylon.
  113988. * @returns the insternal texture
  113989. */
  113990. getInternalTexture(): Nullable<InternalTexture>;
  113991. /**
  113992. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  113993. * @returns true if ready or not blocking
  113994. */
  113995. isReadyOrNotBlocking(): boolean;
  113996. /**
  113997. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  113998. * @returns true if fully ready
  113999. */
  114000. isReady(): boolean;
  114001. private _cachedSize;
  114002. /**
  114003. * Get the size of the texture.
  114004. * @returns the texture size.
  114005. */
  114006. getSize(): ISize;
  114007. /**
  114008. * Get the base size of the texture.
  114009. * It can be different from the size if the texture has been resized for POT for instance
  114010. * @returns the base size
  114011. */
  114012. getBaseSize(): ISize;
  114013. /**
  114014. * Update the sampling mode of the texture.
  114015. * Default is Trilinear mode.
  114016. *
  114017. * | Value | Type | Description |
  114018. * | ----- | ------------------ | ----------- |
  114019. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  114020. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  114021. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  114022. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  114023. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  114024. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  114025. * | 7 | NEAREST_LINEAR | |
  114026. * | 8 | NEAREST_NEAREST | |
  114027. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  114028. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  114029. * | 11 | LINEAR_LINEAR | |
  114030. * | 12 | LINEAR_NEAREST | |
  114031. *
  114032. * > _mag_: magnification filter (close to the viewer)
  114033. * > _min_: minification filter (far from the viewer)
  114034. * > _mip_: filter used between mip map levels
  114035. *@param samplingMode Define the new sampling mode of the texture
  114036. */
  114037. updateSamplingMode(samplingMode: number): void;
  114038. /**
  114039. * Scales the texture if is `canRescale()`
  114040. * @param ratio the resize factor we want to use to rescale
  114041. */
  114042. scale(ratio: number): void;
  114043. /**
  114044. * Get if the texture can rescale.
  114045. */
  114046. get canRescale(): boolean;
  114047. /** @hidden */
  114048. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  114049. /** @hidden */
  114050. _rebuild(): void;
  114051. /**
  114052. * Triggers the load sequence in delayed load mode.
  114053. */
  114054. delayLoad(): void;
  114055. /**
  114056. * Clones the texture.
  114057. * @returns the cloned texture
  114058. */
  114059. clone(): Nullable<BaseTexture>;
  114060. /**
  114061. * Get the texture underlying type (INT, FLOAT...)
  114062. */
  114063. get textureType(): number;
  114064. /**
  114065. * Get the texture underlying format (RGB, RGBA...)
  114066. */
  114067. get textureFormat(): number;
  114068. /**
  114069. * Indicates that textures need to be re-calculated for all materials
  114070. */
  114071. protected _markAllSubMeshesAsTexturesDirty(): void;
  114072. /**
  114073. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  114074. * This will returns an RGBA array buffer containing either in values (0-255) or
  114075. * float values (0-1) depending of the underlying buffer type.
  114076. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  114077. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  114078. * @param buffer defines a user defined buffer to fill with data (can be null)
  114079. * @returns The Array buffer containing the pixels data.
  114080. */
  114081. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  114082. /**
  114083. * Release and destroy the underlying lower level texture aka internalTexture.
  114084. */
  114085. releaseInternalTexture(): void;
  114086. /** @hidden */
  114087. get _lodTextureHigh(): Nullable<BaseTexture>;
  114088. /** @hidden */
  114089. get _lodTextureMid(): Nullable<BaseTexture>;
  114090. /** @hidden */
  114091. get _lodTextureLow(): Nullable<BaseTexture>;
  114092. /**
  114093. * Dispose the texture and release its associated resources.
  114094. */
  114095. dispose(): void;
  114096. /**
  114097. * Serialize the texture into a JSON representation that can be parsed later on.
  114098. * @returns the JSON representation of the texture
  114099. */
  114100. serialize(): any;
  114101. /**
  114102. * Helper function to be called back once a list of texture contains only ready textures.
  114103. * @param textures Define the list of textures to wait for
  114104. * @param callback Define the callback triggered once the entire list will be ready
  114105. */
  114106. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  114107. private static _isScene;
  114108. }
  114109. }
  114110. declare module BABYLON {
  114111. /**
  114112. * Options to be used when creating an effect.
  114113. */
  114114. export interface IEffectCreationOptions {
  114115. /**
  114116. * Atrributes that will be used in the shader.
  114117. */
  114118. attributes: string[];
  114119. /**
  114120. * Uniform varible names that will be set in the shader.
  114121. */
  114122. uniformsNames: string[];
  114123. /**
  114124. * Uniform buffer variable names that will be set in the shader.
  114125. */
  114126. uniformBuffersNames: string[];
  114127. /**
  114128. * Sampler texture variable names that will be set in the shader.
  114129. */
  114130. samplers: string[];
  114131. /**
  114132. * Define statements that will be set in the shader.
  114133. */
  114134. defines: any;
  114135. /**
  114136. * Possible fallbacks for this effect to improve performance when needed.
  114137. */
  114138. fallbacks: Nullable<IEffectFallbacks>;
  114139. /**
  114140. * Callback that will be called when the shader is compiled.
  114141. */
  114142. onCompiled: Nullable<(effect: Effect) => void>;
  114143. /**
  114144. * Callback that will be called if an error occurs during shader compilation.
  114145. */
  114146. onError: Nullable<(effect: Effect, errors: string) => void>;
  114147. /**
  114148. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114149. */
  114150. indexParameters?: any;
  114151. /**
  114152. * Max number of lights that can be used in the shader.
  114153. */
  114154. maxSimultaneousLights?: number;
  114155. /**
  114156. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  114157. */
  114158. transformFeedbackVaryings?: Nullable<string[]>;
  114159. /**
  114160. * 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
  114161. */
  114162. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  114163. /**
  114164. * Is this effect rendering to several color attachments ?
  114165. */
  114166. multiTarget?: boolean;
  114167. }
  114168. /**
  114169. * Effect containing vertex and fragment shader that can be executed on an object.
  114170. */
  114171. export class Effect implements IDisposable {
  114172. /**
  114173. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114174. */
  114175. static ShadersRepository: string;
  114176. /**
  114177. * Enable logging of the shader code when a compilation error occurs
  114178. */
  114179. static LogShaderCodeOnCompilationError: boolean;
  114180. /**
  114181. * Name of the effect.
  114182. */
  114183. name: any;
  114184. /**
  114185. * String container all the define statements that should be set on the shader.
  114186. */
  114187. defines: string;
  114188. /**
  114189. * Callback that will be called when the shader is compiled.
  114190. */
  114191. onCompiled: Nullable<(effect: Effect) => void>;
  114192. /**
  114193. * Callback that will be called if an error occurs during shader compilation.
  114194. */
  114195. onError: Nullable<(effect: Effect, errors: string) => void>;
  114196. /**
  114197. * Callback that will be called when effect is bound.
  114198. */
  114199. onBind: Nullable<(effect: Effect) => void>;
  114200. /**
  114201. * Unique ID of the effect.
  114202. */
  114203. uniqueId: number;
  114204. /**
  114205. * Observable that will be called when the shader is compiled.
  114206. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  114207. */
  114208. onCompileObservable: Observable<Effect>;
  114209. /**
  114210. * Observable that will be called if an error occurs during shader compilation.
  114211. */
  114212. onErrorObservable: Observable<Effect>;
  114213. /** @hidden */
  114214. _onBindObservable: Nullable<Observable<Effect>>;
  114215. /**
  114216. * @hidden
  114217. * Specifies if the effect was previously ready
  114218. */
  114219. _wasPreviouslyReady: boolean;
  114220. /**
  114221. * Observable that will be called when effect is bound.
  114222. */
  114223. get onBindObservable(): Observable<Effect>;
  114224. /** @hidden */
  114225. _bonesComputationForcedToCPU: boolean;
  114226. /** @hidden */
  114227. _multiTarget: boolean;
  114228. private static _uniqueIdSeed;
  114229. private _engine;
  114230. private _uniformBuffersNames;
  114231. private _uniformBuffersNamesList;
  114232. private _uniformsNames;
  114233. private _samplerList;
  114234. private _samplers;
  114235. private _isReady;
  114236. private _compilationError;
  114237. private _allFallbacksProcessed;
  114238. private _attributesNames;
  114239. private _attributes;
  114240. private _attributeLocationByName;
  114241. private _uniforms;
  114242. /**
  114243. * Key for the effect.
  114244. * @hidden
  114245. */
  114246. _key: string;
  114247. private _indexParameters;
  114248. private _fallbacks;
  114249. private _vertexSourceCode;
  114250. private _fragmentSourceCode;
  114251. private _vertexSourceCodeOverride;
  114252. private _fragmentSourceCodeOverride;
  114253. private _transformFeedbackVaryings;
  114254. /**
  114255. * Compiled shader to webGL program.
  114256. * @hidden
  114257. */
  114258. _pipelineContext: Nullable<IPipelineContext>;
  114259. private _valueCache;
  114260. private static _baseCache;
  114261. /**
  114262. * Instantiates an effect.
  114263. * An effect can be used to create/manage/execute vertex and fragment shaders.
  114264. * @param baseName Name of the effect.
  114265. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  114266. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  114267. * @param samplers List of sampler variables that will be passed to the shader.
  114268. * @param engine Engine to be used to render the effect
  114269. * @param defines Define statements to be added to the shader.
  114270. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  114271. * @param onCompiled Callback that will be called when the shader is compiled.
  114272. * @param onError Callback that will be called if an error occurs during shader compilation.
  114273. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114274. */
  114275. 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);
  114276. private _useFinalCode;
  114277. /**
  114278. * Unique key for this effect
  114279. */
  114280. get key(): string;
  114281. /**
  114282. * If the effect has been compiled and prepared.
  114283. * @returns if the effect is compiled and prepared.
  114284. */
  114285. isReady(): boolean;
  114286. private _isReadyInternal;
  114287. /**
  114288. * The engine the effect was initialized with.
  114289. * @returns the engine.
  114290. */
  114291. getEngine(): Engine;
  114292. /**
  114293. * The pipeline context for this effect
  114294. * @returns the associated pipeline context
  114295. */
  114296. getPipelineContext(): Nullable<IPipelineContext>;
  114297. /**
  114298. * The set of names of attribute variables for the shader.
  114299. * @returns An array of attribute names.
  114300. */
  114301. getAttributesNames(): string[];
  114302. /**
  114303. * Returns the attribute at the given index.
  114304. * @param index The index of the attribute.
  114305. * @returns The location of the attribute.
  114306. */
  114307. getAttributeLocation(index: number): number;
  114308. /**
  114309. * Returns the attribute based on the name of the variable.
  114310. * @param name of the attribute to look up.
  114311. * @returns the attribute location.
  114312. */
  114313. getAttributeLocationByName(name: string): number;
  114314. /**
  114315. * The number of attributes.
  114316. * @returns the numnber of attributes.
  114317. */
  114318. getAttributesCount(): number;
  114319. /**
  114320. * Gets the index of a uniform variable.
  114321. * @param uniformName of the uniform to look up.
  114322. * @returns the index.
  114323. */
  114324. getUniformIndex(uniformName: string): number;
  114325. /**
  114326. * Returns the attribute based on the name of the variable.
  114327. * @param uniformName of the uniform to look up.
  114328. * @returns the location of the uniform.
  114329. */
  114330. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  114331. /**
  114332. * Returns an array of sampler variable names
  114333. * @returns The array of sampler variable names.
  114334. */
  114335. getSamplers(): string[];
  114336. /**
  114337. * Returns an array of uniform variable names
  114338. * @returns The array of uniform variable names.
  114339. */
  114340. getUniformNames(): string[];
  114341. /**
  114342. * Returns an array of uniform buffer variable names
  114343. * @returns The array of uniform buffer variable names.
  114344. */
  114345. getUniformBuffersNames(): string[];
  114346. /**
  114347. * Returns the index parameters used to create the effect
  114348. * @returns The index parameters object
  114349. */
  114350. getIndexParameters(): any;
  114351. /**
  114352. * The error from the last compilation.
  114353. * @returns the error string.
  114354. */
  114355. getCompilationError(): string;
  114356. /**
  114357. * Gets a boolean indicating that all fallbacks were used during compilation
  114358. * @returns true if all fallbacks were used
  114359. */
  114360. allFallbacksProcessed(): boolean;
  114361. /**
  114362. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  114363. * @param func The callback to be used.
  114364. */
  114365. executeWhenCompiled(func: (effect: Effect) => void): void;
  114366. private _checkIsReady;
  114367. private _loadShader;
  114368. /**
  114369. * Gets the vertex shader source code of this effect
  114370. */
  114371. get vertexSourceCode(): string;
  114372. /**
  114373. * Gets the fragment shader source code of this effect
  114374. */
  114375. get fragmentSourceCode(): string;
  114376. /**
  114377. * Recompiles the webGL program
  114378. * @param vertexSourceCode The source code for the vertex shader.
  114379. * @param fragmentSourceCode The source code for the fragment shader.
  114380. * @param onCompiled Callback called when completed.
  114381. * @param onError Callback called on error.
  114382. * @hidden
  114383. */
  114384. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  114385. /**
  114386. * Prepares the effect
  114387. * @hidden
  114388. */
  114389. _prepareEffect(): void;
  114390. private _getShaderCodeAndErrorLine;
  114391. private _processCompilationErrors;
  114392. /**
  114393. * Checks if the effect is supported. (Must be called after compilation)
  114394. */
  114395. get isSupported(): boolean;
  114396. /**
  114397. * Binds a texture to the engine to be used as output of the shader.
  114398. * @param channel Name of the output variable.
  114399. * @param texture Texture to bind.
  114400. * @hidden
  114401. */
  114402. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  114403. /**
  114404. * Sets a texture on the engine to be used in the shader.
  114405. * @param channel Name of the sampler variable.
  114406. * @param texture Texture to set.
  114407. */
  114408. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  114409. /**
  114410. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  114411. * @param channel Name of the sampler variable.
  114412. * @param texture Texture to set.
  114413. */
  114414. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  114415. /**
  114416. * Sets an array of textures on the engine to be used in the shader.
  114417. * @param channel Name of the variable.
  114418. * @param textures Textures to set.
  114419. */
  114420. setTextureArray(channel: string, textures: BaseTexture[]): void;
  114421. /**
  114422. * 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)
  114423. * @param channel Name of the sampler variable.
  114424. * @param postProcess Post process to get the input texture from.
  114425. */
  114426. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  114427. /**
  114428. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  114429. * 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)
  114430. * @param channel Name of the sampler variable.
  114431. * @param postProcess Post process to get the output texture from.
  114432. */
  114433. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  114434. /** @hidden */
  114435. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  114436. /** @hidden */
  114437. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  114438. /** @hidden */
  114439. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  114440. /** @hidden */
  114441. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  114442. /**
  114443. * Binds a buffer to a uniform.
  114444. * @param buffer Buffer to bind.
  114445. * @param name Name of the uniform variable to bind to.
  114446. */
  114447. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  114448. /**
  114449. * Binds block to a uniform.
  114450. * @param blockName Name of the block to bind.
  114451. * @param index Index to bind.
  114452. */
  114453. bindUniformBlock(blockName: string, index: number): void;
  114454. /**
  114455. * Sets an interger value on a uniform variable.
  114456. * @param uniformName Name of the variable.
  114457. * @param value Value to be set.
  114458. * @returns this effect.
  114459. */
  114460. setInt(uniformName: string, value: number): Effect;
  114461. /**
  114462. * Sets an int array on a uniform variable.
  114463. * @param uniformName Name of the variable.
  114464. * @param array array to be set.
  114465. * @returns this effect.
  114466. */
  114467. setIntArray(uniformName: string, array: Int32Array): Effect;
  114468. /**
  114469. * 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)
  114470. * @param uniformName Name of the variable.
  114471. * @param array array to be set.
  114472. * @returns this effect.
  114473. */
  114474. setIntArray2(uniformName: string, array: Int32Array): Effect;
  114475. /**
  114476. * 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)
  114477. * @param uniformName Name of the variable.
  114478. * @param array array to be set.
  114479. * @returns this effect.
  114480. */
  114481. setIntArray3(uniformName: string, array: Int32Array): Effect;
  114482. /**
  114483. * 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)
  114484. * @param uniformName Name of the variable.
  114485. * @param array array to be set.
  114486. * @returns this effect.
  114487. */
  114488. setIntArray4(uniformName: string, array: Int32Array): Effect;
  114489. /**
  114490. * Sets an float array on a uniform variable.
  114491. * @param uniformName Name of the variable.
  114492. * @param array array to be set.
  114493. * @returns this effect.
  114494. */
  114495. setFloatArray(uniformName: string, array: Float32Array): Effect;
  114496. /**
  114497. * 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)
  114498. * @param uniformName Name of the variable.
  114499. * @param array array to be set.
  114500. * @returns this effect.
  114501. */
  114502. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  114503. /**
  114504. * 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)
  114505. * @param uniformName Name of the variable.
  114506. * @param array array to be set.
  114507. * @returns this effect.
  114508. */
  114509. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  114510. /**
  114511. * 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)
  114512. * @param uniformName Name of the variable.
  114513. * @param array array to be set.
  114514. * @returns this effect.
  114515. */
  114516. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  114517. /**
  114518. * Sets an array on a uniform variable.
  114519. * @param uniformName Name of the variable.
  114520. * @param array array to be set.
  114521. * @returns this effect.
  114522. */
  114523. setArray(uniformName: string, array: number[]): Effect;
  114524. /**
  114525. * 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)
  114526. * @param uniformName Name of the variable.
  114527. * @param array array to be set.
  114528. * @returns this effect.
  114529. */
  114530. setArray2(uniformName: string, array: number[]): Effect;
  114531. /**
  114532. * 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)
  114533. * @param uniformName Name of the variable.
  114534. * @param array array to be set.
  114535. * @returns this effect.
  114536. */
  114537. setArray3(uniformName: string, array: number[]): Effect;
  114538. /**
  114539. * 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)
  114540. * @param uniformName Name of the variable.
  114541. * @param array array to be set.
  114542. * @returns this effect.
  114543. */
  114544. setArray4(uniformName: string, array: number[]): Effect;
  114545. /**
  114546. * Sets matrices on a uniform variable.
  114547. * @param uniformName Name of the variable.
  114548. * @param matrices matrices to be set.
  114549. * @returns this effect.
  114550. */
  114551. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  114552. /**
  114553. * Sets matrix on a uniform variable.
  114554. * @param uniformName Name of the variable.
  114555. * @param matrix matrix to be set.
  114556. * @returns this effect.
  114557. */
  114558. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  114559. /**
  114560. * 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)
  114561. * @param uniformName Name of the variable.
  114562. * @param matrix matrix to be set.
  114563. * @returns this effect.
  114564. */
  114565. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  114566. /**
  114567. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  114568. * @param uniformName Name of the variable.
  114569. * @param matrix matrix to be set.
  114570. * @returns this effect.
  114571. */
  114572. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  114573. /**
  114574. * Sets a float on a uniform variable.
  114575. * @param uniformName Name of the variable.
  114576. * @param value value to be set.
  114577. * @returns this effect.
  114578. */
  114579. setFloat(uniformName: string, value: number): Effect;
  114580. /**
  114581. * Sets a boolean on a uniform variable.
  114582. * @param uniformName Name of the variable.
  114583. * @param bool value to be set.
  114584. * @returns this effect.
  114585. */
  114586. setBool(uniformName: string, bool: boolean): Effect;
  114587. /**
  114588. * Sets a Vector2 on a uniform variable.
  114589. * @param uniformName Name of the variable.
  114590. * @param vector2 vector2 to be set.
  114591. * @returns this effect.
  114592. */
  114593. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  114594. /**
  114595. * Sets a float2 on a uniform variable.
  114596. * @param uniformName Name of the variable.
  114597. * @param x First float in float2.
  114598. * @param y Second float in float2.
  114599. * @returns this effect.
  114600. */
  114601. setFloat2(uniformName: string, x: number, y: number): Effect;
  114602. /**
  114603. * Sets a Vector3 on a uniform variable.
  114604. * @param uniformName Name of the variable.
  114605. * @param vector3 Value to be set.
  114606. * @returns this effect.
  114607. */
  114608. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  114609. /**
  114610. * Sets a float3 on a uniform variable.
  114611. * @param uniformName Name of the variable.
  114612. * @param x First float in float3.
  114613. * @param y Second float in float3.
  114614. * @param z Third float in float3.
  114615. * @returns this effect.
  114616. */
  114617. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  114618. /**
  114619. * Sets a Vector4 on a uniform variable.
  114620. * @param uniformName Name of the variable.
  114621. * @param vector4 Value to be set.
  114622. * @returns this effect.
  114623. */
  114624. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  114625. /**
  114626. * Sets a float4 on a uniform variable.
  114627. * @param uniformName Name of the variable.
  114628. * @param x First float in float4.
  114629. * @param y Second float in float4.
  114630. * @param z Third float in float4.
  114631. * @param w Fourth float in float4.
  114632. * @returns this effect.
  114633. */
  114634. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  114635. /**
  114636. * Sets a Color3 on a uniform variable.
  114637. * @param uniformName Name of the variable.
  114638. * @param color3 Value to be set.
  114639. * @returns this effect.
  114640. */
  114641. setColor3(uniformName: string, color3: IColor3Like): Effect;
  114642. /**
  114643. * Sets a Color4 on a uniform variable.
  114644. * @param uniformName Name of the variable.
  114645. * @param color3 Value to be set.
  114646. * @param alpha Alpha value to be set.
  114647. * @returns this effect.
  114648. */
  114649. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  114650. /**
  114651. * Sets a Color4 on a uniform variable
  114652. * @param uniformName defines the name of the variable
  114653. * @param color4 defines the value to be set
  114654. * @returns this effect.
  114655. */
  114656. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  114657. /** Release all associated resources */
  114658. dispose(): void;
  114659. /**
  114660. * This function will add a new shader to the shader store
  114661. * @param name the name of the shader
  114662. * @param pixelShader optional pixel shader content
  114663. * @param vertexShader optional vertex shader content
  114664. */
  114665. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  114666. /**
  114667. * Store of each shader (The can be looked up using effect.key)
  114668. */
  114669. static ShadersStore: {
  114670. [key: string]: string;
  114671. };
  114672. /**
  114673. * Store of each included file for a shader (The can be looked up using effect.key)
  114674. */
  114675. static IncludesShadersStore: {
  114676. [key: string]: string;
  114677. };
  114678. /**
  114679. * Resets the cache of effects.
  114680. */
  114681. static ResetCache(): void;
  114682. }
  114683. }
  114684. declare module BABYLON {
  114685. /**
  114686. * Interface used to describe the capabilities of the engine relatively to the current browser
  114687. */
  114688. export interface EngineCapabilities {
  114689. /** Maximum textures units per fragment shader */
  114690. maxTexturesImageUnits: number;
  114691. /** Maximum texture units per vertex shader */
  114692. maxVertexTextureImageUnits: number;
  114693. /** Maximum textures units in the entire pipeline */
  114694. maxCombinedTexturesImageUnits: number;
  114695. /** Maximum texture size */
  114696. maxTextureSize: number;
  114697. /** Maximum texture samples */
  114698. maxSamples?: number;
  114699. /** Maximum cube texture size */
  114700. maxCubemapTextureSize: number;
  114701. /** Maximum render texture size */
  114702. maxRenderTextureSize: number;
  114703. /** Maximum number of vertex attributes */
  114704. maxVertexAttribs: number;
  114705. /** Maximum number of varyings */
  114706. maxVaryingVectors: number;
  114707. /** Maximum number of uniforms per vertex shader */
  114708. maxVertexUniformVectors: number;
  114709. /** Maximum number of uniforms per fragment shader */
  114710. maxFragmentUniformVectors: number;
  114711. /** Defines if standard derivates (dx/dy) are supported */
  114712. standardDerivatives: boolean;
  114713. /** Defines if s3tc texture compression is supported */
  114714. s3tc?: WEBGL_compressed_texture_s3tc;
  114715. /** Defines if pvrtc texture compression is supported */
  114716. pvrtc: any;
  114717. /** Defines if etc1 texture compression is supported */
  114718. etc1: any;
  114719. /** Defines if etc2 texture compression is supported */
  114720. etc2: any;
  114721. /** Defines if astc texture compression is supported */
  114722. astc: any;
  114723. /** Defines if bptc texture compression is supported */
  114724. bptc: any;
  114725. /** Defines if float textures are supported */
  114726. textureFloat: boolean;
  114727. /** Defines if vertex array objects are supported */
  114728. vertexArrayObject: boolean;
  114729. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  114730. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  114731. /** Gets the maximum level of anisotropy supported */
  114732. maxAnisotropy: number;
  114733. /** Defines if instancing is supported */
  114734. instancedArrays: boolean;
  114735. /** Defines if 32 bits indices are supported */
  114736. uintIndices: boolean;
  114737. /** Defines if high precision shaders are supported */
  114738. highPrecisionShaderSupported: boolean;
  114739. /** Defines if depth reading in the fragment shader is supported */
  114740. fragmentDepthSupported: boolean;
  114741. /** Defines if float texture linear filtering is supported*/
  114742. textureFloatLinearFiltering: boolean;
  114743. /** Defines if rendering to float textures is supported */
  114744. textureFloatRender: boolean;
  114745. /** Defines if half float textures are supported*/
  114746. textureHalfFloat: boolean;
  114747. /** Defines if half float texture linear filtering is supported*/
  114748. textureHalfFloatLinearFiltering: boolean;
  114749. /** Defines if rendering to half float textures is supported */
  114750. textureHalfFloatRender: boolean;
  114751. /** Defines if textureLOD shader command is supported */
  114752. textureLOD: boolean;
  114753. /** Defines if draw buffers extension is supported */
  114754. drawBuffersExtension: boolean;
  114755. /** Defines if depth textures are supported */
  114756. depthTextureExtension: boolean;
  114757. /** Defines if float color buffer are supported */
  114758. colorBufferFloat: boolean;
  114759. /** Gets disjoint timer query extension (null if not supported) */
  114760. timerQuery?: EXT_disjoint_timer_query;
  114761. /** Defines if timestamp can be used with timer query */
  114762. canUseTimestampForTimerQuery: boolean;
  114763. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  114764. multiview?: any;
  114765. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  114766. oculusMultiview?: any;
  114767. /** Function used to let the system compiles shaders in background */
  114768. parallelShaderCompile?: {
  114769. COMPLETION_STATUS_KHR: number;
  114770. };
  114771. /** Max number of texture samples for MSAA */
  114772. maxMSAASamples: number;
  114773. /** Defines if the blend min max extension is supported */
  114774. blendMinMax: boolean;
  114775. }
  114776. }
  114777. declare module BABYLON {
  114778. /**
  114779. * @hidden
  114780. **/
  114781. export class DepthCullingState {
  114782. private _isDepthTestDirty;
  114783. private _isDepthMaskDirty;
  114784. private _isDepthFuncDirty;
  114785. private _isCullFaceDirty;
  114786. private _isCullDirty;
  114787. private _isZOffsetDirty;
  114788. private _isFrontFaceDirty;
  114789. private _depthTest;
  114790. private _depthMask;
  114791. private _depthFunc;
  114792. private _cull;
  114793. private _cullFace;
  114794. private _zOffset;
  114795. private _frontFace;
  114796. /**
  114797. * Initializes the state.
  114798. */
  114799. constructor();
  114800. get isDirty(): boolean;
  114801. get zOffset(): number;
  114802. set zOffset(value: number);
  114803. get cullFace(): Nullable<number>;
  114804. set cullFace(value: Nullable<number>);
  114805. get cull(): Nullable<boolean>;
  114806. set cull(value: Nullable<boolean>);
  114807. get depthFunc(): Nullable<number>;
  114808. set depthFunc(value: Nullable<number>);
  114809. get depthMask(): boolean;
  114810. set depthMask(value: boolean);
  114811. get depthTest(): boolean;
  114812. set depthTest(value: boolean);
  114813. get frontFace(): Nullable<number>;
  114814. set frontFace(value: Nullable<number>);
  114815. reset(): void;
  114816. apply(gl: WebGLRenderingContext): void;
  114817. }
  114818. }
  114819. declare module BABYLON {
  114820. /**
  114821. * @hidden
  114822. **/
  114823. export class StencilState {
  114824. /** 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 */
  114825. static readonly ALWAYS: number;
  114826. /** Passed to stencilOperation to specify that stencil value must be kept */
  114827. static readonly KEEP: number;
  114828. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114829. static readonly REPLACE: number;
  114830. private _isStencilTestDirty;
  114831. private _isStencilMaskDirty;
  114832. private _isStencilFuncDirty;
  114833. private _isStencilOpDirty;
  114834. private _stencilTest;
  114835. private _stencilMask;
  114836. private _stencilFunc;
  114837. private _stencilFuncRef;
  114838. private _stencilFuncMask;
  114839. private _stencilOpStencilFail;
  114840. private _stencilOpDepthFail;
  114841. private _stencilOpStencilDepthPass;
  114842. get isDirty(): boolean;
  114843. get stencilFunc(): number;
  114844. set stencilFunc(value: number);
  114845. get stencilFuncRef(): number;
  114846. set stencilFuncRef(value: number);
  114847. get stencilFuncMask(): number;
  114848. set stencilFuncMask(value: number);
  114849. get stencilOpStencilFail(): number;
  114850. set stencilOpStencilFail(value: number);
  114851. get stencilOpDepthFail(): number;
  114852. set stencilOpDepthFail(value: number);
  114853. get stencilOpStencilDepthPass(): number;
  114854. set stencilOpStencilDepthPass(value: number);
  114855. get stencilMask(): number;
  114856. set stencilMask(value: number);
  114857. get stencilTest(): boolean;
  114858. set stencilTest(value: boolean);
  114859. constructor();
  114860. reset(): void;
  114861. apply(gl: WebGLRenderingContext): void;
  114862. }
  114863. }
  114864. declare module BABYLON {
  114865. /**
  114866. * @hidden
  114867. **/
  114868. export class AlphaState {
  114869. private _isAlphaBlendDirty;
  114870. private _isBlendFunctionParametersDirty;
  114871. private _isBlendEquationParametersDirty;
  114872. private _isBlendConstantsDirty;
  114873. private _alphaBlend;
  114874. private _blendFunctionParameters;
  114875. private _blendEquationParameters;
  114876. private _blendConstants;
  114877. /**
  114878. * Initializes the state.
  114879. */
  114880. constructor();
  114881. get isDirty(): boolean;
  114882. get alphaBlend(): boolean;
  114883. set alphaBlend(value: boolean);
  114884. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  114885. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  114886. setAlphaEquationParameters(rgb: number, alpha: number): void;
  114887. reset(): void;
  114888. apply(gl: WebGLRenderingContext): void;
  114889. }
  114890. }
  114891. declare module BABYLON {
  114892. /** @hidden */
  114893. export class WebGL2ShaderProcessor implements IShaderProcessor {
  114894. attributeProcessor(attribute: string): string;
  114895. varyingProcessor(varying: string, isFragment: boolean): string;
  114896. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  114897. }
  114898. }
  114899. declare module BABYLON {
  114900. /**
  114901. * Interface for attribute information associated with buffer instanciation
  114902. */
  114903. export interface InstancingAttributeInfo {
  114904. /**
  114905. * Name of the GLSL attribute
  114906. * if attribute index is not specified, this is used to retrieve the index from the effect
  114907. */
  114908. attributeName: string;
  114909. /**
  114910. * Index/offset of the attribute in the vertex shader
  114911. * if not specified, this will be computes from the name.
  114912. */
  114913. index?: number;
  114914. /**
  114915. * size of the attribute, 1, 2, 3 or 4
  114916. */
  114917. attributeSize: number;
  114918. /**
  114919. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  114920. */
  114921. offset: number;
  114922. /**
  114923. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  114924. * default to 1
  114925. */
  114926. divisor?: number;
  114927. /**
  114928. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  114929. * default is FLOAT
  114930. */
  114931. attributeType?: number;
  114932. /**
  114933. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  114934. */
  114935. normalized?: boolean;
  114936. }
  114937. }
  114938. declare module BABYLON {
  114939. interface ThinEngine {
  114940. /**
  114941. * Update a video texture
  114942. * @param texture defines the texture to update
  114943. * @param video defines the video element to use
  114944. * @param invertY defines if data must be stored with Y axis inverted
  114945. */
  114946. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  114947. }
  114948. }
  114949. declare module BABYLON {
  114950. interface ThinEngine {
  114951. /**
  114952. * Creates a dynamic texture
  114953. * @param width defines the width of the texture
  114954. * @param height defines the height of the texture
  114955. * @param generateMipMaps defines if the engine should generate the mip levels
  114956. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  114957. * @returns the dynamic texture inside an InternalTexture
  114958. */
  114959. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  114960. /**
  114961. * Update the content of a dynamic texture
  114962. * @param texture defines the texture to update
  114963. * @param canvas defines the canvas containing the source
  114964. * @param invertY defines if data must be stored with Y axis inverted
  114965. * @param premulAlpha defines if alpha is stored as premultiplied
  114966. * @param format defines the format of the data
  114967. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  114968. */
  114969. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  114970. }
  114971. }
  114972. declare module BABYLON {
  114973. /**
  114974. * Settings for finer control over video usage
  114975. */
  114976. export interface VideoTextureSettings {
  114977. /**
  114978. * Applies `autoplay` to video, if specified
  114979. */
  114980. autoPlay?: boolean;
  114981. /**
  114982. * Applies `loop` to video, if specified
  114983. */
  114984. loop?: boolean;
  114985. /**
  114986. * Automatically updates internal texture from video at every frame in the render loop
  114987. */
  114988. autoUpdateTexture: boolean;
  114989. /**
  114990. * Image src displayed during the video loading or until the user interacts with the video.
  114991. */
  114992. poster?: string;
  114993. }
  114994. /**
  114995. * If you want to display a video in your scene, this is the special texture for that.
  114996. * This special texture works similar to other textures, with the exception of a few parameters.
  114997. * @see https://doc.babylonjs.com/how_to/video_texture
  114998. */
  114999. export class VideoTexture extends Texture {
  115000. /**
  115001. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  115002. */
  115003. readonly autoUpdateTexture: boolean;
  115004. /**
  115005. * The video instance used by the texture internally
  115006. */
  115007. readonly video: HTMLVideoElement;
  115008. private _onUserActionRequestedObservable;
  115009. /**
  115010. * Event triggerd when a dom action is required by the user to play the video.
  115011. * This happens due to recent changes in browser policies preventing video to auto start.
  115012. */
  115013. get onUserActionRequestedObservable(): Observable<Texture>;
  115014. private _generateMipMaps;
  115015. private _stillImageCaptured;
  115016. private _displayingPosterTexture;
  115017. private _settings;
  115018. private _createInternalTextureOnEvent;
  115019. private _frameId;
  115020. private _currentSrc;
  115021. /**
  115022. * Creates a video texture.
  115023. * If you want to display a video in your scene, this is the special texture for that.
  115024. * This special texture works similar to other textures, with the exception of a few parameters.
  115025. * @see https://doc.babylonjs.com/how_to/video_texture
  115026. * @param name optional name, will detect from video source, if not defined
  115027. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  115028. * @param scene is obviously the current scene.
  115029. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  115030. * @param invertY is false by default but can be used to invert video on Y axis
  115031. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  115032. * @param settings allows finer control over video usage
  115033. */
  115034. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  115035. private _getName;
  115036. private _getVideo;
  115037. private _createInternalTexture;
  115038. private reset;
  115039. /**
  115040. * @hidden Internal method to initiate `update`.
  115041. */
  115042. _rebuild(): void;
  115043. /**
  115044. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  115045. */
  115046. update(): void;
  115047. /**
  115048. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  115049. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  115050. */
  115051. updateTexture(isVisible: boolean): void;
  115052. protected _updateInternalTexture: () => void;
  115053. /**
  115054. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  115055. * @param url New url.
  115056. */
  115057. updateURL(url: string): void;
  115058. /**
  115059. * Clones the texture.
  115060. * @returns the cloned texture
  115061. */
  115062. clone(): VideoTexture;
  115063. /**
  115064. * Dispose the texture and release its associated resources.
  115065. */
  115066. dispose(): void;
  115067. /**
  115068. * Creates a video texture straight from a stream.
  115069. * @param scene Define the scene the texture should be created in
  115070. * @param stream Define the stream the texture should be created from
  115071. * @returns The created video texture as a promise
  115072. */
  115073. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  115074. /**
  115075. * Creates a video texture straight from your WebCam video feed.
  115076. * @param scene Define the scene the texture should be created in
  115077. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115078. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115079. * @returns The created video texture as a promise
  115080. */
  115081. static CreateFromWebCamAsync(scene: Scene, constraints: {
  115082. minWidth: number;
  115083. maxWidth: number;
  115084. minHeight: number;
  115085. maxHeight: number;
  115086. deviceId: string;
  115087. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  115088. /**
  115089. * Creates a video texture straight from your WebCam video feed.
  115090. * @param scene Define the scene the texture should be created in
  115091. * @param onReady Define a callback to triggered once the texture will be ready
  115092. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115093. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115094. */
  115095. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  115096. minWidth: number;
  115097. maxWidth: number;
  115098. minHeight: number;
  115099. maxHeight: number;
  115100. deviceId: string;
  115101. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  115102. }
  115103. }
  115104. declare module BABYLON {
  115105. /**
  115106. * Defines the interface used by objects working like Scene
  115107. * @hidden
  115108. */
  115109. export interface ISceneLike {
  115110. _addPendingData(data: any): void;
  115111. _removePendingData(data: any): void;
  115112. offlineProvider: IOfflineProvider;
  115113. }
  115114. /**
  115115. * Information about the current host
  115116. */
  115117. export interface HostInformation {
  115118. /**
  115119. * Defines if the current host is a mobile
  115120. */
  115121. isMobile: boolean;
  115122. }
  115123. /** Interface defining initialization parameters for Engine class */
  115124. export interface EngineOptions extends WebGLContextAttributes {
  115125. /**
  115126. * Defines if the engine should no exceed a specified device ratio
  115127. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  115128. */
  115129. limitDeviceRatio?: number;
  115130. /**
  115131. * Defines if webvr should be enabled automatically
  115132. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115133. */
  115134. autoEnableWebVR?: boolean;
  115135. /**
  115136. * Defines if webgl2 should be turned off even if supported
  115137. * @see https://doc.babylonjs.com/features/webgl2
  115138. */
  115139. disableWebGL2Support?: boolean;
  115140. /**
  115141. * Defines if webaudio should be initialized as well
  115142. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115143. */
  115144. audioEngine?: boolean;
  115145. /**
  115146. * Defines if animations should run using a deterministic lock step
  115147. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115148. */
  115149. deterministicLockstep?: boolean;
  115150. /** Defines the maximum steps to use with deterministic lock step mode */
  115151. lockstepMaxSteps?: number;
  115152. /** Defines the seconds between each deterministic lock step */
  115153. timeStep?: number;
  115154. /**
  115155. * Defines that engine should ignore context lost events
  115156. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  115157. */
  115158. doNotHandleContextLost?: boolean;
  115159. /**
  115160. * Defines that engine should ignore modifying touch action attribute and style
  115161. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  115162. */
  115163. doNotHandleTouchAction?: boolean;
  115164. /**
  115165. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  115166. */
  115167. useHighPrecisionFloats?: boolean;
  115168. /**
  115169. * Make the canvas XR Compatible for XR sessions
  115170. */
  115171. xrCompatible?: boolean;
  115172. /**
  115173. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  115174. */
  115175. useHighPrecisionMatrix?: boolean;
  115176. }
  115177. /**
  115178. * The base engine class (root of all engines)
  115179. */
  115180. export class ThinEngine {
  115181. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  115182. static ExceptionList: ({
  115183. key: string;
  115184. capture: string;
  115185. captureConstraint: number;
  115186. targets: string[];
  115187. } | {
  115188. key: string;
  115189. capture: null;
  115190. captureConstraint: null;
  115191. targets: string[];
  115192. })[];
  115193. /** @hidden */
  115194. static _TextureLoaders: IInternalTextureLoader[];
  115195. /**
  115196. * Returns the current npm package of the sdk
  115197. */
  115198. static get NpmPackage(): string;
  115199. /**
  115200. * Returns the current version of the framework
  115201. */
  115202. static get Version(): string;
  115203. /**
  115204. * Returns a string describing the current engine
  115205. */
  115206. get description(): string;
  115207. /**
  115208. * Gets or sets the epsilon value used by collision engine
  115209. */
  115210. static CollisionsEpsilon: number;
  115211. /**
  115212. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  115213. */
  115214. static get ShadersRepository(): string;
  115215. static set ShadersRepository(value: string);
  115216. /** @hidden */
  115217. _shaderProcessor: IShaderProcessor;
  115218. /**
  115219. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  115220. */
  115221. forcePOTTextures: boolean;
  115222. /**
  115223. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  115224. */
  115225. isFullscreen: boolean;
  115226. /**
  115227. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  115228. */
  115229. cullBackFaces: boolean;
  115230. /**
  115231. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  115232. */
  115233. renderEvenInBackground: boolean;
  115234. /**
  115235. * Gets or sets a boolean indicating that cache can be kept between frames
  115236. */
  115237. preventCacheWipeBetweenFrames: boolean;
  115238. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  115239. validateShaderPrograms: boolean;
  115240. /**
  115241. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  115242. * This can provide greater z depth for distant objects.
  115243. */
  115244. useReverseDepthBuffer: boolean;
  115245. /**
  115246. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  115247. */
  115248. disableUniformBuffers: boolean;
  115249. /** @hidden */
  115250. _uniformBuffers: UniformBuffer[];
  115251. /**
  115252. * Gets a boolean indicating that the engine supports uniform buffers
  115253. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  115254. */
  115255. get supportsUniformBuffers(): boolean;
  115256. /** @hidden */
  115257. _gl: WebGLRenderingContext;
  115258. /** @hidden */
  115259. _webGLVersion: number;
  115260. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  115261. protected _windowIsBackground: boolean;
  115262. protected _creationOptions: EngineOptions;
  115263. protected _highPrecisionShadersAllowed: boolean;
  115264. /** @hidden */
  115265. get _shouldUseHighPrecisionShader(): boolean;
  115266. /**
  115267. * Gets a boolean indicating that only power of 2 textures are supported
  115268. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  115269. */
  115270. get needPOTTextures(): boolean;
  115271. /** @hidden */
  115272. _badOS: boolean;
  115273. /** @hidden */
  115274. _badDesktopOS: boolean;
  115275. private _hardwareScalingLevel;
  115276. /** @hidden */
  115277. _caps: EngineCapabilities;
  115278. private _isStencilEnable;
  115279. private _glVersion;
  115280. private _glRenderer;
  115281. private _glVendor;
  115282. /** @hidden */
  115283. _videoTextureSupported: boolean;
  115284. protected _renderingQueueLaunched: boolean;
  115285. protected _activeRenderLoops: (() => void)[];
  115286. /**
  115287. * Observable signaled when a context lost event is raised
  115288. */
  115289. onContextLostObservable: Observable<ThinEngine>;
  115290. /**
  115291. * Observable signaled when a context restored event is raised
  115292. */
  115293. onContextRestoredObservable: Observable<ThinEngine>;
  115294. private _onContextLost;
  115295. private _onContextRestored;
  115296. protected _contextWasLost: boolean;
  115297. /** @hidden */
  115298. _doNotHandleContextLost: boolean;
  115299. /**
  115300. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  115301. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  115302. */
  115303. get doNotHandleContextLost(): boolean;
  115304. set doNotHandleContextLost(value: boolean);
  115305. /**
  115306. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  115307. */
  115308. disableVertexArrayObjects: boolean;
  115309. /** @hidden */
  115310. protected _colorWrite: boolean;
  115311. /** @hidden */
  115312. protected _colorWriteChanged: boolean;
  115313. /** @hidden */
  115314. protected _depthCullingState: DepthCullingState;
  115315. /** @hidden */
  115316. protected _stencilState: StencilState;
  115317. /** @hidden */
  115318. _alphaState: AlphaState;
  115319. /** @hidden */
  115320. _alphaMode: number;
  115321. /** @hidden */
  115322. _alphaEquation: number;
  115323. /** @hidden */
  115324. _internalTexturesCache: InternalTexture[];
  115325. /** @hidden */
  115326. protected _activeChannel: number;
  115327. private _currentTextureChannel;
  115328. /** @hidden */
  115329. protected _boundTexturesCache: {
  115330. [key: string]: Nullable<InternalTexture>;
  115331. };
  115332. /** @hidden */
  115333. protected _currentEffect: Nullable<Effect>;
  115334. /** @hidden */
  115335. protected _currentProgram: Nullable<WebGLProgram>;
  115336. private _compiledEffects;
  115337. private _vertexAttribArraysEnabled;
  115338. /** @hidden */
  115339. protected _cachedViewport: Nullable<IViewportLike>;
  115340. private _cachedVertexArrayObject;
  115341. /** @hidden */
  115342. protected _cachedVertexBuffers: any;
  115343. /** @hidden */
  115344. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  115345. /** @hidden */
  115346. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  115347. /** @hidden */
  115348. _currentRenderTarget: Nullable<InternalTexture>;
  115349. private _uintIndicesCurrentlySet;
  115350. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  115351. /** @hidden */
  115352. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  115353. /** @hidden */
  115354. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  115355. private _currentBufferPointers;
  115356. private _currentInstanceLocations;
  115357. private _currentInstanceBuffers;
  115358. private _textureUnits;
  115359. /** @hidden */
  115360. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115361. /** @hidden */
  115362. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115363. /** @hidden */
  115364. _boundRenderFunction: any;
  115365. private _vaoRecordInProgress;
  115366. private _mustWipeVertexAttributes;
  115367. private _emptyTexture;
  115368. private _emptyCubeTexture;
  115369. private _emptyTexture3D;
  115370. private _emptyTexture2DArray;
  115371. /** @hidden */
  115372. _frameHandler: number;
  115373. private _nextFreeTextureSlots;
  115374. private _maxSimultaneousTextures;
  115375. private _activeRequests;
  115376. /** @hidden */
  115377. _transformTextureUrl: Nullable<(url: string) => string>;
  115378. /**
  115379. * Gets information about the current host
  115380. */
  115381. hostInformation: HostInformation;
  115382. protected get _supportsHardwareTextureRescaling(): boolean;
  115383. private _framebufferDimensionsObject;
  115384. /**
  115385. * sets the object from which width and height will be taken from when getting render width and height
  115386. * Will fallback to the gl object
  115387. * @param dimensions the framebuffer width and height that will be used.
  115388. */
  115389. set framebufferDimensionsObject(dimensions: Nullable<{
  115390. framebufferWidth: number;
  115391. framebufferHeight: number;
  115392. }>);
  115393. /**
  115394. * Gets the current viewport
  115395. */
  115396. get currentViewport(): Nullable<IViewportLike>;
  115397. /**
  115398. * Gets the default empty texture
  115399. */
  115400. get emptyTexture(): InternalTexture;
  115401. /**
  115402. * Gets the default empty 3D texture
  115403. */
  115404. get emptyTexture3D(): InternalTexture;
  115405. /**
  115406. * Gets the default empty 2D array texture
  115407. */
  115408. get emptyTexture2DArray(): InternalTexture;
  115409. /**
  115410. * Gets the default empty cube texture
  115411. */
  115412. get emptyCubeTexture(): InternalTexture;
  115413. /**
  115414. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  115415. */
  115416. readonly premultipliedAlpha: boolean;
  115417. /**
  115418. * Observable event triggered before each texture is initialized
  115419. */
  115420. onBeforeTextureInitObservable: Observable<Texture>;
  115421. /**
  115422. * Creates a new engine
  115423. * @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
  115424. * @param antialias defines enable antialiasing (default: false)
  115425. * @param options defines further options to be sent to the getContext() function
  115426. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  115427. */
  115428. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  115429. private _rebuildInternalTextures;
  115430. private _rebuildEffects;
  115431. /**
  115432. * Gets a boolean indicating if all created effects are ready
  115433. * @returns true if all effects are ready
  115434. */
  115435. areAllEffectsReady(): boolean;
  115436. protected _rebuildBuffers(): void;
  115437. protected _initGLContext(): void;
  115438. /**
  115439. * Gets version of the current webGL context
  115440. */
  115441. get webGLVersion(): number;
  115442. /**
  115443. * Gets a string identifying the name of the class
  115444. * @returns "Engine" string
  115445. */
  115446. getClassName(): string;
  115447. /**
  115448. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  115449. */
  115450. get isStencilEnable(): boolean;
  115451. /** @hidden */
  115452. _prepareWorkingCanvas(): void;
  115453. /**
  115454. * Reset the texture cache to empty state
  115455. */
  115456. resetTextureCache(): void;
  115457. /**
  115458. * Gets an object containing information about the current webGL context
  115459. * @returns an object containing the vender, the renderer and the version of the current webGL context
  115460. */
  115461. getGlInfo(): {
  115462. vendor: string;
  115463. renderer: string;
  115464. version: string;
  115465. };
  115466. /**
  115467. * Defines the hardware scaling level.
  115468. * By default the hardware scaling level is computed from the window device ratio.
  115469. * 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.
  115470. * @param level defines the level to use
  115471. */
  115472. setHardwareScalingLevel(level: number): void;
  115473. /**
  115474. * Gets the current hardware scaling level.
  115475. * By default the hardware scaling level is computed from the window device ratio.
  115476. * 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.
  115477. * @returns a number indicating the current hardware scaling level
  115478. */
  115479. getHardwareScalingLevel(): number;
  115480. /**
  115481. * Gets the list of loaded textures
  115482. * @returns an array containing all loaded textures
  115483. */
  115484. getLoadedTexturesCache(): InternalTexture[];
  115485. /**
  115486. * Gets the object containing all engine capabilities
  115487. * @returns the EngineCapabilities object
  115488. */
  115489. getCaps(): EngineCapabilities;
  115490. /**
  115491. * stop executing a render loop function and remove it from the execution array
  115492. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  115493. */
  115494. stopRenderLoop(renderFunction?: () => void): void;
  115495. /** @hidden */
  115496. _renderLoop(): void;
  115497. /**
  115498. * Gets the HTML canvas attached with the current webGL context
  115499. * @returns a HTML canvas
  115500. */
  115501. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  115502. /**
  115503. * Gets host window
  115504. * @returns the host window object
  115505. */
  115506. getHostWindow(): Nullable<Window>;
  115507. /**
  115508. * Gets the current render width
  115509. * @param useScreen defines if screen size must be used (or the current render target if any)
  115510. * @returns a number defining the current render width
  115511. */
  115512. getRenderWidth(useScreen?: boolean): number;
  115513. /**
  115514. * Gets the current render height
  115515. * @param useScreen defines if screen size must be used (or the current render target if any)
  115516. * @returns a number defining the current render height
  115517. */
  115518. getRenderHeight(useScreen?: boolean): number;
  115519. /**
  115520. * Can be used to override the current requestAnimationFrame requester.
  115521. * @hidden
  115522. */
  115523. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  115524. /**
  115525. * Register and execute a render loop. The engine can have more than one render function
  115526. * @param renderFunction defines the function to continuously execute
  115527. */
  115528. runRenderLoop(renderFunction: () => void): void;
  115529. /**
  115530. * Clear the current render buffer or the current render target (if any is set up)
  115531. * @param color defines the color to use
  115532. * @param backBuffer defines if the back buffer must be cleared
  115533. * @param depth defines if the depth buffer must be cleared
  115534. * @param stencil defines if the stencil buffer must be cleared
  115535. */
  115536. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  115537. private _viewportCached;
  115538. /** @hidden */
  115539. _viewport(x: number, y: number, width: number, height: number): void;
  115540. /**
  115541. * Set the WebGL's viewport
  115542. * @param viewport defines the viewport element to be used
  115543. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  115544. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  115545. */
  115546. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  115547. /**
  115548. * Begin a new frame
  115549. */
  115550. beginFrame(): void;
  115551. /**
  115552. * Enf the current frame
  115553. */
  115554. endFrame(): void;
  115555. /**
  115556. * Resize the view according to the canvas' size
  115557. */
  115558. resize(): void;
  115559. /**
  115560. * Force a specific size of the canvas
  115561. * @param width defines the new canvas' width
  115562. * @param height defines the new canvas' height
  115563. * @returns true if the size was changed
  115564. */
  115565. setSize(width: number, height: number): boolean;
  115566. /**
  115567. * Binds the frame buffer to the specified texture.
  115568. * @param texture The texture to render to or null for the default canvas
  115569. * @param faceIndex The face of the texture to render to in case of cube texture
  115570. * @param requiredWidth The width of the target to render to
  115571. * @param requiredHeight The height of the target to render to
  115572. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  115573. * @param lodLevel defines the lod level to bind to the frame buffer
  115574. * @param layer defines the 2d array index to bind to frame buffer to
  115575. */
  115576. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  115577. /** @hidden */
  115578. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  115579. /**
  115580. * Unbind the current render target texture from the webGL context
  115581. * @param texture defines the render target texture to unbind
  115582. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  115583. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  115584. */
  115585. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  115586. /**
  115587. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  115588. */
  115589. flushFramebuffer(): void;
  115590. /**
  115591. * Unbind the current render target and bind the default framebuffer
  115592. */
  115593. restoreDefaultFramebuffer(): void;
  115594. /** @hidden */
  115595. protected _resetVertexBufferBinding(): void;
  115596. /**
  115597. * Creates a vertex buffer
  115598. * @param data the data for the vertex buffer
  115599. * @returns the new WebGL static buffer
  115600. */
  115601. createVertexBuffer(data: DataArray): DataBuffer;
  115602. private _createVertexBuffer;
  115603. /**
  115604. * Creates a dynamic vertex buffer
  115605. * @param data the data for the dynamic vertex buffer
  115606. * @returns the new WebGL dynamic buffer
  115607. */
  115608. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  115609. protected _resetIndexBufferBinding(): void;
  115610. /**
  115611. * Creates a new index buffer
  115612. * @param indices defines the content of the index buffer
  115613. * @param updatable defines if the index buffer must be updatable
  115614. * @returns a new webGL buffer
  115615. */
  115616. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  115617. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  115618. /**
  115619. * Bind a webGL buffer to the webGL context
  115620. * @param buffer defines the buffer to bind
  115621. */
  115622. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  115623. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  115624. private bindBuffer;
  115625. /**
  115626. * update the bound buffer with the given data
  115627. * @param data defines the data to update
  115628. */
  115629. updateArrayBuffer(data: Float32Array): void;
  115630. private _vertexAttribPointer;
  115631. /** @hidden */
  115632. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  115633. private _bindVertexBuffersAttributes;
  115634. /**
  115635. * Records a vertex array object
  115636. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  115637. * @param vertexBuffers defines the list of vertex buffers to store
  115638. * @param indexBuffer defines the index buffer to store
  115639. * @param effect defines the effect to store
  115640. * @returns the new vertex array object
  115641. */
  115642. recordVertexArrayObject(vertexBuffers: {
  115643. [key: string]: VertexBuffer;
  115644. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  115645. /**
  115646. * Bind a specific vertex array object
  115647. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  115648. * @param vertexArrayObject defines the vertex array object to bind
  115649. * @param indexBuffer defines the index buffer to bind
  115650. */
  115651. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  115652. /**
  115653. * Bind webGl buffers directly to the webGL context
  115654. * @param vertexBuffer defines the vertex buffer to bind
  115655. * @param indexBuffer defines the index buffer to bind
  115656. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  115657. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  115658. * @param effect defines the effect associated with the vertex buffer
  115659. */
  115660. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  115661. private _unbindVertexArrayObject;
  115662. /**
  115663. * Bind a list of vertex buffers to the webGL context
  115664. * @param vertexBuffers defines the list of vertex buffers to bind
  115665. * @param indexBuffer defines the index buffer to bind
  115666. * @param effect defines the effect associated with the vertex buffers
  115667. */
  115668. bindBuffers(vertexBuffers: {
  115669. [key: string]: Nullable<VertexBuffer>;
  115670. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  115671. /**
  115672. * Unbind all instance attributes
  115673. */
  115674. unbindInstanceAttributes(): void;
  115675. /**
  115676. * Release and free the memory of a vertex array object
  115677. * @param vao defines the vertex array object to delete
  115678. */
  115679. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  115680. /** @hidden */
  115681. _releaseBuffer(buffer: DataBuffer): boolean;
  115682. protected _deleteBuffer(buffer: DataBuffer): void;
  115683. /**
  115684. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  115685. * @param instancesBuffer defines the webGL buffer to update and bind
  115686. * @param data defines the data to store in the buffer
  115687. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  115688. */
  115689. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  115690. /**
  115691. * Bind the content of a webGL buffer used with instantiation
  115692. * @param instancesBuffer defines the webGL buffer to bind
  115693. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  115694. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  115695. */
  115696. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  115697. /**
  115698. * Disable the instance attribute corresponding to the name in parameter
  115699. * @param name defines the name of the attribute to disable
  115700. */
  115701. disableInstanceAttributeByName(name: string): void;
  115702. /**
  115703. * Disable the instance attribute corresponding to the location in parameter
  115704. * @param attributeLocation defines the attribute location of the attribute to disable
  115705. */
  115706. disableInstanceAttribute(attributeLocation: number): void;
  115707. /**
  115708. * Disable the attribute corresponding to the location in parameter
  115709. * @param attributeLocation defines the attribute location of the attribute to disable
  115710. */
  115711. disableAttributeByIndex(attributeLocation: number): void;
  115712. /**
  115713. * Send a draw order
  115714. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115715. * @param indexStart defines the starting index
  115716. * @param indexCount defines the number of index to draw
  115717. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115718. */
  115719. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  115720. /**
  115721. * Draw a list of points
  115722. * @param verticesStart defines the index of first vertex to draw
  115723. * @param verticesCount defines the count of vertices to draw
  115724. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115725. */
  115726. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115727. /**
  115728. * Draw a list of unindexed primitives
  115729. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115730. * @param verticesStart defines the index of first vertex to draw
  115731. * @param verticesCount defines the count of vertices to draw
  115732. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115733. */
  115734. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115735. /**
  115736. * Draw a list of indexed primitives
  115737. * @param fillMode defines the primitive to use
  115738. * @param indexStart defines the starting index
  115739. * @param indexCount defines the number of index to draw
  115740. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115741. */
  115742. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  115743. /**
  115744. * Draw a list of unindexed primitives
  115745. * @param fillMode defines the primitive to use
  115746. * @param verticesStart defines the index of first vertex to draw
  115747. * @param verticesCount defines the count of vertices to draw
  115748. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115749. */
  115750. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115751. private _drawMode;
  115752. /** @hidden */
  115753. protected _reportDrawCall(): void;
  115754. /** @hidden */
  115755. _releaseEffect(effect: Effect): void;
  115756. /** @hidden */
  115757. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115758. /**
  115759. * Create a new effect (used to store vertex/fragment shaders)
  115760. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  115761. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  115762. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  115763. * @param samplers defines an array of string used to represent textures
  115764. * @param defines defines the string containing the defines to use to compile the shaders
  115765. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  115766. * @param onCompiled defines a function to call when the effect creation is successful
  115767. * @param onError defines a function to call when the effect creation has failed
  115768. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  115769. * @returns the new Effect
  115770. */
  115771. 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;
  115772. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  115773. private _compileShader;
  115774. private _compileRawShader;
  115775. /** @hidden */
  115776. _getShaderSource(shader: WebGLShader): Nullable<string>;
  115777. /**
  115778. * Directly creates a webGL program
  115779. * @param pipelineContext defines the pipeline context to attach to
  115780. * @param vertexCode defines the vertex shader code to use
  115781. * @param fragmentCode defines the fragment shader code to use
  115782. * @param context defines the webGL context to use (if not set, the current one will be used)
  115783. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  115784. * @returns the new webGL program
  115785. */
  115786. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115787. /**
  115788. * Creates a webGL program
  115789. * @param pipelineContext defines the pipeline context to attach to
  115790. * @param vertexCode defines the vertex shader code to use
  115791. * @param fragmentCode defines the fragment shader code to use
  115792. * @param defines defines the string containing the defines to use to compile the shaders
  115793. * @param context defines the webGL context to use (if not set, the current one will be used)
  115794. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  115795. * @returns the new webGL program
  115796. */
  115797. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115798. /**
  115799. * Creates a new pipeline context
  115800. * @returns the new pipeline
  115801. */
  115802. createPipelineContext(): IPipelineContext;
  115803. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115804. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  115805. /** @hidden */
  115806. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  115807. /** @hidden */
  115808. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  115809. /** @hidden */
  115810. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  115811. /**
  115812. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  115813. * @param pipelineContext defines the pipeline context to use
  115814. * @param uniformsNames defines the list of uniform names
  115815. * @returns an array of webGL uniform locations
  115816. */
  115817. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  115818. /**
  115819. * Gets the lsit of active attributes for a given webGL program
  115820. * @param pipelineContext defines the pipeline context to use
  115821. * @param attributesNames defines the list of attribute names to get
  115822. * @returns an array of indices indicating the offset of each attribute
  115823. */
  115824. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  115825. /**
  115826. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  115827. * @param effect defines the effect to activate
  115828. */
  115829. enableEffect(effect: Nullable<Effect>): void;
  115830. /**
  115831. * Set the value of an uniform to a number (int)
  115832. * @param uniform defines the webGL uniform location where to store the value
  115833. * @param value defines the int number to store
  115834. */
  115835. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  115836. /**
  115837. * Set the value of an uniform to an array of int32
  115838. * @param uniform defines the webGL uniform location where to store the value
  115839. * @param array defines the array of int32 to store
  115840. */
  115841. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115842. /**
  115843. * Set the value of an uniform to an array of int32 (stored as vec2)
  115844. * @param uniform defines the webGL uniform location where to store the value
  115845. * @param array defines the array of int32 to store
  115846. */
  115847. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115848. /**
  115849. * Set the value of an uniform to an array of int32 (stored as vec3)
  115850. * @param uniform defines the webGL uniform location where to store the value
  115851. * @param array defines the array of int32 to store
  115852. */
  115853. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115854. /**
  115855. * Set the value of an uniform to an array of int32 (stored as vec4)
  115856. * @param uniform defines the webGL uniform location where to store the value
  115857. * @param array defines the array of int32 to store
  115858. */
  115859. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115860. /**
  115861. * Set the value of an uniform to an array of number
  115862. * @param uniform defines the webGL uniform location where to store the value
  115863. * @param array defines the array of number to store
  115864. */
  115865. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115866. /**
  115867. * Set the value of an uniform to an array of number (stored as vec2)
  115868. * @param uniform defines the webGL uniform location where to store the value
  115869. * @param array defines the array of number to store
  115870. */
  115871. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115872. /**
  115873. * Set the value of an uniform to an array of number (stored as vec3)
  115874. * @param uniform defines the webGL uniform location where to store the value
  115875. * @param array defines the array of number to store
  115876. */
  115877. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115878. /**
  115879. * Set the value of an uniform to an array of number (stored as vec4)
  115880. * @param uniform defines the webGL uniform location where to store the value
  115881. * @param array defines the array of number to store
  115882. */
  115883. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115884. /**
  115885. * Set the value of an uniform to an array of float32 (stored as matrices)
  115886. * @param uniform defines the webGL uniform location where to store the value
  115887. * @param matrices defines the array of float32 to store
  115888. */
  115889. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  115890. /**
  115891. * Set the value of an uniform to a matrix (3x3)
  115892. * @param uniform defines the webGL uniform location where to store the value
  115893. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  115894. */
  115895. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  115896. /**
  115897. * Set the value of an uniform to a matrix (2x2)
  115898. * @param uniform defines the webGL uniform location where to store the value
  115899. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  115900. */
  115901. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  115902. /**
  115903. * Set the value of an uniform to a number (float)
  115904. * @param uniform defines the webGL uniform location where to store the value
  115905. * @param value defines the float number to store
  115906. */
  115907. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  115908. /**
  115909. * Set the value of an uniform to a vec2
  115910. * @param uniform defines the webGL uniform location where to store the value
  115911. * @param x defines the 1st component of the value
  115912. * @param y defines the 2nd component of the value
  115913. */
  115914. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  115915. /**
  115916. * Set the value of an uniform to a vec3
  115917. * @param uniform defines the webGL uniform location where to store the value
  115918. * @param x defines the 1st component of the value
  115919. * @param y defines the 2nd component of the value
  115920. * @param z defines the 3rd component of the value
  115921. */
  115922. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  115923. /**
  115924. * Set the value of an uniform to a vec4
  115925. * @param uniform defines the webGL uniform location where to store the value
  115926. * @param x defines the 1st component of the value
  115927. * @param y defines the 2nd component of the value
  115928. * @param z defines the 3rd component of the value
  115929. * @param w defines the 4th component of the value
  115930. */
  115931. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  115932. /**
  115933. * Apply all cached states (depth, culling, stencil and alpha)
  115934. */
  115935. applyStates(): void;
  115936. /**
  115937. * Enable or disable color writing
  115938. * @param enable defines the state to set
  115939. */
  115940. setColorWrite(enable: boolean): void;
  115941. /**
  115942. * Gets a boolean indicating if color writing is enabled
  115943. * @returns the current color writing state
  115944. */
  115945. getColorWrite(): boolean;
  115946. /**
  115947. * Gets the depth culling state manager
  115948. */
  115949. get depthCullingState(): DepthCullingState;
  115950. /**
  115951. * Gets the alpha state manager
  115952. */
  115953. get alphaState(): AlphaState;
  115954. /**
  115955. * Gets the stencil state manager
  115956. */
  115957. get stencilState(): StencilState;
  115958. /**
  115959. * Clears the list of texture accessible through engine.
  115960. * This can help preventing texture load conflict due to name collision.
  115961. */
  115962. clearInternalTexturesCache(): void;
  115963. /**
  115964. * Force the entire cache to be cleared
  115965. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  115966. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  115967. */
  115968. wipeCaches(bruteForce?: boolean): void;
  115969. /** @hidden */
  115970. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  115971. min: number;
  115972. mag: number;
  115973. };
  115974. /** @hidden */
  115975. _createTexture(): WebGLTexture;
  115976. /**
  115977. * Usually called from Texture.ts.
  115978. * Passed information to create a WebGLTexture
  115979. * @param url defines a value which contains one of the following:
  115980. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  115981. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  115982. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  115983. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  115984. * @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)
  115985. * @param scene needed for loading to the correct scene
  115986. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  115987. * @param onLoad optional callback to be called upon successful completion
  115988. * @param onError optional callback to be called upon failure
  115989. * @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
  115990. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  115991. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  115992. * @param forcedExtension defines the extension to use to pick the right loader
  115993. * @param mimeType defines an optional mime type
  115994. * @returns a InternalTexture for assignment back into BABYLON.Texture
  115995. */
  115996. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  115997. /**
  115998. * Loads an image as an HTMLImageElement.
  115999. * @param input url string, ArrayBuffer, or Blob to load
  116000. * @param onLoad callback called when the image successfully loads
  116001. * @param onError callback called when the image fails to load
  116002. * @param offlineProvider offline provider for caching
  116003. * @param mimeType optional mime type
  116004. * @returns the HTMLImageElement of the loaded image
  116005. * @hidden
  116006. */
  116007. 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>;
  116008. /**
  116009. * @hidden
  116010. */
  116011. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116012. private _unpackFlipYCached;
  116013. /**
  116014. * In case you are sharing the context with other applications, it might
  116015. * be interested to not cache the unpack flip y state to ensure a consistent
  116016. * value would be set.
  116017. */
  116018. enableUnpackFlipYCached: boolean;
  116019. /** @hidden */
  116020. _unpackFlipY(value: boolean): void;
  116021. /** @hidden */
  116022. _getUnpackAlignement(): number;
  116023. private _getTextureTarget;
  116024. /**
  116025. * Update the sampling mode of a given texture
  116026. * @param samplingMode defines the required sampling mode
  116027. * @param texture defines the texture to update
  116028. * @param generateMipMaps defines whether to generate mipmaps for the texture
  116029. */
  116030. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  116031. /**
  116032. * Update the sampling mode of a given texture
  116033. * @param texture defines the texture to update
  116034. * @param wrapU defines the texture wrap mode of the u coordinates
  116035. * @param wrapV defines the texture wrap mode of the v coordinates
  116036. * @param wrapR defines the texture wrap mode of the r coordinates
  116037. */
  116038. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  116039. /** @hidden */
  116040. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  116041. width: number;
  116042. height: number;
  116043. layers?: number;
  116044. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  116045. /** @hidden */
  116046. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116047. /** @hidden */
  116048. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  116049. /**
  116050. * Update a portion of an internal texture
  116051. * @param texture defines the texture to update
  116052. * @param imageData defines the data to store into the texture
  116053. * @param xOffset defines the x coordinates of the update rectangle
  116054. * @param yOffset defines the y coordinates of the update rectangle
  116055. * @param width defines the width of the update rectangle
  116056. * @param height defines the height of the update rectangle
  116057. * @param faceIndex defines the face index if texture is a cube (0 by default)
  116058. * @param lod defines the lod level to update (0 by default)
  116059. */
  116060. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  116061. /** @hidden */
  116062. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116063. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  116064. private _prepareWebGLTexture;
  116065. /** @hidden */
  116066. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  116067. private _getDepthStencilBuffer;
  116068. /** @hidden */
  116069. _releaseFramebufferObjects(texture: InternalTexture): void;
  116070. /** @hidden */
  116071. _releaseTexture(texture: InternalTexture): void;
  116072. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  116073. protected _setProgram(program: WebGLProgram): void;
  116074. protected _boundUniforms: {
  116075. [key: number]: WebGLUniformLocation;
  116076. };
  116077. /**
  116078. * Binds an effect to the webGL context
  116079. * @param effect defines the effect to bind
  116080. */
  116081. bindSamplers(effect: Effect): void;
  116082. private _activateCurrentTexture;
  116083. /** @hidden */
  116084. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  116085. /** @hidden */
  116086. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  116087. /**
  116088. * Unbind all textures from the webGL context
  116089. */
  116090. unbindAllTextures(): void;
  116091. /**
  116092. * Sets a texture to the according uniform.
  116093. * @param channel The texture channel
  116094. * @param uniform The uniform to set
  116095. * @param texture The texture to apply
  116096. */
  116097. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  116098. private _bindSamplerUniformToChannel;
  116099. private _getTextureWrapMode;
  116100. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  116101. /**
  116102. * Sets an array of texture to the webGL context
  116103. * @param channel defines the channel where the texture array must be set
  116104. * @param uniform defines the associated uniform location
  116105. * @param textures defines the array of textures to bind
  116106. */
  116107. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  116108. /** @hidden */
  116109. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  116110. private _setTextureParameterFloat;
  116111. private _setTextureParameterInteger;
  116112. /**
  116113. * Unbind all vertex attributes from the webGL context
  116114. */
  116115. unbindAllAttributes(): void;
  116116. /**
  116117. * 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
  116118. */
  116119. releaseEffects(): void;
  116120. /**
  116121. * Dispose and release all associated resources
  116122. */
  116123. dispose(): void;
  116124. /**
  116125. * Attach a new callback raised when context lost event is fired
  116126. * @param callback defines the callback to call
  116127. */
  116128. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116129. /**
  116130. * Attach a new callback raised when context restored event is fired
  116131. * @param callback defines the callback to call
  116132. */
  116133. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116134. /**
  116135. * Get the current error code of the webGL context
  116136. * @returns the error code
  116137. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116138. */
  116139. getError(): number;
  116140. private _canRenderToFloatFramebuffer;
  116141. private _canRenderToHalfFloatFramebuffer;
  116142. private _canRenderToFramebuffer;
  116143. /** @hidden */
  116144. _getWebGLTextureType(type: number): number;
  116145. /** @hidden */
  116146. _getInternalFormat(format: number): number;
  116147. /** @hidden */
  116148. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  116149. /** @hidden */
  116150. _getRGBAMultiSampleBufferFormat(type: number): number;
  116151. /** @hidden */
  116152. _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;
  116153. /**
  116154. * Loads a file from a url
  116155. * @param url url to load
  116156. * @param onSuccess callback called when the file successfully loads
  116157. * @param onProgress callback called while file is loading (if the server supports this mode)
  116158. * @param offlineProvider defines the offline provider for caching
  116159. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116160. * @param onError callback called when the file fails to load
  116161. * @returns a file request object
  116162. * @hidden
  116163. */
  116164. 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;
  116165. /**
  116166. * Reads pixels from the current frame buffer. Please note that this function can be slow
  116167. * @param x defines the x coordinate of the rectangle where pixels must be read
  116168. * @param y defines the y coordinate of the rectangle where pixels must be read
  116169. * @param width defines the width of the rectangle where pixels must be read
  116170. * @param height defines the height of the rectangle where pixels must be read
  116171. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  116172. * @returns a Uint8Array containing RGBA colors
  116173. */
  116174. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  116175. private static _isSupported;
  116176. /**
  116177. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116178. * @returns true if the engine can be created
  116179. * @ignorenaming
  116180. */
  116181. static isSupported(): boolean;
  116182. /**
  116183. * Find the next highest power of two.
  116184. * @param x Number to start search from.
  116185. * @return Next highest power of two.
  116186. */
  116187. static CeilingPOT(x: number): number;
  116188. /**
  116189. * Find the next lowest power of two.
  116190. * @param x Number to start search from.
  116191. * @return Next lowest power of two.
  116192. */
  116193. static FloorPOT(x: number): number;
  116194. /**
  116195. * Find the nearest power of two.
  116196. * @param x Number to start search from.
  116197. * @return Next nearest power of two.
  116198. */
  116199. static NearestPOT(x: number): number;
  116200. /**
  116201. * Get the closest exponent of two
  116202. * @param value defines the value to approximate
  116203. * @param max defines the maximum value to return
  116204. * @param mode defines how to define the closest value
  116205. * @returns closest exponent of two of the given value
  116206. */
  116207. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  116208. /**
  116209. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  116210. * @param func - the function to be called
  116211. * @param requester - the object that will request the next frame. Falls back to window.
  116212. * @returns frame number
  116213. */
  116214. static QueueNewFrame(func: () => void, requester?: any): number;
  116215. /**
  116216. * Gets host document
  116217. * @returns the host document object
  116218. */
  116219. getHostDocument(): Nullable<Document>;
  116220. }
  116221. }
  116222. declare module BABYLON {
  116223. /**
  116224. * Class representing spherical harmonics coefficients to the 3rd degree
  116225. */
  116226. export class SphericalHarmonics {
  116227. /**
  116228. * Defines whether or not the harmonics have been prescaled for rendering.
  116229. */
  116230. preScaled: boolean;
  116231. /**
  116232. * The l0,0 coefficients of the spherical harmonics
  116233. */
  116234. l00: Vector3;
  116235. /**
  116236. * The l1,-1 coefficients of the spherical harmonics
  116237. */
  116238. l1_1: Vector3;
  116239. /**
  116240. * The l1,0 coefficients of the spherical harmonics
  116241. */
  116242. l10: Vector3;
  116243. /**
  116244. * The l1,1 coefficients of the spherical harmonics
  116245. */
  116246. l11: Vector3;
  116247. /**
  116248. * The l2,-2 coefficients of the spherical harmonics
  116249. */
  116250. l2_2: Vector3;
  116251. /**
  116252. * The l2,-1 coefficients of the spherical harmonics
  116253. */
  116254. l2_1: Vector3;
  116255. /**
  116256. * The l2,0 coefficients of the spherical harmonics
  116257. */
  116258. l20: Vector3;
  116259. /**
  116260. * The l2,1 coefficients of the spherical harmonics
  116261. */
  116262. l21: Vector3;
  116263. /**
  116264. * The l2,2 coefficients of the spherical harmonics
  116265. */
  116266. l22: Vector3;
  116267. /**
  116268. * Adds a light to the spherical harmonics
  116269. * @param direction the direction of the light
  116270. * @param color the color of the light
  116271. * @param deltaSolidAngle the delta solid angle of the light
  116272. */
  116273. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  116274. /**
  116275. * Scales the spherical harmonics by the given amount
  116276. * @param scale the amount to scale
  116277. */
  116278. scaleInPlace(scale: number): void;
  116279. /**
  116280. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  116281. *
  116282. * ```
  116283. * E_lm = A_l * L_lm
  116284. * ```
  116285. *
  116286. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  116287. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  116288. * the scaling factors are given in equation 9.
  116289. */
  116290. convertIncidentRadianceToIrradiance(): void;
  116291. /**
  116292. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  116293. *
  116294. * ```
  116295. * L = (1/pi) * E * rho
  116296. * ```
  116297. *
  116298. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  116299. */
  116300. convertIrradianceToLambertianRadiance(): void;
  116301. /**
  116302. * Integrates the reconstruction coefficients directly in to the SH preventing further
  116303. * required operations at run time.
  116304. *
  116305. * This is simply done by scaling back the SH with Ylm constants parameter.
  116306. * The trigonometric part being applied by the shader at run time.
  116307. */
  116308. preScaleForRendering(): void;
  116309. /**
  116310. * Constructs a spherical harmonics from an array.
  116311. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  116312. * @returns the spherical harmonics
  116313. */
  116314. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  116315. /**
  116316. * Gets the spherical harmonics from polynomial
  116317. * @param polynomial the spherical polynomial
  116318. * @returns the spherical harmonics
  116319. */
  116320. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  116321. }
  116322. /**
  116323. * Class representing spherical polynomial coefficients to the 3rd degree
  116324. */
  116325. export class SphericalPolynomial {
  116326. private _harmonics;
  116327. /**
  116328. * The spherical harmonics used to create the polynomials.
  116329. */
  116330. get preScaledHarmonics(): SphericalHarmonics;
  116331. /**
  116332. * The x coefficients of the spherical polynomial
  116333. */
  116334. x: Vector3;
  116335. /**
  116336. * The y coefficients of the spherical polynomial
  116337. */
  116338. y: Vector3;
  116339. /**
  116340. * The z coefficients of the spherical polynomial
  116341. */
  116342. z: Vector3;
  116343. /**
  116344. * The xx coefficients of the spherical polynomial
  116345. */
  116346. xx: Vector3;
  116347. /**
  116348. * The yy coefficients of the spherical polynomial
  116349. */
  116350. yy: Vector3;
  116351. /**
  116352. * The zz coefficients of the spherical polynomial
  116353. */
  116354. zz: Vector3;
  116355. /**
  116356. * The xy coefficients of the spherical polynomial
  116357. */
  116358. xy: Vector3;
  116359. /**
  116360. * The yz coefficients of the spherical polynomial
  116361. */
  116362. yz: Vector3;
  116363. /**
  116364. * The zx coefficients of the spherical polynomial
  116365. */
  116366. zx: Vector3;
  116367. /**
  116368. * Adds an ambient color to the spherical polynomial
  116369. * @param color the color to add
  116370. */
  116371. addAmbient(color: Color3): void;
  116372. /**
  116373. * Scales the spherical polynomial by the given amount
  116374. * @param scale the amount to scale
  116375. */
  116376. scaleInPlace(scale: number): void;
  116377. /**
  116378. * Gets the spherical polynomial from harmonics
  116379. * @param harmonics the spherical harmonics
  116380. * @returns the spherical polynomial
  116381. */
  116382. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  116383. /**
  116384. * Constructs a spherical polynomial from an array.
  116385. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  116386. * @returns the spherical polynomial
  116387. */
  116388. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  116389. }
  116390. }
  116391. declare module BABYLON {
  116392. /**
  116393. * Defines the source of the internal texture
  116394. */
  116395. export enum InternalTextureSource {
  116396. /**
  116397. * The source of the texture data is unknown
  116398. */
  116399. Unknown = 0,
  116400. /**
  116401. * Texture data comes from an URL
  116402. */
  116403. Url = 1,
  116404. /**
  116405. * Texture data is only used for temporary storage
  116406. */
  116407. Temp = 2,
  116408. /**
  116409. * Texture data comes from raw data (ArrayBuffer)
  116410. */
  116411. Raw = 3,
  116412. /**
  116413. * Texture content is dynamic (video or dynamic texture)
  116414. */
  116415. Dynamic = 4,
  116416. /**
  116417. * Texture content is generated by rendering to it
  116418. */
  116419. RenderTarget = 5,
  116420. /**
  116421. * Texture content is part of a multi render target process
  116422. */
  116423. MultiRenderTarget = 6,
  116424. /**
  116425. * Texture data comes from a cube data file
  116426. */
  116427. Cube = 7,
  116428. /**
  116429. * Texture data comes from a raw cube data
  116430. */
  116431. CubeRaw = 8,
  116432. /**
  116433. * Texture data come from a prefiltered cube data file
  116434. */
  116435. CubePrefiltered = 9,
  116436. /**
  116437. * Texture content is raw 3D data
  116438. */
  116439. Raw3D = 10,
  116440. /**
  116441. * Texture content is raw 2D array data
  116442. */
  116443. Raw2DArray = 11,
  116444. /**
  116445. * Texture content is a depth texture
  116446. */
  116447. Depth = 12,
  116448. /**
  116449. * Texture data comes from a raw cube data encoded with RGBD
  116450. */
  116451. CubeRawRGBD = 13
  116452. }
  116453. /**
  116454. * Class used to store data associated with WebGL texture data for the engine
  116455. * This class should not be used directly
  116456. */
  116457. export class InternalTexture {
  116458. /** @hidden */
  116459. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  116460. /**
  116461. * Defines if the texture is ready
  116462. */
  116463. isReady: boolean;
  116464. /**
  116465. * Defines if the texture is a cube texture
  116466. */
  116467. isCube: boolean;
  116468. /**
  116469. * Defines if the texture contains 3D data
  116470. */
  116471. is3D: boolean;
  116472. /**
  116473. * Defines if the texture contains 2D array data
  116474. */
  116475. is2DArray: boolean;
  116476. /**
  116477. * Defines if the texture contains multiview data
  116478. */
  116479. isMultiview: boolean;
  116480. /**
  116481. * Gets the URL used to load this texture
  116482. */
  116483. url: string;
  116484. /**
  116485. * Gets the sampling mode of the texture
  116486. */
  116487. samplingMode: number;
  116488. /**
  116489. * Gets a boolean indicating if the texture needs mipmaps generation
  116490. */
  116491. generateMipMaps: boolean;
  116492. /**
  116493. * Gets the number of samples used by the texture (WebGL2+ only)
  116494. */
  116495. samples: number;
  116496. /**
  116497. * Gets the type of the texture (int, float...)
  116498. */
  116499. type: number;
  116500. /**
  116501. * Gets the format of the texture (RGB, RGBA...)
  116502. */
  116503. format: number;
  116504. /**
  116505. * Observable called when the texture is loaded
  116506. */
  116507. onLoadedObservable: Observable<InternalTexture>;
  116508. /**
  116509. * Gets the width of the texture
  116510. */
  116511. width: number;
  116512. /**
  116513. * Gets the height of the texture
  116514. */
  116515. height: number;
  116516. /**
  116517. * Gets the depth of the texture
  116518. */
  116519. depth: number;
  116520. /**
  116521. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  116522. */
  116523. baseWidth: number;
  116524. /**
  116525. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  116526. */
  116527. baseHeight: number;
  116528. /**
  116529. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  116530. */
  116531. baseDepth: number;
  116532. /**
  116533. * Gets a boolean indicating if the texture is inverted on Y axis
  116534. */
  116535. invertY: boolean;
  116536. /** @hidden */
  116537. _invertVScale: boolean;
  116538. /** @hidden */
  116539. _associatedChannel: number;
  116540. /** @hidden */
  116541. _source: InternalTextureSource;
  116542. /** @hidden */
  116543. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  116544. /** @hidden */
  116545. _bufferView: Nullable<ArrayBufferView>;
  116546. /** @hidden */
  116547. _bufferViewArray: Nullable<ArrayBufferView[]>;
  116548. /** @hidden */
  116549. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  116550. /** @hidden */
  116551. _size: number;
  116552. /** @hidden */
  116553. _extension: string;
  116554. /** @hidden */
  116555. _files: Nullable<string[]>;
  116556. /** @hidden */
  116557. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  116558. /** @hidden */
  116559. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  116560. /** @hidden */
  116561. _framebuffer: Nullable<WebGLFramebuffer>;
  116562. /** @hidden */
  116563. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  116564. /** @hidden */
  116565. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  116566. /** @hidden */
  116567. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  116568. /** @hidden */
  116569. _attachments: Nullable<number[]>;
  116570. /** @hidden */
  116571. _textureArray: Nullable<InternalTexture[]>;
  116572. /** @hidden */
  116573. _cachedCoordinatesMode: Nullable<number>;
  116574. /** @hidden */
  116575. _cachedWrapU: Nullable<number>;
  116576. /** @hidden */
  116577. _cachedWrapV: Nullable<number>;
  116578. /** @hidden */
  116579. _cachedWrapR: Nullable<number>;
  116580. /** @hidden */
  116581. _cachedAnisotropicFilteringLevel: Nullable<number>;
  116582. /** @hidden */
  116583. _isDisabled: boolean;
  116584. /** @hidden */
  116585. _compression: Nullable<string>;
  116586. /** @hidden */
  116587. _generateStencilBuffer: boolean;
  116588. /** @hidden */
  116589. _generateDepthBuffer: boolean;
  116590. /** @hidden */
  116591. _comparisonFunction: number;
  116592. /** @hidden */
  116593. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  116594. /** @hidden */
  116595. _lodGenerationScale: number;
  116596. /** @hidden */
  116597. _lodGenerationOffset: number;
  116598. /** @hidden */
  116599. _depthStencilTexture: Nullable<InternalTexture>;
  116600. /** @hidden */
  116601. _colorTextureArray: Nullable<WebGLTexture>;
  116602. /** @hidden */
  116603. _depthStencilTextureArray: Nullable<WebGLTexture>;
  116604. /** @hidden */
  116605. _lodTextureHigh: Nullable<BaseTexture>;
  116606. /** @hidden */
  116607. _lodTextureMid: Nullable<BaseTexture>;
  116608. /** @hidden */
  116609. _lodTextureLow: Nullable<BaseTexture>;
  116610. /** @hidden */
  116611. _isRGBD: boolean;
  116612. /** @hidden */
  116613. _linearSpecularLOD: boolean;
  116614. /** @hidden */
  116615. _irradianceTexture: Nullable<BaseTexture>;
  116616. /** @hidden */
  116617. _webGLTexture: Nullable<WebGLTexture>;
  116618. /** @hidden */
  116619. _references: number;
  116620. /** @hidden */
  116621. _gammaSpace: Nullable<boolean>;
  116622. private _engine;
  116623. /**
  116624. * Gets the Engine the texture belongs to.
  116625. * @returns The babylon engine
  116626. */
  116627. getEngine(): ThinEngine;
  116628. /**
  116629. * Gets the data source type of the texture
  116630. */
  116631. get source(): InternalTextureSource;
  116632. /**
  116633. * Creates a new InternalTexture
  116634. * @param engine defines the engine to use
  116635. * @param source defines the type of data that will be used
  116636. * @param delayAllocation if the texture allocation should be delayed (default: false)
  116637. */
  116638. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  116639. /**
  116640. * Increments the number of references (ie. the number of Texture that point to it)
  116641. */
  116642. incrementReferences(): void;
  116643. /**
  116644. * Change the size of the texture (not the size of the content)
  116645. * @param width defines the new width
  116646. * @param height defines the new height
  116647. * @param depth defines the new depth (1 by default)
  116648. */
  116649. updateSize(width: int, height: int, depth?: int): void;
  116650. /** @hidden */
  116651. _rebuild(): void;
  116652. /** @hidden */
  116653. _swapAndDie(target: InternalTexture): void;
  116654. /**
  116655. * Dispose the current allocated resources
  116656. */
  116657. dispose(): void;
  116658. }
  116659. }
  116660. declare module BABYLON {
  116661. /**
  116662. * Class used to work with sound analyzer using fast fourier transform (FFT)
  116663. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116664. */
  116665. export class Analyser {
  116666. /**
  116667. * Gets or sets the smoothing
  116668. * @ignorenaming
  116669. */
  116670. SMOOTHING: number;
  116671. /**
  116672. * Gets or sets the FFT table size
  116673. * @ignorenaming
  116674. */
  116675. FFT_SIZE: number;
  116676. /**
  116677. * Gets or sets the bar graph amplitude
  116678. * @ignorenaming
  116679. */
  116680. BARGRAPHAMPLITUDE: number;
  116681. /**
  116682. * Gets or sets the position of the debug canvas
  116683. * @ignorenaming
  116684. */
  116685. DEBUGCANVASPOS: {
  116686. x: number;
  116687. y: number;
  116688. };
  116689. /**
  116690. * Gets or sets the debug canvas size
  116691. * @ignorenaming
  116692. */
  116693. DEBUGCANVASSIZE: {
  116694. width: number;
  116695. height: number;
  116696. };
  116697. private _byteFreqs;
  116698. private _byteTime;
  116699. private _floatFreqs;
  116700. private _webAudioAnalyser;
  116701. private _debugCanvas;
  116702. private _debugCanvasContext;
  116703. private _scene;
  116704. private _registerFunc;
  116705. private _audioEngine;
  116706. /**
  116707. * Creates a new analyser
  116708. * @param scene defines hosting scene
  116709. */
  116710. constructor(scene: Scene);
  116711. /**
  116712. * Get the number of data values you will have to play with for the visualization
  116713. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  116714. * @returns a number
  116715. */
  116716. getFrequencyBinCount(): number;
  116717. /**
  116718. * Gets the current frequency data as a byte array
  116719. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  116720. * @returns a Uint8Array
  116721. */
  116722. getByteFrequencyData(): Uint8Array;
  116723. /**
  116724. * Gets the current waveform as a byte array
  116725. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  116726. * @returns a Uint8Array
  116727. */
  116728. getByteTimeDomainData(): Uint8Array;
  116729. /**
  116730. * Gets the current frequency data as a float array
  116731. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  116732. * @returns a Float32Array
  116733. */
  116734. getFloatFrequencyData(): Float32Array;
  116735. /**
  116736. * Renders the debug canvas
  116737. */
  116738. drawDebugCanvas(): void;
  116739. /**
  116740. * Stops rendering the debug canvas and removes it
  116741. */
  116742. stopDebugCanvas(): void;
  116743. /**
  116744. * Connects two audio nodes
  116745. * @param inputAudioNode defines first node to connect
  116746. * @param outputAudioNode defines second node to connect
  116747. */
  116748. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  116749. /**
  116750. * Releases all associated resources
  116751. */
  116752. dispose(): void;
  116753. }
  116754. }
  116755. declare module BABYLON {
  116756. /**
  116757. * This represents an audio engine and it is responsible
  116758. * to play, synchronize and analyse sounds throughout the application.
  116759. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116760. */
  116761. export interface IAudioEngine extends IDisposable {
  116762. /**
  116763. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  116764. */
  116765. readonly canUseWebAudio: boolean;
  116766. /**
  116767. * Gets the current AudioContext if available.
  116768. */
  116769. readonly audioContext: Nullable<AudioContext>;
  116770. /**
  116771. * The master gain node defines the global audio volume of your audio engine.
  116772. */
  116773. readonly masterGain: GainNode;
  116774. /**
  116775. * Gets whether or not mp3 are supported by your browser.
  116776. */
  116777. readonly isMP3supported: boolean;
  116778. /**
  116779. * Gets whether or not ogg are supported by your browser.
  116780. */
  116781. readonly isOGGsupported: boolean;
  116782. /**
  116783. * Defines if Babylon should emit a warning if WebAudio is not supported.
  116784. * @ignoreNaming
  116785. */
  116786. WarnedWebAudioUnsupported: boolean;
  116787. /**
  116788. * Defines if the audio engine relies on a custom unlocked button.
  116789. * In this case, the embedded button will not be displayed.
  116790. */
  116791. useCustomUnlockedButton: boolean;
  116792. /**
  116793. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  116794. */
  116795. readonly unlocked: boolean;
  116796. /**
  116797. * Event raised when audio has been unlocked on the browser.
  116798. */
  116799. onAudioUnlockedObservable: Observable<AudioEngine>;
  116800. /**
  116801. * Event raised when audio has been locked on the browser.
  116802. */
  116803. onAudioLockedObservable: Observable<AudioEngine>;
  116804. /**
  116805. * Flags the audio engine in Locked state.
  116806. * This happens due to new browser policies preventing audio to autoplay.
  116807. */
  116808. lock(): void;
  116809. /**
  116810. * Unlocks the audio engine once a user action has been done on the dom.
  116811. * This is helpful to resume play once browser policies have been satisfied.
  116812. */
  116813. unlock(): void;
  116814. /**
  116815. * Gets the global volume sets on the master gain.
  116816. * @returns the global volume if set or -1 otherwise
  116817. */
  116818. getGlobalVolume(): number;
  116819. /**
  116820. * Sets the global volume of your experience (sets on the master gain).
  116821. * @param newVolume Defines the new global volume of the application
  116822. */
  116823. setGlobalVolume(newVolume: number): void;
  116824. /**
  116825. * Connect the audio engine to an audio analyser allowing some amazing
  116826. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  116827. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  116828. * @param analyser The analyser to connect to the engine
  116829. */
  116830. connectToAnalyser(analyser: Analyser): void;
  116831. }
  116832. /**
  116833. * This represents the default audio engine used in babylon.
  116834. * It is responsible to play, synchronize and analyse sounds throughout the application.
  116835. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116836. */
  116837. export class AudioEngine implements IAudioEngine {
  116838. private _audioContext;
  116839. private _audioContextInitialized;
  116840. private _muteButton;
  116841. private _hostElement;
  116842. /**
  116843. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  116844. */
  116845. canUseWebAudio: boolean;
  116846. /**
  116847. * The master gain node defines the global audio volume of your audio engine.
  116848. */
  116849. masterGain: GainNode;
  116850. /**
  116851. * Defines if Babylon should emit a warning if WebAudio is not supported.
  116852. * @ignoreNaming
  116853. */
  116854. WarnedWebAudioUnsupported: boolean;
  116855. /**
  116856. * Gets whether or not mp3 are supported by your browser.
  116857. */
  116858. isMP3supported: boolean;
  116859. /**
  116860. * Gets whether or not ogg are supported by your browser.
  116861. */
  116862. isOGGsupported: boolean;
  116863. /**
  116864. * Gets whether audio has been unlocked on the device.
  116865. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  116866. * a user interaction has happened.
  116867. */
  116868. unlocked: boolean;
  116869. /**
  116870. * Defines if the audio engine relies on a custom unlocked button.
  116871. * In this case, the embedded button will not be displayed.
  116872. */
  116873. useCustomUnlockedButton: boolean;
  116874. /**
  116875. * Event raised when audio has been unlocked on the browser.
  116876. */
  116877. onAudioUnlockedObservable: Observable<AudioEngine>;
  116878. /**
  116879. * Event raised when audio has been locked on the browser.
  116880. */
  116881. onAudioLockedObservable: Observable<AudioEngine>;
  116882. /**
  116883. * Gets the current AudioContext if available.
  116884. */
  116885. get audioContext(): Nullable<AudioContext>;
  116886. private _connectedAnalyser;
  116887. /**
  116888. * Instantiates a new audio engine.
  116889. *
  116890. * There should be only one per page as some browsers restrict the number
  116891. * of audio contexts you can create.
  116892. * @param hostElement defines the host element where to display the mute icon if necessary
  116893. */
  116894. constructor(hostElement?: Nullable<HTMLElement>);
  116895. /**
  116896. * Flags the audio engine in Locked state.
  116897. * This happens due to new browser policies preventing audio to autoplay.
  116898. */
  116899. lock(): void;
  116900. /**
  116901. * Unlocks the audio engine once a user action has been done on the dom.
  116902. * This is helpful to resume play once browser policies have been satisfied.
  116903. */
  116904. unlock(): void;
  116905. private _resumeAudioContext;
  116906. private _initializeAudioContext;
  116907. private _tryToRun;
  116908. private _triggerRunningState;
  116909. private _triggerSuspendedState;
  116910. private _displayMuteButton;
  116911. private _moveButtonToTopLeft;
  116912. private _onResize;
  116913. private _hideMuteButton;
  116914. /**
  116915. * Destroy and release the resources associated with the audio ccontext.
  116916. */
  116917. dispose(): void;
  116918. /**
  116919. * Gets the global volume sets on the master gain.
  116920. * @returns the global volume if set or -1 otherwise
  116921. */
  116922. getGlobalVolume(): number;
  116923. /**
  116924. * Sets the global volume of your experience (sets on the master gain).
  116925. * @param newVolume Defines the new global volume of the application
  116926. */
  116927. setGlobalVolume(newVolume: number): void;
  116928. /**
  116929. * Connect the audio engine to an audio analyser allowing some amazing
  116930. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  116931. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  116932. * @param analyser The analyser to connect to the engine
  116933. */
  116934. connectToAnalyser(analyser: Analyser): void;
  116935. }
  116936. }
  116937. declare module BABYLON {
  116938. /**
  116939. * Interface used to present a loading screen while loading a scene
  116940. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116941. */
  116942. export interface ILoadingScreen {
  116943. /**
  116944. * Function called to display the loading screen
  116945. */
  116946. displayLoadingUI: () => void;
  116947. /**
  116948. * Function called to hide the loading screen
  116949. */
  116950. hideLoadingUI: () => void;
  116951. /**
  116952. * Gets or sets the color to use for the background
  116953. */
  116954. loadingUIBackgroundColor: string;
  116955. /**
  116956. * Gets or sets the text to display while loading
  116957. */
  116958. loadingUIText: string;
  116959. }
  116960. /**
  116961. * Class used for the default loading screen
  116962. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116963. */
  116964. export class DefaultLoadingScreen implements ILoadingScreen {
  116965. private _renderingCanvas;
  116966. private _loadingText;
  116967. private _loadingDivBackgroundColor;
  116968. private _loadingDiv;
  116969. private _loadingTextDiv;
  116970. /** Gets or sets the logo url to use for the default loading screen */
  116971. static DefaultLogoUrl: string;
  116972. /** Gets or sets the spinner url to use for the default loading screen */
  116973. static DefaultSpinnerUrl: string;
  116974. /**
  116975. * Creates a new default loading screen
  116976. * @param _renderingCanvas defines the canvas used to render the scene
  116977. * @param _loadingText defines the default text to display
  116978. * @param _loadingDivBackgroundColor defines the default background color
  116979. */
  116980. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  116981. /**
  116982. * Function called to display the loading screen
  116983. */
  116984. displayLoadingUI(): void;
  116985. /**
  116986. * Function called to hide the loading screen
  116987. */
  116988. hideLoadingUI(): void;
  116989. /**
  116990. * Gets or sets the text to display while loading
  116991. */
  116992. set loadingUIText(text: string);
  116993. get loadingUIText(): string;
  116994. /**
  116995. * Gets or sets the color to use for the background
  116996. */
  116997. get loadingUIBackgroundColor(): string;
  116998. set loadingUIBackgroundColor(color: string);
  116999. private _resizeLoadingUI;
  117000. }
  117001. }
  117002. declare module BABYLON {
  117003. /**
  117004. * Interface for any object that can request an animation frame
  117005. */
  117006. export interface ICustomAnimationFrameRequester {
  117007. /**
  117008. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  117009. */
  117010. renderFunction?: Function;
  117011. /**
  117012. * Called to request the next frame to render to
  117013. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  117014. */
  117015. requestAnimationFrame: Function;
  117016. /**
  117017. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  117018. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  117019. */
  117020. requestID?: number;
  117021. }
  117022. }
  117023. declare module BABYLON {
  117024. /**
  117025. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  117026. */
  117027. export class PerformanceMonitor {
  117028. private _enabled;
  117029. private _rollingFrameTime;
  117030. private _lastFrameTimeMs;
  117031. /**
  117032. * constructor
  117033. * @param frameSampleSize The number of samples required to saturate the sliding window
  117034. */
  117035. constructor(frameSampleSize?: number);
  117036. /**
  117037. * Samples current frame
  117038. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  117039. */
  117040. sampleFrame(timeMs?: number): void;
  117041. /**
  117042. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117043. */
  117044. get averageFrameTime(): number;
  117045. /**
  117046. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117047. */
  117048. get averageFrameTimeVariance(): number;
  117049. /**
  117050. * Returns the frame time of the most recent frame
  117051. */
  117052. get instantaneousFrameTime(): number;
  117053. /**
  117054. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  117055. */
  117056. get averageFPS(): number;
  117057. /**
  117058. * Returns the average framerate in frames per second using the most recent frame time
  117059. */
  117060. get instantaneousFPS(): number;
  117061. /**
  117062. * Returns true if enough samples have been taken to completely fill the sliding window
  117063. */
  117064. get isSaturated(): boolean;
  117065. /**
  117066. * Enables contributions to the sliding window sample set
  117067. */
  117068. enable(): void;
  117069. /**
  117070. * Disables contributions to the sliding window sample set
  117071. * Samples will not be interpolated over the disabled period
  117072. */
  117073. disable(): void;
  117074. /**
  117075. * Returns true if sampling is enabled
  117076. */
  117077. get isEnabled(): boolean;
  117078. /**
  117079. * Resets performance monitor
  117080. */
  117081. reset(): void;
  117082. }
  117083. /**
  117084. * RollingAverage
  117085. *
  117086. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  117087. */
  117088. export class RollingAverage {
  117089. /**
  117090. * Current average
  117091. */
  117092. average: number;
  117093. /**
  117094. * Current variance
  117095. */
  117096. variance: number;
  117097. protected _samples: Array<number>;
  117098. protected _sampleCount: number;
  117099. protected _pos: number;
  117100. protected _m2: number;
  117101. /**
  117102. * constructor
  117103. * @param length The number of samples required to saturate the sliding window
  117104. */
  117105. constructor(length: number);
  117106. /**
  117107. * Adds a sample to the sample set
  117108. * @param v The sample value
  117109. */
  117110. add(v: number): void;
  117111. /**
  117112. * Returns previously added values or null if outside of history or outside the sliding window domain
  117113. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  117114. * @return Value previously recorded with add() or null if outside of range
  117115. */
  117116. history(i: number): number;
  117117. /**
  117118. * Returns true if enough samples have been taken to completely fill the sliding window
  117119. * @return true if sample-set saturated
  117120. */
  117121. isSaturated(): boolean;
  117122. /**
  117123. * Resets the rolling average (equivalent to 0 samples taken so far)
  117124. */
  117125. reset(): void;
  117126. /**
  117127. * Wraps a value around the sample range boundaries
  117128. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  117129. * @return Wrapped position in sample range
  117130. */
  117131. protected _wrapPosition(i: number): number;
  117132. }
  117133. }
  117134. declare module BABYLON {
  117135. /**
  117136. * This class is used to track a performance counter which is number based.
  117137. * The user has access to many properties which give statistics of different nature.
  117138. *
  117139. * The implementer can track two kinds of Performance Counter: time and count.
  117140. * 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.
  117141. * 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.
  117142. */
  117143. export class PerfCounter {
  117144. /**
  117145. * Gets or sets a global boolean to turn on and off all the counters
  117146. */
  117147. static Enabled: boolean;
  117148. /**
  117149. * Returns the smallest value ever
  117150. */
  117151. get min(): number;
  117152. /**
  117153. * Returns the biggest value ever
  117154. */
  117155. get max(): number;
  117156. /**
  117157. * Returns the average value since the performance counter is running
  117158. */
  117159. get average(): number;
  117160. /**
  117161. * Returns the average value of the last second the counter was monitored
  117162. */
  117163. get lastSecAverage(): number;
  117164. /**
  117165. * Returns the current value
  117166. */
  117167. get current(): number;
  117168. /**
  117169. * Gets the accumulated total
  117170. */
  117171. get total(): number;
  117172. /**
  117173. * Gets the total value count
  117174. */
  117175. get count(): number;
  117176. /**
  117177. * Creates a new counter
  117178. */
  117179. constructor();
  117180. /**
  117181. * Call this method to start monitoring a new frame.
  117182. * 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.
  117183. */
  117184. fetchNewFrame(): void;
  117185. /**
  117186. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  117187. * @param newCount the count value to add to the monitored count
  117188. * @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.
  117189. */
  117190. addCount(newCount: number, fetchResult: boolean): void;
  117191. /**
  117192. * Start monitoring this performance counter
  117193. */
  117194. beginMonitoring(): void;
  117195. /**
  117196. * Compute the time lapsed since the previous beginMonitoring() call.
  117197. * @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
  117198. */
  117199. endMonitoring(newFrame?: boolean): void;
  117200. private _fetchResult;
  117201. private _startMonitoringTime;
  117202. private _min;
  117203. private _max;
  117204. private _average;
  117205. private _current;
  117206. private _totalValueCount;
  117207. private _totalAccumulated;
  117208. private _lastSecAverage;
  117209. private _lastSecAccumulated;
  117210. private _lastSecTime;
  117211. private _lastSecValueCount;
  117212. }
  117213. }
  117214. declare module BABYLON {
  117215. interface ThinEngine {
  117216. /** @hidden */
  117217. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  117218. }
  117219. }
  117220. declare module BABYLON {
  117221. /**
  117222. * Defines the interface used by display changed events
  117223. */
  117224. export interface IDisplayChangedEventArgs {
  117225. /** Gets the vrDisplay object (if any) */
  117226. vrDisplay: Nullable<any>;
  117227. /** Gets a boolean indicating if webVR is supported */
  117228. vrSupported: boolean;
  117229. }
  117230. /**
  117231. * Defines the interface used by objects containing a viewport (like a camera)
  117232. */
  117233. interface IViewportOwnerLike {
  117234. /**
  117235. * Gets or sets the viewport
  117236. */
  117237. viewport: IViewportLike;
  117238. }
  117239. /**
  117240. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  117241. */
  117242. export class Engine extends ThinEngine {
  117243. /** Defines that alpha blending is disabled */
  117244. static readonly ALPHA_DISABLE: number;
  117245. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  117246. static readonly ALPHA_ADD: number;
  117247. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  117248. static readonly ALPHA_COMBINE: number;
  117249. /** Defines that alpha blending to DEST - SRC * DEST */
  117250. static readonly ALPHA_SUBTRACT: number;
  117251. /** Defines that alpha blending to SRC * DEST */
  117252. static readonly ALPHA_MULTIPLY: number;
  117253. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  117254. static readonly ALPHA_MAXIMIZED: number;
  117255. /** Defines that alpha blending to SRC + DEST */
  117256. static readonly ALPHA_ONEONE: number;
  117257. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  117258. static readonly ALPHA_PREMULTIPLIED: number;
  117259. /**
  117260. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  117261. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  117262. */
  117263. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  117264. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  117265. static readonly ALPHA_INTERPOLATE: number;
  117266. /**
  117267. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  117268. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  117269. */
  117270. static readonly ALPHA_SCREENMODE: number;
  117271. /** Defines that the ressource is not delayed*/
  117272. static readonly DELAYLOADSTATE_NONE: number;
  117273. /** Defines that the ressource was successfully delay loaded */
  117274. static readonly DELAYLOADSTATE_LOADED: number;
  117275. /** Defines that the ressource is currently delay loading */
  117276. static readonly DELAYLOADSTATE_LOADING: number;
  117277. /** Defines that the ressource is delayed and has not started loading */
  117278. static readonly DELAYLOADSTATE_NOTLOADED: number;
  117279. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  117280. static readonly NEVER: number;
  117281. /** 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 */
  117282. static readonly ALWAYS: number;
  117283. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  117284. static readonly LESS: number;
  117285. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  117286. static readonly EQUAL: number;
  117287. /** 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 */
  117288. static readonly LEQUAL: number;
  117289. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  117290. static readonly GREATER: number;
  117291. /** 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 */
  117292. static readonly GEQUAL: number;
  117293. /** 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 */
  117294. static readonly NOTEQUAL: number;
  117295. /** Passed to stencilOperation to specify that stencil value must be kept */
  117296. static readonly KEEP: number;
  117297. /** Passed to stencilOperation to specify that stencil value must be replaced */
  117298. static readonly REPLACE: number;
  117299. /** Passed to stencilOperation to specify that stencil value must be incremented */
  117300. static readonly INCR: number;
  117301. /** Passed to stencilOperation to specify that stencil value must be decremented */
  117302. static readonly DECR: number;
  117303. /** Passed to stencilOperation to specify that stencil value must be inverted */
  117304. static readonly INVERT: number;
  117305. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  117306. static readonly INCR_WRAP: number;
  117307. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  117308. static readonly DECR_WRAP: number;
  117309. /** Texture is not repeating outside of 0..1 UVs */
  117310. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  117311. /** Texture is repeating outside of 0..1 UVs */
  117312. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  117313. /** Texture is repeating and mirrored */
  117314. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  117315. /** ALPHA */
  117316. static readonly TEXTUREFORMAT_ALPHA: number;
  117317. /** LUMINANCE */
  117318. static readonly TEXTUREFORMAT_LUMINANCE: number;
  117319. /** LUMINANCE_ALPHA */
  117320. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  117321. /** RGB */
  117322. static readonly TEXTUREFORMAT_RGB: number;
  117323. /** RGBA */
  117324. static readonly TEXTUREFORMAT_RGBA: number;
  117325. /** RED */
  117326. static readonly TEXTUREFORMAT_RED: number;
  117327. /** RED (2nd reference) */
  117328. static readonly TEXTUREFORMAT_R: number;
  117329. /** RG */
  117330. static readonly TEXTUREFORMAT_RG: number;
  117331. /** RED_INTEGER */
  117332. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  117333. /** RED_INTEGER (2nd reference) */
  117334. static readonly TEXTUREFORMAT_R_INTEGER: number;
  117335. /** RG_INTEGER */
  117336. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  117337. /** RGB_INTEGER */
  117338. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  117339. /** RGBA_INTEGER */
  117340. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  117341. /** UNSIGNED_BYTE */
  117342. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  117343. /** UNSIGNED_BYTE (2nd reference) */
  117344. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  117345. /** FLOAT */
  117346. static readonly TEXTURETYPE_FLOAT: number;
  117347. /** HALF_FLOAT */
  117348. static readonly TEXTURETYPE_HALF_FLOAT: number;
  117349. /** BYTE */
  117350. static readonly TEXTURETYPE_BYTE: number;
  117351. /** SHORT */
  117352. static readonly TEXTURETYPE_SHORT: number;
  117353. /** UNSIGNED_SHORT */
  117354. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  117355. /** INT */
  117356. static readonly TEXTURETYPE_INT: number;
  117357. /** UNSIGNED_INT */
  117358. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  117359. /** UNSIGNED_SHORT_4_4_4_4 */
  117360. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  117361. /** UNSIGNED_SHORT_5_5_5_1 */
  117362. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  117363. /** UNSIGNED_SHORT_5_6_5 */
  117364. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  117365. /** UNSIGNED_INT_2_10_10_10_REV */
  117366. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  117367. /** UNSIGNED_INT_24_8 */
  117368. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  117369. /** UNSIGNED_INT_10F_11F_11F_REV */
  117370. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  117371. /** UNSIGNED_INT_5_9_9_9_REV */
  117372. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  117373. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  117374. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  117375. /** nearest is mag = nearest and min = nearest and mip = linear */
  117376. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  117377. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117378. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  117379. /** Trilinear is mag = linear and min = linear and mip = linear */
  117380. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  117381. /** nearest is mag = nearest and min = nearest and mip = linear */
  117382. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  117383. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117384. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  117385. /** Trilinear is mag = linear and min = linear and mip = linear */
  117386. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  117387. /** mag = nearest and min = nearest and mip = nearest */
  117388. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  117389. /** mag = nearest and min = linear and mip = nearest */
  117390. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  117391. /** mag = nearest and min = linear and mip = linear */
  117392. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  117393. /** mag = nearest and min = linear and mip = none */
  117394. static readonly TEXTURE_NEAREST_LINEAR: number;
  117395. /** mag = nearest and min = nearest and mip = none */
  117396. static readonly TEXTURE_NEAREST_NEAREST: number;
  117397. /** mag = linear and min = nearest and mip = nearest */
  117398. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  117399. /** mag = linear and min = nearest and mip = linear */
  117400. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  117401. /** mag = linear and min = linear and mip = none */
  117402. static readonly TEXTURE_LINEAR_LINEAR: number;
  117403. /** mag = linear and min = nearest and mip = none */
  117404. static readonly TEXTURE_LINEAR_NEAREST: number;
  117405. /** Explicit coordinates mode */
  117406. static readonly TEXTURE_EXPLICIT_MODE: number;
  117407. /** Spherical coordinates mode */
  117408. static readonly TEXTURE_SPHERICAL_MODE: number;
  117409. /** Planar coordinates mode */
  117410. static readonly TEXTURE_PLANAR_MODE: number;
  117411. /** Cubic coordinates mode */
  117412. static readonly TEXTURE_CUBIC_MODE: number;
  117413. /** Projection coordinates mode */
  117414. static readonly TEXTURE_PROJECTION_MODE: number;
  117415. /** Skybox coordinates mode */
  117416. static readonly TEXTURE_SKYBOX_MODE: number;
  117417. /** Inverse Cubic coordinates mode */
  117418. static readonly TEXTURE_INVCUBIC_MODE: number;
  117419. /** Equirectangular coordinates mode */
  117420. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  117421. /** Equirectangular Fixed coordinates mode */
  117422. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  117423. /** Equirectangular Fixed Mirrored coordinates mode */
  117424. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  117425. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  117426. static readonly SCALEMODE_FLOOR: number;
  117427. /** Defines that texture rescaling will look for the nearest power of 2 size */
  117428. static readonly SCALEMODE_NEAREST: number;
  117429. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  117430. static readonly SCALEMODE_CEILING: number;
  117431. /**
  117432. * Returns the current npm package of the sdk
  117433. */
  117434. static get NpmPackage(): string;
  117435. /**
  117436. * Returns the current version of the framework
  117437. */
  117438. static get Version(): string;
  117439. /** Gets the list of created engines */
  117440. static get Instances(): Engine[];
  117441. /**
  117442. * Gets the latest created engine
  117443. */
  117444. static get LastCreatedEngine(): Nullable<Engine>;
  117445. /**
  117446. * Gets the latest created scene
  117447. */
  117448. static get LastCreatedScene(): Nullable<Scene>;
  117449. /**
  117450. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  117451. * @param flag defines which part of the materials must be marked as dirty
  117452. * @param predicate defines a predicate used to filter which materials should be affected
  117453. */
  117454. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117455. /**
  117456. * Method called to create the default loading screen.
  117457. * This can be overriden in your own app.
  117458. * @param canvas The rendering canvas element
  117459. * @returns The loading screen
  117460. */
  117461. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  117462. /**
  117463. * Method called to create the default rescale post process on each engine.
  117464. */
  117465. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  117466. /**
  117467. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  117468. **/
  117469. enableOfflineSupport: boolean;
  117470. /**
  117471. * 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)
  117472. **/
  117473. disableManifestCheck: boolean;
  117474. /**
  117475. * Gets the list of created scenes
  117476. */
  117477. scenes: Scene[];
  117478. /**
  117479. * Event raised when a new scene is created
  117480. */
  117481. onNewSceneAddedObservable: Observable<Scene>;
  117482. /**
  117483. * Gets the list of created postprocesses
  117484. */
  117485. postProcesses: PostProcess[];
  117486. /**
  117487. * Gets a boolean indicating if the pointer is currently locked
  117488. */
  117489. isPointerLock: boolean;
  117490. /**
  117491. * Observable event triggered each time the rendering canvas is resized
  117492. */
  117493. onResizeObservable: Observable<Engine>;
  117494. /**
  117495. * Observable event triggered each time the canvas loses focus
  117496. */
  117497. onCanvasBlurObservable: Observable<Engine>;
  117498. /**
  117499. * Observable event triggered each time the canvas gains focus
  117500. */
  117501. onCanvasFocusObservable: Observable<Engine>;
  117502. /**
  117503. * Observable event triggered each time the canvas receives pointerout event
  117504. */
  117505. onCanvasPointerOutObservable: Observable<PointerEvent>;
  117506. /**
  117507. * Observable raised when the engine begins a new frame
  117508. */
  117509. onBeginFrameObservable: Observable<Engine>;
  117510. /**
  117511. * If set, will be used to request the next animation frame for the render loop
  117512. */
  117513. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  117514. /**
  117515. * Observable raised when the engine ends the current frame
  117516. */
  117517. onEndFrameObservable: Observable<Engine>;
  117518. /**
  117519. * Observable raised when the engine is about to compile a shader
  117520. */
  117521. onBeforeShaderCompilationObservable: Observable<Engine>;
  117522. /**
  117523. * Observable raised when the engine has jsut compiled a shader
  117524. */
  117525. onAfterShaderCompilationObservable: Observable<Engine>;
  117526. /**
  117527. * Gets the audio engine
  117528. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117529. * @ignorenaming
  117530. */
  117531. static audioEngine: IAudioEngine;
  117532. /**
  117533. * Default AudioEngine factory responsible of creating the Audio Engine.
  117534. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  117535. */
  117536. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  117537. /**
  117538. * Default offline support factory responsible of creating a tool used to store data locally.
  117539. * By default, this will create a Database object if the workload has been embedded.
  117540. */
  117541. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  117542. private _loadingScreen;
  117543. private _pointerLockRequested;
  117544. private _rescalePostProcess;
  117545. private _deterministicLockstep;
  117546. private _lockstepMaxSteps;
  117547. private _timeStep;
  117548. protected get _supportsHardwareTextureRescaling(): boolean;
  117549. private _fps;
  117550. private _deltaTime;
  117551. /** @hidden */
  117552. _drawCalls: PerfCounter;
  117553. /** 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 */
  117554. canvasTabIndex: number;
  117555. /**
  117556. * Turn this value on if you want to pause FPS computation when in background
  117557. */
  117558. disablePerformanceMonitorInBackground: boolean;
  117559. private _performanceMonitor;
  117560. /**
  117561. * Gets the performance monitor attached to this engine
  117562. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117563. */
  117564. get performanceMonitor(): PerformanceMonitor;
  117565. private _onFocus;
  117566. private _onBlur;
  117567. private _onCanvasPointerOut;
  117568. private _onCanvasBlur;
  117569. private _onCanvasFocus;
  117570. private _onFullscreenChange;
  117571. private _onPointerLockChange;
  117572. /**
  117573. * Gets the HTML element used to attach event listeners
  117574. * @returns a HTML element
  117575. */
  117576. getInputElement(): Nullable<HTMLElement>;
  117577. /**
  117578. * Creates a new engine
  117579. * @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
  117580. * @param antialias defines enable antialiasing (default: false)
  117581. * @param options defines further options to be sent to the getContext() function
  117582. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  117583. */
  117584. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  117585. /**
  117586. * Gets current aspect ratio
  117587. * @param viewportOwner defines the camera to use to get the aspect ratio
  117588. * @param useScreen defines if screen size must be used (or the current render target if any)
  117589. * @returns a number defining the aspect ratio
  117590. */
  117591. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  117592. /**
  117593. * Gets current screen aspect ratio
  117594. * @returns a number defining the aspect ratio
  117595. */
  117596. getScreenAspectRatio(): number;
  117597. /**
  117598. * Gets the client rect of the HTML canvas attached with the current webGL context
  117599. * @returns a client rectanglee
  117600. */
  117601. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  117602. /**
  117603. * Gets the client rect of the HTML element used for events
  117604. * @returns a client rectanglee
  117605. */
  117606. getInputElementClientRect(): Nullable<ClientRect>;
  117607. /**
  117608. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  117609. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117610. * @returns true if engine is in deterministic lock step mode
  117611. */
  117612. isDeterministicLockStep(): boolean;
  117613. /**
  117614. * Gets the max steps when engine is running in deterministic lock step
  117615. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117616. * @returns the max steps
  117617. */
  117618. getLockstepMaxSteps(): number;
  117619. /**
  117620. * Returns the time in ms between steps when using deterministic lock step.
  117621. * @returns time step in (ms)
  117622. */
  117623. getTimeStep(): number;
  117624. /**
  117625. * Force the mipmap generation for the given render target texture
  117626. * @param texture defines the render target texture to use
  117627. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  117628. */
  117629. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  117630. /** States */
  117631. /**
  117632. * Set various states to the webGL context
  117633. * @param culling defines backface culling state
  117634. * @param zOffset defines the value to apply to zOffset (0 by default)
  117635. * @param force defines if states must be applied even if cache is up to date
  117636. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  117637. */
  117638. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  117639. /**
  117640. * Set the z offset to apply to current rendering
  117641. * @param value defines the offset to apply
  117642. */
  117643. setZOffset(value: number): void;
  117644. /**
  117645. * Gets the current value of the zOffset
  117646. * @returns the current zOffset state
  117647. */
  117648. getZOffset(): number;
  117649. /**
  117650. * Enable or disable depth buffering
  117651. * @param enable defines the state to set
  117652. */
  117653. setDepthBuffer(enable: boolean): void;
  117654. /**
  117655. * Gets a boolean indicating if depth writing is enabled
  117656. * @returns the current depth writing state
  117657. */
  117658. getDepthWrite(): boolean;
  117659. /**
  117660. * Enable or disable depth writing
  117661. * @param enable defines the state to set
  117662. */
  117663. setDepthWrite(enable: boolean): void;
  117664. /**
  117665. * Gets a boolean indicating if stencil buffer is enabled
  117666. * @returns the current stencil buffer state
  117667. */
  117668. getStencilBuffer(): boolean;
  117669. /**
  117670. * Enable or disable the stencil buffer
  117671. * @param enable defines if the stencil buffer must be enabled or disabled
  117672. */
  117673. setStencilBuffer(enable: boolean): void;
  117674. /**
  117675. * Gets the current stencil mask
  117676. * @returns a number defining the new stencil mask to use
  117677. */
  117678. getStencilMask(): number;
  117679. /**
  117680. * Sets the current stencil mask
  117681. * @param mask defines the new stencil mask to use
  117682. */
  117683. setStencilMask(mask: number): void;
  117684. /**
  117685. * Gets the current stencil function
  117686. * @returns a number defining the stencil function to use
  117687. */
  117688. getStencilFunction(): number;
  117689. /**
  117690. * Gets the current stencil reference value
  117691. * @returns a number defining the stencil reference value to use
  117692. */
  117693. getStencilFunctionReference(): number;
  117694. /**
  117695. * Gets the current stencil mask
  117696. * @returns a number defining the stencil mask to use
  117697. */
  117698. getStencilFunctionMask(): number;
  117699. /**
  117700. * Sets the current stencil function
  117701. * @param stencilFunc defines the new stencil function to use
  117702. */
  117703. setStencilFunction(stencilFunc: number): void;
  117704. /**
  117705. * Sets the current stencil reference
  117706. * @param reference defines the new stencil reference to use
  117707. */
  117708. setStencilFunctionReference(reference: number): void;
  117709. /**
  117710. * Sets the current stencil mask
  117711. * @param mask defines the new stencil mask to use
  117712. */
  117713. setStencilFunctionMask(mask: number): void;
  117714. /**
  117715. * Gets the current stencil operation when stencil fails
  117716. * @returns a number defining stencil operation to use when stencil fails
  117717. */
  117718. getStencilOperationFail(): number;
  117719. /**
  117720. * Gets the current stencil operation when depth fails
  117721. * @returns a number defining stencil operation to use when depth fails
  117722. */
  117723. getStencilOperationDepthFail(): number;
  117724. /**
  117725. * Gets the current stencil operation when stencil passes
  117726. * @returns a number defining stencil operation to use when stencil passes
  117727. */
  117728. getStencilOperationPass(): number;
  117729. /**
  117730. * Sets the stencil operation to use when stencil fails
  117731. * @param operation defines the stencil operation to use when stencil fails
  117732. */
  117733. setStencilOperationFail(operation: number): void;
  117734. /**
  117735. * Sets the stencil operation to use when depth fails
  117736. * @param operation defines the stencil operation to use when depth fails
  117737. */
  117738. setStencilOperationDepthFail(operation: number): void;
  117739. /**
  117740. * Sets the stencil operation to use when stencil passes
  117741. * @param operation defines the stencil operation to use when stencil passes
  117742. */
  117743. setStencilOperationPass(operation: number): void;
  117744. /**
  117745. * Sets a boolean indicating if the dithering state is enabled or disabled
  117746. * @param value defines the dithering state
  117747. */
  117748. setDitheringState(value: boolean): void;
  117749. /**
  117750. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  117751. * @param value defines the rasterizer state
  117752. */
  117753. setRasterizerState(value: boolean): void;
  117754. /**
  117755. * Gets the current depth function
  117756. * @returns a number defining the depth function
  117757. */
  117758. getDepthFunction(): Nullable<number>;
  117759. /**
  117760. * Sets the current depth function
  117761. * @param depthFunc defines the function to use
  117762. */
  117763. setDepthFunction(depthFunc: number): void;
  117764. /**
  117765. * Sets the current depth function to GREATER
  117766. */
  117767. setDepthFunctionToGreater(): void;
  117768. /**
  117769. * Sets the current depth function to GEQUAL
  117770. */
  117771. setDepthFunctionToGreaterOrEqual(): void;
  117772. /**
  117773. * Sets the current depth function to LESS
  117774. */
  117775. setDepthFunctionToLess(): void;
  117776. /**
  117777. * Sets the current depth function to LEQUAL
  117778. */
  117779. setDepthFunctionToLessOrEqual(): void;
  117780. private _cachedStencilBuffer;
  117781. private _cachedStencilFunction;
  117782. private _cachedStencilMask;
  117783. private _cachedStencilOperationPass;
  117784. private _cachedStencilOperationFail;
  117785. private _cachedStencilOperationDepthFail;
  117786. private _cachedStencilReference;
  117787. /**
  117788. * Caches the the state of the stencil buffer
  117789. */
  117790. cacheStencilState(): void;
  117791. /**
  117792. * Restores the state of the stencil buffer
  117793. */
  117794. restoreStencilState(): void;
  117795. /**
  117796. * Directly set the WebGL Viewport
  117797. * @param x defines the x coordinate of the viewport (in screen space)
  117798. * @param y defines the y coordinate of the viewport (in screen space)
  117799. * @param width defines the width of the viewport (in screen space)
  117800. * @param height defines the height of the viewport (in screen space)
  117801. * @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
  117802. */
  117803. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  117804. /**
  117805. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  117806. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  117807. * @param y defines the y-coordinate of the corner of the clear rectangle
  117808. * @param width defines the width of the clear rectangle
  117809. * @param height defines the height of the clear rectangle
  117810. * @param clearColor defines the clear color
  117811. */
  117812. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  117813. /**
  117814. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  117815. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  117816. * @param y defines the y-coordinate of the corner of the clear rectangle
  117817. * @param width defines the width of the clear rectangle
  117818. * @param height defines the height of the clear rectangle
  117819. */
  117820. enableScissor(x: number, y: number, width: number, height: number): void;
  117821. /**
  117822. * Disable previously set scissor test rectangle
  117823. */
  117824. disableScissor(): void;
  117825. protected _reportDrawCall(): void;
  117826. /**
  117827. * Initializes a webVR display and starts listening to display change events
  117828. * The onVRDisplayChangedObservable will be notified upon these changes
  117829. * @returns The onVRDisplayChangedObservable
  117830. */
  117831. initWebVR(): Observable<IDisplayChangedEventArgs>;
  117832. /** @hidden */
  117833. _prepareVRComponent(): void;
  117834. /** @hidden */
  117835. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  117836. /** @hidden */
  117837. _submitVRFrame(): void;
  117838. /**
  117839. * Call this function to leave webVR mode
  117840. * Will do nothing if webVR is not supported or if there is no webVR device
  117841. * @see https://doc.babylonjs.com/how_to/webvr_camera
  117842. */
  117843. disableVR(): void;
  117844. /**
  117845. * Gets a boolean indicating that the system is in VR mode and is presenting
  117846. * @returns true if VR mode is engaged
  117847. */
  117848. isVRPresenting(): boolean;
  117849. /** @hidden */
  117850. _requestVRFrame(): void;
  117851. /** @hidden */
  117852. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117853. /**
  117854. * Gets the source code of the vertex shader associated with a specific webGL program
  117855. * @param program defines the program to use
  117856. * @returns a string containing the source code of the vertex shader associated with the program
  117857. */
  117858. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  117859. /**
  117860. * Gets the source code of the fragment shader associated with a specific webGL program
  117861. * @param program defines the program to use
  117862. * @returns a string containing the source code of the fragment shader associated with the program
  117863. */
  117864. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  117865. /**
  117866. * Sets a depth stencil texture from a render target to the according uniform.
  117867. * @param channel The texture channel
  117868. * @param uniform The uniform to set
  117869. * @param texture The render target texture containing the depth stencil texture to apply
  117870. */
  117871. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  117872. /**
  117873. * Sets a texture to the webGL context from a postprocess
  117874. * @param channel defines the channel to use
  117875. * @param postProcess defines the source postprocess
  117876. */
  117877. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  117878. /**
  117879. * Binds the output of the passed in post process to the texture channel specified
  117880. * @param channel The channel the texture should be bound to
  117881. * @param postProcess The post process which's output should be bound
  117882. */
  117883. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  117884. protected _rebuildBuffers(): void;
  117885. /** @hidden */
  117886. _renderFrame(): void;
  117887. _renderLoop(): void;
  117888. /** @hidden */
  117889. _renderViews(): boolean;
  117890. /**
  117891. * Toggle full screen mode
  117892. * @param requestPointerLock defines if a pointer lock should be requested from the user
  117893. */
  117894. switchFullscreen(requestPointerLock: boolean): void;
  117895. /**
  117896. * Enters full screen mode
  117897. * @param requestPointerLock defines if a pointer lock should be requested from the user
  117898. */
  117899. enterFullscreen(requestPointerLock: boolean): void;
  117900. /**
  117901. * Exits full screen mode
  117902. */
  117903. exitFullscreen(): void;
  117904. /**
  117905. * Enters Pointerlock mode
  117906. */
  117907. enterPointerlock(): void;
  117908. /**
  117909. * Exits Pointerlock mode
  117910. */
  117911. exitPointerlock(): void;
  117912. /**
  117913. * Begin a new frame
  117914. */
  117915. beginFrame(): void;
  117916. /**
  117917. * Enf the current frame
  117918. */
  117919. endFrame(): void;
  117920. resize(): void;
  117921. /**
  117922. * Force a specific size of the canvas
  117923. * @param width defines the new canvas' width
  117924. * @param height defines the new canvas' height
  117925. * @returns true if the size was changed
  117926. */
  117927. setSize(width: number, height: number): boolean;
  117928. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  117929. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  117930. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  117931. _releaseTexture(texture: InternalTexture): void;
  117932. /**
  117933. * @hidden
  117934. * Rescales a texture
  117935. * @param source input texutre
  117936. * @param destination destination texture
  117937. * @param scene scene to use to render the resize
  117938. * @param internalFormat format to use when resizing
  117939. * @param onComplete callback to be called when resize has completed
  117940. */
  117941. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  117942. /**
  117943. * Gets the current framerate
  117944. * @returns a number representing the framerate
  117945. */
  117946. getFps(): number;
  117947. /**
  117948. * Gets the time spent between current and previous frame
  117949. * @returns a number representing the delta time in ms
  117950. */
  117951. getDeltaTime(): number;
  117952. private _measureFps;
  117953. /** @hidden */
  117954. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  117955. /**
  117956. * Updates the sample count of a render target texture
  117957. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  117958. * @param texture defines the texture to update
  117959. * @param samples defines the sample count to set
  117960. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  117961. */
  117962. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  117963. /**
  117964. * Updates a depth texture Comparison Mode and Function.
  117965. * If the comparison Function is equal to 0, the mode will be set to none.
  117966. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  117967. * @param texture The texture to set the comparison function for
  117968. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  117969. */
  117970. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  117971. /**
  117972. * Creates a webGL buffer to use with instanciation
  117973. * @param capacity defines the size of the buffer
  117974. * @returns the webGL buffer
  117975. */
  117976. createInstancesBuffer(capacity: number): DataBuffer;
  117977. /**
  117978. * Delete a webGL buffer used with instanciation
  117979. * @param buffer defines the webGL buffer to delete
  117980. */
  117981. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  117982. private _clientWaitAsync;
  117983. /** @hidden */
  117984. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  117985. dispose(): void;
  117986. private _disableTouchAction;
  117987. /**
  117988. * Display the loading screen
  117989. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117990. */
  117991. displayLoadingUI(): void;
  117992. /**
  117993. * Hide the loading screen
  117994. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117995. */
  117996. hideLoadingUI(): void;
  117997. /**
  117998. * Gets the current loading screen object
  117999. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118000. */
  118001. get loadingScreen(): ILoadingScreen;
  118002. /**
  118003. * Sets the current loading screen object
  118004. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118005. */
  118006. set loadingScreen(loadingScreen: ILoadingScreen);
  118007. /**
  118008. * Sets the current loading screen text
  118009. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118010. */
  118011. set loadingUIText(text: string);
  118012. /**
  118013. * Sets the current loading screen background color
  118014. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118015. */
  118016. set loadingUIBackgroundColor(color: string);
  118017. /** Pointerlock and fullscreen */
  118018. /**
  118019. * Ask the browser to promote the current element to pointerlock mode
  118020. * @param element defines the DOM element to promote
  118021. */
  118022. static _RequestPointerlock(element: HTMLElement): void;
  118023. /**
  118024. * Asks the browser to exit pointerlock mode
  118025. */
  118026. static _ExitPointerlock(): void;
  118027. /**
  118028. * Ask the browser to promote the current element to fullscreen rendering mode
  118029. * @param element defines the DOM element to promote
  118030. */
  118031. static _RequestFullscreen(element: HTMLElement): void;
  118032. /**
  118033. * Asks the browser to exit fullscreen mode
  118034. */
  118035. static _ExitFullscreen(): void;
  118036. }
  118037. }
  118038. declare module BABYLON {
  118039. /**
  118040. * The engine store class is responsible to hold all the instances of Engine and Scene created
  118041. * during the life time of the application.
  118042. */
  118043. export class EngineStore {
  118044. /** Gets the list of created engines */
  118045. static Instances: Engine[];
  118046. /** @hidden */
  118047. static _LastCreatedScene: Nullable<Scene>;
  118048. /**
  118049. * Gets the latest created engine
  118050. */
  118051. static get LastCreatedEngine(): Nullable<Engine>;
  118052. /**
  118053. * Gets the latest created scene
  118054. */
  118055. static get LastCreatedScene(): Nullable<Scene>;
  118056. /**
  118057. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118058. * @ignorenaming
  118059. */
  118060. static UseFallbackTexture: boolean;
  118061. /**
  118062. * Texture content used if a texture cannot loaded
  118063. * @ignorenaming
  118064. */
  118065. static FallbackTexture: string;
  118066. }
  118067. }
  118068. declare module BABYLON {
  118069. /**
  118070. * Helper class that provides a small promise polyfill
  118071. */
  118072. export class PromisePolyfill {
  118073. /**
  118074. * Static function used to check if the polyfill is required
  118075. * If this is the case then the function will inject the polyfill to window.Promise
  118076. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  118077. */
  118078. static Apply(force?: boolean): void;
  118079. }
  118080. }
  118081. declare module BABYLON {
  118082. /**
  118083. * Interface for screenshot methods with describe argument called `size` as object with options
  118084. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  118085. */
  118086. export interface IScreenshotSize {
  118087. /**
  118088. * number in pixels for canvas height
  118089. */
  118090. height?: number;
  118091. /**
  118092. * multiplier allowing render at a higher or lower resolution
  118093. * If value is defined then height and width will be ignored and taken from camera
  118094. */
  118095. precision?: number;
  118096. /**
  118097. * number in pixels for canvas width
  118098. */
  118099. width?: number;
  118100. }
  118101. }
  118102. declare module BABYLON {
  118103. interface IColor4Like {
  118104. r: float;
  118105. g: float;
  118106. b: float;
  118107. a: float;
  118108. }
  118109. /**
  118110. * Class containing a set of static utilities functions
  118111. */
  118112. export class Tools {
  118113. /**
  118114. * Gets or sets the base URL to use to load assets
  118115. */
  118116. static get BaseUrl(): string;
  118117. static set BaseUrl(value: string);
  118118. /**
  118119. * Enable/Disable Custom HTTP Request Headers globally.
  118120. * default = false
  118121. * @see CustomRequestHeaders
  118122. */
  118123. static UseCustomRequestHeaders: boolean;
  118124. /**
  118125. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  118126. * i.e. when loading files, where the server/service expects an Authorization header
  118127. */
  118128. static CustomRequestHeaders: {
  118129. [key: string]: string;
  118130. };
  118131. /**
  118132. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  118133. */
  118134. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  118135. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  118136. /**
  118137. * Default behaviour for cors in the application.
  118138. * It can be a string if the expected behavior is identical in the entire app.
  118139. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  118140. */
  118141. static get CorsBehavior(): string | ((url: string | string[]) => string);
  118142. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  118143. /**
  118144. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118145. * @ignorenaming
  118146. */
  118147. static get UseFallbackTexture(): boolean;
  118148. static set UseFallbackTexture(value: boolean);
  118149. /**
  118150. * Use this object to register external classes like custom textures or material
  118151. * to allow the laoders to instantiate them
  118152. */
  118153. static get RegisteredExternalClasses(): {
  118154. [key: string]: Object;
  118155. };
  118156. static set RegisteredExternalClasses(classes: {
  118157. [key: string]: Object;
  118158. });
  118159. /**
  118160. * Texture content used if a texture cannot loaded
  118161. * @ignorenaming
  118162. */
  118163. static get fallbackTexture(): string;
  118164. static set fallbackTexture(value: string);
  118165. /**
  118166. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  118167. * @param u defines the coordinate on X axis
  118168. * @param v defines the coordinate on Y axis
  118169. * @param width defines the width of the source data
  118170. * @param height defines the height of the source data
  118171. * @param pixels defines the source byte array
  118172. * @param color defines the output color
  118173. */
  118174. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  118175. /**
  118176. * Interpolates between a and b via alpha
  118177. * @param a The lower value (returned when alpha = 0)
  118178. * @param b The upper value (returned when alpha = 1)
  118179. * @param alpha The interpolation-factor
  118180. * @return The mixed value
  118181. */
  118182. static Mix(a: number, b: number, alpha: number): number;
  118183. /**
  118184. * Tries to instantiate a new object from a given class name
  118185. * @param className defines the class name to instantiate
  118186. * @returns the new object or null if the system was not able to do the instantiation
  118187. */
  118188. static Instantiate(className: string): any;
  118189. /**
  118190. * Provides a slice function that will work even on IE
  118191. * @param data defines the array to slice
  118192. * @param start defines the start of the data (optional)
  118193. * @param end defines the end of the data (optional)
  118194. * @returns the new sliced array
  118195. */
  118196. static Slice<T>(data: T, start?: number, end?: number): T;
  118197. /**
  118198. * Polyfill for setImmediate
  118199. * @param action defines the action to execute after the current execution block
  118200. */
  118201. static SetImmediate(action: () => void): void;
  118202. /**
  118203. * Function indicating if a number is an exponent of 2
  118204. * @param value defines the value to test
  118205. * @returns true if the value is an exponent of 2
  118206. */
  118207. static IsExponentOfTwo(value: number): boolean;
  118208. private static _tmpFloatArray;
  118209. /**
  118210. * Returns the nearest 32-bit single precision float representation of a Number
  118211. * @param value A Number. If the parameter is of a different type, it will get converted
  118212. * to a number or to NaN if it cannot be converted
  118213. * @returns number
  118214. */
  118215. static FloatRound(value: number): number;
  118216. /**
  118217. * Extracts the filename from a path
  118218. * @param path defines the path to use
  118219. * @returns the filename
  118220. */
  118221. static GetFilename(path: string): string;
  118222. /**
  118223. * Extracts the "folder" part of a path (everything before the filename).
  118224. * @param uri The URI to extract the info from
  118225. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  118226. * @returns The "folder" part of the path
  118227. */
  118228. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  118229. /**
  118230. * Extracts text content from a DOM element hierarchy
  118231. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  118232. */
  118233. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  118234. /**
  118235. * Convert an angle in radians to degrees
  118236. * @param angle defines the angle to convert
  118237. * @returns the angle in degrees
  118238. */
  118239. static ToDegrees(angle: number): number;
  118240. /**
  118241. * Convert an angle in degrees to radians
  118242. * @param angle defines the angle to convert
  118243. * @returns the angle in radians
  118244. */
  118245. static ToRadians(angle: number): number;
  118246. /**
  118247. * Returns an array if obj is not an array
  118248. * @param obj defines the object to evaluate as an array
  118249. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  118250. * @returns either obj directly if obj is an array or a new array containing obj
  118251. */
  118252. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  118253. /**
  118254. * Gets the pointer prefix to use
  118255. * @param engine defines the engine we are finding the prefix for
  118256. * @returns "pointer" if touch is enabled. Else returns "mouse"
  118257. */
  118258. static GetPointerPrefix(engine: Engine): string;
  118259. /**
  118260. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  118261. * @param url define the url we are trying
  118262. * @param element define the dom element where to configure the cors policy
  118263. */
  118264. static SetCorsBehavior(url: string | string[], element: {
  118265. crossOrigin: string | null;
  118266. }): void;
  118267. /**
  118268. * Removes unwanted characters from an url
  118269. * @param url defines the url to clean
  118270. * @returns the cleaned url
  118271. */
  118272. static CleanUrl(url: string): string;
  118273. /**
  118274. * Gets or sets a function used to pre-process url before using them to load assets
  118275. */
  118276. static get PreprocessUrl(): (url: string) => string;
  118277. static set PreprocessUrl(processor: (url: string) => string);
  118278. /**
  118279. * Loads an image as an HTMLImageElement.
  118280. * @param input url string, ArrayBuffer, or Blob to load
  118281. * @param onLoad callback called when the image successfully loads
  118282. * @param onError callback called when the image fails to load
  118283. * @param offlineProvider offline provider for caching
  118284. * @param mimeType optional mime type
  118285. * @returns the HTMLImageElement of the loaded image
  118286. */
  118287. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  118288. /**
  118289. * Loads a file from a url
  118290. * @param url url string, ArrayBuffer, or Blob to load
  118291. * @param onSuccess callback called when the file successfully loads
  118292. * @param onProgress callback called while file is loading (if the server supports this mode)
  118293. * @param offlineProvider defines the offline provider for caching
  118294. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118295. * @param onError callback called when the file fails to load
  118296. * @returns a file request object
  118297. */
  118298. 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;
  118299. /**
  118300. * Loads a file from a url
  118301. * @param url the file url to load
  118302. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118303. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  118304. */
  118305. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  118306. /**
  118307. * Load a script (identified by an url). When the url returns, the
  118308. * content of this file is added into a new script element, attached to the DOM (body element)
  118309. * @param scriptUrl defines the url of the script to laod
  118310. * @param onSuccess defines the callback called when the script is loaded
  118311. * @param onError defines the callback to call if an error occurs
  118312. * @param scriptId defines the id of the script element
  118313. */
  118314. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  118315. /**
  118316. * Load an asynchronous script (identified by an url). When the url returns, the
  118317. * content of this file is added into a new script element, attached to the DOM (body element)
  118318. * @param scriptUrl defines the url of the script to laod
  118319. * @param scriptId defines the id of the script element
  118320. * @returns a promise request object
  118321. */
  118322. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  118323. /**
  118324. * Loads a file from a blob
  118325. * @param fileToLoad defines the blob to use
  118326. * @param callback defines the callback to call when data is loaded
  118327. * @param progressCallback defines the callback to call during loading process
  118328. * @returns a file request object
  118329. */
  118330. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  118331. /**
  118332. * Reads a file from a File object
  118333. * @param file defines the file to load
  118334. * @param onSuccess defines the callback to call when data is loaded
  118335. * @param onProgress defines the callback to call during loading process
  118336. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  118337. * @param onError defines the callback to call when an error occurs
  118338. * @returns a file request object
  118339. */
  118340. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118341. /**
  118342. * Creates a data url from a given string content
  118343. * @param content defines the content to convert
  118344. * @returns the new data url link
  118345. */
  118346. static FileAsURL(content: string): string;
  118347. /**
  118348. * Format the given number to a specific decimal format
  118349. * @param value defines the number to format
  118350. * @param decimals defines the number of decimals to use
  118351. * @returns the formatted string
  118352. */
  118353. static Format(value: number, decimals?: number): string;
  118354. /**
  118355. * Tries to copy an object by duplicating every property
  118356. * @param source defines the source object
  118357. * @param destination defines the target object
  118358. * @param doNotCopyList defines a list of properties to avoid
  118359. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  118360. */
  118361. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  118362. /**
  118363. * Gets a boolean indicating if the given object has no own property
  118364. * @param obj defines the object to test
  118365. * @returns true if object has no own property
  118366. */
  118367. static IsEmpty(obj: any): boolean;
  118368. /**
  118369. * Function used to register events at window level
  118370. * @param windowElement defines the Window object to use
  118371. * @param events defines the events to register
  118372. */
  118373. static RegisterTopRootEvents(windowElement: Window, events: {
  118374. name: string;
  118375. handler: Nullable<(e: FocusEvent) => any>;
  118376. }[]): void;
  118377. /**
  118378. * Function used to unregister events from window level
  118379. * @param windowElement defines the Window object to use
  118380. * @param events defines the events to unregister
  118381. */
  118382. static UnregisterTopRootEvents(windowElement: Window, events: {
  118383. name: string;
  118384. handler: Nullable<(e: FocusEvent) => any>;
  118385. }[]): void;
  118386. /**
  118387. * @ignore
  118388. */
  118389. static _ScreenshotCanvas: HTMLCanvasElement;
  118390. /**
  118391. * Dumps the current bound framebuffer
  118392. * @param width defines the rendering width
  118393. * @param height defines the rendering height
  118394. * @param engine defines the hosting engine
  118395. * @param successCallback defines the callback triggered once the data are available
  118396. * @param mimeType defines the mime type of the result
  118397. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  118398. */
  118399. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118400. /**
  118401. * Converts the canvas data to blob.
  118402. * This acts as a polyfill for browsers not supporting the to blob function.
  118403. * @param canvas Defines the canvas to extract the data from
  118404. * @param successCallback Defines the callback triggered once the data are available
  118405. * @param mimeType Defines the mime type of the result
  118406. */
  118407. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  118408. /**
  118409. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  118410. * @param successCallback defines the callback triggered once the data are available
  118411. * @param mimeType defines the mime type of the result
  118412. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  118413. */
  118414. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118415. /**
  118416. * Downloads a blob in the browser
  118417. * @param blob defines the blob to download
  118418. * @param fileName defines the name of the downloaded file
  118419. */
  118420. static Download(blob: Blob, fileName: string): void;
  118421. /**
  118422. * Captures a screenshot of the current rendering
  118423. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118424. * @param engine defines the rendering engine
  118425. * @param camera defines the source camera
  118426. * @param size This parameter can be set to a single number or to an object with the
  118427. * following (optional) properties: precision, width, height. If a single number is passed,
  118428. * it will be used for both width and height. If an object is passed, the screenshot size
  118429. * will be derived from the parameters. The precision property is a multiplier allowing
  118430. * rendering at a higher or lower resolution
  118431. * @param successCallback defines the callback receives a single parameter which contains the
  118432. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118433. * src parameter of an <img> to display it
  118434. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118435. * Check your browser for supported MIME types
  118436. */
  118437. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  118438. /**
  118439. * Captures a screenshot of the current rendering
  118440. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118441. * @param engine defines the rendering engine
  118442. * @param camera defines the source camera
  118443. * @param size This parameter can be set to a single number or to an object with the
  118444. * following (optional) properties: precision, width, height. If a single number is passed,
  118445. * it will be used for both width and height. If an object is passed, the screenshot size
  118446. * will be derived from the parameters. The precision property is a multiplier allowing
  118447. * rendering at a higher or lower resolution
  118448. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118449. * Check your browser for supported MIME types
  118450. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118451. * to the src parameter of an <img> to display it
  118452. */
  118453. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  118454. /**
  118455. * Generates an image screenshot from the specified camera.
  118456. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118457. * @param engine The engine to use for rendering
  118458. * @param camera The camera to use for rendering
  118459. * @param size This parameter can be set to a single number or to an object with the
  118460. * following (optional) properties: precision, width, height. If a single number is passed,
  118461. * it will be used for both width and height. If an object is passed, the screenshot size
  118462. * will be derived from the parameters. The precision property is a multiplier allowing
  118463. * rendering at a higher or lower resolution
  118464. * @param successCallback The callback receives a single parameter which contains the
  118465. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118466. * src parameter of an <img> to display it
  118467. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118468. * Check your browser for supported MIME types
  118469. * @param samples Texture samples (default: 1)
  118470. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118471. * @param fileName A name for for the downloaded file.
  118472. */
  118473. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  118474. /**
  118475. * Generates an image screenshot from the specified camera.
  118476. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118477. * @param engine The engine to use for rendering
  118478. * @param camera The camera to use for rendering
  118479. * @param size This parameter can be set to a single number or to an object with the
  118480. * following (optional) properties: precision, width, height. If a single number is passed,
  118481. * it will be used for both width and height. If an object is passed, the screenshot size
  118482. * will be derived from the parameters. The precision property is a multiplier allowing
  118483. * rendering at a higher or lower resolution
  118484. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118485. * Check your browser for supported MIME types
  118486. * @param samples Texture samples (default: 1)
  118487. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118488. * @param fileName A name for for the downloaded file.
  118489. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118490. * to the src parameter of an <img> to display it
  118491. */
  118492. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  118493. /**
  118494. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  118495. * Be aware Math.random() could cause collisions, but:
  118496. * "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"
  118497. * @returns a pseudo random id
  118498. */
  118499. static RandomId(): string;
  118500. /**
  118501. * Test if the given uri is a base64 string
  118502. * @param uri The uri to test
  118503. * @return True if the uri is a base64 string or false otherwise
  118504. */
  118505. static IsBase64(uri: string): boolean;
  118506. /**
  118507. * Decode the given base64 uri.
  118508. * @param uri The uri to decode
  118509. * @return The decoded base64 data.
  118510. */
  118511. static DecodeBase64(uri: string): ArrayBuffer;
  118512. /**
  118513. * Gets the absolute url.
  118514. * @param url the input url
  118515. * @return the absolute url
  118516. */
  118517. static GetAbsoluteUrl(url: string): string;
  118518. /**
  118519. * No log
  118520. */
  118521. static readonly NoneLogLevel: number;
  118522. /**
  118523. * Only message logs
  118524. */
  118525. static readonly MessageLogLevel: number;
  118526. /**
  118527. * Only warning logs
  118528. */
  118529. static readonly WarningLogLevel: number;
  118530. /**
  118531. * Only error logs
  118532. */
  118533. static readonly ErrorLogLevel: number;
  118534. /**
  118535. * All logs
  118536. */
  118537. static readonly AllLogLevel: number;
  118538. /**
  118539. * Gets a value indicating the number of loading errors
  118540. * @ignorenaming
  118541. */
  118542. static get errorsCount(): number;
  118543. /**
  118544. * Callback called when a new log is added
  118545. */
  118546. static OnNewCacheEntry: (entry: string) => void;
  118547. /**
  118548. * Log a message to the console
  118549. * @param message defines the message to log
  118550. */
  118551. static Log(message: string): void;
  118552. /**
  118553. * Write a warning message to the console
  118554. * @param message defines the message to log
  118555. */
  118556. static Warn(message: string): void;
  118557. /**
  118558. * Write an error message to the console
  118559. * @param message defines the message to log
  118560. */
  118561. static Error(message: string): void;
  118562. /**
  118563. * Gets current log cache (list of logs)
  118564. */
  118565. static get LogCache(): string;
  118566. /**
  118567. * Clears the log cache
  118568. */
  118569. static ClearLogCache(): void;
  118570. /**
  118571. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  118572. */
  118573. static set LogLevels(level: number);
  118574. /**
  118575. * Checks if the window object exists
  118576. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  118577. */
  118578. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  118579. /**
  118580. * No performance log
  118581. */
  118582. static readonly PerformanceNoneLogLevel: number;
  118583. /**
  118584. * Use user marks to log performance
  118585. */
  118586. static readonly PerformanceUserMarkLogLevel: number;
  118587. /**
  118588. * Log performance to the console
  118589. */
  118590. static readonly PerformanceConsoleLogLevel: number;
  118591. private static _performance;
  118592. /**
  118593. * Sets the current performance log level
  118594. */
  118595. static set PerformanceLogLevel(level: number);
  118596. private static _StartPerformanceCounterDisabled;
  118597. private static _EndPerformanceCounterDisabled;
  118598. private static _StartUserMark;
  118599. private static _EndUserMark;
  118600. private static _StartPerformanceConsole;
  118601. private static _EndPerformanceConsole;
  118602. /**
  118603. * Starts a performance counter
  118604. */
  118605. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  118606. /**
  118607. * Ends a specific performance coutner
  118608. */
  118609. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  118610. /**
  118611. * Gets either window.performance.now() if supported or Date.now() else
  118612. */
  118613. static get Now(): number;
  118614. /**
  118615. * This method will return the name of the class used to create the instance of the given object.
  118616. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  118617. * @param object the object to get the class name from
  118618. * @param isType defines if the object is actually a type
  118619. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  118620. */
  118621. static GetClassName(object: any, isType?: boolean): string;
  118622. /**
  118623. * Gets the first element of an array satisfying a given predicate
  118624. * @param array defines the array to browse
  118625. * @param predicate defines the predicate to use
  118626. * @returns null if not found or the element
  118627. */
  118628. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  118629. /**
  118630. * This method will return the name of the full name of the class, including its owning module (if any).
  118631. * 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).
  118632. * @param object the object to get the class name from
  118633. * @param isType defines if the object is actually a type
  118634. * @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.
  118635. * @ignorenaming
  118636. */
  118637. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  118638. /**
  118639. * Returns a promise that resolves after the given amount of time.
  118640. * @param delay Number of milliseconds to delay
  118641. * @returns Promise that resolves after the given amount of time
  118642. */
  118643. static DelayAsync(delay: number): Promise<void>;
  118644. /**
  118645. * Utility function to detect if the current user agent is Safari
  118646. * @returns whether or not the current user agent is safari
  118647. */
  118648. static IsSafari(): boolean;
  118649. }
  118650. /**
  118651. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  118652. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  118653. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  118654. * @param name The name of the class, case should be preserved
  118655. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  118656. */
  118657. export function className(name: string, module?: string): (target: Object) => void;
  118658. /**
  118659. * An implementation of a loop for asynchronous functions.
  118660. */
  118661. export class AsyncLoop {
  118662. /**
  118663. * Defines the number of iterations for the loop
  118664. */
  118665. iterations: number;
  118666. /**
  118667. * Defines the current index of the loop.
  118668. */
  118669. index: number;
  118670. private _done;
  118671. private _fn;
  118672. private _successCallback;
  118673. /**
  118674. * Constructor.
  118675. * @param iterations the number of iterations.
  118676. * @param func the function to run each iteration
  118677. * @param successCallback the callback that will be called upon succesful execution
  118678. * @param offset starting offset.
  118679. */
  118680. constructor(
  118681. /**
  118682. * Defines the number of iterations for the loop
  118683. */
  118684. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  118685. /**
  118686. * Execute the next iteration. Must be called after the last iteration was finished.
  118687. */
  118688. executeNext(): void;
  118689. /**
  118690. * Break the loop and run the success callback.
  118691. */
  118692. breakLoop(): void;
  118693. /**
  118694. * Create and run an async loop.
  118695. * @param iterations the number of iterations.
  118696. * @param fn the function to run each iteration
  118697. * @param successCallback the callback that will be called upon succesful execution
  118698. * @param offset starting offset.
  118699. * @returns the created async loop object
  118700. */
  118701. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  118702. /**
  118703. * A for-loop that will run a given number of iterations synchronous and the rest async.
  118704. * @param iterations total number of iterations
  118705. * @param syncedIterations number of synchronous iterations in each async iteration.
  118706. * @param fn the function to call each iteration.
  118707. * @param callback a success call back that will be called when iterating stops.
  118708. * @param breakFunction a break condition (optional)
  118709. * @param timeout timeout settings for the setTimeout function. default - 0.
  118710. * @returns the created async loop object
  118711. */
  118712. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  118713. }
  118714. }
  118715. declare module BABYLON {
  118716. /**
  118717. * This class implement a typical dictionary using a string as key and the generic type T as value.
  118718. * The underlying implementation relies on an associative array to ensure the best performances.
  118719. * The value can be anything including 'null' but except 'undefined'
  118720. */
  118721. export class StringDictionary<T> {
  118722. /**
  118723. * This will clear this dictionary and copy the content from the 'source' one.
  118724. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  118725. * @param source the dictionary to take the content from and copy to this dictionary
  118726. */
  118727. copyFrom(source: StringDictionary<T>): void;
  118728. /**
  118729. * Get a value based from its key
  118730. * @param key the given key to get the matching value from
  118731. * @return the value if found, otherwise undefined is returned
  118732. */
  118733. get(key: string): T | undefined;
  118734. /**
  118735. * Get a value from its key or add it if it doesn't exist.
  118736. * This method will ensure you that a given key/data will be present in the dictionary.
  118737. * @param key the given key to get the matching value from
  118738. * @param factory the factory that will create the value if the key is not present in the dictionary.
  118739. * The factory will only be invoked if there's no data for the given key.
  118740. * @return the value corresponding to the key.
  118741. */
  118742. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  118743. /**
  118744. * Get a value from its key if present in the dictionary otherwise add it
  118745. * @param key the key to get the value from
  118746. * @param val if there's no such key/value pair in the dictionary add it with this value
  118747. * @return the value corresponding to the key
  118748. */
  118749. getOrAdd(key: string, val: T): T;
  118750. /**
  118751. * Check if there's a given key in the dictionary
  118752. * @param key the key to check for
  118753. * @return true if the key is present, false otherwise
  118754. */
  118755. contains(key: string): boolean;
  118756. /**
  118757. * Add a new key and its corresponding value
  118758. * @param key the key to add
  118759. * @param value the value corresponding to the key
  118760. * @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
  118761. */
  118762. add(key: string, value: T): boolean;
  118763. /**
  118764. * Update a specific value associated to a key
  118765. * @param key defines the key to use
  118766. * @param value defines the value to store
  118767. * @returns true if the value was updated (or false if the key was not found)
  118768. */
  118769. set(key: string, value: T): boolean;
  118770. /**
  118771. * Get the element of the given key and remove it from the dictionary
  118772. * @param key defines the key to search
  118773. * @returns the value associated with the key or null if not found
  118774. */
  118775. getAndRemove(key: string): Nullable<T>;
  118776. /**
  118777. * Remove a key/value from the dictionary.
  118778. * @param key the key to remove
  118779. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  118780. */
  118781. remove(key: string): boolean;
  118782. /**
  118783. * Clear the whole content of the dictionary
  118784. */
  118785. clear(): void;
  118786. /**
  118787. * Gets the current count
  118788. */
  118789. get count(): number;
  118790. /**
  118791. * Execute a callback on each key/val of the dictionary.
  118792. * Note that you can remove any element in this dictionary in the callback implementation
  118793. * @param callback the callback to execute on a given key/value pair
  118794. */
  118795. forEach(callback: (key: string, val: T) => void): void;
  118796. /**
  118797. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  118798. * If the callback returns null or undefined the method will iterate to the next key/value pair
  118799. * Note that you can remove any element in this dictionary in the callback implementation
  118800. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  118801. * @returns the first item
  118802. */
  118803. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  118804. private _count;
  118805. private _data;
  118806. }
  118807. }
  118808. declare module BABYLON {
  118809. /** @hidden */
  118810. export interface ICollisionCoordinator {
  118811. createCollider(): Collider;
  118812. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  118813. init(scene: Scene): void;
  118814. }
  118815. /** @hidden */
  118816. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  118817. private _scene;
  118818. private _scaledPosition;
  118819. private _scaledVelocity;
  118820. private _finalPosition;
  118821. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  118822. createCollider(): Collider;
  118823. init(scene: Scene): void;
  118824. private _collideWithWorld;
  118825. }
  118826. }
  118827. declare module BABYLON {
  118828. /**
  118829. * Class used to manage all inputs for the scene.
  118830. */
  118831. export class InputManager {
  118832. /** The distance in pixel that you have to move to prevent some events */
  118833. static DragMovementThreshold: number;
  118834. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  118835. static LongPressDelay: number;
  118836. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  118837. static DoubleClickDelay: number;
  118838. /** If you need to check double click without raising a single click at first click, enable this flag */
  118839. static ExclusiveDoubleClickMode: boolean;
  118840. /** 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. */
  118841. private _alreadyAttached;
  118842. private _wheelEventName;
  118843. private _onPointerMove;
  118844. private _onPointerDown;
  118845. private _onPointerUp;
  118846. private _initClickEvent;
  118847. private _initActionManager;
  118848. private _delayedSimpleClick;
  118849. private _delayedSimpleClickTimeout;
  118850. private _previousDelayedSimpleClickTimeout;
  118851. private _meshPickProceed;
  118852. private _previousButtonPressed;
  118853. private _currentPickResult;
  118854. private _previousPickResult;
  118855. private _totalPointersPressed;
  118856. private _doubleClickOccured;
  118857. private _pointerOverMesh;
  118858. private _pickedDownMesh;
  118859. private _pickedUpMesh;
  118860. private _pointerX;
  118861. private _pointerY;
  118862. private _unTranslatedPointerX;
  118863. private _unTranslatedPointerY;
  118864. private _startingPointerPosition;
  118865. private _previousStartingPointerPosition;
  118866. private _startingPointerTime;
  118867. private _previousStartingPointerTime;
  118868. private _pointerCaptures;
  118869. private _meshUnderPointerId;
  118870. private _onKeyDown;
  118871. private _onKeyUp;
  118872. private _onCanvasFocusObserver;
  118873. private _onCanvasBlurObserver;
  118874. private _scene;
  118875. /**
  118876. * Creates a new InputManager
  118877. * @param scene defines the hosting scene
  118878. */
  118879. constructor(scene: Scene);
  118880. /**
  118881. * Gets the mesh that is currently under the pointer
  118882. */
  118883. get meshUnderPointer(): Nullable<AbstractMesh>;
  118884. /**
  118885. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  118886. * @param pointerId the pointer id to use
  118887. * @returns The mesh under this pointer id or null if not found
  118888. */
  118889. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  118890. /**
  118891. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  118892. */
  118893. get unTranslatedPointer(): Vector2;
  118894. /**
  118895. * Gets or sets the current on-screen X position of the pointer
  118896. */
  118897. get pointerX(): number;
  118898. set pointerX(value: number);
  118899. /**
  118900. * Gets or sets the current on-screen Y position of the pointer
  118901. */
  118902. get pointerY(): number;
  118903. set pointerY(value: number);
  118904. private _updatePointerPosition;
  118905. private _processPointerMove;
  118906. private _setRayOnPointerInfo;
  118907. private _checkPrePointerObservable;
  118908. /**
  118909. * Use this method to simulate a pointer move on a mesh
  118910. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118911. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118912. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118913. */
  118914. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  118915. /**
  118916. * Use this method to simulate a pointer down on a mesh
  118917. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118918. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118919. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118920. */
  118921. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  118922. private _processPointerDown;
  118923. /** @hidden */
  118924. _isPointerSwiping(): boolean;
  118925. /**
  118926. * Use this method to simulate a pointer up on a mesh
  118927. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118928. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118929. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118930. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  118931. */
  118932. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  118933. private _processPointerUp;
  118934. /**
  118935. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  118936. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  118937. * @returns true if the pointer was captured
  118938. */
  118939. isPointerCaptured(pointerId?: number): boolean;
  118940. /**
  118941. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  118942. * @param attachUp defines if you want to attach events to pointerup
  118943. * @param attachDown defines if you want to attach events to pointerdown
  118944. * @param attachMove defines if you want to attach events to pointermove
  118945. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  118946. */
  118947. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  118948. /**
  118949. * Detaches all event handlers
  118950. */
  118951. detachControl(): void;
  118952. /**
  118953. * Force the value of meshUnderPointer
  118954. * @param mesh defines the mesh to use
  118955. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  118956. */
  118957. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  118958. /**
  118959. * Gets the mesh under the pointer
  118960. * @returns a Mesh or null if no mesh is under the pointer
  118961. */
  118962. getPointerOverMesh(): Nullable<AbstractMesh>;
  118963. }
  118964. }
  118965. declare module BABYLON {
  118966. /**
  118967. * This class defines the direct association between an animation and a target
  118968. */
  118969. export class TargetedAnimation {
  118970. /**
  118971. * Animation to perform
  118972. */
  118973. animation: Animation;
  118974. /**
  118975. * Target to animate
  118976. */
  118977. target: any;
  118978. /**
  118979. * Returns the string "TargetedAnimation"
  118980. * @returns "TargetedAnimation"
  118981. */
  118982. getClassName(): string;
  118983. /**
  118984. * Serialize the object
  118985. * @returns the JSON object representing the current entity
  118986. */
  118987. serialize(): any;
  118988. }
  118989. /**
  118990. * Use this class to create coordinated animations on multiple targets
  118991. */
  118992. export class AnimationGroup implements IDisposable {
  118993. /** The name of the animation group */
  118994. name: string;
  118995. private _scene;
  118996. private _targetedAnimations;
  118997. private _animatables;
  118998. private _from;
  118999. private _to;
  119000. private _isStarted;
  119001. private _isPaused;
  119002. private _speedRatio;
  119003. private _loopAnimation;
  119004. private _isAdditive;
  119005. /**
  119006. * Gets or sets the unique id of the node
  119007. */
  119008. uniqueId: number;
  119009. /**
  119010. * This observable will notify when one animation have ended
  119011. */
  119012. onAnimationEndObservable: Observable<TargetedAnimation>;
  119013. /**
  119014. * Observer raised when one animation loops
  119015. */
  119016. onAnimationLoopObservable: Observable<TargetedAnimation>;
  119017. /**
  119018. * Observer raised when all animations have looped
  119019. */
  119020. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  119021. /**
  119022. * This observable will notify when all animations have ended.
  119023. */
  119024. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  119025. /**
  119026. * This observable will notify when all animations have paused.
  119027. */
  119028. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  119029. /**
  119030. * This observable will notify when all animations are playing.
  119031. */
  119032. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  119033. /**
  119034. * Gets the first frame
  119035. */
  119036. get from(): number;
  119037. /**
  119038. * Gets the last frame
  119039. */
  119040. get to(): number;
  119041. /**
  119042. * Define if the animations are started
  119043. */
  119044. get isStarted(): boolean;
  119045. /**
  119046. * Gets a value indicating that the current group is playing
  119047. */
  119048. get isPlaying(): boolean;
  119049. /**
  119050. * Gets or sets the speed ratio to use for all animations
  119051. */
  119052. get speedRatio(): number;
  119053. /**
  119054. * Gets or sets the speed ratio to use for all animations
  119055. */
  119056. set speedRatio(value: number);
  119057. /**
  119058. * Gets or sets if all animations should loop or not
  119059. */
  119060. get loopAnimation(): boolean;
  119061. set loopAnimation(value: boolean);
  119062. /**
  119063. * Gets or sets if all animations should be evaluated additively
  119064. */
  119065. get isAdditive(): boolean;
  119066. set isAdditive(value: boolean);
  119067. /**
  119068. * Gets the targeted animations for this animation group
  119069. */
  119070. get targetedAnimations(): Array<TargetedAnimation>;
  119071. /**
  119072. * returning the list of animatables controlled by this animation group.
  119073. */
  119074. get animatables(): Array<Animatable>;
  119075. /**
  119076. * Gets the list of target animations
  119077. */
  119078. get children(): TargetedAnimation[];
  119079. /**
  119080. * Instantiates a new Animation Group.
  119081. * This helps managing several animations at once.
  119082. * @see https://doc.babylonjs.com/how_to/group
  119083. * @param name Defines the name of the group
  119084. * @param scene Defines the scene the group belongs to
  119085. */
  119086. constructor(
  119087. /** The name of the animation group */
  119088. name: string, scene?: Nullable<Scene>);
  119089. /**
  119090. * Add an animation (with its target) in the group
  119091. * @param animation defines the animation we want to add
  119092. * @param target defines the target of the animation
  119093. * @returns the TargetedAnimation object
  119094. */
  119095. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  119096. /**
  119097. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  119098. * It can add constant keys at begin or end
  119099. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  119100. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  119101. * @returns the animation group
  119102. */
  119103. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  119104. private _animationLoopCount;
  119105. private _animationLoopFlags;
  119106. private _processLoop;
  119107. /**
  119108. * Start all animations on given targets
  119109. * @param loop defines if animations must loop
  119110. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  119111. * @param from defines the from key (optional)
  119112. * @param to defines the to key (optional)
  119113. * @param isAdditive defines the additive state for the resulting animatables (optional)
  119114. * @returns the current animation group
  119115. */
  119116. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  119117. /**
  119118. * Pause all animations
  119119. * @returns the animation group
  119120. */
  119121. pause(): AnimationGroup;
  119122. /**
  119123. * Play all animations to initial state
  119124. * This function will start() the animations if they were not started or will restart() them if they were paused
  119125. * @param loop defines if animations must loop
  119126. * @returns the animation group
  119127. */
  119128. play(loop?: boolean): AnimationGroup;
  119129. /**
  119130. * Reset all animations to initial state
  119131. * @returns the animation group
  119132. */
  119133. reset(): AnimationGroup;
  119134. /**
  119135. * Restart animations from key 0
  119136. * @returns the animation group
  119137. */
  119138. restart(): AnimationGroup;
  119139. /**
  119140. * Stop all animations
  119141. * @returns the animation group
  119142. */
  119143. stop(): AnimationGroup;
  119144. /**
  119145. * Set animation weight for all animatables
  119146. * @param weight defines the weight to use
  119147. * @return the animationGroup
  119148. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119149. */
  119150. setWeightForAllAnimatables(weight: number): AnimationGroup;
  119151. /**
  119152. * Synchronize and normalize all animatables with a source animatable
  119153. * @param root defines the root animatable to synchronize with
  119154. * @return the animationGroup
  119155. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119156. */
  119157. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  119158. /**
  119159. * Goes to a specific frame in this animation group
  119160. * @param frame the frame number to go to
  119161. * @return the animationGroup
  119162. */
  119163. goToFrame(frame: number): AnimationGroup;
  119164. /**
  119165. * Dispose all associated resources
  119166. */
  119167. dispose(): void;
  119168. private _checkAnimationGroupEnded;
  119169. /**
  119170. * Clone the current animation group and returns a copy
  119171. * @param newName defines the name of the new group
  119172. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  119173. * @returns the new aniamtion group
  119174. */
  119175. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  119176. /**
  119177. * Serializes the animationGroup to an object
  119178. * @returns Serialized object
  119179. */
  119180. serialize(): any;
  119181. /**
  119182. * Returns a new AnimationGroup object parsed from the source provided.
  119183. * @param parsedAnimationGroup defines the source
  119184. * @param scene defines the scene that will receive the animationGroup
  119185. * @returns a new AnimationGroup
  119186. */
  119187. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  119188. /**
  119189. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  119190. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  119191. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  119192. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  119193. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  119194. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  119195. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  119196. */
  119197. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  119198. /**
  119199. * Returns the string "AnimationGroup"
  119200. * @returns "AnimationGroup"
  119201. */
  119202. getClassName(): string;
  119203. /**
  119204. * Creates a detailled string about the object
  119205. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  119206. * @returns a string representing the object
  119207. */
  119208. toString(fullDetails?: boolean): string;
  119209. }
  119210. }
  119211. declare module BABYLON {
  119212. /**
  119213. * Define an interface for all classes that will hold resources
  119214. */
  119215. export interface IDisposable {
  119216. /**
  119217. * Releases all held resources
  119218. */
  119219. dispose(): void;
  119220. }
  119221. /** Interface defining initialization parameters for Scene class */
  119222. export interface SceneOptions {
  119223. /**
  119224. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  119225. * It will improve performance when the number of geometries becomes important.
  119226. */
  119227. useGeometryUniqueIdsMap?: boolean;
  119228. /**
  119229. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  119230. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119231. */
  119232. useMaterialMeshMap?: boolean;
  119233. /**
  119234. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  119235. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119236. */
  119237. useClonedMeshMap?: boolean;
  119238. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  119239. virtual?: boolean;
  119240. }
  119241. /**
  119242. * Represents a scene to be rendered by the engine.
  119243. * @see https://doc.babylonjs.com/features/scene
  119244. */
  119245. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  119246. /** The fog is deactivated */
  119247. static readonly FOGMODE_NONE: number;
  119248. /** The fog density is following an exponential function */
  119249. static readonly FOGMODE_EXP: number;
  119250. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  119251. static readonly FOGMODE_EXP2: number;
  119252. /** The fog density is following a linear function. */
  119253. static readonly FOGMODE_LINEAR: number;
  119254. /**
  119255. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  119256. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119257. */
  119258. static MinDeltaTime: number;
  119259. /**
  119260. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  119261. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119262. */
  119263. static MaxDeltaTime: number;
  119264. /**
  119265. * Factory used to create the default material.
  119266. * @param name The name of the material to create
  119267. * @param scene The scene to create the material for
  119268. * @returns The default material
  119269. */
  119270. static DefaultMaterialFactory(scene: Scene): Material;
  119271. /**
  119272. * Factory used to create the a collision coordinator.
  119273. * @returns The collision coordinator
  119274. */
  119275. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  119276. /** @hidden */
  119277. _inputManager: InputManager;
  119278. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  119279. cameraToUseForPointers: Nullable<Camera>;
  119280. /** @hidden */
  119281. readonly _isScene: boolean;
  119282. /** @hidden */
  119283. _blockEntityCollection: boolean;
  119284. /**
  119285. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  119286. */
  119287. autoClear: boolean;
  119288. /**
  119289. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  119290. */
  119291. autoClearDepthAndStencil: boolean;
  119292. /**
  119293. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  119294. */
  119295. clearColor: Color4;
  119296. /**
  119297. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  119298. */
  119299. ambientColor: Color3;
  119300. /**
  119301. * This is use to store the default BRDF lookup for PBR materials in your scene.
  119302. * It should only be one of the following (if not the default embedded one):
  119303. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  119304. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  119305. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  119306. * The material properties need to be setup according to the type of texture in use.
  119307. */
  119308. environmentBRDFTexture: BaseTexture;
  119309. /**
  119310. * Texture used in all pbr material as the reflection texture.
  119311. * As in the majority of the scene they are the same (exception for multi room and so on),
  119312. * this is easier to reference from here than from all the materials.
  119313. */
  119314. get environmentTexture(): Nullable<BaseTexture>;
  119315. /**
  119316. * Texture used in all pbr material as the reflection texture.
  119317. * As in the majority of the scene they are the same (exception for multi room and so on),
  119318. * this is easier to set here than in all the materials.
  119319. */
  119320. set environmentTexture(value: Nullable<BaseTexture>);
  119321. /** @hidden */
  119322. protected _environmentIntensity: number;
  119323. /**
  119324. * Intensity of the environment in all pbr material.
  119325. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119326. * As in the majority of the scene they are the same (exception for multi room and so on),
  119327. * this is easier to reference from here than from all the materials.
  119328. */
  119329. get environmentIntensity(): number;
  119330. /**
  119331. * Intensity of the environment in all pbr material.
  119332. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119333. * As in the majority of the scene they are the same (exception for multi room and so on),
  119334. * this is easier to set here than in all the materials.
  119335. */
  119336. set environmentIntensity(value: number);
  119337. /** @hidden */
  119338. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119339. /**
  119340. * Default image processing configuration used either in the rendering
  119341. * Forward main pass or through the imageProcessingPostProcess if present.
  119342. * As in the majority of the scene they are the same (exception for multi camera),
  119343. * this is easier to reference from here than from all the materials and post process.
  119344. *
  119345. * No setter as we it is a shared configuration, you can set the values instead.
  119346. */
  119347. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  119348. private _forceWireframe;
  119349. /**
  119350. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  119351. */
  119352. set forceWireframe(value: boolean);
  119353. get forceWireframe(): boolean;
  119354. private _skipFrustumClipping;
  119355. /**
  119356. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  119357. */
  119358. set skipFrustumClipping(value: boolean);
  119359. get skipFrustumClipping(): boolean;
  119360. private _forcePointsCloud;
  119361. /**
  119362. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  119363. */
  119364. set forcePointsCloud(value: boolean);
  119365. get forcePointsCloud(): boolean;
  119366. /**
  119367. * Gets or sets the active clipplane 1
  119368. */
  119369. clipPlane: Nullable<Plane>;
  119370. /**
  119371. * Gets or sets the active clipplane 2
  119372. */
  119373. clipPlane2: Nullable<Plane>;
  119374. /**
  119375. * Gets or sets the active clipplane 3
  119376. */
  119377. clipPlane3: Nullable<Plane>;
  119378. /**
  119379. * Gets or sets the active clipplane 4
  119380. */
  119381. clipPlane4: Nullable<Plane>;
  119382. /**
  119383. * Gets or sets the active clipplane 5
  119384. */
  119385. clipPlane5: Nullable<Plane>;
  119386. /**
  119387. * Gets or sets the active clipplane 6
  119388. */
  119389. clipPlane6: Nullable<Plane>;
  119390. /**
  119391. * Gets or sets a boolean indicating if animations are enabled
  119392. */
  119393. animationsEnabled: boolean;
  119394. private _animationPropertiesOverride;
  119395. /**
  119396. * Gets or sets the animation properties override
  119397. */
  119398. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  119399. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  119400. /**
  119401. * Gets or sets a boolean indicating if a constant deltatime has to be used
  119402. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  119403. */
  119404. useConstantAnimationDeltaTime: boolean;
  119405. /**
  119406. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  119407. * Please note that it requires to run a ray cast through the scene on every frame
  119408. */
  119409. constantlyUpdateMeshUnderPointer: boolean;
  119410. /**
  119411. * Defines the HTML cursor to use when hovering over interactive elements
  119412. */
  119413. hoverCursor: string;
  119414. /**
  119415. * Defines the HTML default cursor to use (empty by default)
  119416. */
  119417. defaultCursor: string;
  119418. /**
  119419. * Defines whether cursors are handled by the scene.
  119420. */
  119421. doNotHandleCursors: boolean;
  119422. /**
  119423. * This is used to call preventDefault() on pointer down
  119424. * in order to block unwanted artifacts like system double clicks
  119425. */
  119426. preventDefaultOnPointerDown: boolean;
  119427. /**
  119428. * This is used to call preventDefault() on pointer up
  119429. * in order to block unwanted artifacts like system double clicks
  119430. */
  119431. preventDefaultOnPointerUp: boolean;
  119432. /**
  119433. * Gets or sets user defined metadata
  119434. */
  119435. metadata: any;
  119436. /**
  119437. * For internal use only. Please do not use.
  119438. */
  119439. reservedDataStore: any;
  119440. /**
  119441. * Gets the name of the plugin used to load this scene (null by default)
  119442. */
  119443. loadingPluginName: string;
  119444. /**
  119445. * Use this array to add regular expressions used to disable offline support for specific urls
  119446. */
  119447. disableOfflineSupportExceptionRules: RegExp[];
  119448. /**
  119449. * An event triggered when the scene is disposed.
  119450. */
  119451. onDisposeObservable: Observable<Scene>;
  119452. private _onDisposeObserver;
  119453. /** Sets a function to be executed when this scene is disposed. */
  119454. set onDispose(callback: () => void);
  119455. /**
  119456. * An event triggered before rendering the scene (right after animations and physics)
  119457. */
  119458. onBeforeRenderObservable: Observable<Scene>;
  119459. private _onBeforeRenderObserver;
  119460. /** Sets a function to be executed before rendering this scene */
  119461. set beforeRender(callback: Nullable<() => void>);
  119462. /**
  119463. * An event triggered after rendering the scene
  119464. */
  119465. onAfterRenderObservable: Observable<Scene>;
  119466. /**
  119467. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  119468. */
  119469. onAfterRenderCameraObservable: Observable<Camera>;
  119470. private _onAfterRenderObserver;
  119471. /** Sets a function to be executed after rendering this scene */
  119472. set afterRender(callback: Nullable<() => void>);
  119473. /**
  119474. * An event triggered before animating the scene
  119475. */
  119476. onBeforeAnimationsObservable: Observable<Scene>;
  119477. /**
  119478. * An event triggered after animations processing
  119479. */
  119480. onAfterAnimationsObservable: Observable<Scene>;
  119481. /**
  119482. * An event triggered before draw calls are ready to be sent
  119483. */
  119484. onBeforeDrawPhaseObservable: Observable<Scene>;
  119485. /**
  119486. * An event triggered after draw calls have been sent
  119487. */
  119488. onAfterDrawPhaseObservable: Observable<Scene>;
  119489. /**
  119490. * An event triggered when the scene is ready
  119491. */
  119492. onReadyObservable: Observable<Scene>;
  119493. /**
  119494. * An event triggered before rendering a camera
  119495. */
  119496. onBeforeCameraRenderObservable: Observable<Camera>;
  119497. private _onBeforeCameraRenderObserver;
  119498. /** Sets a function to be executed before rendering a camera*/
  119499. set beforeCameraRender(callback: () => void);
  119500. /**
  119501. * An event triggered after rendering a camera
  119502. */
  119503. onAfterCameraRenderObservable: Observable<Camera>;
  119504. private _onAfterCameraRenderObserver;
  119505. /** Sets a function to be executed after rendering a camera*/
  119506. set afterCameraRender(callback: () => void);
  119507. /**
  119508. * An event triggered when active meshes evaluation is about to start
  119509. */
  119510. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  119511. /**
  119512. * An event triggered when active meshes evaluation is done
  119513. */
  119514. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  119515. /**
  119516. * An event triggered when particles rendering is about to start
  119517. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119518. */
  119519. onBeforeParticlesRenderingObservable: Observable<Scene>;
  119520. /**
  119521. * An event triggered when particles rendering is done
  119522. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119523. */
  119524. onAfterParticlesRenderingObservable: Observable<Scene>;
  119525. /**
  119526. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  119527. */
  119528. onDataLoadedObservable: Observable<Scene>;
  119529. /**
  119530. * An event triggered when a camera is created
  119531. */
  119532. onNewCameraAddedObservable: Observable<Camera>;
  119533. /**
  119534. * An event triggered when a camera is removed
  119535. */
  119536. onCameraRemovedObservable: Observable<Camera>;
  119537. /**
  119538. * An event triggered when a light is created
  119539. */
  119540. onNewLightAddedObservable: Observable<Light>;
  119541. /**
  119542. * An event triggered when a light is removed
  119543. */
  119544. onLightRemovedObservable: Observable<Light>;
  119545. /**
  119546. * An event triggered when a geometry is created
  119547. */
  119548. onNewGeometryAddedObservable: Observable<Geometry>;
  119549. /**
  119550. * An event triggered when a geometry is removed
  119551. */
  119552. onGeometryRemovedObservable: Observable<Geometry>;
  119553. /**
  119554. * An event triggered when a transform node is created
  119555. */
  119556. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  119557. /**
  119558. * An event triggered when a transform node is removed
  119559. */
  119560. onTransformNodeRemovedObservable: Observable<TransformNode>;
  119561. /**
  119562. * An event triggered when a mesh is created
  119563. */
  119564. onNewMeshAddedObservable: Observable<AbstractMesh>;
  119565. /**
  119566. * An event triggered when a mesh is removed
  119567. */
  119568. onMeshRemovedObservable: Observable<AbstractMesh>;
  119569. /**
  119570. * An event triggered when a skeleton is created
  119571. */
  119572. onNewSkeletonAddedObservable: Observable<Skeleton>;
  119573. /**
  119574. * An event triggered when a skeleton is removed
  119575. */
  119576. onSkeletonRemovedObservable: Observable<Skeleton>;
  119577. /**
  119578. * An event triggered when a material is created
  119579. */
  119580. onNewMaterialAddedObservable: Observable<Material>;
  119581. /**
  119582. * An event triggered when a material is removed
  119583. */
  119584. onMaterialRemovedObservable: Observable<Material>;
  119585. /**
  119586. * An event triggered when a texture is created
  119587. */
  119588. onNewTextureAddedObservable: Observable<BaseTexture>;
  119589. /**
  119590. * An event triggered when a texture is removed
  119591. */
  119592. onTextureRemovedObservable: Observable<BaseTexture>;
  119593. /**
  119594. * An event triggered when render targets are about to be rendered
  119595. * Can happen multiple times per frame.
  119596. */
  119597. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  119598. /**
  119599. * An event triggered when render targets were rendered.
  119600. * Can happen multiple times per frame.
  119601. */
  119602. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  119603. /**
  119604. * An event triggered before calculating deterministic simulation step
  119605. */
  119606. onBeforeStepObservable: Observable<Scene>;
  119607. /**
  119608. * An event triggered after calculating deterministic simulation step
  119609. */
  119610. onAfterStepObservable: Observable<Scene>;
  119611. /**
  119612. * An event triggered when the activeCamera property is updated
  119613. */
  119614. onActiveCameraChanged: Observable<Scene>;
  119615. /**
  119616. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  119617. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  119618. * 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)
  119619. */
  119620. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  119621. /**
  119622. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  119623. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  119624. * 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)
  119625. */
  119626. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  119627. /**
  119628. * This Observable will when a mesh has been imported into the scene.
  119629. */
  119630. onMeshImportedObservable: Observable<AbstractMesh>;
  119631. /**
  119632. * This Observable will when an animation file has been imported into the scene.
  119633. */
  119634. onAnimationFileImportedObservable: Observable<Scene>;
  119635. /**
  119636. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  119637. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  119638. */
  119639. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  119640. /** @hidden */
  119641. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  119642. /**
  119643. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  119644. */
  119645. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  119646. /**
  119647. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  119648. */
  119649. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  119650. /**
  119651. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  119652. */
  119653. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  119654. /** Callback called when a pointer move is detected */
  119655. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  119656. /** Callback called when a pointer down is detected */
  119657. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  119658. /** Callback called when a pointer up is detected */
  119659. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  119660. /** Callback called when a pointer pick is detected */
  119661. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  119662. /**
  119663. * 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).
  119664. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  119665. */
  119666. onPrePointerObservable: Observable<PointerInfoPre>;
  119667. /**
  119668. * Observable event triggered each time an input event is received from the rendering canvas
  119669. */
  119670. onPointerObservable: Observable<PointerInfo>;
  119671. /**
  119672. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  119673. */
  119674. get unTranslatedPointer(): Vector2;
  119675. /**
  119676. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  119677. */
  119678. static get DragMovementThreshold(): number;
  119679. static set DragMovementThreshold(value: number);
  119680. /**
  119681. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  119682. */
  119683. static get LongPressDelay(): number;
  119684. static set LongPressDelay(value: number);
  119685. /**
  119686. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  119687. */
  119688. static get DoubleClickDelay(): number;
  119689. static set DoubleClickDelay(value: number);
  119690. /** If you need to check double click without raising a single click at first click, enable this flag */
  119691. static get ExclusiveDoubleClickMode(): boolean;
  119692. static set ExclusiveDoubleClickMode(value: boolean);
  119693. /** @hidden */
  119694. _mirroredCameraPosition: Nullable<Vector3>;
  119695. /**
  119696. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  119697. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  119698. */
  119699. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  119700. /**
  119701. * Observable event triggered each time an keyboard event is received from the hosting window
  119702. */
  119703. onKeyboardObservable: Observable<KeyboardInfo>;
  119704. private _useRightHandedSystem;
  119705. /**
  119706. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  119707. */
  119708. set useRightHandedSystem(value: boolean);
  119709. get useRightHandedSystem(): boolean;
  119710. private _timeAccumulator;
  119711. private _currentStepId;
  119712. private _currentInternalStep;
  119713. /**
  119714. * Sets the step Id used by deterministic lock step
  119715. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119716. * @param newStepId defines the step Id
  119717. */
  119718. setStepId(newStepId: number): void;
  119719. /**
  119720. * Gets the step Id used by deterministic lock step
  119721. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119722. * @returns the step Id
  119723. */
  119724. getStepId(): number;
  119725. /**
  119726. * Gets the internal step used by deterministic lock step
  119727. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119728. * @returns the internal step
  119729. */
  119730. getInternalStep(): number;
  119731. private _fogEnabled;
  119732. /**
  119733. * Gets or sets a boolean indicating if fog is enabled on this scene
  119734. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119735. * (Default is true)
  119736. */
  119737. set fogEnabled(value: boolean);
  119738. get fogEnabled(): boolean;
  119739. private _fogMode;
  119740. /**
  119741. * Gets or sets the fog mode to use
  119742. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119743. * | mode | value |
  119744. * | --- | --- |
  119745. * | FOGMODE_NONE | 0 |
  119746. * | FOGMODE_EXP | 1 |
  119747. * | FOGMODE_EXP2 | 2 |
  119748. * | FOGMODE_LINEAR | 3 |
  119749. */
  119750. set fogMode(value: number);
  119751. get fogMode(): number;
  119752. /**
  119753. * Gets or sets the fog color to use
  119754. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119755. * (Default is Color3(0.2, 0.2, 0.3))
  119756. */
  119757. fogColor: Color3;
  119758. /**
  119759. * Gets or sets the fog density to use
  119760. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119761. * (Default is 0.1)
  119762. */
  119763. fogDensity: number;
  119764. /**
  119765. * Gets or sets the fog start distance to use
  119766. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119767. * (Default is 0)
  119768. */
  119769. fogStart: number;
  119770. /**
  119771. * Gets or sets the fog end distance to use
  119772. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119773. * (Default is 1000)
  119774. */
  119775. fogEnd: number;
  119776. /**
  119777. * Flag indicating that the frame buffer binding is handled by another component
  119778. */
  119779. prePass: boolean;
  119780. private _shadowsEnabled;
  119781. /**
  119782. * Gets or sets a boolean indicating if shadows are enabled on this scene
  119783. */
  119784. set shadowsEnabled(value: boolean);
  119785. get shadowsEnabled(): boolean;
  119786. private _lightsEnabled;
  119787. /**
  119788. * Gets or sets a boolean indicating if lights are enabled on this scene
  119789. */
  119790. set lightsEnabled(value: boolean);
  119791. get lightsEnabled(): boolean;
  119792. /** All of the active cameras added to this scene. */
  119793. activeCameras: Camera[];
  119794. /** @hidden */
  119795. _activeCamera: Nullable<Camera>;
  119796. /** Gets or sets the current active camera */
  119797. get activeCamera(): Nullable<Camera>;
  119798. set activeCamera(value: Nullable<Camera>);
  119799. private _defaultMaterial;
  119800. /** The default material used on meshes when no material is affected */
  119801. get defaultMaterial(): Material;
  119802. /** The default material used on meshes when no material is affected */
  119803. set defaultMaterial(value: Material);
  119804. private _texturesEnabled;
  119805. /**
  119806. * Gets or sets a boolean indicating if textures are enabled on this scene
  119807. */
  119808. set texturesEnabled(value: boolean);
  119809. get texturesEnabled(): boolean;
  119810. /**
  119811. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  119812. */
  119813. physicsEnabled: boolean;
  119814. /**
  119815. * Gets or sets a boolean indicating if particles are enabled on this scene
  119816. */
  119817. particlesEnabled: boolean;
  119818. /**
  119819. * Gets or sets a boolean indicating if sprites are enabled on this scene
  119820. */
  119821. spritesEnabled: boolean;
  119822. private _skeletonsEnabled;
  119823. /**
  119824. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  119825. */
  119826. set skeletonsEnabled(value: boolean);
  119827. get skeletonsEnabled(): boolean;
  119828. /**
  119829. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  119830. */
  119831. lensFlaresEnabled: boolean;
  119832. /**
  119833. * Gets or sets a boolean indicating if collisions are enabled on this scene
  119834. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  119835. */
  119836. collisionsEnabled: boolean;
  119837. private _collisionCoordinator;
  119838. /** @hidden */
  119839. get collisionCoordinator(): ICollisionCoordinator;
  119840. /**
  119841. * Defines the gravity applied to this scene (used only for collisions)
  119842. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  119843. */
  119844. gravity: Vector3;
  119845. /**
  119846. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  119847. */
  119848. postProcessesEnabled: boolean;
  119849. /**
  119850. * Gets the current postprocess manager
  119851. */
  119852. postProcessManager: PostProcessManager;
  119853. /**
  119854. * Gets or sets a boolean indicating if render targets are enabled on this scene
  119855. */
  119856. renderTargetsEnabled: boolean;
  119857. /**
  119858. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  119859. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  119860. */
  119861. dumpNextRenderTargets: boolean;
  119862. /**
  119863. * The list of user defined render targets added to the scene
  119864. */
  119865. customRenderTargets: RenderTargetTexture[];
  119866. /**
  119867. * Defines if texture loading must be delayed
  119868. * If true, textures will only be loaded when they need to be rendered
  119869. */
  119870. useDelayedTextureLoading: boolean;
  119871. /**
  119872. * Gets the list of meshes imported to the scene through SceneLoader
  119873. */
  119874. importedMeshesFiles: String[];
  119875. /**
  119876. * Gets or sets a boolean indicating if probes are enabled on this scene
  119877. */
  119878. probesEnabled: boolean;
  119879. /**
  119880. * Gets or sets the current offline provider to use to store scene data
  119881. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  119882. */
  119883. offlineProvider: IOfflineProvider;
  119884. /**
  119885. * Gets or sets the action manager associated with the scene
  119886. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  119887. */
  119888. actionManager: AbstractActionManager;
  119889. private _meshesForIntersections;
  119890. /**
  119891. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  119892. */
  119893. proceduralTexturesEnabled: boolean;
  119894. private _engine;
  119895. private _totalVertices;
  119896. /** @hidden */
  119897. _activeIndices: PerfCounter;
  119898. /** @hidden */
  119899. _activeParticles: PerfCounter;
  119900. /** @hidden */
  119901. _activeBones: PerfCounter;
  119902. private _animationRatio;
  119903. /** @hidden */
  119904. _animationTimeLast: number;
  119905. /** @hidden */
  119906. _animationTime: number;
  119907. /**
  119908. * Gets or sets a general scale for animation speed
  119909. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  119910. */
  119911. animationTimeScale: number;
  119912. /** @hidden */
  119913. _cachedMaterial: Nullable<Material>;
  119914. /** @hidden */
  119915. _cachedEffect: Nullable<Effect>;
  119916. /** @hidden */
  119917. _cachedVisibility: Nullable<number>;
  119918. private _renderId;
  119919. private _frameId;
  119920. private _executeWhenReadyTimeoutId;
  119921. private _intermediateRendering;
  119922. private _viewUpdateFlag;
  119923. private _projectionUpdateFlag;
  119924. /** @hidden */
  119925. _toBeDisposed: Nullable<IDisposable>[];
  119926. private _activeRequests;
  119927. /** @hidden */
  119928. _pendingData: any[];
  119929. private _isDisposed;
  119930. /**
  119931. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  119932. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  119933. */
  119934. dispatchAllSubMeshesOfActiveMeshes: boolean;
  119935. private _activeMeshes;
  119936. private _processedMaterials;
  119937. private _renderTargets;
  119938. /** @hidden */
  119939. _activeParticleSystems: SmartArray<IParticleSystem>;
  119940. private _activeSkeletons;
  119941. private _softwareSkinnedMeshes;
  119942. private _renderingManager;
  119943. /** @hidden */
  119944. _activeAnimatables: Animatable[];
  119945. private _transformMatrix;
  119946. private _sceneUbo;
  119947. /** @hidden */
  119948. _viewMatrix: Matrix;
  119949. private _projectionMatrix;
  119950. /** @hidden */
  119951. _forcedViewPosition: Nullable<Vector3>;
  119952. /** @hidden */
  119953. _frustumPlanes: Plane[];
  119954. /**
  119955. * Gets the list of frustum planes (built from the active camera)
  119956. */
  119957. get frustumPlanes(): Plane[];
  119958. /**
  119959. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  119960. * This is useful if there are more lights that the maximum simulteanous authorized
  119961. */
  119962. requireLightSorting: boolean;
  119963. /** @hidden */
  119964. readonly useMaterialMeshMap: boolean;
  119965. /** @hidden */
  119966. readonly useClonedMeshMap: boolean;
  119967. private _externalData;
  119968. private _uid;
  119969. /**
  119970. * @hidden
  119971. * Backing store of defined scene components.
  119972. */
  119973. _components: ISceneComponent[];
  119974. /**
  119975. * @hidden
  119976. * Backing store of defined scene components.
  119977. */
  119978. _serializableComponents: ISceneSerializableComponent[];
  119979. /**
  119980. * List of components to register on the next registration step.
  119981. */
  119982. private _transientComponents;
  119983. /**
  119984. * Registers the transient components if needed.
  119985. */
  119986. private _registerTransientComponents;
  119987. /**
  119988. * @hidden
  119989. * Add a component to the scene.
  119990. * Note that the ccomponent could be registered on th next frame if this is called after
  119991. * the register component stage.
  119992. * @param component Defines the component to add to the scene
  119993. */
  119994. _addComponent(component: ISceneComponent): void;
  119995. /**
  119996. * @hidden
  119997. * Gets a component from the scene.
  119998. * @param name defines the name of the component to retrieve
  119999. * @returns the component or null if not present
  120000. */
  120001. _getComponent(name: string): Nullable<ISceneComponent>;
  120002. /**
  120003. * @hidden
  120004. * Defines the actions happening before camera updates.
  120005. */
  120006. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  120007. /**
  120008. * @hidden
  120009. * Defines the actions happening before clear the canvas.
  120010. */
  120011. _beforeClearStage: Stage<SimpleStageAction>;
  120012. /**
  120013. * @hidden
  120014. * Defines the actions when collecting render targets for the frame.
  120015. */
  120016. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120017. /**
  120018. * @hidden
  120019. * Defines the actions happening for one camera in the frame.
  120020. */
  120021. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120022. /**
  120023. * @hidden
  120024. * Defines the actions happening during the per mesh ready checks.
  120025. */
  120026. _isReadyForMeshStage: Stage<MeshStageAction>;
  120027. /**
  120028. * @hidden
  120029. * Defines the actions happening before evaluate active mesh checks.
  120030. */
  120031. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  120032. /**
  120033. * @hidden
  120034. * Defines the actions happening during the evaluate sub mesh checks.
  120035. */
  120036. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  120037. /**
  120038. * @hidden
  120039. * Defines the actions happening during the active mesh stage.
  120040. */
  120041. _activeMeshStage: Stage<ActiveMeshStageAction>;
  120042. /**
  120043. * @hidden
  120044. * Defines the actions happening during the per camera render target step.
  120045. */
  120046. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  120047. /**
  120048. * @hidden
  120049. * Defines the actions happening just before the active camera is drawing.
  120050. */
  120051. _beforeCameraDrawStage: Stage<CameraStageAction>;
  120052. /**
  120053. * @hidden
  120054. * Defines the actions happening just before a render target is drawing.
  120055. */
  120056. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120057. /**
  120058. * @hidden
  120059. * Defines the actions happening just before a rendering group is drawing.
  120060. */
  120061. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120062. /**
  120063. * @hidden
  120064. * Defines the actions happening just before a mesh is drawing.
  120065. */
  120066. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120067. /**
  120068. * @hidden
  120069. * Defines the actions happening just after a mesh has been drawn.
  120070. */
  120071. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120072. /**
  120073. * @hidden
  120074. * Defines the actions happening just after a rendering group has been drawn.
  120075. */
  120076. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120077. /**
  120078. * @hidden
  120079. * Defines the actions happening just after the active camera has been drawn.
  120080. */
  120081. _afterCameraDrawStage: Stage<CameraStageAction>;
  120082. /**
  120083. * @hidden
  120084. * Defines the actions happening just after a render target has been drawn.
  120085. */
  120086. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120087. /**
  120088. * @hidden
  120089. * Defines the actions happening just after rendering all cameras and computing intersections.
  120090. */
  120091. _afterRenderStage: Stage<SimpleStageAction>;
  120092. /**
  120093. * @hidden
  120094. * Defines the actions happening when a pointer move event happens.
  120095. */
  120096. _pointerMoveStage: Stage<PointerMoveStageAction>;
  120097. /**
  120098. * @hidden
  120099. * Defines the actions happening when a pointer down event happens.
  120100. */
  120101. _pointerDownStage: Stage<PointerUpDownStageAction>;
  120102. /**
  120103. * @hidden
  120104. * Defines the actions happening when a pointer up event happens.
  120105. */
  120106. _pointerUpStage: Stage<PointerUpDownStageAction>;
  120107. /**
  120108. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  120109. */
  120110. private geometriesByUniqueId;
  120111. /**
  120112. * Creates a new Scene
  120113. * @param engine defines the engine to use to render this scene
  120114. * @param options defines the scene options
  120115. */
  120116. constructor(engine: Engine, options?: SceneOptions);
  120117. /**
  120118. * Gets a string identifying the name of the class
  120119. * @returns "Scene" string
  120120. */
  120121. getClassName(): string;
  120122. private _defaultMeshCandidates;
  120123. /**
  120124. * @hidden
  120125. */
  120126. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120127. private _defaultSubMeshCandidates;
  120128. /**
  120129. * @hidden
  120130. */
  120131. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120132. /**
  120133. * Sets the default candidate providers for the scene.
  120134. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  120135. * and getCollidingSubMeshCandidates to their default function
  120136. */
  120137. setDefaultCandidateProviders(): void;
  120138. /**
  120139. * Gets the mesh that is currently under the pointer
  120140. */
  120141. get meshUnderPointer(): Nullable<AbstractMesh>;
  120142. /**
  120143. * Gets or sets the current on-screen X position of the pointer
  120144. */
  120145. get pointerX(): number;
  120146. set pointerX(value: number);
  120147. /**
  120148. * Gets or sets the current on-screen Y position of the pointer
  120149. */
  120150. get pointerY(): number;
  120151. set pointerY(value: number);
  120152. /**
  120153. * Gets the cached material (ie. the latest rendered one)
  120154. * @returns the cached material
  120155. */
  120156. getCachedMaterial(): Nullable<Material>;
  120157. /**
  120158. * Gets the cached effect (ie. the latest rendered one)
  120159. * @returns the cached effect
  120160. */
  120161. getCachedEffect(): Nullable<Effect>;
  120162. /**
  120163. * Gets the cached visibility state (ie. the latest rendered one)
  120164. * @returns the cached visibility state
  120165. */
  120166. getCachedVisibility(): Nullable<number>;
  120167. /**
  120168. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  120169. * @param material defines the current material
  120170. * @param effect defines the current effect
  120171. * @param visibility defines the current visibility state
  120172. * @returns true if one parameter is not cached
  120173. */
  120174. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  120175. /**
  120176. * Gets the engine associated with the scene
  120177. * @returns an Engine
  120178. */
  120179. getEngine(): Engine;
  120180. /**
  120181. * Gets the total number of vertices rendered per frame
  120182. * @returns the total number of vertices rendered per frame
  120183. */
  120184. getTotalVertices(): number;
  120185. /**
  120186. * Gets the performance counter for total vertices
  120187. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120188. */
  120189. get totalVerticesPerfCounter(): PerfCounter;
  120190. /**
  120191. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  120192. * @returns the total number of active indices rendered per frame
  120193. */
  120194. getActiveIndices(): number;
  120195. /**
  120196. * Gets the performance counter for active indices
  120197. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120198. */
  120199. get totalActiveIndicesPerfCounter(): PerfCounter;
  120200. /**
  120201. * Gets the total number of active particles rendered per frame
  120202. * @returns the total number of active particles rendered per frame
  120203. */
  120204. getActiveParticles(): number;
  120205. /**
  120206. * Gets the performance counter for active particles
  120207. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120208. */
  120209. get activeParticlesPerfCounter(): PerfCounter;
  120210. /**
  120211. * Gets the total number of active bones rendered per frame
  120212. * @returns the total number of active bones rendered per frame
  120213. */
  120214. getActiveBones(): number;
  120215. /**
  120216. * Gets the performance counter for active bones
  120217. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120218. */
  120219. get activeBonesPerfCounter(): PerfCounter;
  120220. /**
  120221. * Gets the array of active meshes
  120222. * @returns an array of AbstractMesh
  120223. */
  120224. getActiveMeshes(): SmartArray<AbstractMesh>;
  120225. /**
  120226. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  120227. * @returns a number
  120228. */
  120229. getAnimationRatio(): number;
  120230. /**
  120231. * Gets an unique Id for the current render phase
  120232. * @returns a number
  120233. */
  120234. getRenderId(): number;
  120235. /**
  120236. * Gets an unique Id for the current frame
  120237. * @returns a number
  120238. */
  120239. getFrameId(): number;
  120240. /** Call this function if you want to manually increment the render Id*/
  120241. incrementRenderId(): void;
  120242. private _createUbo;
  120243. /**
  120244. * Use this method to simulate a pointer move on a mesh
  120245. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120246. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120247. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120248. * @returns the current scene
  120249. */
  120250. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120251. /**
  120252. * Use this method to simulate a pointer down on a mesh
  120253. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120254. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120255. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120256. * @returns the current scene
  120257. */
  120258. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120259. /**
  120260. * Use this method to simulate a pointer up on a mesh
  120261. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120262. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120263. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120264. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  120265. * @returns the current scene
  120266. */
  120267. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  120268. /**
  120269. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  120270. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  120271. * @returns true if the pointer was captured
  120272. */
  120273. isPointerCaptured(pointerId?: number): boolean;
  120274. /**
  120275. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  120276. * @param attachUp defines if you want to attach events to pointerup
  120277. * @param attachDown defines if you want to attach events to pointerdown
  120278. * @param attachMove defines if you want to attach events to pointermove
  120279. */
  120280. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  120281. /** Detaches all event handlers*/
  120282. detachControl(): void;
  120283. /**
  120284. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  120285. * Delay loaded resources are not taking in account
  120286. * @return true if all required resources are ready
  120287. */
  120288. isReady(): boolean;
  120289. /** Resets all cached information relative to material (including effect and visibility) */
  120290. resetCachedMaterial(): void;
  120291. /**
  120292. * Registers a function to be called before every frame render
  120293. * @param func defines the function to register
  120294. */
  120295. registerBeforeRender(func: () => void): void;
  120296. /**
  120297. * Unregisters a function called before every frame render
  120298. * @param func defines the function to unregister
  120299. */
  120300. unregisterBeforeRender(func: () => void): void;
  120301. /**
  120302. * Registers a function to be called after every frame render
  120303. * @param func defines the function to register
  120304. */
  120305. registerAfterRender(func: () => void): void;
  120306. /**
  120307. * Unregisters a function called after every frame render
  120308. * @param func defines the function to unregister
  120309. */
  120310. unregisterAfterRender(func: () => void): void;
  120311. private _executeOnceBeforeRender;
  120312. /**
  120313. * The provided function will run before render once and will be disposed afterwards.
  120314. * A timeout delay can be provided so that the function will be executed in N ms.
  120315. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  120316. * @param func The function to be executed.
  120317. * @param timeout optional delay in ms
  120318. */
  120319. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  120320. /** @hidden */
  120321. _addPendingData(data: any): void;
  120322. /** @hidden */
  120323. _removePendingData(data: any): void;
  120324. /**
  120325. * Returns the number of items waiting to be loaded
  120326. * @returns the number of items waiting to be loaded
  120327. */
  120328. getWaitingItemsCount(): number;
  120329. /**
  120330. * Returns a boolean indicating if the scene is still loading data
  120331. */
  120332. get isLoading(): boolean;
  120333. /**
  120334. * Registers a function to be executed when the scene is ready
  120335. * @param {Function} func - the function to be executed
  120336. */
  120337. executeWhenReady(func: () => void): void;
  120338. /**
  120339. * Returns a promise that resolves when the scene is ready
  120340. * @returns A promise that resolves when the scene is ready
  120341. */
  120342. whenReadyAsync(): Promise<void>;
  120343. /** @hidden */
  120344. _checkIsReady(): void;
  120345. /**
  120346. * Gets all animatable attached to the scene
  120347. */
  120348. get animatables(): Animatable[];
  120349. /**
  120350. * Resets the last animation time frame.
  120351. * Useful to override when animations start running when loading a scene for the first time.
  120352. */
  120353. resetLastAnimationTimeFrame(): void;
  120354. /**
  120355. * Gets the current view matrix
  120356. * @returns a Matrix
  120357. */
  120358. getViewMatrix(): Matrix;
  120359. /**
  120360. * Gets the current projection matrix
  120361. * @returns a Matrix
  120362. */
  120363. getProjectionMatrix(): Matrix;
  120364. /**
  120365. * Gets the current transform matrix
  120366. * @returns a Matrix made of View * Projection
  120367. */
  120368. getTransformMatrix(): Matrix;
  120369. /**
  120370. * Sets the current transform matrix
  120371. * @param viewL defines the View matrix to use
  120372. * @param projectionL defines the Projection matrix to use
  120373. * @param viewR defines the right View matrix to use (if provided)
  120374. * @param projectionR defines the right Projection matrix to use (if provided)
  120375. */
  120376. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  120377. /**
  120378. * Gets the uniform buffer used to store scene data
  120379. * @returns a UniformBuffer
  120380. */
  120381. getSceneUniformBuffer(): UniformBuffer;
  120382. /**
  120383. * Gets an unique (relatively to the current scene) Id
  120384. * @returns an unique number for the scene
  120385. */
  120386. getUniqueId(): number;
  120387. /**
  120388. * Add a mesh to the list of scene's meshes
  120389. * @param newMesh defines the mesh to add
  120390. * @param recursive if all child meshes should also be added to the scene
  120391. */
  120392. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  120393. /**
  120394. * Remove a mesh for the list of scene's meshes
  120395. * @param toRemove defines the mesh to remove
  120396. * @param recursive if all child meshes should also be removed from the scene
  120397. * @returns the index where the mesh was in the mesh list
  120398. */
  120399. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  120400. /**
  120401. * Add a transform node to the list of scene's transform nodes
  120402. * @param newTransformNode defines the transform node to add
  120403. */
  120404. addTransformNode(newTransformNode: TransformNode): void;
  120405. /**
  120406. * Remove a transform node for the list of scene's transform nodes
  120407. * @param toRemove defines the transform node to remove
  120408. * @returns the index where the transform node was in the transform node list
  120409. */
  120410. removeTransformNode(toRemove: TransformNode): number;
  120411. /**
  120412. * Remove a skeleton for the list of scene's skeletons
  120413. * @param toRemove defines the skeleton to remove
  120414. * @returns the index where the skeleton was in the skeleton list
  120415. */
  120416. removeSkeleton(toRemove: Skeleton): number;
  120417. /**
  120418. * Remove a morph target for the list of scene's morph targets
  120419. * @param toRemove defines the morph target to remove
  120420. * @returns the index where the morph target was in the morph target list
  120421. */
  120422. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  120423. /**
  120424. * Remove a light for the list of scene's lights
  120425. * @param toRemove defines the light to remove
  120426. * @returns the index where the light was in the light list
  120427. */
  120428. removeLight(toRemove: Light): number;
  120429. /**
  120430. * Remove a camera for the list of scene's cameras
  120431. * @param toRemove defines the camera to remove
  120432. * @returns the index where the camera was in the camera list
  120433. */
  120434. removeCamera(toRemove: Camera): number;
  120435. /**
  120436. * Remove a particle system for the list of scene's particle systems
  120437. * @param toRemove defines the particle system to remove
  120438. * @returns the index where the particle system was in the particle system list
  120439. */
  120440. removeParticleSystem(toRemove: IParticleSystem): number;
  120441. /**
  120442. * Remove a animation for the list of scene's animations
  120443. * @param toRemove defines the animation to remove
  120444. * @returns the index where the animation was in the animation list
  120445. */
  120446. removeAnimation(toRemove: Animation): number;
  120447. /**
  120448. * Will stop the animation of the given target
  120449. * @param target - the target
  120450. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  120451. * @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)
  120452. */
  120453. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  120454. /**
  120455. * Removes the given animation group from this scene.
  120456. * @param toRemove The animation group to remove
  120457. * @returns The index of the removed animation group
  120458. */
  120459. removeAnimationGroup(toRemove: AnimationGroup): number;
  120460. /**
  120461. * Removes the given multi-material from this scene.
  120462. * @param toRemove The multi-material to remove
  120463. * @returns The index of the removed multi-material
  120464. */
  120465. removeMultiMaterial(toRemove: MultiMaterial): number;
  120466. /**
  120467. * Removes the given material from this scene.
  120468. * @param toRemove The material to remove
  120469. * @returns The index of the removed material
  120470. */
  120471. removeMaterial(toRemove: Material): number;
  120472. /**
  120473. * Removes the given action manager from this scene.
  120474. * @param toRemove The action manager to remove
  120475. * @returns The index of the removed action manager
  120476. */
  120477. removeActionManager(toRemove: AbstractActionManager): number;
  120478. /**
  120479. * Removes the given texture from this scene.
  120480. * @param toRemove The texture to remove
  120481. * @returns The index of the removed texture
  120482. */
  120483. removeTexture(toRemove: BaseTexture): number;
  120484. /**
  120485. * Adds the given light to this scene
  120486. * @param newLight The light to add
  120487. */
  120488. addLight(newLight: Light): void;
  120489. /**
  120490. * Sorts the list list based on light priorities
  120491. */
  120492. sortLightsByPriority(): void;
  120493. /**
  120494. * Adds the given camera to this scene
  120495. * @param newCamera The camera to add
  120496. */
  120497. addCamera(newCamera: Camera): void;
  120498. /**
  120499. * Adds the given skeleton to this scene
  120500. * @param newSkeleton The skeleton to add
  120501. */
  120502. addSkeleton(newSkeleton: Skeleton): void;
  120503. /**
  120504. * Adds the given particle system to this scene
  120505. * @param newParticleSystem The particle system to add
  120506. */
  120507. addParticleSystem(newParticleSystem: IParticleSystem): void;
  120508. /**
  120509. * Adds the given animation to this scene
  120510. * @param newAnimation The animation to add
  120511. */
  120512. addAnimation(newAnimation: Animation): void;
  120513. /**
  120514. * Adds the given animation group to this scene.
  120515. * @param newAnimationGroup The animation group to add
  120516. */
  120517. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  120518. /**
  120519. * Adds the given multi-material to this scene
  120520. * @param newMultiMaterial The multi-material to add
  120521. */
  120522. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  120523. /**
  120524. * Adds the given material to this scene
  120525. * @param newMaterial The material to add
  120526. */
  120527. addMaterial(newMaterial: Material): void;
  120528. /**
  120529. * Adds the given morph target to this scene
  120530. * @param newMorphTargetManager The morph target to add
  120531. */
  120532. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  120533. /**
  120534. * Adds the given geometry to this scene
  120535. * @param newGeometry The geometry to add
  120536. */
  120537. addGeometry(newGeometry: Geometry): void;
  120538. /**
  120539. * Adds the given action manager to this scene
  120540. * @param newActionManager The action manager to add
  120541. */
  120542. addActionManager(newActionManager: AbstractActionManager): void;
  120543. /**
  120544. * Adds the given texture to this scene.
  120545. * @param newTexture The texture to add
  120546. */
  120547. addTexture(newTexture: BaseTexture): void;
  120548. /**
  120549. * Switch active camera
  120550. * @param newCamera defines the new active camera
  120551. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  120552. */
  120553. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  120554. /**
  120555. * sets the active camera of the scene using its ID
  120556. * @param id defines the camera's ID
  120557. * @return the new active camera or null if none found.
  120558. */
  120559. setActiveCameraByID(id: string): Nullable<Camera>;
  120560. /**
  120561. * sets the active camera of the scene using its name
  120562. * @param name defines the camera's name
  120563. * @returns the new active camera or null if none found.
  120564. */
  120565. setActiveCameraByName(name: string): Nullable<Camera>;
  120566. /**
  120567. * get an animation group using its name
  120568. * @param name defines the material's name
  120569. * @return the animation group or null if none found.
  120570. */
  120571. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  120572. /**
  120573. * Get a material using its unique id
  120574. * @param uniqueId defines the material's unique id
  120575. * @return the material or null if none found.
  120576. */
  120577. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  120578. /**
  120579. * get a material using its id
  120580. * @param id defines the material's ID
  120581. * @return the material or null if none found.
  120582. */
  120583. getMaterialByID(id: string): Nullable<Material>;
  120584. /**
  120585. * Gets a the last added material using a given id
  120586. * @param id defines the material's ID
  120587. * @return the last material with the given id or null if none found.
  120588. */
  120589. getLastMaterialByID(id: string): Nullable<Material>;
  120590. /**
  120591. * Gets a material using its name
  120592. * @param name defines the material's name
  120593. * @return the material or null if none found.
  120594. */
  120595. getMaterialByName(name: string): Nullable<Material>;
  120596. /**
  120597. * Get a texture using its unique id
  120598. * @param uniqueId defines the texture's unique id
  120599. * @return the texture or null if none found.
  120600. */
  120601. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  120602. /**
  120603. * Gets a camera using its id
  120604. * @param id defines the id to look for
  120605. * @returns the camera or null if not found
  120606. */
  120607. getCameraByID(id: string): Nullable<Camera>;
  120608. /**
  120609. * Gets a camera using its unique id
  120610. * @param uniqueId defines the unique id to look for
  120611. * @returns the camera or null if not found
  120612. */
  120613. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  120614. /**
  120615. * Gets a camera using its name
  120616. * @param name defines the camera's name
  120617. * @return the camera or null if none found.
  120618. */
  120619. getCameraByName(name: string): Nullable<Camera>;
  120620. /**
  120621. * Gets a bone using its id
  120622. * @param id defines the bone's id
  120623. * @return the bone or null if not found
  120624. */
  120625. getBoneByID(id: string): Nullable<Bone>;
  120626. /**
  120627. * Gets a bone using its id
  120628. * @param name defines the bone's name
  120629. * @return the bone or null if not found
  120630. */
  120631. getBoneByName(name: string): Nullable<Bone>;
  120632. /**
  120633. * Gets a light node using its name
  120634. * @param name defines the the light's name
  120635. * @return the light or null if none found.
  120636. */
  120637. getLightByName(name: string): Nullable<Light>;
  120638. /**
  120639. * Gets a light node using its id
  120640. * @param id defines the light's id
  120641. * @return the light or null if none found.
  120642. */
  120643. getLightByID(id: string): Nullable<Light>;
  120644. /**
  120645. * Gets a light node using its scene-generated unique ID
  120646. * @param uniqueId defines the light's unique id
  120647. * @return the light or null if none found.
  120648. */
  120649. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  120650. /**
  120651. * Gets a particle system by id
  120652. * @param id defines the particle system id
  120653. * @return the corresponding system or null if none found
  120654. */
  120655. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  120656. /**
  120657. * Gets a geometry using its ID
  120658. * @param id defines the geometry's id
  120659. * @return the geometry or null if none found.
  120660. */
  120661. getGeometryByID(id: string): Nullable<Geometry>;
  120662. private _getGeometryByUniqueID;
  120663. /**
  120664. * Add a new geometry to this scene
  120665. * @param geometry defines the geometry to be added to the scene.
  120666. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  120667. * @return a boolean defining if the geometry was added or not
  120668. */
  120669. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  120670. /**
  120671. * Removes an existing geometry
  120672. * @param geometry defines the geometry to be removed from the scene
  120673. * @return a boolean defining if the geometry was removed or not
  120674. */
  120675. removeGeometry(geometry: Geometry): boolean;
  120676. /**
  120677. * Gets the list of geometries attached to the scene
  120678. * @returns an array of Geometry
  120679. */
  120680. getGeometries(): Geometry[];
  120681. /**
  120682. * Gets the first added mesh found of a given ID
  120683. * @param id defines the id to search for
  120684. * @return the mesh found or null if not found at all
  120685. */
  120686. getMeshByID(id: string): Nullable<AbstractMesh>;
  120687. /**
  120688. * Gets a list of meshes using their id
  120689. * @param id defines the id to search for
  120690. * @returns a list of meshes
  120691. */
  120692. getMeshesByID(id: string): Array<AbstractMesh>;
  120693. /**
  120694. * Gets the first added transform node found of a given ID
  120695. * @param id defines the id to search for
  120696. * @return the found transform node or null if not found at all.
  120697. */
  120698. getTransformNodeByID(id: string): Nullable<TransformNode>;
  120699. /**
  120700. * Gets a transform node with its auto-generated unique id
  120701. * @param uniqueId efines the unique id to search for
  120702. * @return the found transform node or null if not found at all.
  120703. */
  120704. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  120705. /**
  120706. * Gets a list of transform nodes using their id
  120707. * @param id defines the id to search for
  120708. * @returns a list of transform nodes
  120709. */
  120710. getTransformNodesByID(id: string): Array<TransformNode>;
  120711. /**
  120712. * Gets a mesh with its auto-generated unique id
  120713. * @param uniqueId defines the unique id to search for
  120714. * @return the found mesh or null if not found at all.
  120715. */
  120716. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  120717. /**
  120718. * Gets a the last added mesh using a given id
  120719. * @param id defines the id to search for
  120720. * @return the found mesh or null if not found at all.
  120721. */
  120722. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  120723. /**
  120724. * Gets a the last added node (Mesh, Camera, Light) using a given id
  120725. * @param id defines the id to search for
  120726. * @return the found node or null if not found at all
  120727. */
  120728. getLastEntryByID(id: string): Nullable<Node>;
  120729. /**
  120730. * Gets a node (Mesh, Camera, Light) using a given id
  120731. * @param id defines the id to search for
  120732. * @return the found node or null if not found at all
  120733. */
  120734. getNodeByID(id: string): Nullable<Node>;
  120735. /**
  120736. * Gets a node (Mesh, Camera, Light) using a given name
  120737. * @param name defines the name to search for
  120738. * @return the found node or null if not found at all.
  120739. */
  120740. getNodeByName(name: string): Nullable<Node>;
  120741. /**
  120742. * Gets a mesh using a given name
  120743. * @param name defines the name to search for
  120744. * @return the found mesh or null if not found at all.
  120745. */
  120746. getMeshByName(name: string): Nullable<AbstractMesh>;
  120747. /**
  120748. * Gets a transform node using a given name
  120749. * @param name defines the name to search for
  120750. * @return the found transform node or null if not found at all.
  120751. */
  120752. getTransformNodeByName(name: string): Nullable<TransformNode>;
  120753. /**
  120754. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  120755. * @param id defines the id to search for
  120756. * @return the found skeleton or null if not found at all.
  120757. */
  120758. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  120759. /**
  120760. * Gets a skeleton using a given auto generated unique id
  120761. * @param uniqueId defines the unique id to search for
  120762. * @return the found skeleton or null if not found at all.
  120763. */
  120764. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  120765. /**
  120766. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  120767. * @param id defines the id to search for
  120768. * @return the found skeleton or null if not found at all.
  120769. */
  120770. getSkeletonById(id: string): Nullable<Skeleton>;
  120771. /**
  120772. * Gets a skeleton using a given name
  120773. * @param name defines the name to search for
  120774. * @return the found skeleton or null if not found at all.
  120775. */
  120776. getSkeletonByName(name: string): Nullable<Skeleton>;
  120777. /**
  120778. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  120779. * @param id defines the id to search for
  120780. * @return the found morph target manager or null if not found at all.
  120781. */
  120782. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  120783. /**
  120784. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  120785. * @param id defines the id to search for
  120786. * @return the found morph target or null if not found at all.
  120787. */
  120788. getMorphTargetById(id: string): Nullable<MorphTarget>;
  120789. /**
  120790. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  120791. * @param name defines the name to search for
  120792. * @return the found morph target or null if not found at all.
  120793. */
  120794. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  120795. /**
  120796. * Gets a post process using a given name (if many are found, this function will pick the first one)
  120797. * @param name defines the name to search for
  120798. * @return the found post process or null if not found at all.
  120799. */
  120800. getPostProcessByName(name: string): Nullable<PostProcess>;
  120801. /**
  120802. * Gets a boolean indicating if the given mesh is active
  120803. * @param mesh defines the mesh to look for
  120804. * @returns true if the mesh is in the active list
  120805. */
  120806. isActiveMesh(mesh: AbstractMesh): boolean;
  120807. /**
  120808. * Return a unique id as a string which can serve as an identifier for the scene
  120809. */
  120810. get uid(): string;
  120811. /**
  120812. * Add an externaly attached data from its key.
  120813. * This method call will fail and return false, if such key already exists.
  120814. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  120815. * @param key the unique key that identifies the data
  120816. * @param data the data object to associate to the key for this Engine instance
  120817. * @return true if no such key were already present and the data was added successfully, false otherwise
  120818. */
  120819. addExternalData<T>(key: string, data: T): boolean;
  120820. /**
  120821. * Get an externaly attached data from its key
  120822. * @param key the unique key that identifies the data
  120823. * @return the associated data, if present (can be null), or undefined if not present
  120824. */
  120825. getExternalData<T>(key: string): Nullable<T>;
  120826. /**
  120827. * Get an externaly attached data from its key, create it using a factory if it's not already present
  120828. * @param key the unique key that identifies the data
  120829. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  120830. * @return the associated data, can be null if the factory returned null.
  120831. */
  120832. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  120833. /**
  120834. * Remove an externaly attached data from the Engine instance
  120835. * @param key the unique key that identifies the data
  120836. * @return true if the data was successfully removed, false if it doesn't exist
  120837. */
  120838. removeExternalData(key: string): boolean;
  120839. private _evaluateSubMesh;
  120840. /**
  120841. * Clear the processed materials smart array preventing retention point in material dispose.
  120842. */
  120843. freeProcessedMaterials(): void;
  120844. private _preventFreeActiveMeshesAndRenderingGroups;
  120845. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  120846. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  120847. * when disposing several meshes in a row or a hierarchy of meshes.
  120848. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  120849. */
  120850. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  120851. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  120852. /**
  120853. * Clear the active meshes smart array preventing retention point in mesh dispose.
  120854. */
  120855. freeActiveMeshes(): void;
  120856. /**
  120857. * Clear the info related to rendering groups preventing retention points during dispose.
  120858. */
  120859. freeRenderingGroups(): void;
  120860. /** @hidden */
  120861. _isInIntermediateRendering(): boolean;
  120862. /**
  120863. * Lambda returning the list of potentially active meshes.
  120864. */
  120865. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  120866. /**
  120867. * Lambda returning the list of potentially active sub meshes.
  120868. */
  120869. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  120870. /**
  120871. * Lambda returning the list of potentially intersecting sub meshes.
  120872. */
  120873. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  120874. /**
  120875. * Lambda returning the list of potentially colliding sub meshes.
  120876. */
  120877. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  120878. private _activeMeshesFrozen;
  120879. private _skipEvaluateActiveMeshesCompletely;
  120880. /**
  120881. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  120882. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  120883. * @returns the current scene
  120884. */
  120885. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  120886. /**
  120887. * Use this function to restart evaluating active meshes on every frame
  120888. * @returns the current scene
  120889. */
  120890. unfreezeActiveMeshes(): Scene;
  120891. private _evaluateActiveMeshes;
  120892. private _activeMesh;
  120893. /**
  120894. * Update the transform matrix to update from the current active camera
  120895. * @param force defines a boolean used to force the update even if cache is up to date
  120896. */
  120897. updateTransformMatrix(force?: boolean): void;
  120898. private _bindFrameBuffer;
  120899. /** @hidden */
  120900. _allowPostProcessClearColor: boolean;
  120901. /** @hidden */
  120902. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  120903. private _processSubCameras;
  120904. private _checkIntersections;
  120905. /** @hidden */
  120906. _advancePhysicsEngineStep(step: number): void;
  120907. /**
  120908. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  120909. */
  120910. getDeterministicFrameTime: () => number;
  120911. /** @hidden */
  120912. _animate(): void;
  120913. /** Execute all animations (for a frame) */
  120914. animate(): void;
  120915. /**
  120916. * Render the scene
  120917. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  120918. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  120919. */
  120920. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  120921. /**
  120922. * Freeze all materials
  120923. * A frozen material will not be updatable but should be faster to render
  120924. */
  120925. freezeMaterials(): void;
  120926. /**
  120927. * Unfreeze all materials
  120928. * A frozen material will not be updatable but should be faster to render
  120929. */
  120930. unfreezeMaterials(): void;
  120931. /**
  120932. * Releases all held ressources
  120933. */
  120934. dispose(): void;
  120935. /**
  120936. * Gets if the scene is already disposed
  120937. */
  120938. get isDisposed(): boolean;
  120939. /**
  120940. * Call this function to reduce memory footprint of the scene.
  120941. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  120942. */
  120943. clearCachedVertexData(): void;
  120944. /**
  120945. * This function will remove the local cached buffer data from texture.
  120946. * It will save memory but will prevent the texture from being rebuilt
  120947. */
  120948. cleanCachedTextureBuffer(): void;
  120949. /**
  120950. * Get the world extend vectors with an optional filter
  120951. *
  120952. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  120953. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  120954. */
  120955. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  120956. min: Vector3;
  120957. max: Vector3;
  120958. };
  120959. /**
  120960. * Creates a ray that can be used to pick in the scene
  120961. * @param x defines the x coordinate of the origin (on-screen)
  120962. * @param y defines the y coordinate of the origin (on-screen)
  120963. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  120964. * @param camera defines the camera to use for the picking
  120965. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  120966. * @returns a Ray
  120967. */
  120968. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  120969. /**
  120970. * Creates a ray that can be used to pick in the scene
  120971. * @param x defines the x coordinate of the origin (on-screen)
  120972. * @param y defines the y coordinate of the origin (on-screen)
  120973. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  120974. * @param result defines the ray where to store the picking ray
  120975. * @param camera defines the camera to use for the picking
  120976. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  120977. * @returns the current scene
  120978. */
  120979. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  120980. /**
  120981. * Creates a ray that can be used to pick in the scene
  120982. * @param x defines the x coordinate of the origin (on-screen)
  120983. * @param y defines the y coordinate of the origin (on-screen)
  120984. * @param camera defines the camera to use for the picking
  120985. * @returns a Ray
  120986. */
  120987. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  120988. /**
  120989. * Creates a ray that can be used to pick in the scene
  120990. * @param x defines the x coordinate of the origin (on-screen)
  120991. * @param y defines the y coordinate of the origin (on-screen)
  120992. * @param result defines the ray where to store the picking ray
  120993. * @param camera defines the camera to use for the picking
  120994. * @returns the current scene
  120995. */
  120996. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  120997. /** Launch a ray to try to pick a mesh in the scene
  120998. * @param x position on screen
  120999. * @param y position on screen
  121000. * @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
  121001. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121002. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121003. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121004. * @returns a PickingInfo
  121005. */
  121006. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121007. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  121008. * @param x position on screen
  121009. * @param y position on screen
  121010. * @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
  121011. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121012. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121013. * @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)
  121014. */
  121015. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  121016. /** Use the given ray to pick a mesh in the scene
  121017. * @param ray The ray to use to pick meshes
  121018. * @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
  121019. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121020. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121021. * @returns a PickingInfo
  121022. */
  121023. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121024. /**
  121025. * Launch a ray to try to pick a mesh in the scene
  121026. * @param x X position on screen
  121027. * @param y Y position on screen
  121028. * @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
  121029. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121030. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121031. * @returns an array of PickingInfo
  121032. */
  121033. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121034. /**
  121035. * Launch a ray to try to pick a mesh in the scene
  121036. * @param ray Ray to use
  121037. * @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
  121038. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121039. * @returns an array of PickingInfo
  121040. */
  121041. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121042. /**
  121043. * Force the value of meshUnderPointer
  121044. * @param mesh defines the mesh to use
  121045. * @param pointerId optional pointer id when using more than one pointer
  121046. */
  121047. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  121048. /**
  121049. * Gets the mesh under the pointer
  121050. * @returns a Mesh or null if no mesh is under the pointer
  121051. */
  121052. getPointerOverMesh(): Nullable<AbstractMesh>;
  121053. /** @hidden */
  121054. _rebuildGeometries(): void;
  121055. /** @hidden */
  121056. _rebuildTextures(): void;
  121057. private _getByTags;
  121058. /**
  121059. * Get a list of meshes by tags
  121060. * @param tagsQuery defines the tags query to use
  121061. * @param forEach defines a predicate used to filter results
  121062. * @returns an array of Mesh
  121063. */
  121064. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  121065. /**
  121066. * Get a list of cameras by tags
  121067. * @param tagsQuery defines the tags query to use
  121068. * @param forEach defines a predicate used to filter results
  121069. * @returns an array of Camera
  121070. */
  121071. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  121072. /**
  121073. * Get a list of lights by tags
  121074. * @param tagsQuery defines the tags query to use
  121075. * @param forEach defines a predicate used to filter results
  121076. * @returns an array of Light
  121077. */
  121078. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  121079. /**
  121080. * Get a list of materials by tags
  121081. * @param tagsQuery defines the tags query to use
  121082. * @param forEach defines a predicate used to filter results
  121083. * @returns an array of Material
  121084. */
  121085. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  121086. /**
  121087. * Get a list of transform nodes by tags
  121088. * @param tagsQuery defines the tags query to use
  121089. * @param forEach defines a predicate used to filter results
  121090. * @returns an array of TransformNode
  121091. */
  121092. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  121093. /**
  121094. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  121095. * This allowed control for front to back rendering or reversly depending of the special needs.
  121096. *
  121097. * @param renderingGroupId The rendering group id corresponding to its index
  121098. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  121099. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  121100. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  121101. */
  121102. 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;
  121103. /**
  121104. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  121105. *
  121106. * @param renderingGroupId The rendering group id corresponding to its index
  121107. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121108. * @param depth Automatically clears depth between groups if true and autoClear is true.
  121109. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  121110. */
  121111. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  121112. /**
  121113. * Gets the current auto clear configuration for one rendering group of the rendering
  121114. * manager.
  121115. * @param index the rendering group index to get the information for
  121116. * @returns The auto clear setup for the requested rendering group
  121117. */
  121118. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  121119. private _blockMaterialDirtyMechanism;
  121120. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  121121. get blockMaterialDirtyMechanism(): boolean;
  121122. set blockMaterialDirtyMechanism(value: boolean);
  121123. /**
  121124. * Will flag all materials as dirty to trigger new shader compilation
  121125. * @param flag defines the flag used to specify which material part must be marked as dirty
  121126. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  121127. */
  121128. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121129. /** @hidden */
  121130. _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;
  121131. /** @hidden */
  121132. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121133. /** @hidden */
  121134. _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;
  121135. /** @hidden */
  121136. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  121137. /** @hidden */
  121138. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  121139. /** @hidden */
  121140. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121141. }
  121142. }
  121143. declare module BABYLON {
  121144. /**
  121145. * Set of assets to keep when moving a scene into an asset container.
  121146. */
  121147. export class KeepAssets extends AbstractScene {
  121148. }
  121149. /**
  121150. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  121151. */
  121152. export class InstantiatedEntries {
  121153. /**
  121154. * List of new root nodes (eg. nodes with no parent)
  121155. */
  121156. rootNodes: TransformNode[];
  121157. /**
  121158. * List of new skeletons
  121159. */
  121160. skeletons: Skeleton[];
  121161. /**
  121162. * List of new animation groups
  121163. */
  121164. animationGroups: AnimationGroup[];
  121165. }
  121166. /**
  121167. * Container with a set of assets that can be added or removed from a scene.
  121168. */
  121169. export class AssetContainer extends AbstractScene {
  121170. private _wasAddedToScene;
  121171. /**
  121172. * The scene the AssetContainer belongs to.
  121173. */
  121174. scene: Scene;
  121175. /**
  121176. * Instantiates an AssetContainer.
  121177. * @param scene The scene the AssetContainer belongs to.
  121178. */
  121179. constructor(scene: Scene);
  121180. /**
  121181. * Instantiate or clone all meshes and add the new ones to the scene.
  121182. * Skeletons and animation groups will all be cloned
  121183. * @param nameFunction defines an optional function used to get new names for clones
  121184. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  121185. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  121186. */
  121187. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  121188. /**
  121189. * Adds all the assets from the container to the scene.
  121190. */
  121191. addAllToScene(): void;
  121192. /**
  121193. * Removes all the assets in the container from the scene
  121194. */
  121195. removeAllFromScene(): void;
  121196. /**
  121197. * Disposes all the assets in the container
  121198. */
  121199. dispose(): void;
  121200. private _moveAssets;
  121201. /**
  121202. * Removes all the assets contained in the scene and adds them to the container.
  121203. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  121204. */
  121205. moveAllFromScene(keepAssets?: KeepAssets): void;
  121206. /**
  121207. * 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.
  121208. * @returns the root mesh
  121209. */
  121210. createRootMesh(): Mesh;
  121211. /**
  121212. * Merge animations (direct and animation groups) from this asset container into a scene
  121213. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  121214. * @param animatables set of animatables to retarget to a node from the scene
  121215. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  121216. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  121217. */
  121218. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  121219. }
  121220. }
  121221. declare module BABYLON {
  121222. /**
  121223. * Defines how the parser contract is defined.
  121224. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  121225. */
  121226. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  121227. /**
  121228. * Defines how the individual parser contract is defined.
  121229. * These parser can parse an individual asset
  121230. */
  121231. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  121232. /**
  121233. * Base class of the scene acting as a container for the different elements composing a scene.
  121234. * This class is dynamically extended by the different components of the scene increasing
  121235. * flexibility and reducing coupling
  121236. */
  121237. export abstract class AbstractScene {
  121238. /**
  121239. * Stores the list of available parsers in the application.
  121240. */
  121241. private static _BabylonFileParsers;
  121242. /**
  121243. * Stores the list of available individual parsers in the application.
  121244. */
  121245. private static _IndividualBabylonFileParsers;
  121246. /**
  121247. * Adds a parser in the list of available ones
  121248. * @param name Defines the name of the parser
  121249. * @param parser Defines the parser to add
  121250. */
  121251. static AddParser(name: string, parser: BabylonFileParser): void;
  121252. /**
  121253. * Gets a general parser from the list of avaialble ones
  121254. * @param name Defines the name of the parser
  121255. * @returns the requested parser or null
  121256. */
  121257. static GetParser(name: string): Nullable<BabylonFileParser>;
  121258. /**
  121259. * Adds n individual parser in the list of available ones
  121260. * @param name Defines the name of the parser
  121261. * @param parser Defines the parser to add
  121262. */
  121263. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  121264. /**
  121265. * Gets an individual parser from the list of avaialble ones
  121266. * @param name Defines the name of the parser
  121267. * @returns the requested parser or null
  121268. */
  121269. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  121270. /**
  121271. * Parser json data and populate both a scene and its associated container object
  121272. * @param jsonData Defines the data to parse
  121273. * @param scene Defines the scene to parse the data for
  121274. * @param container Defines the container attached to the parsing sequence
  121275. * @param rootUrl Defines the root url of the data
  121276. */
  121277. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  121278. /**
  121279. * Gets the list of root nodes (ie. nodes with no parent)
  121280. */
  121281. rootNodes: Node[];
  121282. /** All of the cameras added to this scene
  121283. * @see https://doc.babylonjs.com/babylon101/cameras
  121284. */
  121285. cameras: Camera[];
  121286. /**
  121287. * All of the lights added to this scene
  121288. * @see https://doc.babylonjs.com/babylon101/lights
  121289. */
  121290. lights: Light[];
  121291. /**
  121292. * All of the (abstract) meshes added to this scene
  121293. */
  121294. meshes: AbstractMesh[];
  121295. /**
  121296. * The list of skeletons added to the scene
  121297. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  121298. */
  121299. skeletons: Skeleton[];
  121300. /**
  121301. * All of the particle systems added to this scene
  121302. * @see https://doc.babylonjs.com/babylon101/particles
  121303. */
  121304. particleSystems: IParticleSystem[];
  121305. /**
  121306. * Gets a list of Animations associated with the scene
  121307. */
  121308. animations: Animation[];
  121309. /**
  121310. * All of the animation groups added to this scene
  121311. * @see https://doc.babylonjs.com/how_to/group
  121312. */
  121313. animationGroups: AnimationGroup[];
  121314. /**
  121315. * All of the multi-materials added to this scene
  121316. * @see https://doc.babylonjs.com/how_to/multi_materials
  121317. */
  121318. multiMaterials: MultiMaterial[];
  121319. /**
  121320. * All of the materials added to this scene
  121321. * In the context of a Scene, it is not supposed to be modified manually.
  121322. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  121323. * Note also that the order of the Material within the array is not significant and might change.
  121324. * @see https://doc.babylonjs.com/babylon101/materials
  121325. */
  121326. materials: Material[];
  121327. /**
  121328. * The list of morph target managers added to the scene
  121329. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  121330. */
  121331. morphTargetManagers: MorphTargetManager[];
  121332. /**
  121333. * The list of geometries used in the scene.
  121334. */
  121335. geometries: Geometry[];
  121336. /**
  121337. * All of the tranform nodes added to this scene
  121338. * In the context of a Scene, it is not supposed to be modified manually.
  121339. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  121340. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  121341. * @see https://doc.babylonjs.com/how_to/transformnode
  121342. */
  121343. transformNodes: TransformNode[];
  121344. /**
  121345. * ActionManagers available on the scene.
  121346. */
  121347. actionManagers: AbstractActionManager[];
  121348. /**
  121349. * Textures to keep.
  121350. */
  121351. textures: BaseTexture[];
  121352. /** @hidden */
  121353. protected _environmentTexture: Nullable<BaseTexture>;
  121354. /**
  121355. * Texture used in all pbr material as the reflection texture.
  121356. * As in the majority of the scene they are the same (exception for multi room and so on),
  121357. * this is easier to reference from here than from all the materials.
  121358. */
  121359. get environmentTexture(): Nullable<BaseTexture>;
  121360. set environmentTexture(value: Nullable<BaseTexture>);
  121361. /**
  121362. * The list of postprocesses added to the scene
  121363. */
  121364. postProcesses: PostProcess[];
  121365. /**
  121366. * @returns all meshes, lights, cameras, transformNodes and bones
  121367. */
  121368. getNodes(): Array<Node>;
  121369. }
  121370. }
  121371. declare module BABYLON {
  121372. /**
  121373. * Interface used to define options for Sound class
  121374. */
  121375. export interface ISoundOptions {
  121376. /**
  121377. * Does the sound autoplay once loaded.
  121378. */
  121379. autoplay?: boolean;
  121380. /**
  121381. * Does the sound loop after it finishes playing once.
  121382. */
  121383. loop?: boolean;
  121384. /**
  121385. * Sound's volume
  121386. */
  121387. volume?: number;
  121388. /**
  121389. * Is it a spatial sound?
  121390. */
  121391. spatialSound?: boolean;
  121392. /**
  121393. * Maximum distance to hear that sound
  121394. */
  121395. maxDistance?: number;
  121396. /**
  121397. * Uses user defined attenuation function
  121398. */
  121399. useCustomAttenuation?: boolean;
  121400. /**
  121401. * Define the roll off factor of spatial sounds.
  121402. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121403. */
  121404. rolloffFactor?: number;
  121405. /**
  121406. * Define the reference distance the sound should be heard perfectly.
  121407. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121408. */
  121409. refDistance?: number;
  121410. /**
  121411. * Define the distance attenuation model the sound will follow.
  121412. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121413. */
  121414. distanceModel?: string;
  121415. /**
  121416. * Defines the playback speed (1 by default)
  121417. */
  121418. playbackRate?: number;
  121419. /**
  121420. * Defines if the sound is from a streaming source
  121421. */
  121422. streaming?: boolean;
  121423. /**
  121424. * Defines an optional length (in seconds) inside the sound file
  121425. */
  121426. length?: number;
  121427. /**
  121428. * Defines an optional offset (in seconds) inside the sound file
  121429. */
  121430. offset?: number;
  121431. /**
  121432. * If true, URLs will not be required to state the audio file codec to use.
  121433. */
  121434. skipCodecCheck?: boolean;
  121435. }
  121436. /**
  121437. * Defines a sound that can be played in the application.
  121438. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  121439. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121440. */
  121441. export class Sound {
  121442. /**
  121443. * The name of the sound in the scene.
  121444. */
  121445. name: string;
  121446. /**
  121447. * Does the sound autoplay once loaded.
  121448. */
  121449. autoplay: boolean;
  121450. /**
  121451. * Does the sound loop after it finishes playing once.
  121452. */
  121453. loop: boolean;
  121454. /**
  121455. * Does the sound use a custom attenuation curve to simulate the falloff
  121456. * happening when the source gets further away from the camera.
  121457. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121458. */
  121459. useCustomAttenuation: boolean;
  121460. /**
  121461. * The sound track id this sound belongs to.
  121462. */
  121463. soundTrackId: number;
  121464. /**
  121465. * Is this sound currently played.
  121466. */
  121467. isPlaying: boolean;
  121468. /**
  121469. * Is this sound currently paused.
  121470. */
  121471. isPaused: boolean;
  121472. /**
  121473. * Does this sound enables spatial sound.
  121474. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121475. */
  121476. spatialSound: boolean;
  121477. /**
  121478. * Define the reference distance the sound should be heard perfectly.
  121479. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121480. */
  121481. refDistance: number;
  121482. /**
  121483. * Define the roll off factor of spatial sounds.
  121484. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121485. */
  121486. rolloffFactor: number;
  121487. /**
  121488. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  121489. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121490. */
  121491. maxDistance: number;
  121492. /**
  121493. * Define the distance attenuation model the sound will follow.
  121494. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121495. */
  121496. distanceModel: string;
  121497. /**
  121498. * @hidden
  121499. * Back Compat
  121500. **/
  121501. onended: () => any;
  121502. /**
  121503. * Gets or sets an object used to store user defined information for the sound.
  121504. */
  121505. metadata: any;
  121506. /**
  121507. * Observable event when the current playing sound finishes.
  121508. */
  121509. onEndedObservable: Observable<Sound>;
  121510. private _panningModel;
  121511. private _playbackRate;
  121512. private _streaming;
  121513. private _startTime;
  121514. private _startOffset;
  121515. private _position;
  121516. /** @hidden */
  121517. _positionInEmitterSpace: boolean;
  121518. private _localDirection;
  121519. private _volume;
  121520. private _isReadyToPlay;
  121521. private _isDirectional;
  121522. private _readyToPlayCallback;
  121523. private _audioBuffer;
  121524. private _soundSource;
  121525. private _streamingSource;
  121526. private _soundPanner;
  121527. private _soundGain;
  121528. private _inputAudioNode;
  121529. private _outputAudioNode;
  121530. private _coneInnerAngle;
  121531. private _coneOuterAngle;
  121532. private _coneOuterGain;
  121533. private _scene;
  121534. private _connectedTransformNode;
  121535. private _customAttenuationFunction;
  121536. private _registerFunc;
  121537. private _isOutputConnected;
  121538. private _htmlAudioElement;
  121539. private _urlType;
  121540. private _length?;
  121541. private _offset?;
  121542. /** @hidden */
  121543. static _SceneComponentInitialization: (scene: Scene) => void;
  121544. /**
  121545. * Create a sound and attach it to a scene
  121546. * @param name Name of your sound
  121547. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  121548. * @param scene defines the scene the sound belongs to
  121549. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  121550. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  121551. */
  121552. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  121553. /**
  121554. * Release the sound and its associated resources
  121555. */
  121556. dispose(): void;
  121557. /**
  121558. * Gets if the sounds is ready to be played or not.
  121559. * @returns true if ready, otherwise false
  121560. */
  121561. isReady(): boolean;
  121562. private _soundLoaded;
  121563. /**
  121564. * Sets the data of the sound from an audiobuffer
  121565. * @param audioBuffer The audioBuffer containing the data
  121566. */
  121567. setAudioBuffer(audioBuffer: AudioBuffer): void;
  121568. /**
  121569. * Updates the current sounds options such as maxdistance, loop...
  121570. * @param options A JSON object containing values named as the object properties
  121571. */
  121572. updateOptions(options: ISoundOptions): void;
  121573. private _createSpatialParameters;
  121574. private _updateSpatialParameters;
  121575. /**
  121576. * Switch the panning model to HRTF:
  121577. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  121578. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121579. */
  121580. switchPanningModelToHRTF(): void;
  121581. /**
  121582. * Switch the panning model to Equal Power:
  121583. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  121584. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121585. */
  121586. switchPanningModelToEqualPower(): void;
  121587. private _switchPanningModel;
  121588. /**
  121589. * Connect this sound to a sound track audio node like gain...
  121590. * @param soundTrackAudioNode the sound track audio node to connect to
  121591. */
  121592. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  121593. /**
  121594. * Transform this sound into a directional source
  121595. * @param coneInnerAngle Size of the inner cone in degree
  121596. * @param coneOuterAngle Size of the outer cone in degree
  121597. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  121598. */
  121599. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  121600. /**
  121601. * Gets or sets the inner angle for the directional cone.
  121602. */
  121603. get directionalConeInnerAngle(): number;
  121604. /**
  121605. * Gets or sets the inner angle for the directional cone.
  121606. */
  121607. set directionalConeInnerAngle(value: number);
  121608. /**
  121609. * Gets or sets the outer angle for the directional cone.
  121610. */
  121611. get directionalConeOuterAngle(): number;
  121612. /**
  121613. * Gets or sets the outer angle for the directional cone.
  121614. */
  121615. set directionalConeOuterAngle(value: number);
  121616. /**
  121617. * Sets the position of the emitter if spatial sound is enabled
  121618. * @param newPosition Defines the new posisiton
  121619. */
  121620. setPosition(newPosition: Vector3): void;
  121621. /**
  121622. * Sets the local direction of the emitter if spatial sound is enabled
  121623. * @param newLocalDirection Defines the new local direction
  121624. */
  121625. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  121626. private _updateDirection;
  121627. /** @hidden */
  121628. updateDistanceFromListener(): void;
  121629. /**
  121630. * Sets a new custom attenuation function for the sound.
  121631. * @param callback Defines the function used for the attenuation
  121632. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121633. */
  121634. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  121635. /**
  121636. * Play the sound
  121637. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  121638. * @param offset (optional) Start the sound at a specific time in seconds
  121639. * @param length (optional) Sound duration (in seconds)
  121640. */
  121641. play(time?: number, offset?: number, length?: number): void;
  121642. private _onended;
  121643. /**
  121644. * Stop the sound
  121645. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  121646. */
  121647. stop(time?: number): void;
  121648. /**
  121649. * Put the sound in pause
  121650. */
  121651. pause(): void;
  121652. /**
  121653. * Sets a dedicated volume for this sounds
  121654. * @param newVolume Define the new volume of the sound
  121655. * @param time Define time for gradual change to new volume
  121656. */
  121657. setVolume(newVolume: number, time?: number): void;
  121658. /**
  121659. * Set the sound play back rate
  121660. * @param newPlaybackRate Define the playback rate the sound should be played at
  121661. */
  121662. setPlaybackRate(newPlaybackRate: number): void;
  121663. /**
  121664. * Gets the volume of the sound.
  121665. * @returns the volume of the sound
  121666. */
  121667. getVolume(): number;
  121668. /**
  121669. * Attach the sound to a dedicated mesh
  121670. * @param transformNode The transform node to connect the sound with
  121671. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  121672. */
  121673. attachToMesh(transformNode: TransformNode): void;
  121674. /**
  121675. * Detach the sound from the previously attached mesh
  121676. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  121677. */
  121678. detachFromMesh(): void;
  121679. private _onRegisterAfterWorldMatrixUpdate;
  121680. /**
  121681. * Clone the current sound in the scene.
  121682. * @returns the new sound clone
  121683. */
  121684. clone(): Nullable<Sound>;
  121685. /**
  121686. * Gets the current underlying audio buffer containing the data
  121687. * @returns the audio buffer
  121688. */
  121689. getAudioBuffer(): Nullable<AudioBuffer>;
  121690. /**
  121691. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  121692. * @returns the source node
  121693. */
  121694. getSoundSource(): Nullable<AudioBufferSourceNode>;
  121695. /**
  121696. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  121697. * @returns the gain node
  121698. */
  121699. getSoundGain(): Nullable<GainNode>;
  121700. /**
  121701. * Serializes the Sound in a JSON representation
  121702. * @returns the JSON representation of the sound
  121703. */
  121704. serialize(): any;
  121705. /**
  121706. * Parse a JSON representation of a sound to innstantiate in a given scene
  121707. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  121708. * @param scene Define the scene the new parsed sound should be created in
  121709. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  121710. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  121711. * @returns the newly parsed sound
  121712. */
  121713. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  121714. }
  121715. }
  121716. declare module BABYLON {
  121717. /**
  121718. * This defines an action helpful to play a defined sound on a triggered action.
  121719. */
  121720. export class PlaySoundAction extends Action {
  121721. private _sound;
  121722. /**
  121723. * Instantiate the action
  121724. * @param triggerOptions defines the trigger options
  121725. * @param sound defines the sound to play
  121726. * @param condition defines the trigger related conditions
  121727. */
  121728. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  121729. /** @hidden */
  121730. _prepare(): void;
  121731. /**
  121732. * Execute the action and play the sound.
  121733. */
  121734. execute(): void;
  121735. /**
  121736. * Serializes the actions and its related information.
  121737. * @param parent defines the object to serialize in
  121738. * @returns the serialized object
  121739. */
  121740. serialize(parent: any): any;
  121741. }
  121742. /**
  121743. * This defines an action helpful to stop a defined sound on a triggered action.
  121744. */
  121745. export class StopSoundAction extends Action {
  121746. private _sound;
  121747. /**
  121748. * Instantiate the action
  121749. * @param triggerOptions defines the trigger options
  121750. * @param sound defines the sound to stop
  121751. * @param condition defines the trigger related conditions
  121752. */
  121753. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  121754. /** @hidden */
  121755. _prepare(): void;
  121756. /**
  121757. * Execute the action and stop the sound.
  121758. */
  121759. execute(): void;
  121760. /**
  121761. * Serializes the actions and its related information.
  121762. * @param parent defines the object to serialize in
  121763. * @returns the serialized object
  121764. */
  121765. serialize(parent: any): any;
  121766. }
  121767. }
  121768. declare module BABYLON {
  121769. /**
  121770. * This defines an action responsible to change the value of a property
  121771. * by interpolating between its current value and the newly set one once triggered.
  121772. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  121773. */
  121774. export class InterpolateValueAction extends Action {
  121775. /**
  121776. * Defines the path of the property where the value should be interpolated
  121777. */
  121778. propertyPath: string;
  121779. /**
  121780. * Defines the target value at the end of the interpolation.
  121781. */
  121782. value: any;
  121783. /**
  121784. * Defines the time it will take for the property to interpolate to the value.
  121785. */
  121786. duration: number;
  121787. /**
  121788. * Defines if the other scene animations should be stopped when the action has been triggered
  121789. */
  121790. stopOtherAnimations?: boolean;
  121791. /**
  121792. * Defines a callback raised once the interpolation animation has been done.
  121793. */
  121794. onInterpolationDone?: () => void;
  121795. /**
  121796. * Observable triggered once the interpolation animation has been done.
  121797. */
  121798. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  121799. private _target;
  121800. private _effectiveTarget;
  121801. private _property;
  121802. /**
  121803. * Instantiate the action
  121804. * @param triggerOptions defines the trigger options
  121805. * @param target defines the object containing the value to interpolate
  121806. * @param propertyPath defines the path to the property in the target object
  121807. * @param value defines the target value at the end of the interpolation
  121808. * @param duration deines the time it will take for the property to interpolate to the value.
  121809. * @param condition defines the trigger related conditions
  121810. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  121811. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  121812. */
  121813. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  121814. /** @hidden */
  121815. _prepare(): void;
  121816. /**
  121817. * Execute the action starts the value interpolation.
  121818. */
  121819. execute(): void;
  121820. /**
  121821. * Serializes the actions and its related information.
  121822. * @param parent defines the object to serialize in
  121823. * @returns the serialized object
  121824. */
  121825. serialize(parent: any): any;
  121826. }
  121827. }
  121828. declare module BABYLON {
  121829. /**
  121830. * Options allowed during the creation of a sound track.
  121831. */
  121832. export interface ISoundTrackOptions {
  121833. /**
  121834. * The volume the sound track should take during creation
  121835. */
  121836. volume?: number;
  121837. /**
  121838. * Define if the sound track is the main sound track of the scene
  121839. */
  121840. mainTrack?: boolean;
  121841. }
  121842. /**
  121843. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  121844. * It will be also used in a future release to apply effects on a specific track.
  121845. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  121846. */
  121847. export class SoundTrack {
  121848. /**
  121849. * The unique identifier of the sound track in the scene.
  121850. */
  121851. id: number;
  121852. /**
  121853. * The list of sounds included in the sound track.
  121854. */
  121855. soundCollection: Array<Sound>;
  121856. private _outputAudioNode;
  121857. private _scene;
  121858. private _connectedAnalyser;
  121859. private _options;
  121860. private _isInitialized;
  121861. /**
  121862. * Creates a new sound track.
  121863. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  121864. * @param scene Define the scene the sound track belongs to
  121865. * @param options
  121866. */
  121867. constructor(scene: Scene, options?: ISoundTrackOptions);
  121868. private _initializeSoundTrackAudioGraph;
  121869. /**
  121870. * Release the sound track and its associated resources
  121871. */
  121872. dispose(): void;
  121873. /**
  121874. * Adds a sound to this sound track
  121875. * @param sound define the cound to add
  121876. * @ignoreNaming
  121877. */
  121878. AddSound(sound: Sound): void;
  121879. /**
  121880. * Removes a sound to this sound track
  121881. * @param sound define the cound to remove
  121882. * @ignoreNaming
  121883. */
  121884. RemoveSound(sound: Sound): void;
  121885. /**
  121886. * Set a global volume for the full sound track.
  121887. * @param newVolume Define the new volume of the sound track
  121888. */
  121889. setVolume(newVolume: number): void;
  121890. /**
  121891. * Switch the panning model to HRTF:
  121892. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  121893. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121894. */
  121895. switchPanningModelToHRTF(): void;
  121896. /**
  121897. * Switch the panning model to Equal Power:
  121898. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  121899. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121900. */
  121901. switchPanningModelToEqualPower(): void;
  121902. /**
  121903. * Connect the sound track to an audio analyser allowing some amazing
  121904. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  121905. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  121906. * @param analyser The analyser to connect to the engine
  121907. */
  121908. connectToAnalyser(analyser: Analyser): void;
  121909. }
  121910. }
  121911. declare module BABYLON {
  121912. interface AbstractScene {
  121913. /**
  121914. * The list of sounds used in the scene.
  121915. */
  121916. sounds: Nullable<Array<Sound>>;
  121917. }
  121918. interface Scene {
  121919. /**
  121920. * @hidden
  121921. * Backing field
  121922. */
  121923. _mainSoundTrack: SoundTrack;
  121924. /**
  121925. * The main sound track played by the scene.
  121926. * It cotains your primary collection of sounds.
  121927. */
  121928. mainSoundTrack: SoundTrack;
  121929. /**
  121930. * The list of sound tracks added to the scene
  121931. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121932. */
  121933. soundTracks: Nullable<Array<SoundTrack>>;
  121934. /**
  121935. * Gets a sound using a given name
  121936. * @param name defines the name to search for
  121937. * @return the found sound or null if not found at all.
  121938. */
  121939. getSoundByName(name: string): Nullable<Sound>;
  121940. /**
  121941. * Gets or sets if audio support is enabled
  121942. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121943. */
  121944. audioEnabled: boolean;
  121945. /**
  121946. * Gets or sets if audio will be output to headphones
  121947. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121948. */
  121949. headphone: boolean;
  121950. /**
  121951. * Gets or sets custom audio listener position provider
  121952. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121953. */
  121954. audioListenerPositionProvider: Nullable<() => Vector3>;
  121955. /**
  121956. * Gets or sets a refresh rate when using 3D audio positioning
  121957. */
  121958. audioPositioningRefreshRate: number;
  121959. }
  121960. /**
  121961. * Defines the sound scene component responsible to manage any sounds
  121962. * in a given scene.
  121963. */
  121964. export class AudioSceneComponent implements ISceneSerializableComponent {
  121965. private static _CameraDirectionLH;
  121966. private static _CameraDirectionRH;
  121967. /**
  121968. * The component name helpfull to identify the component in the list of scene components.
  121969. */
  121970. readonly name: string;
  121971. /**
  121972. * The scene the component belongs to.
  121973. */
  121974. scene: Scene;
  121975. private _audioEnabled;
  121976. /**
  121977. * Gets whether audio is enabled or not.
  121978. * Please use related enable/disable method to switch state.
  121979. */
  121980. get audioEnabled(): boolean;
  121981. private _headphone;
  121982. /**
  121983. * Gets whether audio is outputing to headphone or not.
  121984. * Please use the according Switch methods to change output.
  121985. */
  121986. get headphone(): boolean;
  121987. /**
  121988. * Gets or sets a refresh rate when using 3D audio positioning
  121989. */
  121990. audioPositioningRefreshRate: number;
  121991. private _audioListenerPositionProvider;
  121992. /**
  121993. * Gets the current audio listener position provider
  121994. */
  121995. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  121996. /**
  121997. * Sets a custom listener position for all sounds in the scene
  121998. * By default, this is the position of the first active camera
  121999. */
  122000. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  122001. /**
  122002. * Creates a new instance of the component for the given scene
  122003. * @param scene Defines the scene to register the component in
  122004. */
  122005. constructor(scene: Scene);
  122006. /**
  122007. * Registers the component in a given scene
  122008. */
  122009. register(): void;
  122010. /**
  122011. * Rebuilds the elements related to this component in case of
  122012. * context lost for instance.
  122013. */
  122014. rebuild(): void;
  122015. /**
  122016. * Serializes the component data to the specified json object
  122017. * @param serializationObject The object to serialize to
  122018. */
  122019. serialize(serializationObject: any): void;
  122020. /**
  122021. * Adds all the elements from the container to the scene
  122022. * @param container the container holding the elements
  122023. */
  122024. addFromContainer(container: AbstractScene): void;
  122025. /**
  122026. * Removes all the elements in the container from the scene
  122027. * @param container contains the elements to remove
  122028. * @param dispose if the removed element should be disposed (default: false)
  122029. */
  122030. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122031. /**
  122032. * Disposes the component and the associated ressources.
  122033. */
  122034. dispose(): void;
  122035. /**
  122036. * Disables audio in the associated scene.
  122037. */
  122038. disableAudio(): void;
  122039. /**
  122040. * Enables audio in the associated scene.
  122041. */
  122042. enableAudio(): void;
  122043. /**
  122044. * Switch audio to headphone output.
  122045. */
  122046. switchAudioModeForHeadphones(): void;
  122047. /**
  122048. * Switch audio to normal speakers.
  122049. */
  122050. switchAudioModeForNormalSpeakers(): void;
  122051. private _cachedCameraDirection;
  122052. private _cachedCameraPosition;
  122053. private _lastCheck;
  122054. private _afterRender;
  122055. }
  122056. }
  122057. declare module BABYLON {
  122058. /**
  122059. * Wraps one or more Sound objects and selects one with random weight for playback.
  122060. */
  122061. export class WeightedSound {
  122062. /** When true a Sound will be selected and played when the current playing Sound completes. */
  122063. loop: boolean;
  122064. private _coneInnerAngle;
  122065. private _coneOuterAngle;
  122066. private _volume;
  122067. /** A Sound is currently playing. */
  122068. isPlaying: boolean;
  122069. /** A Sound is currently paused. */
  122070. isPaused: boolean;
  122071. private _sounds;
  122072. private _weights;
  122073. private _currentIndex?;
  122074. /**
  122075. * Creates a new WeightedSound from the list of sounds given.
  122076. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  122077. * @param sounds Array of Sounds that will be selected from.
  122078. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  122079. */
  122080. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  122081. /**
  122082. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  122083. */
  122084. get directionalConeInnerAngle(): number;
  122085. /**
  122086. * The size of cone in degress for a directional sound in which there will be no attenuation.
  122087. */
  122088. set directionalConeInnerAngle(value: number);
  122089. /**
  122090. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122091. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122092. */
  122093. get directionalConeOuterAngle(): number;
  122094. /**
  122095. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122096. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122097. */
  122098. set directionalConeOuterAngle(value: number);
  122099. /**
  122100. * Playback volume.
  122101. */
  122102. get volume(): number;
  122103. /**
  122104. * Playback volume.
  122105. */
  122106. set volume(value: number);
  122107. private _onended;
  122108. /**
  122109. * Suspend playback
  122110. */
  122111. pause(): void;
  122112. /**
  122113. * Stop playback
  122114. */
  122115. stop(): void;
  122116. /**
  122117. * Start playback.
  122118. * @param startOffset Position the clip head at a specific time in seconds.
  122119. */
  122120. play(startOffset?: number): void;
  122121. }
  122122. }
  122123. declare module BABYLON {
  122124. /**
  122125. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  122126. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122127. */
  122128. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  122129. /**
  122130. * Gets the name of the behavior.
  122131. */
  122132. get name(): string;
  122133. /**
  122134. * The easing function used by animations
  122135. */
  122136. static EasingFunction: BackEase;
  122137. /**
  122138. * The easing mode used by animations
  122139. */
  122140. static EasingMode: number;
  122141. /**
  122142. * The duration of the animation, in milliseconds
  122143. */
  122144. transitionDuration: number;
  122145. /**
  122146. * Length of the distance animated by the transition when lower radius is reached
  122147. */
  122148. lowerRadiusTransitionRange: number;
  122149. /**
  122150. * Length of the distance animated by the transition when upper radius is reached
  122151. */
  122152. upperRadiusTransitionRange: number;
  122153. private _autoTransitionRange;
  122154. /**
  122155. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122156. */
  122157. get autoTransitionRange(): boolean;
  122158. /**
  122159. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122160. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  122161. */
  122162. set autoTransitionRange(value: boolean);
  122163. private _attachedCamera;
  122164. private _onAfterCheckInputsObserver;
  122165. private _onMeshTargetChangedObserver;
  122166. /**
  122167. * Initializes the behavior.
  122168. */
  122169. init(): void;
  122170. /**
  122171. * Attaches the behavior to its arc rotate camera.
  122172. * @param camera Defines the camera to attach the behavior to
  122173. */
  122174. attach(camera: ArcRotateCamera): void;
  122175. /**
  122176. * Detaches the behavior from its current arc rotate camera.
  122177. */
  122178. detach(): void;
  122179. private _radiusIsAnimating;
  122180. private _radiusBounceTransition;
  122181. private _animatables;
  122182. private _cachedWheelPrecision;
  122183. /**
  122184. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  122185. * @param radiusLimit The limit to check against.
  122186. * @return Bool to indicate if at limit.
  122187. */
  122188. private _isRadiusAtLimit;
  122189. /**
  122190. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  122191. * @param radiusDelta The delta by which to animate to. Can be negative.
  122192. */
  122193. private _applyBoundRadiusAnimation;
  122194. /**
  122195. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  122196. */
  122197. protected _clearAnimationLocks(): void;
  122198. /**
  122199. * Stops and removes all animations that have been applied to the camera
  122200. */
  122201. stopAllAnimations(): void;
  122202. }
  122203. }
  122204. declare module BABYLON {
  122205. /**
  122206. * 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.
  122207. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122208. */
  122209. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  122210. /**
  122211. * Gets the name of the behavior.
  122212. */
  122213. get name(): string;
  122214. private _mode;
  122215. private _radiusScale;
  122216. private _positionScale;
  122217. private _defaultElevation;
  122218. private _elevationReturnTime;
  122219. private _elevationReturnWaitTime;
  122220. private _zoomStopsAnimation;
  122221. private _framingTime;
  122222. /**
  122223. * The easing function used by animations
  122224. */
  122225. static EasingFunction: ExponentialEase;
  122226. /**
  122227. * The easing mode used by animations
  122228. */
  122229. static EasingMode: number;
  122230. /**
  122231. * Sets the current mode used by the behavior
  122232. */
  122233. set mode(mode: number);
  122234. /**
  122235. * Gets current mode used by the behavior.
  122236. */
  122237. get mode(): number;
  122238. /**
  122239. * Sets the scale applied to the radius (1 by default)
  122240. */
  122241. set radiusScale(radius: number);
  122242. /**
  122243. * Gets the scale applied to the radius
  122244. */
  122245. get radiusScale(): number;
  122246. /**
  122247. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122248. */
  122249. set positionScale(scale: number);
  122250. /**
  122251. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122252. */
  122253. get positionScale(): number;
  122254. /**
  122255. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122256. * behaviour is triggered, in radians.
  122257. */
  122258. set defaultElevation(elevation: number);
  122259. /**
  122260. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122261. * behaviour is triggered, in radians.
  122262. */
  122263. get defaultElevation(): number;
  122264. /**
  122265. * Sets the time (in milliseconds) taken to return to the default beta position.
  122266. * Negative value indicates camera should not return to default.
  122267. */
  122268. set elevationReturnTime(speed: number);
  122269. /**
  122270. * Gets the time (in milliseconds) taken to return to the default beta position.
  122271. * Negative value indicates camera should not return to default.
  122272. */
  122273. get elevationReturnTime(): number;
  122274. /**
  122275. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122276. */
  122277. set elevationReturnWaitTime(time: number);
  122278. /**
  122279. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122280. */
  122281. get elevationReturnWaitTime(): number;
  122282. /**
  122283. * Sets the flag that indicates if user zooming should stop animation.
  122284. */
  122285. set zoomStopsAnimation(flag: boolean);
  122286. /**
  122287. * Gets the flag that indicates if user zooming should stop animation.
  122288. */
  122289. get zoomStopsAnimation(): boolean;
  122290. /**
  122291. * Sets the transition time when framing the mesh, in milliseconds
  122292. */
  122293. set framingTime(time: number);
  122294. /**
  122295. * Gets the transition time when framing the mesh, in milliseconds
  122296. */
  122297. get framingTime(): number;
  122298. /**
  122299. * Define if the behavior should automatically change the configured
  122300. * camera limits and sensibilities.
  122301. */
  122302. autoCorrectCameraLimitsAndSensibility: boolean;
  122303. private _onPrePointerObservableObserver;
  122304. private _onAfterCheckInputsObserver;
  122305. private _onMeshTargetChangedObserver;
  122306. private _attachedCamera;
  122307. private _isPointerDown;
  122308. private _lastInteractionTime;
  122309. /**
  122310. * Initializes the behavior.
  122311. */
  122312. init(): void;
  122313. /**
  122314. * Attaches the behavior to its arc rotate camera.
  122315. * @param camera Defines the camera to attach the behavior to
  122316. */
  122317. attach(camera: ArcRotateCamera): void;
  122318. /**
  122319. * Detaches the behavior from its current arc rotate camera.
  122320. */
  122321. detach(): void;
  122322. private _animatables;
  122323. private _betaIsAnimating;
  122324. private _betaTransition;
  122325. private _radiusTransition;
  122326. private _vectorTransition;
  122327. /**
  122328. * Targets the given mesh and updates zoom level accordingly.
  122329. * @param mesh The mesh to target.
  122330. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122331. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122332. */
  122333. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122334. /**
  122335. * Targets the given mesh with its children and updates zoom level accordingly.
  122336. * @param mesh The mesh to target.
  122337. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122338. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122339. */
  122340. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122341. /**
  122342. * Targets the given meshes with their children and updates zoom level accordingly.
  122343. * @param meshes The mesh to target.
  122344. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122345. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122346. */
  122347. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122348. /**
  122349. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  122350. * @param minimumWorld Determines the smaller position of the bounding box extend
  122351. * @param maximumWorld Determines the bigger position of the bounding box extend
  122352. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122353. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122354. */
  122355. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122356. /**
  122357. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  122358. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  122359. * frustum width.
  122360. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  122361. * to fully enclose the mesh in the viewing frustum.
  122362. */
  122363. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  122364. /**
  122365. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  122366. * is automatically returned to its default position (expected to be above ground plane).
  122367. */
  122368. private _maintainCameraAboveGround;
  122369. /**
  122370. * Returns the frustum slope based on the canvas ratio and camera FOV
  122371. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  122372. */
  122373. private _getFrustumSlope;
  122374. /**
  122375. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  122376. */
  122377. private _clearAnimationLocks;
  122378. /**
  122379. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122380. */
  122381. private _applyUserInteraction;
  122382. /**
  122383. * Stops and removes all animations that have been applied to the camera
  122384. */
  122385. stopAllAnimations(): void;
  122386. /**
  122387. * Gets a value indicating if the user is moving the camera
  122388. */
  122389. get isUserIsMoving(): boolean;
  122390. /**
  122391. * The camera can move all the way towards the mesh.
  122392. */
  122393. static IgnoreBoundsSizeMode: number;
  122394. /**
  122395. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  122396. */
  122397. static FitFrustumSidesMode: number;
  122398. }
  122399. }
  122400. declare module BABYLON {
  122401. /**
  122402. * Base class for Camera Pointer Inputs.
  122403. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  122404. * for example usage.
  122405. */
  122406. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  122407. /**
  122408. * Defines the camera the input is attached to.
  122409. */
  122410. abstract camera: Camera;
  122411. /**
  122412. * Whether keyboard modifier keys are pressed at time of last mouse event.
  122413. */
  122414. protected _altKey: boolean;
  122415. protected _ctrlKey: boolean;
  122416. protected _metaKey: boolean;
  122417. protected _shiftKey: boolean;
  122418. /**
  122419. * Which mouse buttons were pressed at time of last mouse event.
  122420. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  122421. */
  122422. protected _buttonsPressed: number;
  122423. /**
  122424. * Defines the buttons associated with the input to handle camera move.
  122425. */
  122426. buttons: number[];
  122427. /**
  122428. * Attach the input controls to a specific dom element to get the input from.
  122429. * @param element Defines the element the controls should be listened from
  122430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122431. */
  122432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122433. /**
  122434. * Detach the current controls from the specified dom element.
  122435. * @param element Defines the element to stop listening the inputs from
  122436. */
  122437. detachControl(element: Nullable<HTMLElement>): void;
  122438. /**
  122439. * Gets the class name of the current input.
  122440. * @returns the class name
  122441. */
  122442. getClassName(): string;
  122443. /**
  122444. * Get the friendly name associated with the input class.
  122445. * @returns the input friendly name
  122446. */
  122447. getSimpleName(): string;
  122448. /**
  122449. * Called on pointer POINTERDOUBLETAP event.
  122450. * Override this method to provide functionality on POINTERDOUBLETAP event.
  122451. */
  122452. protected onDoubleTap(type: string): void;
  122453. /**
  122454. * Called on pointer POINTERMOVE event if only a single touch is active.
  122455. * Override this method to provide functionality.
  122456. */
  122457. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122458. /**
  122459. * Called on pointer POINTERMOVE event if multiple touches are active.
  122460. * Override this method to provide functionality.
  122461. */
  122462. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122463. /**
  122464. * Called on JS contextmenu event.
  122465. * Override this method to provide functionality.
  122466. */
  122467. protected onContextMenu(evt: PointerEvent): void;
  122468. /**
  122469. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122470. * press.
  122471. * Override this method to provide functionality.
  122472. */
  122473. protected onButtonDown(evt: PointerEvent): void;
  122474. /**
  122475. * Called each time a new POINTERUP event occurs. Ie, for each button
  122476. * release.
  122477. * Override this method to provide functionality.
  122478. */
  122479. protected onButtonUp(evt: PointerEvent): void;
  122480. /**
  122481. * Called when window becomes inactive.
  122482. * Override this method to provide functionality.
  122483. */
  122484. protected onLostFocus(): void;
  122485. private _pointerInput;
  122486. private _observer;
  122487. private _onLostFocus;
  122488. private pointA;
  122489. private pointB;
  122490. }
  122491. }
  122492. declare module BABYLON {
  122493. /**
  122494. * Manage the pointers inputs to control an arc rotate camera.
  122495. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122496. */
  122497. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  122498. /**
  122499. * Defines the camera the input is attached to.
  122500. */
  122501. camera: ArcRotateCamera;
  122502. /**
  122503. * Gets the class name of the current input.
  122504. * @returns the class name
  122505. */
  122506. getClassName(): string;
  122507. /**
  122508. * Defines the buttons associated with the input to handle camera move.
  122509. */
  122510. buttons: number[];
  122511. /**
  122512. * Defines the pointer angular sensibility along the X axis or how fast is
  122513. * the camera rotating.
  122514. */
  122515. angularSensibilityX: number;
  122516. /**
  122517. * Defines the pointer angular sensibility along the Y axis or how fast is
  122518. * the camera rotating.
  122519. */
  122520. angularSensibilityY: number;
  122521. /**
  122522. * Defines the pointer pinch precision or how fast is the camera zooming.
  122523. */
  122524. pinchPrecision: number;
  122525. /**
  122526. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  122527. * from 0.
  122528. * It defines the percentage of current camera.radius to use as delta when
  122529. * pinch zoom is used.
  122530. */
  122531. pinchDeltaPercentage: number;
  122532. /**
  122533. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  122534. * that any object in the plane at the camera's target point will scale
  122535. * perfectly with finger motion.
  122536. * Overrides pinchDeltaPercentage and pinchPrecision.
  122537. */
  122538. useNaturalPinchZoom: boolean;
  122539. /**
  122540. * Defines the pointer panning sensibility or how fast is the camera moving.
  122541. */
  122542. panningSensibility: number;
  122543. /**
  122544. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  122545. */
  122546. multiTouchPanning: boolean;
  122547. /**
  122548. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  122549. * zoom (pinch) through multitouch.
  122550. */
  122551. multiTouchPanAndZoom: boolean;
  122552. /**
  122553. * Revers pinch action direction.
  122554. */
  122555. pinchInwards: boolean;
  122556. private _isPanClick;
  122557. private _twoFingerActivityCount;
  122558. private _isPinching;
  122559. /**
  122560. * Called on pointer POINTERMOVE event if only a single touch is active.
  122561. */
  122562. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122563. /**
  122564. * Called on pointer POINTERDOUBLETAP event.
  122565. */
  122566. protected onDoubleTap(type: string): void;
  122567. /**
  122568. * Called on pointer POINTERMOVE event if multiple touches are active.
  122569. */
  122570. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122571. /**
  122572. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122573. * press.
  122574. */
  122575. protected onButtonDown(evt: PointerEvent): void;
  122576. /**
  122577. * Called each time a new POINTERUP event occurs. Ie, for each button
  122578. * release.
  122579. */
  122580. protected onButtonUp(evt: PointerEvent): void;
  122581. /**
  122582. * Called when window becomes inactive.
  122583. */
  122584. protected onLostFocus(): void;
  122585. }
  122586. }
  122587. declare module BABYLON {
  122588. /**
  122589. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  122590. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122591. */
  122592. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  122593. /**
  122594. * Defines the camera the input is attached to.
  122595. */
  122596. camera: ArcRotateCamera;
  122597. /**
  122598. * Defines the list of key codes associated with the up action (increase alpha)
  122599. */
  122600. keysUp: number[];
  122601. /**
  122602. * Defines the list of key codes associated with the down action (decrease alpha)
  122603. */
  122604. keysDown: number[];
  122605. /**
  122606. * Defines the list of key codes associated with the left action (increase beta)
  122607. */
  122608. keysLeft: number[];
  122609. /**
  122610. * Defines the list of key codes associated with the right action (decrease beta)
  122611. */
  122612. keysRight: number[];
  122613. /**
  122614. * Defines the list of key codes associated with the reset action.
  122615. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  122616. */
  122617. keysReset: number[];
  122618. /**
  122619. * Defines the panning sensibility of the inputs.
  122620. * (How fast is the camera panning)
  122621. */
  122622. panningSensibility: number;
  122623. /**
  122624. * Defines the zooming sensibility of the inputs.
  122625. * (How fast is the camera zooming)
  122626. */
  122627. zoomingSensibility: number;
  122628. /**
  122629. * Defines whether maintaining the alt key down switch the movement mode from
  122630. * orientation to zoom.
  122631. */
  122632. useAltToZoom: boolean;
  122633. /**
  122634. * Rotation speed of the camera
  122635. */
  122636. angularSpeed: number;
  122637. private _keys;
  122638. private _ctrlPressed;
  122639. private _altPressed;
  122640. private _onCanvasBlurObserver;
  122641. private _onKeyboardObserver;
  122642. private _engine;
  122643. private _scene;
  122644. /**
  122645. * Attach the input controls to a specific dom element to get the input from.
  122646. * @param element Defines the element the controls should be listened from
  122647. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122648. */
  122649. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122650. /**
  122651. * Detach the current controls from the specified dom element.
  122652. * @param element Defines the element to stop listening the inputs from
  122653. */
  122654. detachControl(element: Nullable<HTMLElement>): void;
  122655. /**
  122656. * Update the current camera state depending on the inputs that have been used this frame.
  122657. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122658. */
  122659. checkInputs(): void;
  122660. /**
  122661. * Gets the class name of the current intput.
  122662. * @returns the class name
  122663. */
  122664. getClassName(): string;
  122665. /**
  122666. * Get the friendly name associated with the input class.
  122667. * @returns the input friendly name
  122668. */
  122669. getSimpleName(): string;
  122670. }
  122671. }
  122672. declare module BABYLON {
  122673. /**
  122674. * Manage the mouse wheel inputs to control an arc rotate camera.
  122675. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122676. */
  122677. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  122678. /**
  122679. * Defines the camera the input is attached to.
  122680. */
  122681. camera: ArcRotateCamera;
  122682. /**
  122683. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  122684. */
  122685. wheelPrecision: number;
  122686. /**
  122687. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  122688. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  122689. */
  122690. wheelDeltaPercentage: number;
  122691. private _wheel;
  122692. private _observer;
  122693. private computeDeltaFromMouseWheelLegacyEvent;
  122694. /**
  122695. * Attach the input controls to a specific dom element to get the input from.
  122696. * @param element Defines the element the controls should be listened from
  122697. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122698. */
  122699. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122700. /**
  122701. * Detach the current controls from the specified dom element.
  122702. * @param element Defines the element to stop listening the inputs from
  122703. */
  122704. detachControl(element: Nullable<HTMLElement>): void;
  122705. /**
  122706. * Gets the class name of the current intput.
  122707. * @returns the class name
  122708. */
  122709. getClassName(): string;
  122710. /**
  122711. * Get the friendly name associated with the input class.
  122712. * @returns the input friendly name
  122713. */
  122714. getSimpleName(): string;
  122715. }
  122716. }
  122717. declare module BABYLON {
  122718. /**
  122719. * Default Inputs manager for the ArcRotateCamera.
  122720. * It groups all the default supported inputs for ease of use.
  122721. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122722. */
  122723. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  122724. /**
  122725. * Instantiates a new ArcRotateCameraInputsManager.
  122726. * @param camera Defines the camera the inputs belong to
  122727. */
  122728. constructor(camera: ArcRotateCamera);
  122729. /**
  122730. * Add mouse wheel input support to the input manager.
  122731. * @returns the current input manager
  122732. */
  122733. addMouseWheel(): ArcRotateCameraInputsManager;
  122734. /**
  122735. * Add pointers input support to the input manager.
  122736. * @returns the current input manager
  122737. */
  122738. addPointers(): ArcRotateCameraInputsManager;
  122739. /**
  122740. * Add keyboard input support to the input manager.
  122741. * @returns the current input manager
  122742. */
  122743. addKeyboard(): ArcRotateCameraInputsManager;
  122744. }
  122745. }
  122746. declare module BABYLON {
  122747. /**
  122748. * This represents an orbital type of camera.
  122749. *
  122750. * 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.
  122751. * 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.
  122752. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  122753. */
  122754. export class ArcRotateCamera extends TargetCamera {
  122755. /**
  122756. * Defines the rotation angle of the camera along the longitudinal axis.
  122757. */
  122758. alpha: number;
  122759. /**
  122760. * Defines the rotation angle of the camera along the latitudinal axis.
  122761. */
  122762. beta: number;
  122763. /**
  122764. * Defines the radius of the camera from it s target point.
  122765. */
  122766. radius: number;
  122767. protected _target: Vector3;
  122768. protected _targetHost: Nullable<AbstractMesh>;
  122769. /**
  122770. * Defines the target point of the camera.
  122771. * The camera looks towards it form the radius distance.
  122772. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  122773. */
  122774. get target(): Vector3;
  122775. set target(value: Vector3);
  122776. /**
  122777. * Define the current local position of the camera in the scene
  122778. */
  122779. get position(): Vector3;
  122780. set position(newPosition: Vector3);
  122781. protected _upToYMatrix: Matrix;
  122782. protected _YToUpMatrix: Matrix;
  122783. /**
  122784. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  122785. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  122786. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  122787. */
  122788. set upVector(vec: Vector3);
  122789. get upVector(): Vector3;
  122790. /**
  122791. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  122792. */
  122793. setMatUp(): void;
  122794. /**
  122795. * Current inertia value on the longitudinal axis.
  122796. * The bigger this number the longer it will take for the camera to stop.
  122797. */
  122798. inertialAlphaOffset: number;
  122799. /**
  122800. * Current inertia value on the latitudinal axis.
  122801. * The bigger this number the longer it will take for the camera to stop.
  122802. */
  122803. inertialBetaOffset: number;
  122804. /**
  122805. * Current inertia value on the radius axis.
  122806. * The bigger this number the longer it will take for the camera to stop.
  122807. */
  122808. inertialRadiusOffset: number;
  122809. /**
  122810. * Minimum allowed angle on the longitudinal axis.
  122811. * This can help limiting how the Camera is able to move in the scene.
  122812. */
  122813. lowerAlphaLimit: Nullable<number>;
  122814. /**
  122815. * Maximum allowed angle on the longitudinal axis.
  122816. * This can help limiting how the Camera is able to move in the scene.
  122817. */
  122818. upperAlphaLimit: Nullable<number>;
  122819. /**
  122820. * Minimum allowed angle on the latitudinal axis.
  122821. * This can help limiting how the Camera is able to move in the scene.
  122822. */
  122823. lowerBetaLimit: number;
  122824. /**
  122825. * Maximum allowed angle on the latitudinal axis.
  122826. * This can help limiting how the Camera is able to move in the scene.
  122827. */
  122828. upperBetaLimit: number;
  122829. /**
  122830. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  122831. * This can help limiting how the Camera is able to move in the scene.
  122832. */
  122833. lowerRadiusLimit: Nullable<number>;
  122834. /**
  122835. * Maximum allowed distance of the camera to the target (The camera can not get further).
  122836. * This can help limiting how the Camera is able to move in the scene.
  122837. */
  122838. upperRadiusLimit: Nullable<number>;
  122839. /**
  122840. * Defines the current inertia value used during panning of the camera along the X axis.
  122841. */
  122842. inertialPanningX: number;
  122843. /**
  122844. * Defines the current inertia value used during panning of the camera along the Y axis.
  122845. */
  122846. inertialPanningY: number;
  122847. /**
  122848. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  122849. * Basically if your fingers moves away from more than this distance you will be considered
  122850. * in pinch mode.
  122851. */
  122852. pinchToPanMaxDistance: number;
  122853. /**
  122854. * Defines the maximum distance the camera can pan.
  122855. * This could help keeping the cammera always in your scene.
  122856. */
  122857. panningDistanceLimit: Nullable<number>;
  122858. /**
  122859. * Defines the target of the camera before paning.
  122860. */
  122861. panningOriginTarget: Vector3;
  122862. /**
  122863. * Defines the value of the inertia used during panning.
  122864. * 0 would mean stop inertia and one would mean no decelleration at all.
  122865. */
  122866. panningInertia: number;
  122867. /**
  122868. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  122869. */
  122870. get angularSensibilityX(): number;
  122871. set angularSensibilityX(value: number);
  122872. /**
  122873. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  122874. */
  122875. get angularSensibilityY(): number;
  122876. set angularSensibilityY(value: number);
  122877. /**
  122878. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  122879. */
  122880. get pinchPrecision(): number;
  122881. set pinchPrecision(value: number);
  122882. /**
  122883. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  122884. * It will be used instead of pinchDeltaPrecision if different from 0.
  122885. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  122886. */
  122887. get pinchDeltaPercentage(): number;
  122888. set pinchDeltaPercentage(value: number);
  122889. /**
  122890. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  122891. * and pinch delta percentage.
  122892. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  122893. * that any object in the plane at the camera's target point will scale
  122894. * perfectly with finger motion.
  122895. */
  122896. get useNaturalPinchZoom(): boolean;
  122897. set useNaturalPinchZoom(value: boolean);
  122898. /**
  122899. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  122900. */
  122901. get panningSensibility(): number;
  122902. set panningSensibility(value: number);
  122903. /**
  122904. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  122905. */
  122906. get keysUp(): number[];
  122907. set keysUp(value: number[]);
  122908. /**
  122909. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  122910. */
  122911. get keysDown(): number[];
  122912. set keysDown(value: number[]);
  122913. /**
  122914. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  122915. */
  122916. get keysLeft(): number[];
  122917. set keysLeft(value: number[]);
  122918. /**
  122919. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  122920. */
  122921. get keysRight(): number[];
  122922. set keysRight(value: number[]);
  122923. /**
  122924. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  122925. */
  122926. get wheelPrecision(): number;
  122927. set wheelPrecision(value: number);
  122928. /**
  122929. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  122930. * It will be used instead of pinchDeltaPrecision if different from 0.
  122931. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  122932. */
  122933. get wheelDeltaPercentage(): number;
  122934. set wheelDeltaPercentage(value: number);
  122935. /**
  122936. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  122937. */
  122938. zoomOnFactor: number;
  122939. /**
  122940. * Defines a screen offset for the camera position.
  122941. */
  122942. targetScreenOffset: Vector2;
  122943. /**
  122944. * Allows the camera to be completely reversed.
  122945. * If false the camera can not arrive upside down.
  122946. */
  122947. allowUpsideDown: boolean;
  122948. /**
  122949. * Define if double tap/click is used to restore the previously saved state of the camera.
  122950. */
  122951. useInputToRestoreState: boolean;
  122952. /** @hidden */
  122953. _viewMatrix: Matrix;
  122954. /** @hidden */
  122955. _useCtrlForPanning: boolean;
  122956. /** @hidden */
  122957. _panningMouseButton: number;
  122958. /**
  122959. * Defines the input associated to the camera.
  122960. */
  122961. inputs: ArcRotateCameraInputsManager;
  122962. /** @hidden */
  122963. _reset: () => void;
  122964. /**
  122965. * Defines the allowed panning axis.
  122966. */
  122967. panningAxis: Vector3;
  122968. protected _localDirection: Vector3;
  122969. protected _transformedDirection: Vector3;
  122970. private _bouncingBehavior;
  122971. /**
  122972. * Gets the bouncing behavior of the camera if it has been enabled.
  122973. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122974. */
  122975. get bouncingBehavior(): Nullable<BouncingBehavior>;
  122976. /**
  122977. * Defines if the bouncing behavior of the camera is enabled on the camera.
  122978. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122979. */
  122980. get useBouncingBehavior(): boolean;
  122981. set useBouncingBehavior(value: boolean);
  122982. private _framingBehavior;
  122983. /**
  122984. * Gets the framing behavior of the camera if it has been enabled.
  122985. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122986. */
  122987. get framingBehavior(): Nullable<FramingBehavior>;
  122988. /**
  122989. * Defines if the framing behavior of the camera is enabled on the camera.
  122990. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122991. */
  122992. get useFramingBehavior(): boolean;
  122993. set useFramingBehavior(value: boolean);
  122994. private _autoRotationBehavior;
  122995. /**
  122996. * Gets the auto rotation behavior of the camera if it has been enabled.
  122997. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122998. */
  122999. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  123000. /**
  123001. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  123002. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123003. */
  123004. get useAutoRotationBehavior(): boolean;
  123005. set useAutoRotationBehavior(value: boolean);
  123006. /**
  123007. * Observable triggered when the mesh target has been changed on the camera.
  123008. */
  123009. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  123010. /**
  123011. * Event raised when the camera is colliding with a mesh.
  123012. */
  123013. onCollide: (collidedMesh: AbstractMesh) => void;
  123014. /**
  123015. * Defines whether the camera should check collision with the objects oh the scene.
  123016. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  123017. */
  123018. checkCollisions: boolean;
  123019. /**
  123020. * Defines the collision radius of the camera.
  123021. * This simulates a sphere around the camera.
  123022. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123023. */
  123024. collisionRadius: Vector3;
  123025. protected _collider: Collider;
  123026. protected _previousPosition: Vector3;
  123027. protected _collisionVelocity: Vector3;
  123028. protected _newPosition: Vector3;
  123029. protected _previousAlpha: number;
  123030. protected _previousBeta: number;
  123031. protected _previousRadius: number;
  123032. protected _collisionTriggered: boolean;
  123033. protected _targetBoundingCenter: Nullable<Vector3>;
  123034. private _computationVector;
  123035. /**
  123036. * Instantiates a new ArcRotateCamera in a given scene
  123037. * @param name Defines the name of the camera
  123038. * @param alpha Defines the camera rotation along the logitudinal axis
  123039. * @param beta Defines the camera rotation along the latitudinal axis
  123040. * @param radius Defines the camera distance from its target
  123041. * @param target Defines the camera target
  123042. * @param scene Defines the scene the camera belongs to
  123043. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  123044. */
  123045. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123046. /** @hidden */
  123047. _initCache(): void;
  123048. /** @hidden */
  123049. _updateCache(ignoreParentClass?: boolean): void;
  123050. protected _getTargetPosition(): Vector3;
  123051. private _storedAlpha;
  123052. private _storedBeta;
  123053. private _storedRadius;
  123054. private _storedTarget;
  123055. private _storedTargetScreenOffset;
  123056. /**
  123057. * Stores the current state of the camera (alpha, beta, radius and target)
  123058. * @returns the camera itself
  123059. */
  123060. storeState(): Camera;
  123061. /**
  123062. * @hidden
  123063. * Restored camera state. You must call storeState() first
  123064. */
  123065. _restoreStateValues(): boolean;
  123066. /** @hidden */
  123067. _isSynchronizedViewMatrix(): boolean;
  123068. /**
  123069. * Attached controls to the current camera.
  123070. * @param element Defines the element the controls should be listened from
  123071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123072. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  123073. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  123074. */
  123075. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  123076. /**
  123077. * Detach the current controls from the camera.
  123078. * The camera will stop reacting to inputs.
  123079. * @param element Defines the element to stop listening the inputs from
  123080. */
  123081. detachControl(element: HTMLElement): void;
  123082. /** @hidden */
  123083. _checkInputs(): void;
  123084. protected _checkLimits(): void;
  123085. /**
  123086. * Rebuilds angles (alpha, beta) and radius from the give position and target
  123087. */
  123088. rebuildAnglesAndRadius(): void;
  123089. /**
  123090. * Use a position to define the current camera related information like alpha, beta and radius
  123091. * @param position Defines the position to set the camera at
  123092. */
  123093. setPosition(position: Vector3): void;
  123094. /**
  123095. * Defines the target the camera should look at.
  123096. * This will automatically adapt alpha beta and radius to fit within the new target.
  123097. * @param target Defines the new target as a Vector or a mesh
  123098. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  123099. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  123100. */
  123101. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  123102. /** @hidden */
  123103. _getViewMatrix(): Matrix;
  123104. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  123105. /**
  123106. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  123107. * @param meshes Defines the mesh to zoom on
  123108. * @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)
  123109. */
  123110. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  123111. /**
  123112. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  123113. * The target will be changed but the radius
  123114. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  123115. * @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)
  123116. */
  123117. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  123118. min: Vector3;
  123119. max: Vector3;
  123120. distance: number;
  123121. }, doNotUpdateMaxZ?: boolean): void;
  123122. /**
  123123. * @override
  123124. * Override Camera.createRigCamera
  123125. */
  123126. createRigCamera(name: string, cameraIndex: number): Camera;
  123127. /**
  123128. * @hidden
  123129. * @override
  123130. * Override Camera._updateRigCameras
  123131. */
  123132. _updateRigCameras(): void;
  123133. /**
  123134. * Destroy the camera and release the current resources hold by it.
  123135. */
  123136. dispose(): void;
  123137. /**
  123138. * Gets the current object class name.
  123139. * @return the class name
  123140. */
  123141. getClassName(): string;
  123142. }
  123143. }
  123144. declare module BABYLON {
  123145. /**
  123146. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  123147. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123148. */
  123149. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  123150. /**
  123151. * Gets the name of the behavior.
  123152. */
  123153. get name(): string;
  123154. private _zoomStopsAnimation;
  123155. private _idleRotationSpeed;
  123156. private _idleRotationWaitTime;
  123157. private _idleRotationSpinupTime;
  123158. /**
  123159. * Sets the flag that indicates if user zooming should stop animation.
  123160. */
  123161. set zoomStopsAnimation(flag: boolean);
  123162. /**
  123163. * Gets the flag that indicates if user zooming should stop animation.
  123164. */
  123165. get zoomStopsAnimation(): boolean;
  123166. /**
  123167. * Sets the default speed at which the camera rotates around the model.
  123168. */
  123169. set idleRotationSpeed(speed: number);
  123170. /**
  123171. * Gets the default speed at which the camera rotates around the model.
  123172. */
  123173. get idleRotationSpeed(): number;
  123174. /**
  123175. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  123176. */
  123177. set idleRotationWaitTime(time: number);
  123178. /**
  123179. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  123180. */
  123181. get idleRotationWaitTime(): number;
  123182. /**
  123183. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123184. */
  123185. set idleRotationSpinupTime(time: number);
  123186. /**
  123187. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123188. */
  123189. get idleRotationSpinupTime(): number;
  123190. /**
  123191. * Gets a value indicating if the camera is currently rotating because of this behavior
  123192. */
  123193. get rotationInProgress(): boolean;
  123194. private _onPrePointerObservableObserver;
  123195. private _onAfterCheckInputsObserver;
  123196. private _attachedCamera;
  123197. private _isPointerDown;
  123198. private _lastFrameTime;
  123199. private _lastInteractionTime;
  123200. private _cameraRotationSpeed;
  123201. /**
  123202. * Initializes the behavior.
  123203. */
  123204. init(): void;
  123205. /**
  123206. * Attaches the behavior to its arc rotate camera.
  123207. * @param camera Defines the camera to attach the behavior to
  123208. */
  123209. attach(camera: ArcRotateCamera): void;
  123210. /**
  123211. * Detaches the behavior from its current arc rotate camera.
  123212. */
  123213. detach(): void;
  123214. /**
  123215. * Returns true if user is scrolling.
  123216. * @return true if user is scrolling.
  123217. */
  123218. private _userIsZooming;
  123219. private _lastFrameRadius;
  123220. private _shouldAnimationStopForInteraction;
  123221. /**
  123222. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  123223. */
  123224. private _applyUserInteraction;
  123225. private _userIsMoving;
  123226. }
  123227. }
  123228. declare module BABYLON {
  123229. /**
  123230. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  123231. */
  123232. export class AttachToBoxBehavior implements Behavior<Mesh> {
  123233. private ui;
  123234. /**
  123235. * The name of the behavior
  123236. */
  123237. name: string;
  123238. /**
  123239. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  123240. */
  123241. distanceAwayFromFace: number;
  123242. /**
  123243. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  123244. */
  123245. distanceAwayFromBottomOfFace: number;
  123246. private _faceVectors;
  123247. private _target;
  123248. private _scene;
  123249. private _onRenderObserver;
  123250. private _tmpMatrix;
  123251. private _tmpVector;
  123252. /**
  123253. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  123254. * @param ui The transform node that should be attched to the mesh
  123255. */
  123256. constructor(ui: TransformNode);
  123257. /**
  123258. * Initializes the behavior
  123259. */
  123260. init(): void;
  123261. private _closestFace;
  123262. private _zeroVector;
  123263. private _lookAtTmpMatrix;
  123264. private _lookAtToRef;
  123265. /**
  123266. * Attaches the AttachToBoxBehavior to the passed in mesh
  123267. * @param target The mesh that the specified node will be attached to
  123268. */
  123269. attach(target: Mesh): void;
  123270. /**
  123271. * Detaches the behavior from the mesh
  123272. */
  123273. detach(): void;
  123274. }
  123275. }
  123276. declare module BABYLON {
  123277. /**
  123278. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  123279. */
  123280. export class FadeInOutBehavior implements Behavior<Mesh> {
  123281. /**
  123282. * Time in milliseconds to delay before fading in (Default: 0)
  123283. */
  123284. delay: number;
  123285. /**
  123286. * Time in milliseconds for the mesh to fade in (Default: 300)
  123287. */
  123288. fadeInTime: number;
  123289. private _millisecondsPerFrame;
  123290. private _hovered;
  123291. private _hoverValue;
  123292. private _ownerNode;
  123293. /**
  123294. * Instatiates the FadeInOutBehavior
  123295. */
  123296. constructor();
  123297. /**
  123298. * The name of the behavior
  123299. */
  123300. get name(): string;
  123301. /**
  123302. * Initializes the behavior
  123303. */
  123304. init(): void;
  123305. /**
  123306. * Attaches the fade behavior on the passed in mesh
  123307. * @param ownerNode The mesh that will be faded in/out once attached
  123308. */
  123309. attach(ownerNode: Mesh): void;
  123310. /**
  123311. * Detaches the behavior from the mesh
  123312. */
  123313. detach(): void;
  123314. /**
  123315. * Triggers the mesh to begin fading in or out
  123316. * @param value if the object should fade in or out (true to fade in)
  123317. */
  123318. fadeIn(value: boolean): void;
  123319. private _update;
  123320. private _setAllVisibility;
  123321. }
  123322. }
  123323. declare module BABYLON {
  123324. /**
  123325. * Class containing a set of static utilities functions for managing Pivots
  123326. * @hidden
  123327. */
  123328. export class PivotTools {
  123329. private static _PivotCached;
  123330. private static _OldPivotPoint;
  123331. private static _PivotTranslation;
  123332. private static _PivotTmpVector;
  123333. private static _PivotPostMultiplyPivotMatrix;
  123334. /** @hidden */
  123335. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  123336. /** @hidden */
  123337. static _RestorePivotPoint(mesh: AbstractMesh): void;
  123338. }
  123339. }
  123340. declare module BABYLON {
  123341. /**
  123342. * Class containing static functions to help procedurally build meshes
  123343. */
  123344. export class PlaneBuilder {
  123345. /**
  123346. * Creates a plane mesh
  123347. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123348. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123349. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123353. * @param name defines the name of the mesh
  123354. * @param options defines the options used to create the mesh
  123355. * @param scene defines the hosting scene
  123356. * @returns the plane mesh
  123357. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123358. */
  123359. static CreatePlane(name: string, options: {
  123360. size?: number;
  123361. width?: number;
  123362. height?: number;
  123363. sideOrientation?: number;
  123364. frontUVs?: Vector4;
  123365. backUVs?: Vector4;
  123366. updatable?: boolean;
  123367. sourcePlane?: Plane;
  123368. }, scene?: Nullable<Scene>): Mesh;
  123369. }
  123370. }
  123371. declare module BABYLON {
  123372. /**
  123373. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  123374. */
  123375. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  123376. private static _AnyMouseID;
  123377. /**
  123378. * Abstract mesh the behavior is set on
  123379. */
  123380. attachedNode: AbstractMesh;
  123381. private _dragPlane;
  123382. private _scene;
  123383. private _pointerObserver;
  123384. private _beforeRenderObserver;
  123385. private static _planeScene;
  123386. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  123387. /**
  123388. * 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)
  123389. */
  123390. maxDragAngle: number;
  123391. /**
  123392. * @hidden
  123393. */
  123394. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  123395. /**
  123396. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123397. */
  123398. currentDraggingPointerID: number;
  123399. /**
  123400. * The last position where the pointer hit the drag plane in world space
  123401. */
  123402. lastDragPosition: Vector3;
  123403. /**
  123404. * If the behavior is currently in a dragging state
  123405. */
  123406. dragging: boolean;
  123407. /**
  123408. * 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)
  123409. */
  123410. dragDeltaRatio: number;
  123411. /**
  123412. * If the drag plane orientation should be updated during the dragging (Default: true)
  123413. */
  123414. updateDragPlane: boolean;
  123415. private _debugMode;
  123416. private _moving;
  123417. /**
  123418. * Fires each time the attached mesh is dragged with the pointer
  123419. * * delta between last drag position and current drag position in world space
  123420. * * dragDistance along the drag axis
  123421. * * dragPlaneNormal normal of the current drag plane used during the drag
  123422. * * dragPlanePoint in world space where the drag intersects the drag plane
  123423. */
  123424. onDragObservable: Observable<{
  123425. delta: Vector3;
  123426. dragPlanePoint: Vector3;
  123427. dragPlaneNormal: Vector3;
  123428. dragDistance: number;
  123429. pointerId: number;
  123430. }>;
  123431. /**
  123432. * Fires each time a drag begins (eg. mouse down on mesh)
  123433. */
  123434. onDragStartObservable: Observable<{
  123435. dragPlanePoint: Vector3;
  123436. pointerId: number;
  123437. }>;
  123438. /**
  123439. * Fires each time a drag ends (eg. mouse release after drag)
  123440. */
  123441. onDragEndObservable: Observable<{
  123442. dragPlanePoint: Vector3;
  123443. pointerId: number;
  123444. }>;
  123445. /**
  123446. * If the attached mesh should be moved when dragged
  123447. */
  123448. moveAttached: boolean;
  123449. /**
  123450. * If the drag behavior will react to drag events (Default: true)
  123451. */
  123452. enabled: boolean;
  123453. /**
  123454. * If pointer events should start and release the drag (Default: true)
  123455. */
  123456. startAndReleaseDragOnPointerEvents: boolean;
  123457. /**
  123458. * If camera controls should be detached during the drag
  123459. */
  123460. detachCameraControls: boolean;
  123461. /**
  123462. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  123463. */
  123464. useObjectOrientationForDragging: boolean;
  123465. private _options;
  123466. /**
  123467. * Gets the options used by the behavior
  123468. */
  123469. get options(): {
  123470. dragAxis?: Vector3;
  123471. dragPlaneNormal?: Vector3;
  123472. };
  123473. /**
  123474. * Sets the options used by the behavior
  123475. */
  123476. set options(options: {
  123477. dragAxis?: Vector3;
  123478. dragPlaneNormal?: Vector3;
  123479. });
  123480. /**
  123481. * Creates a pointer drag behavior that can be attached to a mesh
  123482. * @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)
  123483. */
  123484. constructor(options?: {
  123485. dragAxis?: Vector3;
  123486. dragPlaneNormal?: Vector3;
  123487. });
  123488. /**
  123489. * Predicate to determine if it is valid to move the object to a new position when it is moved
  123490. */
  123491. validateDrag: (targetPosition: Vector3) => boolean;
  123492. /**
  123493. * The name of the behavior
  123494. */
  123495. get name(): string;
  123496. /**
  123497. * Initializes the behavior
  123498. */
  123499. init(): void;
  123500. private _tmpVector;
  123501. private _alternatePickedPoint;
  123502. private _worldDragAxis;
  123503. private _targetPosition;
  123504. private _attachedElement;
  123505. /**
  123506. * Attaches the drag behavior the passed in mesh
  123507. * @param ownerNode The mesh that will be dragged around once attached
  123508. * @param predicate Predicate to use for pick filtering
  123509. */
  123510. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  123511. /**
  123512. * Force relase the drag action by code.
  123513. */
  123514. releaseDrag(): void;
  123515. private _startDragRay;
  123516. private _lastPointerRay;
  123517. /**
  123518. * Simulates the start of a pointer drag event on the behavior
  123519. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  123520. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  123521. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  123522. */
  123523. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  123524. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  123525. private _dragDelta;
  123526. protected _moveDrag(ray: Ray): void;
  123527. private _pickWithRayOnDragPlane;
  123528. private _pointA;
  123529. private _pointC;
  123530. private _localAxis;
  123531. private _lookAt;
  123532. private _updateDragPlanePosition;
  123533. /**
  123534. * Detaches the behavior from the mesh
  123535. */
  123536. detach(): void;
  123537. }
  123538. }
  123539. declare module BABYLON {
  123540. /**
  123541. * A behavior that when attached to a mesh will allow the mesh to be scaled
  123542. */
  123543. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  123544. private _dragBehaviorA;
  123545. private _dragBehaviorB;
  123546. private _startDistance;
  123547. private _initialScale;
  123548. private _targetScale;
  123549. private _ownerNode;
  123550. private _sceneRenderObserver;
  123551. /**
  123552. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  123553. */
  123554. constructor();
  123555. /**
  123556. * The name of the behavior
  123557. */
  123558. get name(): string;
  123559. /**
  123560. * Initializes the behavior
  123561. */
  123562. init(): void;
  123563. private _getCurrentDistance;
  123564. /**
  123565. * Attaches the scale behavior the passed in mesh
  123566. * @param ownerNode The mesh that will be scaled around once attached
  123567. */
  123568. attach(ownerNode: Mesh): void;
  123569. /**
  123570. * Detaches the behavior from the mesh
  123571. */
  123572. detach(): void;
  123573. }
  123574. }
  123575. declare module BABYLON {
  123576. /**
  123577. * 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
  123578. */
  123579. export class SixDofDragBehavior implements Behavior<Mesh> {
  123580. private static _virtualScene;
  123581. private _ownerNode;
  123582. private _sceneRenderObserver;
  123583. private _scene;
  123584. private _targetPosition;
  123585. private _virtualOriginMesh;
  123586. private _virtualDragMesh;
  123587. private _pointerObserver;
  123588. private _moving;
  123589. private _startingOrientation;
  123590. private _attachedElement;
  123591. /**
  123592. * 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)
  123593. */
  123594. private zDragFactor;
  123595. /**
  123596. * If the object should rotate to face the drag origin
  123597. */
  123598. rotateDraggedObject: boolean;
  123599. /**
  123600. * If the behavior is currently in a dragging state
  123601. */
  123602. dragging: boolean;
  123603. /**
  123604. * 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)
  123605. */
  123606. dragDeltaRatio: number;
  123607. /**
  123608. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123609. */
  123610. currentDraggingPointerID: number;
  123611. /**
  123612. * If camera controls should be detached during the drag
  123613. */
  123614. detachCameraControls: boolean;
  123615. /**
  123616. * Fires each time a drag starts
  123617. */
  123618. onDragStartObservable: Observable<{}>;
  123619. /**
  123620. * Fires each time a drag ends (eg. mouse release after drag)
  123621. */
  123622. onDragEndObservable: Observable<{}>;
  123623. /**
  123624. * 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
  123625. */
  123626. constructor();
  123627. /**
  123628. * The name of the behavior
  123629. */
  123630. get name(): string;
  123631. /**
  123632. * Initializes the behavior
  123633. */
  123634. init(): void;
  123635. /**
  123636. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  123637. */
  123638. private get _pointerCamera();
  123639. /**
  123640. * Attaches the scale behavior the passed in mesh
  123641. * @param ownerNode The mesh that will be scaled around once attached
  123642. */
  123643. attach(ownerNode: Mesh): void;
  123644. /**
  123645. * Detaches the behavior from the mesh
  123646. */
  123647. detach(): void;
  123648. }
  123649. }
  123650. declare module BABYLON {
  123651. /**
  123652. * Class used to apply inverse kinematics to bones
  123653. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  123654. */
  123655. export class BoneIKController {
  123656. private static _tmpVecs;
  123657. private static _tmpQuat;
  123658. private static _tmpMats;
  123659. /**
  123660. * Gets or sets the target mesh
  123661. */
  123662. targetMesh: AbstractMesh;
  123663. /** Gets or sets the mesh used as pole */
  123664. poleTargetMesh: AbstractMesh;
  123665. /**
  123666. * Gets or sets the bone used as pole
  123667. */
  123668. poleTargetBone: Nullable<Bone>;
  123669. /**
  123670. * Gets or sets the target position
  123671. */
  123672. targetPosition: Vector3;
  123673. /**
  123674. * Gets or sets the pole target position
  123675. */
  123676. poleTargetPosition: Vector3;
  123677. /**
  123678. * Gets or sets the pole target local offset
  123679. */
  123680. poleTargetLocalOffset: Vector3;
  123681. /**
  123682. * Gets or sets the pole angle
  123683. */
  123684. poleAngle: number;
  123685. /**
  123686. * Gets or sets the mesh associated with the controller
  123687. */
  123688. mesh: AbstractMesh;
  123689. /**
  123690. * 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)
  123691. */
  123692. slerpAmount: number;
  123693. private _bone1Quat;
  123694. private _bone1Mat;
  123695. private _bone2Ang;
  123696. private _bone1;
  123697. private _bone2;
  123698. private _bone1Length;
  123699. private _bone2Length;
  123700. private _maxAngle;
  123701. private _maxReach;
  123702. private _rightHandedSystem;
  123703. private _bendAxis;
  123704. private _slerping;
  123705. private _adjustRoll;
  123706. /**
  123707. * Gets or sets maximum allowed angle
  123708. */
  123709. get maxAngle(): number;
  123710. set maxAngle(value: number);
  123711. /**
  123712. * Creates a new BoneIKController
  123713. * @param mesh defines the mesh to control
  123714. * @param bone defines the bone to control
  123715. * @param options defines options to set up the controller
  123716. */
  123717. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  123718. targetMesh?: AbstractMesh;
  123719. poleTargetMesh?: AbstractMesh;
  123720. poleTargetBone?: Bone;
  123721. poleTargetLocalOffset?: Vector3;
  123722. poleAngle?: number;
  123723. bendAxis?: Vector3;
  123724. maxAngle?: number;
  123725. slerpAmount?: number;
  123726. });
  123727. private _setMaxAngle;
  123728. /**
  123729. * Force the controller to update the bones
  123730. */
  123731. update(): void;
  123732. }
  123733. }
  123734. declare module BABYLON {
  123735. /**
  123736. * Class used to make a bone look toward a point in space
  123737. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  123738. */
  123739. export class BoneLookController {
  123740. private static _tmpVecs;
  123741. private static _tmpQuat;
  123742. private static _tmpMats;
  123743. /**
  123744. * The target Vector3 that the bone will look at
  123745. */
  123746. target: Vector3;
  123747. /**
  123748. * The mesh that the bone is attached to
  123749. */
  123750. mesh: AbstractMesh;
  123751. /**
  123752. * The bone that will be looking to the target
  123753. */
  123754. bone: Bone;
  123755. /**
  123756. * The up axis of the coordinate system that is used when the bone is rotated
  123757. */
  123758. upAxis: Vector3;
  123759. /**
  123760. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  123761. */
  123762. upAxisSpace: Space;
  123763. /**
  123764. * Used to make an adjustment to the yaw of the bone
  123765. */
  123766. adjustYaw: number;
  123767. /**
  123768. * Used to make an adjustment to the pitch of the bone
  123769. */
  123770. adjustPitch: number;
  123771. /**
  123772. * Used to make an adjustment to the roll of the bone
  123773. */
  123774. adjustRoll: number;
  123775. /**
  123776. * 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)
  123777. */
  123778. slerpAmount: number;
  123779. private _minYaw;
  123780. private _maxYaw;
  123781. private _minPitch;
  123782. private _maxPitch;
  123783. private _minYawSin;
  123784. private _minYawCos;
  123785. private _maxYawSin;
  123786. private _maxYawCos;
  123787. private _midYawConstraint;
  123788. private _minPitchTan;
  123789. private _maxPitchTan;
  123790. private _boneQuat;
  123791. private _slerping;
  123792. private _transformYawPitch;
  123793. private _transformYawPitchInv;
  123794. private _firstFrameSkipped;
  123795. private _yawRange;
  123796. private _fowardAxis;
  123797. /**
  123798. * Gets or sets the minimum yaw angle that the bone can look to
  123799. */
  123800. get minYaw(): number;
  123801. set minYaw(value: number);
  123802. /**
  123803. * Gets or sets the maximum yaw angle that the bone can look to
  123804. */
  123805. get maxYaw(): number;
  123806. set maxYaw(value: number);
  123807. /**
  123808. * Gets or sets the minimum pitch angle that the bone can look to
  123809. */
  123810. get minPitch(): number;
  123811. set minPitch(value: number);
  123812. /**
  123813. * Gets or sets the maximum pitch angle that the bone can look to
  123814. */
  123815. get maxPitch(): number;
  123816. set maxPitch(value: number);
  123817. /**
  123818. * Create a BoneLookController
  123819. * @param mesh the mesh that the bone belongs to
  123820. * @param bone the bone that will be looking to the target
  123821. * @param target the target Vector3 to look at
  123822. * @param options optional settings:
  123823. * * maxYaw: the maximum angle the bone will yaw to
  123824. * * minYaw: the minimum angle the bone will yaw to
  123825. * * maxPitch: the maximum angle the bone will pitch to
  123826. * * minPitch: the minimum angle the bone will yaw to
  123827. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  123828. * * upAxis: the up axis of the coordinate system
  123829. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  123830. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  123831. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  123832. * * adjustYaw: used to make an adjustment to the yaw of the bone
  123833. * * adjustPitch: used to make an adjustment to the pitch of the bone
  123834. * * adjustRoll: used to make an adjustment to the roll of the bone
  123835. **/
  123836. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  123837. maxYaw?: number;
  123838. minYaw?: number;
  123839. maxPitch?: number;
  123840. minPitch?: number;
  123841. slerpAmount?: number;
  123842. upAxis?: Vector3;
  123843. upAxisSpace?: Space;
  123844. yawAxis?: Vector3;
  123845. pitchAxis?: Vector3;
  123846. adjustYaw?: number;
  123847. adjustPitch?: number;
  123848. adjustRoll?: number;
  123849. });
  123850. /**
  123851. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  123852. */
  123853. update(): void;
  123854. private _getAngleDiff;
  123855. private _getAngleBetween;
  123856. private _isAngleBetween;
  123857. }
  123858. }
  123859. declare module BABYLON {
  123860. /**
  123861. * Manage the gamepad inputs to control an arc rotate camera.
  123862. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123863. */
  123864. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  123865. /**
  123866. * Defines the camera the input is attached to.
  123867. */
  123868. camera: ArcRotateCamera;
  123869. /**
  123870. * Defines the gamepad the input is gathering event from.
  123871. */
  123872. gamepad: Nullable<Gamepad>;
  123873. /**
  123874. * Defines the gamepad rotation sensiblity.
  123875. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123876. */
  123877. gamepadRotationSensibility: number;
  123878. /**
  123879. * Defines the gamepad move sensiblity.
  123880. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123881. */
  123882. gamepadMoveSensibility: number;
  123883. private _yAxisScale;
  123884. /**
  123885. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  123886. */
  123887. get invertYAxis(): boolean;
  123888. set invertYAxis(value: boolean);
  123889. private _onGamepadConnectedObserver;
  123890. private _onGamepadDisconnectedObserver;
  123891. /**
  123892. * Attach the input controls to a specific dom element to get the input from.
  123893. * @param element Defines the element the controls should be listened from
  123894. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123895. */
  123896. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123897. /**
  123898. * Detach the current controls from the specified dom element.
  123899. * @param element Defines the element to stop listening the inputs from
  123900. */
  123901. detachControl(element: Nullable<HTMLElement>): void;
  123902. /**
  123903. * Update the current camera state depending on the inputs that have been used this frame.
  123904. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123905. */
  123906. checkInputs(): void;
  123907. /**
  123908. * Gets the class name of the current intput.
  123909. * @returns the class name
  123910. */
  123911. getClassName(): string;
  123912. /**
  123913. * Get the friendly name associated with the input class.
  123914. * @returns the input friendly name
  123915. */
  123916. getSimpleName(): string;
  123917. }
  123918. }
  123919. declare module BABYLON {
  123920. interface ArcRotateCameraInputsManager {
  123921. /**
  123922. * Add orientation input support to the input manager.
  123923. * @returns the current input manager
  123924. */
  123925. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  123926. }
  123927. /**
  123928. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  123929. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123930. */
  123931. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  123932. /**
  123933. * Defines the camera the input is attached to.
  123934. */
  123935. camera: ArcRotateCamera;
  123936. /**
  123937. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  123938. */
  123939. alphaCorrection: number;
  123940. /**
  123941. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  123942. */
  123943. gammaCorrection: number;
  123944. private _alpha;
  123945. private _gamma;
  123946. private _dirty;
  123947. private _deviceOrientationHandler;
  123948. /**
  123949. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  123950. */
  123951. constructor();
  123952. /**
  123953. * Attach the input controls to a specific dom element to get the input from.
  123954. * @param element Defines the element the controls should be listened from
  123955. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123956. */
  123957. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123958. /** @hidden */
  123959. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  123960. /**
  123961. * Update the current camera state depending on the inputs that have been used this frame.
  123962. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123963. */
  123964. checkInputs(): void;
  123965. /**
  123966. * Detach the current controls from the specified dom element.
  123967. * @param element Defines the element to stop listening the inputs from
  123968. */
  123969. detachControl(element: Nullable<HTMLElement>): void;
  123970. /**
  123971. * Gets the class name of the current intput.
  123972. * @returns the class name
  123973. */
  123974. getClassName(): string;
  123975. /**
  123976. * Get the friendly name associated with the input class.
  123977. * @returns the input friendly name
  123978. */
  123979. getSimpleName(): string;
  123980. }
  123981. }
  123982. declare module BABYLON {
  123983. /**
  123984. * Listen to mouse events to control the camera.
  123985. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123986. */
  123987. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  123988. /**
  123989. * Defines the camera the input is attached to.
  123990. */
  123991. camera: FlyCamera;
  123992. /**
  123993. * Defines if touch is enabled. (Default is true.)
  123994. */
  123995. touchEnabled: boolean;
  123996. /**
  123997. * Defines the buttons associated with the input to handle camera rotation.
  123998. */
  123999. buttons: number[];
  124000. /**
  124001. * Assign buttons for Yaw control.
  124002. */
  124003. buttonsYaw: number[];
  124004. /**
  124005. * Assign buttons for Pitch control.
  124006. */
  124007. buttonsPitch: number[];
  124008. /**
  124009. * Assign buttons for Roll control.
  124010. */
  124011. buttonsRoll: number[];
  124012. /**
  124013. * Detect if any button is being pressed while mouse is moved.
  124014. * -1 = Mouse locked.
  124015. * 0 = Left button.
  124016. * 1 = Middle Button.
  124017. * 2 = Right Button.
  124018. */
  124019. activeButton: number;
  124020. /**
  124021. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  124022. * Higher values reduce its sensitivity.
  124023. */
  124024. angularSensibility: number;
  124025. private _mousemoveCallback;
  124026. private _observer;
  124027. private _rollObserver;
  124028. private previousPosition;
  124029. private noPreventDefault;
  124030. private element;
  124031. /**
  124032. * Listen to mouse events to control the camera.
  124033. * @param touchEnabled Define if touch is enabled. (Default is true.)
  124034. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124035. */
  124036. constructor(touchEnabled?: boolean);
  124037. /**
  124038. * Attach the mouse control to the HTML DOM element.
  124039. * @param element Defines the element that listens to the input events.
  124040. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  124041. */
  124042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124043. /**
  124044. * Detach the current controls from the specified dom element.
  124045. * @param element Defines the element to stop listening the inputs from
  124046. */
  124047. detachControl(element: Nullable<HTMLElement>): void;
  124048. /**
  124049. * Gets the class name of the current input.
  124050. * @returns the class name.
  124051. */
  124052. getClassName(): string;
  124053. /**
  124054. * Get the friendly name associated with the input class.
  124055. * @returns the input's friendly name.
  124056. */
  124057. getSimpleName(): string;
  124058. private _pointerInput;
  124059. private _onMouseMove;
  124060. /**
  124061. * Rotate camera by mouse offset.
  124062. */
  124063. private rotateCamera;
  124064. }
  124065. }
  124066. declare module BABYLON {
  124067. /**
  124068. * Default Inputs manager for the FlyCamera.
  124069. * It groups all the default supported inputs for ease of use.
  124070. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124071. */
  124072. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  124073. /**
  124074. * Instantiates a new FlyCameraInputsManager.
  124075. * @param camera Defines the camera the inputs belong to.
  124076. */
  124077. constructor(camera: FlyCamera);
  124078. /**
  124079. * Add keyboard input support to the input manager.
  124080. * @returns the new FlyCameraKeyboardMoveInput().
  124081. */
  124082. addKeyboard(): FlyCameraInputsManager;
  124083. /**
  124084. * Add mouse input support to the input manager.
  124085. * @param touchEnabled Enable touch screen support.
  124086. * @returns the new FlyCameraMouseInput().
  124087. */
  124088. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  124089. }
  124090. }
  124091. declare module BABYLON {
  124092. /**
  124093. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124094. * such as in a 3D Space Shooter or a Flight Simulator.
  124095. */
  124096. export class FlyCamera extends TargetCamera {
  124097. /**
  124098. * Define the collision ellipsoid of the camera.
  124099. * This is helpful for simulating a camera body, like a player's body.
  124100. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  124101. */
  124102. ellipsoid: Vector3;
  124103. /**
  124104. * Define an offset for the position of the ellipsoid around the camera.
  124105. * This can be helpful if the camera is attached away from the player's body center,
  124106. * such as at its head.
  124107. */
  124108. ellipsoidOffset: Vector3;
  124109. /**
  124110. * Enable or disable collisions of the camera with the rest of the scene objects.
  124111. */
  124112. checkCollisions: boolean;
  124113. /**
  124114. * Enable or disable gravity on the camera.
  124115. */
  124116. applyGravity: boolean;
  124117. /**
  124118. * Define the current direction the camera is moving to.
  124119. */
  124120. cameraDirection: Vector3;
  124121. /**
  124122. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  124123. * This overrides and empties cameraRotation.
  124124. */
  124125. rotationQuaternion: Quaternion;
  124126. /**
  124127. * Track Roll to maintain the wanted Rolling when looking around.
  124128. */
  124129. _trackRoll: number;
  124130. /**
  124131. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  124132. */
  124133. rollCorrect: number;
  124134. /**
  124135. * Mimic a banked turn, Rolling the camera when Yawing.
  124136. * It's recommended to use rollCorrect = 10 for faster banking correction.
  124137. */
  124138. bankedTurn: boolean;
  124139. /**
  124140. * Limit in radians for how much Roll banking will add. (Default: 90°)
  124141. */
  124142. bankedTurnLimit: number;
  124143. /**
  124144. * Value of 0 disables the banked Roll.
  124145. * Value of 1 is equal to the Yaw angle in radians.
  124146. */
  124147. bankedTurnMultiplier: number;
  124148. /**
  124149. * The inputs manager loads all the input sources, such as keyboard and mouse.
  124150. */
  124151. inputs: FlyCameraInputsManager;
  124152. /**
  124153. * Gets the input sensibility for mouse input.
  124154. * Higher values reduce sensitivity.
  124155. */
  124156. get angularSensibility(): number;
  124157. /**
  124158. * Sets the input sensibility for a mouse input.
  124159. * Higher values reduce sensitivity.
  124160. */
  124161. set angularSensibility(value: number);
  124162. /**
  124163. * Get the keys for camera movement forward.
  124164. */
  124165. get keysForward(): number[];
  124166. /**
  124167. * Set the keys for camera movement forward.
  124168. */
  124169. set keysForward(value: number[]);
  124170. /**
  124171. * Get the keys for camera movement backward.
  124172. */
  124173. get keysBackward(): number[];
  124174. set keysBackward(value: number[]);
  124175. /**
  124176. * Get the keys for camera movement up.
  124177. */
  124178. get keysUp(): number[];
  124179. /**
  124180. * Set the keys for camera movement up.
  124181. */
  124182. set keysUp(value: number[]);
  124183. /**
  124184. * Get the keys for camera movement down.
  124185. */
  124186. get keysDown(): number[];
  124187. /**
  124188. * Set the keys for camera movement down.
  124189. */
  124190. set keysDown(value: number[]);
  124191. /**
  124192. * Get the keys for camera movement left.
  124193. */
  124194. get keysLeft(): number[];
  124195. /**
  124196. * Set the keys for camera movement left.
  124197. */
  124198. set keysLeft(value: number[]);
  124199. /**
  124200. * Set the keys for camera movement right.
  124201. */
  124202. get keysRight(): number[];
  124203. /**
  124204. * Set the keys for camera movement right.
  124205. */
  124206. set keysRight(value: number[]);
  124207. /**
  124208. * Event raised when the camera collides with a mesh in the scene.
  124209. */
  124210. onCollide: (collidedMesh: AbstractMesh) => void;
  124211. private _collider;
  124212. private _needMoveForGravity;
  124213. private _oldPosition;
  124214. private _diffPosition;
  124215. private _newPosition;
  124216. /** @hidden */
  124217. _localDirection: Vector3;
  124218. /** @hidden */
  124219. _transformedDirection: Vector3;
  124220. /**
  124221. * Instantiates a FlyCamera.
  124222. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124223. * such as in a 3D Space Shooter or a Flight Simulator.
  124224. * @param name Define the name of the camera in the scene.
  124225. * @param position Define the starting position of the camera in the scene.
  124226. * @param scene Define the scene the camera belongs to.
  124227. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  124228. */
  124229. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  124230. /**
  124231. * Attach a control to the HTML DOM element.
  124232. * @param element Defines the element that listens to the input events.
  124233. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  124234. */
  124235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124236. /**
  124237. * Detach a control from the HTML DOM element.
  124238. * The camera will stop reacting to that input.
  124239. * @param element Defines the element that listens to the input events.
  124240. */
  124241. detachControl(element: HTMLElement): void;
  124242. private _collisionMask;
  124243. /**
  124244. * Get the mask that the camera ignores in collision events.
  124245. */
  124246. get collisionMask(): number;
  124247. /**
  124248. * Set the mask that the camera ignores in collision events.
  124249. */
  124250. set collisionMask(mask: number);
  124251. /** @hidden */
  124252. _collideWithWorld(displacement: Vector3): void;
  124253. /** @hidden */
  124254. private _onCollisionPositionChange;
  124255. /** @hidden */
  124256. _checkInputs(): void;
  124257. /** @hidden */
  124258. _decideIfNeedsToMove(): boolean;
  124259. /** @hidden */
  124260. _updatePosition(): void;
  124261. /**
  124262. * Restore the Roll to its target value at the rate specified.
  124263. * @param rate - Higher means slower restoring.
  124264. * @hidden
  124265. */
  124266. restoreRoll(rate: number): void;
  124267. /**
  124268. * Destroy the camera and release the current resources held by it.
  124269. */
  124270. dispose(): void;
  124271. /**
  124272. * Get the current object class name.
  124273. * @returns the class name.
  124274. */
  124275. getClassName(): string;
  124276. }
  124277. }
  124278. declare module BABYLON {
  124279. /**
  124280. * Listen to keyboard events to control the camera.
  124281. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124282. */
  124283. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  124284. /**
  124285. * Defines the camera the input is attached to.
  124286. */
  124287. camera: FlyCamera;
  124288. /**
  124289. * The list of keyboard keys used to control the forward move of the camera.
  124290. */
  124291. keysForward: number[];
  124292. /**
  124293. * The list of keyboard keys used to control the backward move of the camera.
  124294. */
  124295. keysBackward: number[];
  124296. /**
  124297. * The list of keyboard keys used to control the forward move of the camera.
  124298. */
  124299. keysUp: number[];
  124300. /**
  124301. * The list of keyboard keys used to control the backward move of the camera.
  124302. */
  124303. keysDown: number[];
  124304. /**
  124305. * The list of keyboard keys used to control the right strafe move of the camera.
  124306. */
  124307. keysRight: number[];
  124308. /**
  124309. * The list of keyboard keys used to control the left strafe move of the camera.
  124310. */
  124311. keysLeft: number[];
  124312. private _keys;
  124313. private _onCanvasBlurObserver;
  124314. private _onKeyboardObserver;
  124315. private _engine;
  124316. private _scene;
  124317. /**
  124318. * Attach the input controls to a specific dom element to get the input from.
  124319. * @param element Defines the element the controls should be listened from
  124320. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124321. */
  124322. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124323. /**
  124324. * Detach the current controls from the specified dom element.
  124325. * @param element Defines the element to stop listening the inputs from
  124326. */
  124327. detachControl(element: Nullable<HTMLElement>): void;
  124328. /**
  124329. * Gets the class name of the current intput.
  124330. * @returns the class name
  124331. */
  124332. getClassName(): string;
  124333. /** @hidden */
  124334. _onLostFocus(e: FocusEvent): void;
  124335. /**
  124336. * Get the friendly name associated with the input class.
  124337. * @returns the input friendly name
  124338. */
  124339. getSimpleName(): string;
  124340. /**
  124341. * Update the current camera state depending on the inputs that have been used this frame.
  124342. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124343. */
  124344. checkInputs(): void;
  124345. }
  124346. }
  124347. declare module BABYLON {
  124348. /**
  124349. * Manage the mouse wheel inputs to control a follow camera.
  124350. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124351. */
  124352. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  124353. /**
  124354. * Defines the camera the input is attached to.
  124355. */
  124356. camera: FollowCamera;
  124357. /**
  124358. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  124359. */
  124360. axisControlRadius: boolean;
  124361. /**
  124362. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  124363. */
  124364. axisControlHeight: boolean;
  124365. /**
  124366. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  124367. */
  124368. axisControlRotation: boolean;
  124369. /**
  124370. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  124371. * relation to mouseWheel events.
  124372. */
  124373. wheelPrecision: number;
  124374. /**
  124375. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  124376. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  124377. */
  124378. wheelDeltaPercentage: number;
  124379. private _wheel;
  124380. private _observer;
  124381. /**
  124382. * Attach the input controls to a specific dom element to get the input from.
  124383. * @param element Defines the element the controls should be listened from
  124384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124385. */
  124386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124387. /**
  124388. * Detach the current controls from the specified dom element.
  124389. * @param element Defines the element to stop listening the inputs from
  124390. */
  124391. detachControl(element: Nullable<HTMLElement>): void;
  124392. /**
  124393. * Gets the class name of the current intput.
  124394. * @returns the class name
  124395. */
  124396. getClassName(): string;
  124397. /**
  124398. * Get the friendly name associated with the input class.
  124399. * @returns the input friendly name
  124400. */
  124401. getSimpleName(): string;
  124402. }
  124403. }
  124404. declare module BABYLON {
  124405. /**
  124406. * Manage the pointers inputs to control an follow camera.
  124407. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124408. */
  124409. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  124410. /**
  124411. * Defines the camera the input is attached to.
  124412. */
  124413. camera: FollowCamera;
  124414. /**
  124415. * Gets the class name of the current input.
  124416. * @returns the class name
  124417. */
  124418. getClassName(): string;
  124419. /**
  124420. * Defines the pointer angular sensibility along the X axis or how fast is
  124421. * the camera rotating.
  124422. * A negative number will reverse the axis direction.
  124423. */
  124424. angularSensibilityX: number;
  124425. /**
  124426. * Defines the pointer angular sensibility along the Y axis or how fast is
  124427. * the camera rotating.
  124428. * A negative number will reverse the axis direction.
  124429. */
  124430. angularSensibilityY: number;
  124431. /**
  124432. * Defines the pointer pinch precision or how fast is the camera zooming.
  124433. * A negative number will reverse the axis direction.
  124434. */
  124435. pinchPrecision: number;
  124436. /**
  124437. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  124438. * from 0.
  124439. * It defines the percentage of current camera.radius to use as delta when
  124440. * pinch zoom is used.
  124441. */
  124442. pinchDeltaPercentage: number;
  124443. /**
  124444. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  124445. */
  124446. axisXControlRadius: boolean;
  124447. /**
  124448. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  124449. */
  124450. axisXControlHeight: boolean;
  124451. /**
  124452. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  124453. */
  124454. axisXControlRotation: boolean;
  124455. /**
  124456. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  124457. */
  124458. axisYControlRadius: boolean;
  124459. /**
  124460. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  124461. */
  124462. axisYControlHeight: boolean;
  124463. /**
  124464. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  124465. */
  124466. axisYControlRotation: boolean;
  124467. /**
  124468. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  124469. */
  124470. axisPinchControlRadius: boolean;
  124471. /**
  124472. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  124473. */
  124474. axisPinchControlHeight: boolean;
  124475. /**
  124476. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  124477. */
  124478. axisPinchControlRotation: boolean;
  124479. /**
  124480. * Log error messages if basic misconfiguration has occurred.
  124481. */
  124482. warningEnable: boolean;
  124483. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  124484. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  124485. private _warningCounter;
  124486. private _warning;
  124487. }
  124488. }
  124489. declare module BABYLON {
  124490. /**
  124491. * Default Inputs manager for the FollowCamera.
  124492. * It groups all the default supported inputs for ease of use.
  124493. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124494. */
  124495. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  124496. /**
  124497. * Instantiates a new FollowCameraInputsManager.
  124498. * @param camera Defines the camera the inputs belong to
  124499. */
  124500. constructor(camera: FollowCamera);
  124501. /**
  124502. * Add keyboard input support to the input manager.
  124503. * @returns the current input manager
  124504. */
  124505. addKeyboard(): FollowCameraInputsManager;
  124506. /**
  124507. * Add mouse wheel input support to the input manager.
  124508. * @returns the current input manager
  124509. */
  124510. addMouseWheel(): FollowCameraInputsManager;
  124511. /**
  124512. * Add pointers input support to the input manager.
  124513. * @returns the current input manager
  124514. */
  124515. addPointers(): FollowCameraInputsManager;
  124516. /**
  124517. * Add orientation input support to the input manager.
  124518. * @returns the current input manager
  124519. */
  124520. addVRDeviceOrientation(): FollowCameraInputsManager;
  124521. }
  124522. }
  124523. declare module BABYLON {
  124524. /**
  124525. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  124526. * an arc rotate version arcFollowCamera are available.
  124527. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124528. */
  124529. export class FollowCamera extends TargetCamera {
  124530. /**
  124531. * Distance the follow camera should follow an object at
  124532. */
  124533. radius: number;
  124534. /**
  124535. * Minimum allowed distance of the camera to the axis of rotation
  124536. * (The camera can not get closer).
  124537. * This can help limiting how the Camera is able to move in the scene.
  124538. */
  124539. lowerRadiusLimit: Nullable<number>;
  124540. /**
  124541. * Maximum allowed distance of the camera to the axis of rotation
  124542. * (The camera can not get further).
  124543. * This can help limiting how the Camera is able to move in the scene.
  124544. */
  124545. upperRadiusLimit: Nullable<number>;
  124546. /**
  124547. * Define a rotation offset between the camera and the object it follows
  124548. */
  124549. rotationOffset: number;
  124550. /**
  124551. * Minimum allowed angle to camera position relative to target object.
  124552. * This can help limiting how the Camera is able to move in the scene.
  124553. */
  124554. lowerRotationOffsetLimit: Nullable<number>;
  124555. /**
  124556. * Maximum allowed angle to camera position relative to target object.
  124557. * This can help limiting how the Camera is able to move in the scene.
  124558. */
  124559. upperRotationOffsetLimit: Nullable<number>;
  124560. /**
  124561. * Define a height offset between the camera and the object it follows.
  124562. * It can help following an object from the top (like a car chaing a plane)
  124563. */
  124564. heightOffset: number;
  124565. /**
  124566. * Minimum allowed height of camera position relative to target object.
  124567. * This can help limiting how the Camera is able to move in the scene.
  124568. */
  124569. lowerHeightOffsetLimit: Nullable<number>;
  124570. /**
  124571. * Maximum allowed height of camera position relative to target object.
  124572. * This can help limiting how the Camera is able to move in the scene.
  124573. */
  124574. upperHeightOffsetLimit: Nullable<number>;
  124575. /**
  124576. * Define how fast the camera can accelerate to follow it s target.
  124577. */
  124578. cameraAcceleration: number;
  124579. /**
  124580. * Define the speed limit of the camera following an object.
  124581. */
  124582. maxCameraSpeed: number;
  124583. /**
  124584. * Define the target of the camera.
  124585. */
  124586. lockedTarget: Nullable<AbstractMesh>;
  124587. /**
  124588. * Defines the input associated with the camera.
  124589. */
  124590. inputs: FollowCameraInputsManager;
  124591. /**
  124592. * Instantiates the follow camera.
  124593. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124594. * @param name Define the name of the camera in the scene
  124595. * @param position Define the position of the camera
  124596. * @param scene Define the scene the camera belong to
  124597. * @param lockedTarget Define the target of the camera
  124598. */
  124599. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  124600. private _follow;
  124601. /**
  124602. * Attached controls to the current camera.
  124603. * @param element Defines the element the controls should be listened from
  124604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124605. */
  124606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124607. /**
  124608. * Detach the current controls from the camera.
  124609. * The camera will stop reacting to inputs.
  124610. * @param element Defines the element to stop listening the inputs from
  124611. */
  124612. detachControl(element: HTMLElement): void;
  124613. /** @hidden */
  124614. _checkInputs(): void;
  124615. private _checkLimits;
  124616. /**
  124617. * Gets the camera class name.
  124618. * @returns the class name
  124619. */
  124620. getClassName(): string;
  124621. }
  124622. /**
  124623. * Arc Rotate version of the follow camera.
  124624. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  124625. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124626. */
  124627. export class ArcFollowCamera extends TargetCamera {
  124628. /** The longitudinal angle of the camera */
  124629. alpha: number;
  124630. /** The latitudinal angle of the camera */
  124631. beta: number;
  124632. /** The radius of the camera from its target */
  124633. radius: number;
  124634. private _cartesianCoordinates;
  124635. /** Define the camera target (the mesh it should follow) */
  124636. private _meshTarget;
  124637. /**
  124638. * Instantiates a new ArcFollowCamera
  124639. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124640. * @param name Define the name of the camera
  124641. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  124642. * @param beta Define the rotation angle of the camera around the elevation axis
  124643. * @param radius Define the radius of the camera from its target point
  124644. * @param target Define the target of the camera
  124645. * @param scene Define the scene the camera belongs to
  124646. */
  124647. constructor(name: string,
  124648. /** The longitudinal angle of the camera */
  124649. alpha: number,
  124650. /** The latitudinal angle of the camera */
  124651. beta: number,
  124652. /** The radius of the camera from its target */
  124653. radius: number,
  124654. /** Define the camera target (the mesh it should follow) */
  124655. target: Nullable<AbstractMesh>, scene: Scene);
  124656. private _follow;
  124657. /** @hidden */
  124658. _checkInputs(): void;
  124659. /**
  124660. * Returns the class name of the object.
  124661. * It is mostly used internally for serialization purposes.
  124662. */
  124663. getClassName(): string;
  124664. }
  124665. }
  124666. declare module BABYLON {
  124667. /**
  124668. * Manage the keyboard inputs to control the movement of a follow camera.
  124669. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124670. */
  124671. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  124672. /**
  124673. * Defines the camera the input is attached to.
  124674. */
  124675. camera: FollowCamera;
  124676. /**
  124677. * Defines the list of key codes associated with the up action (increase heightOffset)
  124678. */
  124679. keysHeightOffsetIncr: number[];
  124680. /**
  124681. * Defines the list of key codes associated with the down action (decrease heightOffset)
  124682. */
  124683. keysHeightOffsetDecr: number[];
  124684. /**
  124685. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  124686. */
  124687. keysHeightOffsetModifierAlt: boolean;
  124688. /**
  124689. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  124690. */
  124691. keysHeightOffsetModifierCtrl: boolean;
  124692. /**
  124693. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  124694. */
  124695. keysHeightOffsetModifierShift: boolean;
  124696. /**
  124697. * Defines the list of key codes associated with the left action (increase rotationOffset)
  124698. */
  124699. keysRotationOffsetIncr: number[];
  124700. /**
  124701. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  124702. */
  124703. keysRotationOffsetDecr: number[];
  124704. /**
  124705. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  124706. */
  124707. keysRotationOffsetModifierAlt: boolean;
  124708. /**
  124709. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  124710. */
  124711. keysRotationOffsetModifierCtrl: boolean;
  124712. /**
  124713. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  124714. */
  124715. keysRotationOffsetModifierShift: boolean;
  124716. /**
  124717. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  124718. */
  124719. keysRadiusIncr: number[];
  124720. /**
  124721. * Defines the list of key codes associated with the zoom-out action (increase radius)
  124722. */
  124723. keysRadiusDecr: number[];
  124724. /**
  124725. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  124726. */
  124727. keysRadiusModifierAlt: boolean;
  124728. /**
  124729. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  124730. */
  124731. keysRadiusModifierCtrl: boolean;
  124732. /**
  124733. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  124734. */
  124735. keysRadiusModifierShift: boolean;
  124736. /**
  124737. * Defines the rate of change of heightOffset.
  124738. */
  124739. heightSensibility: number;
  124740. /**
  124741. * Defines the rate of change of rotationOffset.
  124742. */
  124743. rotationSensibility: number;
  124744. /**
  124745. * Defines the rate of change of radius.
  124746. */
  124747. radiusSensibility: number;
  124748. private _keys;
  124749. private _ctrlPressed;
  124750. private _altPressed;
  124751. private _shiftPressed;
  124752. private _onCanvasBlurObserver;
  124753. private _onKeyboardObserver;
  124754. private _engine;
  124755. private _scene;
  124756. /**
  124757. * Attach the input controls to a specific dom element to get the input from.
  124758. * @param element Defines the element the controls should be listened from
  124759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124760. */
  124761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124762. /**
  124763. * Detach the current controls from the specified dom element.
  124764. * @param element Defines the element to stop listening the inputs from
  124765. */
  124766. detachControl(element: Nullable<HTMLElement>): void;
  124767. /**
  124768. * Update the current camera state depending on the inputs that have been used this frame.
  124769. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124770. */
  124771. checkInputs(): void;
  124772. /**
  124773. * Gets the class name of the current input.
  124774. * @returns the class name
  124775. */
  124776. getClassName(): string;
  124777. /**
  124778. * Get the friendly name associated with the input class.
  124779. * @returns the input friendly name
  124780. */
  124781. getSimpleName(): string;
  124782. /**
  124783. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124784. * allow modification of the heightOffset value.
  124785. */
  124786. private _modifierHeightOffset;
  124787. /**
  124788. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124789. * allow modification of the rotationOffset value.
  124790. */
  124791. private _modifierRotationOffset;
  124792. /**
  124793. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124794. * allow modification of the radius value.
  124795. */
  124796. private _modifierRadius;
  124797. }
  124798. }
  124799. declare module BABYLON {
  124800. interface FreeCameraInputsManager {
  124801. /**
  124802. * @hidden
  124803. */
  124804. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  124805. /**
  124806. * Add orientation input support to the input manager.
  124807. * @returns the current input manager
  124808. */
  124809. addDeviceOrientation(): FreeCameraInputsManager;
  124810. }
  124811. /**
  124812. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  124813. * Screen rotation is taken into account.
  124814. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124815. */
  124816. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  124817. private _camera;
  124818. private _screenOrientationAngle;
  124819. private _constantTranform;
  124820. private _screenQuaternion;
  124821. private _alpha;
  124822. private _beta;
  124823. private _gamma;
  124824. /**
  124825. * Can be used to detect if a device orientation sensor is available on a device
  124826. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  124827. * @returns a promise that will resolve on orientation change
  124828. */
  124829. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  124830. /**
  124831. * @hidden
  124832. */
  124833. _onDeviceOrientationChangedObservable: Observable<void>;
  124834. /**
  124835. * Instantiates a new input
  124836. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124837. */
  124838. constructor();
  124839. /**
  124840. * Define the camera controlled by the input.
  124841. */
  124842. get camera(): FreeCamera;
  124843. set camera(camera: FreeCamera);
  124844. /**
  124845. * Attach the input controls to a specific dom element to get the input from.
  124846. * @param element Defines the element the controls should be listened from
  124847. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124848. */
  124849. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124850. private _orientationChanged;
  124851. private _deviceOrientation;
  124852. /**
  124853. * Detach the current controls from the specified dom element.
  124854. * @param element Defines the element to stop listening the inputs from
  124855. */
  124856. detachControl(element: Nullable<HTMLElement>): void;
  124857. /**
  124858. * Update the current camera state depending on the inputs that have been used this frame.
  124859. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124860. */
  124861. checkInputs(): void;
  124862. /**
  124863. * Gets the class name of the current intput.
  124864. * @returns the class name
  124865. */
  124866. getClassName(): string;
  124867. /**
  124868. * Get the friendly name associated with the input class.
  124869. * @returns the input friendly name
  124870. */
  124871. getSimpleName(): string;
  124872. }
  124873. }
  124874. declare module BABYLON {
  124875. /**
  124876. * Manage the gamepad inputs to control a free camera.
  124877. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124878. */
  124879. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  124880. /**
  124881. * Define the camera the input is attached to.
  124882. */
  124883. camera: FreeCamera;
  124884. /**
  124885. * Define the Gamepad controlling the input
  124886. */
  124887. gamepad: Nullable<Gamepad>;
  124888. /**
  124889. * Defines the gamepad rotation sensiblity.
  124890. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124891. */
  124892. gamepadAngularSensibility: number;
  124893. /**
  124894. * Defines the gamepad move sensiblity.
  124895. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124896. */
  124897. gamepadMoveSensibility: number;
  124898. private _yAxisScale;
  124899. /**
  124900. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124901. */
  124902. get invertYAxis(): boolean;
  124903. set invertYAxis(value: boolean);
  124904. private _onGamepadConnectedObserver;
  124905. private _onGamepadDisconnectedObserver;
  124906. private _cameraTransform;
  124907. private _deltaTransform;
  124908. private _vector3;
  124909. private _vector2;
  124910. /**
  124911. * Attach the input controls to a specific dom element to get the input from.
  124912. * @param element Defines the element the controls should be listened from
  124913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124914. */
  124915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124916. /**
  124917. * Detach the current controls from the specified dom element.
  124918. * @param element Defines the element to stop listening the inputs from
  124919. */
  124920. detachControl(element: Nullable<HTMLElement>): void;
  124921. /**
  124922. * Update the current camera state depending on the inputs that have been used this frame.
  124923. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124924. */
  124925. checkInputs(): void;
  124926. /**
  124927. * Gets the class name of the current intput.
  124928. * @returns the class name
  124929. */
  124930. getClassName(): string;
  124931. /**
  124932. * Get the friendly name associated with the input class.
  124933. * @returns the input friendly name
  124934. */
  124935. getSimpleName(): string;
  124936. }
  124937. }
  124938. declare module BABYLON {
  124939. /**
  124940. * Defines the potential axis of a Joystick
  124941. */
  124942. export enum JoystickAxis {
  124943. /** X axis */
  124944. X = 0,
  124945. /** Y axis */
  124946. Y = 1,
  124947. /** Z axis */
  124948. Z = 2
  124949. }
  124950. /**
  124951. * Represents the different customization options available
  124952. * for VirtualJoystick
  124953. */
  124954. interface VirtualJoystickCustomizations {
  124955. /**
  124956. * Size of the joystick's puck
  124957. */
  124958. puckSize: number;
  124959. /**
  124960. * Size of the joystick's container
  124961. */
  124962. containerSize: number;
  124963. /**
  124964. * Color of the joystick && puck
  124965. */
  124966. color: string;
  124967. /**
  124968. * Image URL for the joystick's puck
  124969. */
  124970. puckImage?: string;
  124971. /**
  124972. * Image URL for the joystick's container
  124973. */
  124974. containerImage?: string;
  124975. /**
  124976. * Defines the unmoving position of the joystick container
  124977. */
  124978. position?: {
  124979. x: number;
  124980. y: number;
  124981. };
  124982. /**
  124983. * Defines whether or not the joystick container is always visible
  124984. */
  124985. alwaysVisible: boolean;
  124986. /**
  124987. * Defines whether or not to limit the movement of the puck to the joystick's container
  124988. */
  124989. limitToContainer: boolean;
  124990. }
  124991. /**
  124992. * Class used to define virtual joystick (used in touch mode)
  124993. */
  124994. export class VirtualJoystick {
  124995. /**
  124996. * Gets or sets a boolean indicating that left and right values must be inverted
  124997. */
  124998. reverseLeftRight: boolean;
  124999. /**
  125000. * Gets or sets a boolean indicating that up and down values must be inverted
  125001. */
  125002. reverseUpDown: boolean;
  125003. /**
  125004. * Gets the offset value for the position (ie. the change of the position value)
  125005. */
  125006. deltaPosition: Vector3;
  125007. /**
  125008. * Gets a boolean indicating if the virtual joystick was pressed
  125009. */
  125010. pressed: boolean;
  125011. /**
  125012. * Canvas the virtual joystick will render onto, default z-index of this is 5
  125013. */
  125014. static Canvas: Nullable<HTMLCanvasElement>;
  125015. /**
  125016. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  125017. */
  125018. limitToContainer: boolean;
  125019. private static _globalJoystickIndex;
  125020. private static _alwaysVisibleSticks;
  125021. private static vjCanvasContext;
  125022. private static vjCanvasWidth;
  125023. private static vjCanvasHeight;
  125024. private static halfWidth;
  125025. private static _GetDefaultOptions;
  125026. private _action;
  125027. private _axisTargetedByLeftAndRight;
  125028. private _axisTargetedByUpAndDown;
  125029. private _joystickSensibility;
  125030. private _inversedSensibility;
  125031. private _joystickPointerID;
  125032. private _joystickColor;
  125033. private _joystickPointerPos;
  125034. private _joystickPreviousPointerPos;
  125035. private _joystickPointerStartPos;
  125036. private _deltaJoystickVector;
  125037. private _leftJoystick;
  125038. private _touches;
  125039. private _joystickPosition;
  125040. private _alwaysVisible;
  125041. private _puckImage;
  125042. private _containerImage;
  125043. private _joystickPuckSize;
  125044. private _joystickContainerSize;
  125045. private _clearPuckSize;
  125046. private _clearContainerSize;
  125047. private _clearPuckSizeOffset;
  125048. private _clearContainerSizeOffset;
  125049. private _onPointerDownHandlerRef;
  125050. private _onPointerMoveHandlerRef;
  125051. private _onPointerUpHandlerRef;
  125052. private _onResize;
  125053. /**
  125054. * Creates a new virtual joystick
  125055. * @param leftJoystick defines that the joystick is for left hand (false by default)
  125056. * @param customizations Defines the options we want to customize the VirtualJoystick
  125057. */
  125058. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  125059. /**
  125060. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  125061. * @param newJoystickSensibility defines the new sensibility
  125062. */
  125063. setJoystickSensibility(newJoystickSensibility: number): void;
  125064. private _onPointerDown;
  125065. private _onPointerMove;
  125066. private _onPointerUp;
  125067. /**
  125068. * Change the color of the virtual joystick
  125069. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  125070. */
  125071. setJoystickColor(newColor: string): void;
  125072. /**
  125073. * Size of the joystick's container
  125074. */
  125075. set containerSize(newSize: number);
  125076. get containerSize(): number;
  125077. /**
  125078. * Size of the joystick's puck
  125079. */
  125080. set puckSize(newSize: number);
  125081. get puckSize(): number;
  125082. /**
  125083. * Clears the set position of the joystick
  125084. */
  125085. clearPosition(): void;
  125086. /**
  125087. * Defines whether or not the joystick container is always visible
  125088. */
  125089. set alwaysVisible(value: boolean);
  125090. get alwaysVisible(): boolean;
  125091. /**
  125092. * Sets the constant position of the Joystick container
  125093. * @param x X axis coordinate
  125094. * @param y Y axis coordinate
  125095. */
  125096. setPosition(x: number, y: number): void;
  125097. /**
  125098. * Defines a callback to call when the joystick is touched
  125099. * @param action defines the callback
  125100. */
  125101. setActionOnTouch(action: () => any): void;
  125102. /**
  125103. * Defines which axis you'd like to control for left & right
  125104. * @param axis defines the axis to use
  125105. */
  125106. setAxisForLeftRight(axis: JoystickAxis): void;
  125107. /**
  125108. * Defines which axis you'd like to control for up & down
  125109. * @param axis defines the axis to use
  125110. */
  125111. setAxisForUpDown(axis: JoystickAxis): void;
  125112. /**
  125113. * Clears the canvas from the previous puck / container draw
  125114. */
  125115. private _clearPreviousDraw;
  125116. /**
  125117. * Loads `urlPath` to be used for the container's image
  125118. * @param urlPath defines the urlPath of an image to use
  125119. */
  125120. setContainerImage(urlPath: string): void;
  125121. /**
  125122. * Loads `urlPath` to be used for the puck's image
  125123. * @param urlPath defines the urlPath of an image to use
  125124. */
  125125. setPuckImage(urlPath: string): void;
  125126. /**
  125127. * Draws the Virtual Joystick's container
  125128. */
  125129. private _drawContainer;
  125130. /**
  125131. * Draws the Virtual Joystick's puck
  125132. */
  125133. private _drawPuck;
  125134. private _drawVirtualJoystick;
  125135. /**
  125136. * Release internal HTML canvas
  125137. */
  125138. releaseCanvas(): void;
  125139. }
  125140. }
  125141. declare module BABYLON {
  125142. interface FreeCameraInputsManager {
  125143. /**
  125144. * Add virtual joystick input support to the input manager.
  125145. * @returns the current input manager
  125146. */
  125147. addVirtualJoystick(): FreeCameraInputsManager;
  125148. }
  125149. /**
  125150. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  125151. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125152. */
  125153. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  125154. /**
  125155. * Defines the camera the input is attached to.
  125156. */
  125157. camera: FreeCamera;
  125158. private _leftjoystick;
  125159. private _rightjoystick;
  125160. /**
  125161. * Gets the left stick of the virtual joystick.
  125162. * @returns The virtual Joystick
  125163. */
  125164. getLeftJoystick(): VirtualJoystick;
  125165. /**
  125166. * Gets the right stick of the virtual joystick.
  125167. * @returns The virtual Joystick
  125168. */
  125169. getRightJoystick(): VirtualJoystick;
  125170. /**
  125171. * Update the current camera state depending on the inputs that have been used this frame.
  125172. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125173. */
  125174. checkInputs(): void;
  125175. /**
  125176. * Attach the input controls to a specific dom element to get the input from.
  125177. * @param element Defines the element the controls should be listened from
  125178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125179. */
  125180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125181. /**
  125182. * Detach the current controls from the specified dom element.
  125183. * @param element Defines the element to stop listening the inputs from
  125184. */
  125185. detachControl(element: Nullable<HTMLElement>): void;
  125186. /**
  125187. * Gets the class name of the current intput.
  125188. * @returns the class name
  125189. */
  125190. getClassName(): string;
  125191. /**
  125192. * Get the friendly name associated with the input class.
  125193. * @returns the input friendly name
  125194. */
  125195. getSimpleName(): string;
  125196. }
  125197. }
  125198. declare module BABYLON {
  125199. /**
  125200. * This represents a FPS type of camera controlled by touch.
  125201. * This is like a universal camera minus the Gamepad controls.
  125202. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125203. */
  125204. export class TouchCamera extends FreeCamera {
  125205. /**
  125206. * Defines the touch sensibility for rotation.
  125207. * The higher the faster.
  125208. */
  125209. get touchAngularSensibility(): number;
  125210. set touchAngularSensibility(value: number);
  125211. /**
  125212. * Defines the touch sensibility for move.
  125213. * The higher the faster.
  125214. */
  125215. get touchMoveSensibility(): number;
  125216. set touchMoveSensibility(value: number);
  125217. /**
  125218. * Instantiates a new touch camera.
  125219. * This represents a FPS type of camera controlled by touch.
  125220. * This is like a universal camera minus the Gamepad controls.
  125221. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125222. * @param name Define the name of the camera in the scene
  125223. * @param position Define the start position of the camera in the scene
  125224. * @param scene Define the scene the camera belongs to
  125225. */
  125226. constructor(name: string, position: Vector3, scene: Scene);
  125227. /**
  125228. * Gets the current object class name.
  125229. * @return the class name
  125230. */
  125231. getClassName(): string;
  125232. /** @hidden */
  125233. _setupInputs(): void;
  125234. }
  125235. }
  125236. declare module BABYLON {
  125237. /**
  125238. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  125239. * being tilted forward or back and left or right.
  125240. */
  125241. export class DeviceOrientationCamera extends FreeCamera {
  125242. private _initialQuaternion;
  125243. private _quaternionCache;
  125244. private _tmpDragQuaternion;
  125245. private _disablePointerInputWhenUsingDeviceOrientation;
  125246. /**
  125247. * Creates a new device orientation camera
  125248. * @param name The name of the camera
  125249. * @param position The start position camera
  125250. * @param scene The scene the camera belongs to
  125251. */
  125252. constructor(name: string, position: Vector3, scene: Scene);
  125253. /**
  125254. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  125255. */
  125256. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  125257. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  125258. private _dragFactor;
  125259. /**
  125260. * Enabled turning on the y axis when the orientation sensor is active
  125261. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  125262. */
  125263. enableHorizontalDragging(dragFactor?: number): void;
  125264. /**
  125265. * Gets the current instance class name ("DeviceOrientationCamera").
  125266. * This helps avoiding instanceof at run time.
  125267. * @returns the class name
  125268. */
  125269. getClassName(): string;
  125270. /**
  125271. * @hidden
  125272. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  125273. */
  125274. _checkInputs(): void;
  125275. /**
  125276. * Reset the camera to its default orientation on the specified axis only.
  125277. * @param axis The axis to reset
  125278. */
  125279. resetToCurrentRotation(axis?: Axis): void;
  125280. }
  125281. }
  125282. declare module BABYLON {
  125283. /**
  125284. * Defines supported buttons for XBox360 compatible gamepads
  125285. */
  125286. export enum Xbox360Button {
  125287. /** A */
  125288. A = 0,
  125289. /** B */
  125290. B = 1,
  125291. /** X */
  125292. X = 2,
  125293. /** Y */
  125294. Y = 3,
  125295. /** Left button */
  125296. LB = 4,
  125297. /** Right button */
  125298. RB = 5,
  125299. /** Back */
  125300. Back = 8,
  125301. /** Start */
  125302. Start = 9,
  125303. /** Left stick */
  125304. LeftStick = 10,
  125305. /** Right stick */
  125306. RightStick = 11
  125307. }
  125308. /** Defines values for XBox360 DPad */
  125309. export enum Xbox360Dpad {
  125310. /** Up */
  125311. Up = 12,
  125312. /** Down */
  125313. Down = 13,
  125314. /** Left */
  125315. Left = 14,
  125316. /** Right */
  125317. Right = 15
  125318. }
  125319. /**
  125320. * Defines a XBox360 gamepad
  125321. */
  125322. export class Xbox360Pad extends Gamepad {
  125323. private _leftTrigger;
  125324. private _rightTrigger;
  125325. private _onlefttriggerchanged;
  125326. private _onrighttriggerchanged;
  125327. private _onbuttondown;
  125328. private _onbuttonup;
  125329. private _ondpaddown;
  125330. private _ondpadup;
  125331. /** Observable raised when a button is pressed */
  125332. onButtonDownObservable: Observable<Xbox360Button>;
  125333. /** Observable raised when a button is released */
  125334. onButtonUpObservable: Observable<Xbox360Button>;
  125335. /** Observable raised when a pad is pressed */
  125336. onPadDownObservable: Observable<Xbox360Dpad>;
  125337. /** Observable raised when a pad is released */
  125338. onPadUpObservable: Observable<Xbox360Dpad>;
  125339. private _buttonA;
  125340. private _buttonB;
  125341. private _buttonX;
  125342. private _buttonY;
  125343. private _buttonBack;
  125344. private _buttonStart;
  125345. private _buttonLB;
  125346. private _buttonRB;
  125347. private _buttonLeftStick;
  125348. private _buttonRightStick;
  125349. private _dPadUp;
  125350. private _dPadDown;
  125351. private _dPadLeft;
  125352. private _dPadRight;
  125353. private _isXboxOnePad;
  125354. /**
  125355. * Creates a new XBox360 gamepad object
  125356. * @param id defines the id of this gamepad
  125357. * @param index defines its index
  125358. * @param gamepad defines the internal HTML gamepad object
  125359. * @param xboxOne defines if it is a XBox One gamepad
  125360. */
  125361. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  125362. /**
  125363. * Defines the callback to call when left trigger is pressed
  125364. * @param callback defines the callback to use
  125365. */
  125366. onlefttriggerchanged(callback: (value: number) => void): void;
  125367. /**
  125368. * Defines the callback to call when right trigger is pressed
  125369. * @param callback defines the callback to use
  125370. */
  125371. onrighttriggerchanged(callback: (value: number) => void): void;
  125372. /**
  125373. * Gets the left trigger value
  125374. */
  125375. get leftTrigger(): number;
  125376. /**
  125377. * Sets the left trigger value
  125378. */
  125379. set leftTrigger(newValue: number);
  125380. /**
  125381. * Gets the right trigger value
  125382. */
  125383. get rightTrigger(): number;
  125384. /**
  125385. * Sets the right trigger value
  125386. */
  125387. set rightTrigger(newValue: number);
  125388. /**
  125389. * Defines the callback to call when a button is pressed
  125390. * @param callback defines the callback to use
  125391. */
  125392. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  125393. /**
  125394. * Defines the callback to call when a button is released
  125395. * @param callback defines the callback to use
  125396. */
  125397. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  125398. /**
  125399. * Defines the callback to call when a pad is pressed
  125400. * @param callback defines the callback to use
  125401. */
  125402. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  125403. /**
  125404. * Defines the callback to call when a pad is released
  125405. * @param callback defines the callback to use
  125406. */
  125407. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  125408. private _setButtonValue;
  125409. private _setDPadValue;
  125410. /**
  125411. * Gets the value of the `A` button
  125412. */
  125413. get buttonA(): number;
  125414. /**
  125415. * Sets the value of the `A` button
  125416. */
  125417. set buttonA(value: number);
  125418. /**
  125419. * Gets the value of the `B` button
  125420. */
  125421. get buttonB(): number;
  125422. /**
  125423. * Sets the value of the `B` button
  125424. */
  125425. set buttonB(value: number);
  125426. /**
  125427. * Gets the value of the `X` button
  125428. */
  125429. get buttonX(): number;
  125430. /**
  125431. * Sets the value of the `X` button
  125432. */
  125433. set buttonX(value: number);
  125434. /**
  125435. * Gets the value of the `Y` button
  125436. */
  125437. get buttonY(): number;
  125438. /**
  125439. * Sets the value of the `Y` button
  125440. */
  125441. set buttonY(value: number);
  125442. /**
  125443. * Gets the value of the `Start` button
  125444. */
  125445. get buttonStart(): number;
  125446. /**
  125447. * Sets the value of the `Start` button
  125448. */
  125449. set buttonStart(value: number);
  125450. /**
  125451. * Gets the value of the `Back` button
  125452. */
  125453. get buttonBack(): number;
  125454. /**
  125455. * Sets the value of the `Back` button
  125456. */
  125457. set buttonBack(value: number);
  125458. /**
  125459. * Gets the value of the `Left` button
  125460. */
  125461. get buttonLB(): number;
  125462. /**
  125463. * Sets the value of the `Left` button
  125464. */
  125465. set buttonLB(value: number);
  125466. /**
  125467. * Gets the value of the `Right` button
  125468. */
  125469. get buttonRB(): number;
  125470. /**
  125471. * Sets the value of the `Right` button
  125472. */
  125473. set buttonRB(value: number);
  125474. /**
  125475. * Gets the value of the Left joystick
  125476. */
  125477. get buttonLeftStick(): number;
  125478. /**
  125479. * Sets the value of the Left joystick
  125480. */
  125481. set buttonLeftStick(value: number);
  125482. /**
  125483. * Gets the value of the Right joystick
  125484. */
  125485. get buttonRightStick(): number;
  125486. /**
  125487. * Sets the value of the Right joystick
  125488. */
  125489. set buttonRightStick(value: number);
  125490. /**
  125491. * Gets the value of D-pad up
  125492. */
  125493. get dPadUp(): number;
  125494. /**
  125495. * Sets the value of D-pad up
  125496. */
  125497. set dPadUp(value: number);
  125498. /**
  125499. * Gets the value of D-pad down
  125500. */
  125501. get dPadDown(): number;
  125502. /**
  125503. * Sets the value of D-pad down
  125504. */
  125505. set dPadDown(value: number);
  125506. /**
  125507. * Gets the value of D-pad left
  125508. */
  125509. get dPadLeft(): number;
  125510. /**
  125511. * Sets the value of D-pad left
  125512. */
  125513. set dPadLeft(value: number);
  125514. /**
  125515. * Gets the value of D-pad right
  125516. */
  125517. get dPadRight(): number;
  125518. /**
  125519. * Sets the value of D-pad right
  125520. */
  125521. set dPadRight(value: number);
  125522. /**
  125523. * Force the gamepad to synchronize with device values
  125524. */
  125525. update(): void;
  125526. /**
  125527. * Disposes the gamepad
  125528. */
  125529. dispose(): void;
  125530. }
  125531. }
  125532. declare module BABYLON {
  125533. /**
  125534. * Defines supported buttons for DualShock compatible gamepads
  125535. */
  125536. export enum DualShockButton {
  125537. /** Cross */
  125538. Cross = 0,
  125539. /** Circle */
  125540. Circle = 1,
  125541. /** Square */
  125542. Square = 2,
  125543. /** Triangle */
  125544. Triangle = 3,
  125545. /** L1 */
  125546. L1 = 4,
  125547. /** R1 */
  125548. R1 = 5,
  125549. /** Share */
  125550. Share = 8,
  125551. /** Options */
  125552. Options = 9,
  125553. /** Left stick */
  125554. LeftStick = 10,
  125555. /** Right stick */
  125556. RightStick = 11
  125557. }
  125558. /** Defines values for DualShock DPad */
  125559. export enum DualShockDpad {
  125560. /** Up */
  125561. Up = 12,
  125562. /** Down */
  125563. Down = 13,
  125564. /** Left */
  125565. Left = 14,
  125566. /** Right */
  125567. Right = 15
  125568. }
  125569. /**
  125570. * Defines a DualShock gamepad
  125571. */
  125572. export class DualShockPad extends Gamepad {
  125573. private _leftTrigger;
  125574. private _rightTrigger;
  125575. private _onlefttriggerchanged;
  125576. private _onrighttriggerchanged;
  125577. private _onbuttondown;
  125578. private _onbuttonup;
  125579. private _ondpaddown;
  125580. private _ondpadup;
  125581. /** Observable raised when a button is pressed */
  125582. onButtonDownObservable: Observable<DualShockButton>;
  125583. /** Observable raised when a button is released */
  125584. onButtonUpObservable: Observable<DualShockButton>;
  125585. /** Observable raised when a pad is pressed */
  125586. onPadDownObservable: Observable<DualShockDpad>;
  125587. /** Observable raised when a pad is released */
  125588. onPadUpObservable: Observable<DualShockDpad>;
  125589. private _buttonCross;
  125590. private _buttonCircle;
  125591. private _buttonSquare;
  125592. private _buttonTriangle;
  125593. private _buttonShare;
  125594. private _buttonOptions;
  125595. private _buttonL1;
  125596. private _buttonR1;
  125597. private _buttonLeftStick;
  125598. private _buttonRightStick;
  125599. private _dPadUp;
  125600. private _dPadDown;
  125601. private _dPadLeft;
  125602. private _dPadRight;
  125603. /**
  125604. * Creates a new DualShock gamepad object
  125605. * @param id defines the id of this gamepad
  125606. * @param index defines its index
  125607. * @param gamepad defines the internal HTML gamepad object
  125608. */
  125609. constructor(id: string, index: number, gamepad: any);
  125610. /**
  125611. * Defines the callback to call when left trigger is pressed
  125612. * @param callback defines the callback to use
  125613. */
  125614. onlefttriggerchanged(callback: (value: number) => void): void;
  125615. /**
  125616. * Defines the callback to call when right trigger is pressed
  125617. * @param callback defines the callback to use
  125618. */
  125619. onrighttriggerchanged(callback: (value: number) => void): void;
  125620. /**
  125621. * Gets the left trigger value
  125622. */
  125623. get leftTrigger(): number;
  125624. /**
  125625. * Sets the left trigger value
  125626. */
  125627. set leftTrigger(newValue: number);
  125628. /**
  125629. * Gets the right trigger value
  125630. */
  125631. get rightTrigger(): number;
  125632. /**
  125633. * Sets the right trigger value
  125634. */
  125635. set rightTrigger(newValue: number);
  125636. /**
  125637. * Defines the callback to call when a button is pressed
  125638. * @param callback defines the callback to use
  125639. */
  125640. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  125641. /**
  125642. * Defines the callback to call when a button is released
  125643. * @param callback defines the callback to use
  125644. */
  125645. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  125646. /**
  125647. * Defines the callback to call when a pad is pressed
  125648. * @param callback defines the callback to use
  125649. */
  125650. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  125651. /**
  125652. * Defines the callback to call when a pad is released
  125653. * @param callback defines the callback to use
  125654. */
  125655. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  125656. private _setButtonValue;
  125657. private _setDPadValue;
  125658. /**
  125659. * Gets the value of the `Cross` button
  125660. */
  125661. get buttonCross(): number;
  125662. /**
  125663. * Sets the value of the `Cross` button
  125664. */
  125665. set buttonCross(value: number);
  125666. /**
  125667. * Gets the value of the `Circle` button
  125668. */
  125669. get buttonCircle(): number;
  125670. /**
  125671. * Sets the value of the `Circle` button
  125672. */
  125673. set buttonCircle(value: number);
  125674. /**
  125675. * Gets the value of the `Square` button
  125676. */
  125677. get buttonSquare(): number;
  125678. /**
  125679. * Sets the value of the `Square` button
  125680. */
  125681. set buttonSquare(value: number);
  125682. /**
  125683. * Gets the value of the `Triangle` button
  125684. */
  125685. get buttonTriangle(): number;
  125686. /**
  125687. * Sets the value of the `Triangle` button
  125688. */
  125689. set buttonTriangle(value: number);
  125690. /**
  125691. * Gets the value of the `Options` button
  125692. */
  125693. get buttonOptions(): number;
  125694. /**
  125695. * Sets the value of the `Options` button
  125696. */
  125697. set buttonOptions(value: number);
  125698. /**
  125699. * Gets the value of the `Share` button
  125700. */
  125701. get buttonShare(): number;
  125702. /**
  125703. * Sets the value of the `Share` button
  125704. */
  125705. set buttonShare(value: number);
  125706. /**
  125707. * Gets the value of the `L1` button
  125708. */
  125709. get buttonL1(): number;
  125710. /**
  125711. * Sets the value of the `L1` button
  125712. */
  125713. set buttonL1(value: number);
  125714. /**
  125715. * Gets the value of the `R1` button
  125716. */
  125717. get buttonR1(): number;
  125718. /**
  125719. * Sets the value of the `R1` button
  125720. */
  125721. set buttonR1(value: number);
  125722. /**
  125723. * Gets the value of the Left joystick
  125724. */
  125725. get buttonLeftStick(): number;
  125726. /**
  125727. * Sets the value of the Left joystick
  125728. */
  125729. set buttonLeftStick(value: number);
  125730. /**
  125731. * Gets the value of the Right joystick
  125732. */
  125733. get buttonRightStick(): number;
  125734. /**
  125735. * Sets the value of the Right joystick
  125736. */
  125737. set buttonRightStick(value: number);
  125738. /**
  125739. * Gets the value of D-pad up
  125740. */
  125741. get dPadUp(): number;
  125742. /**
  125743. * Sets the value of D-pad up
  125744. */
  125745. set dPadUp(value: number);
  125746. /**
  125747. * Gets the value of D-pad down
  125748. */
  125749. get dPadDown(): number;
  125750. /**
  125751. * Sets the value of D-pad down
  125752. */
  125753. set dPadDown(value: number);
  125754. /**
  125755. * Gets the value of D-pad left
  125756. */
  125757. get dPadLeft(): number;
  125758. /**
  125759. * Sets the value of D-pad left
  125760. */
  125761. set dPadLeft(value: number);
  125762. /**
  125763. * Gets the value of D-pad right
  125764. */
  125765. get dPadRight(): number;
  125766. /**
  125767. * Sets the value of D-pad right
  125768. */
  125769. set dPadRight(value: number);
  125770. /**
  125771. * Force the gamepad to synchronize with device values
  125772. */
  125773. update(): void;
  125774. /**
  125775. * Disposes the gamepad
  125776. */
  125777. dispose(): void;
  125778. }
  125779. }
  125780. declare module BABYLON {
  125781. /**
  125782. * Manager for handling gamepads
  125783. */
  125784. export class GamepadManager {
  125785. private _scene?;
  125786. private _babylonGamepads;
  125787. private _oneGamepadConnected;
  125788. /** @hidden */
  125789. _isMonitoring: boolean;
  125790. private _gamepadEventSupported;
  125791. private _gamepadSupport?;
  125792. /**
  125793. * observable to be triggered when the gamepad controller has been connected
  125794. */
  125795. onGamepadConnectedObservable: Observable<Gamepad>;
  125796. /**
  125797. * observable to be triggered when the gamepad controller has been disconnected
  125798. */
  125799. onGamepadDisconnectedObservable: Observable<Gamepad>;
  125800. private _onGamepadConnectedEvent;
  125801. private _onGamepadDisconnectedEvent;
  125802. /**
  125803. * Initializes the gamepad manager
  125804. * @param _scene BabylonJS scene
  125805. */
  125806. constructor(_scene?: Scene | undefined);
  125807. /**
  125808. * The gamepads in the game pad manager
  125809. */
  125810. get gamepads(): Gamepad[];
  125811. /**
  125812. * Get the gamepad controllers based on type
  125813. * @param type The type of gamepad controller
  125814. * @returns Nullable gamepad
  125815. */
  125816. getGamepadByType(type?: number): Nullable<Gamepad>;
  125817. /**
  125818. * Disposes the gamepad manager
  125819. */
  125820. dispose(): void;
  125821. private _addNewGamepad;
  125822. private _startMonitoringGamepads;
  125823. private _stopMonitoringGamepads;
  125824. /** @hidden */
  125825. _checkGamepadsStatus(): void;
  125826. private _updateGamepadObjects;
  125827. }
  125828. }
  125829. declare module BABYLON {
  125830. interface Scene {
  125831. /** @hidden */
  125832. _gamepadManager: Nullable<GamepadManager>;
  125833. /**
  125834. * Gets the gamepad manager associated with the scene
  125835. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  125836. */
  125837. gamepadManager: GamepadManager;
  125838. }
  125839. /**
  125840. * Interface representing a free camera inputs manager
  125841. */
  125842. interface FreeCameraInputsManager {
  125843. /**
  125844. * Adds gamepad input support to the FreeCameraInputsManager.
  125845. * @returns the FreeCameraInputsManager
  125846. */
  125847. addGamepad(): FreeCameraInputsManager;
  125848. }
  125849. /**
  125850. * Interface representing an arc rotate camera inputs manager
  125851. */
  125852. interface ArcRotateCameraInputsManager {
  125853. /**
  125854. * Adds gamepad input support to the ArcRotateCamera InputManager.
  125855. * @returns the camera inputs manager
  125856. */
  125857. addGamepad(): ArcRotateCameraInputsManager;
  125858. }
  125859. /**
  125860. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  125861. */
  125862. export class GamepadSystemSceneComponent implements ISceneComponent {
  125863. /**
  125864. * The component name helpfull to identify the component in the list of scene components.
  125865. */
  125866. readonly name: string;
  125867. /**
  125868. * The scene the component belongs to.
  125869. */
  125870. scene: Scene;
  125871. /**
  125872. * Creates a new instance of the component for the given scene
  125873. * @param scene Defines the scene to register the component in
  125874. */
  125875. constructor(scene: Scene);
  125876. /**
  125877. * Registers the component in a given scene
  125878. */
  125879. register(): void;
  125880. /**
  125881. * Rebuilds the elements related to this component in case of
  125882. * context lost for instance.
  125883. */
  125884. rebuild(): void;
  125885. /**
  125886. * Disposes the component and the associated ressources
  125887. */
  125888. dispose(): void;
  125889. private _beforeCameraUpdate;
  125890. }
  125891. }
  125892. declare module BABYLON {
  125893. /**
  125894. * 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,
  125895. * which still works and will still be found in many Playgrounds.
  125896. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125897. */
  125898. export class UniversalCamera extends TouchCamera {
  125899. /**
  125900. * Defines the gamepad rotation sensiblity.
  125901. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125902. */
  125903. get gamepadAngularSensibility(): number;
  125904. set gamepadAngularSensibility(value: number);
  125905. /**
  125906. * Defines the gamepad move sensiblity.
  125907. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125908. */
  125909. get gamepadMoveSensibility(): number;
  125910. set gamepadMoveSensibility(value: number);
  125911. /**
  125912. * 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,
  125913. * which still works and will still be found in many Playgrounds.
  125914. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125915. * @param name Define the name of the camera in the scene
  125916. * @param position Define the start position of the camera in the scene
  125917. * @param scene Define the scene the camera belongs to
  125918. */
  125919. constructor(name: string, position: Vector3, scene: Scene);
  125920. /**
  125921. * Gets the current object class name.
  125922. * @return the class name
  125923. */
  125924. getClassName(): string;
  125925. }
  125926. }
  125927. declare module BABYLON {
  125928. /**
  125929. * This represents a FPS type of camera. This is only here for back compat purpose.
  125930. * Please use the UniversalCamera instead as both are identical.
  125931. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125932. */
  125933. export class GamepadCamera extends UniversalCamera {
  125934. /**
  125935. * Instantiates a new Gamepad Camera
  125936. * This represents a FPS type of camera. This is only here for back compat purpose.
  125937. * Please use the UniversalCamera instead as both are identical.
  125938. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125939. * @param name Define the name of the camera in the scene
  125940. * @param position Define the start position of the camera in the scene
  125941. * @param scene Define the scene the camera belongs to
  125942. */
  125943. constructor(name: string, position: Vector3, scene: Scene);
  125944. /**
  125945. * Gets the current object class name.
  125946. * @return the class name
  125947. */
  125948. getClassName(): string;
  125949. }
  125950. }
  125951. declare module BABYLON {
  125952. /** @hidden */
  125953. export var passPixelShader: {
  125954. name: string;
  125955. shader: string;
  125956. };
  125957. }
  125958. declare module BABYLON {
  125959. /** @hidden */
  125960. export var passCubePixelShader: {
  125961. name: string;
  125962. shader: string;
  125963. };
  125964. }
  125965. declare module BABYLON {
  125966. /**
  125967. * PassPostProcess which produces an output the same as it's input
  125968. */
  125969. export class PassPostProcess extends PostProcess {
  125970. /**
  125971. * Gets a string identifying the name of the class
  125972. * @returns "PassPostProcess" string
  125973. */
  125974. getClassName(): string;
  125975. /**
  125976. * Creates the PassPostProcess
  125977. * @param name The name of the effect.
  125978. * @param options The required width/height ratio to downsize to before computing the render pass.
  125979. * @param camera The camera to apply the render pass to.
  125980. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125981. * @param engine The engine which the post process will be applied. (default: current engine)
  125982. * @param reusable If the post process can be reused on the same frame. (default: false)
  125983. * @param textureType The type of texture to be used when performing the post processing.
  125984. * @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)
  125985. */
  125986. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125987. /** @hidden */
  125988. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  125989. }
  125990. /**
  125991. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  125992. */
  125993. export class PassCubePostProcess extends PostProcess {
  125994. private _face;
  125995. /**
  125996. * Gets or sets the cube face to display.
  125997. * * 0 is +X
  125998. * * 1 is -X
  125999. * * 2 is +Y
  126000. * * 3 is -Y
  126001. * * 4 is +Z
  126002. * * 5 is -Z
  126003. */
  126004. get face(): number;
  126005. set face(value: number);
  126006. /**
  126007. * Gets a string identifying the name of the class
  126008. * @returns "PassCubePostProcess" string
  126009. */
  126010. getClassName(): string;
  126011. /**
  126012. * Creates the PassCubePostProcess
  126013. * @param name The name of the effect.
  126014. * @param options The required width/height ratio to downsize to before computing the render pass.
  126015. * @param camera The camera to apply the render pass to.
  126016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126017. * @param engine The engine which the post process will be applied. (default: current engine)
  126018. * @param reusable If the post process can be reused on the same frame. (default: false)
  126019. * @param textureType The type of texture to be used when performing the post processing.
  126020. * @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)
  126021. */
  126022. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126023. /** @hidden */
  126024. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  126025. }
  126026. }
  126027. declare module BABYLON {
  126028. /** @hidden */
  126029. export var anaglyphPixelShader: {
  126030. name: string;
  126031. shader: string;
  126032. };
  126033. }
  126034. declare module BABYLON {
  126035. /**
  126036. * Postprocess used to generate anaglyphic rendering
  126037. */
  126038. export class AnaglyphPostProcess extends PostProcess {
  126039. private _passedProcess;
  126040. /**
  126041. * Gets a string identifying the name of the class
  126042. * @returns "AnaglyphPostProcess" string
  126043. */
  126044. getClassName(): string;
  126045. /**
  126046. * Creates a new AnaglyphPostProcess
  126047. * @param name defines postprocess name
  126048. * @param options defines creation options or target ratio scale
  126049. * @param rigCameras defines cameras using this postprocess
  126050. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  126051. * @param engine defines hosting engine
  126052. * @param reusable defines if the postprocess will be reused multiple times per frame
  126053. */
  126054. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  126055. }
  126056. }
  126057. declare module BABYLON {
  126058. /**
  126059. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  126060. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126061. */
  126062. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  126063. /**
  126064. * Creates a new AnaglyphArcRotateCamera
  126065. * @param name defines camera name
  126066. * @param alpha defines alpha angle (in radians)
  126067. * @param beta defines beta angle (in radians)
  126068. * @param radius defines radius
  126069. * @param target defines camera target
  126070. * @param interaxialDistance defines distance between each color axis
  126071. * @param scene defines the hosting scene
  126072. */
  126073. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  126074. /**
  126075. * Gets camera class name
  126076. * @returns AnaglyphArcRotateCamera
  126077. */
  126078. getClassName(): string;
  126079. }
  126080. }
  126081. declare module BABYLON {
  126082. /**
  126083. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  126084. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126085. */
  126086. export class AnaglyphFreeCamera extends FreeCamera {
  126087. /**
  126088. * Creates a new AnaglyphFreeCamera
  126089. * @param name defines camera name
  126090. * @param position defines initial position
  126091. * @param interaxialDistance defines distance between each color axis
  126092. * @param scene defines the hosting scene
  126093. */
  126094. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126095. /**
  126096. * Gets camera class name
  126097. * @returns AnaglyphFreeCamera
  126098. */
  126099. getClassName(): string;
  126100. }
  126101. }
  126102. declare module BABYLON {
  126103. /**
  126104. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  126105. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126106. */
  126107. export class AnaglyphGamepadCamera extends GamepadCamera {
  126108. /**
  126109. * Creates a new AnaglyphGamepadCamera
  126110. * @param name defines camera name
  126111. * @param position defines initial position
  126112. * @param interaxialDistance defines distance between each color axis
  126113. * @param scene defines the hosting scene
  126114. */
  126115. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126116. /**
  126117. * Gets camera class name
  126118. * @returns AnaglyphGamepadCamera
  126119. */
  126120. getClassName(): string;
  126121. }
  126122. }
  126123. declare module BABYLON {
  126124. /**
  126125. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  126126. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126127. */
  126128. export class AnaglyphUniversalCamera extends UniversalCamera {
  126129. /**
  126130. * Creates a new AnaglyphUniversalCamera
  126131. * @param name defines camera name
  126132. * @param position defines initial position
  126133. * @param interaxialDistance defines distance between each color axis
  126134. * @param scene defines the hosting scene
  126135. */
  126136. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126137. /**
  126138. * Gets camera class name
  126139. * @returns AnaglyphUniversalCamera
  126140. */
  126141. getClassName(): string;
  126142. }
  126143. }
  126144. declare module BABYLON {
  126145. /**
  126146. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  126147. * @see https://doc.babylonjs.com/features/cameras
  126148. */
  126149. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  126150. /**
  126151. * Creates a new StereoscopicArcRotateCamera
  126152. * @param name defines camera name
  126153. * @param alpha defines alpha angle (in radians)
  126154. * @param beta defines beta angle (in radians)
  126155. * @param radius defines radius
  126156. * @param target defines camera target
  126157. * @param interaxialDistance defines distance between each color axis
  126158. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126159. * @param scene defines the hosting scene
  126160. */
  126161. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126162. /**
  126163. * Gets camera class name
  126164. * @returns StereoscopicArcRotateCamera
  126165. */
  126166. getClassName(): string;
  126167. }
  126168. }
  126169. declare module BABYLON {
  126170. /**
  126171. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  126172. * @see https://doc.babylonjs.com/features/cameras
  126173. */
  126174. export class StereoscopicFreeCamera extends FreeCamera {
  126175. /**
  126176. * Creates a new StereoscopicFreeCamera
  126177. * @param name defines camera name
  126178. * @param position defines initial position
  126179. * @param interaxialDistance defines distance between each color axis
  126180. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126181. * @param scene defines the hosting scene
  126182. */
  126183. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126184. /**
  126185. * Gets camera class name
  126186. * @returns StereoscopicFreeCamera
  126187. */
  126188. getClassName(): string;
  126189. }
  126190. }
  126191. declare module BABYLON {
  126192. /**
  126193. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  126194. * @see https://doc.babylonjs.com/features/cameras
  126195. */
  126196. export class StereoscopicGamepadCamera extends GamepadCamera {
  126197. /**
  126198. * Creates a new StereoscopicGamepadCamera
  126199. * @param name defines camera name
  126200. * @param position defines initial position
  126201. * @param interaxialDistance defines distance between each color axis
  126202. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126203. * @param scene defines the hosting scene
  126204. */
  126205. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126206. /**
  126207. * Gets camera class name
  126208. * @returns StereoscopicGamepadCamera
  126209. */
  126210. getClassName(): string;
  126211. }
  126212. }
  126213. declare module BABYLON {
  126214. /**
  126215. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  126216. * @see https://doc.babylonjs.com/features/cameras
  126217. */
  126218. export class StereoscopicUniversalCamera extends UniversalCamera {
  126219. /**
  126220. * Creates a new StereoscopicUniversalCamera
  126221. * @param name defines camera name
  126222. * @param position defines initial position
  126223. * @param interaxialDistance defines distance between each color axis
  126224. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126225. * @param scene defines the hosting scene
  126226. */
  126227. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126228. /**
  126229. * Gets camera class name
  126230. * @returns StereoscopicUniversalCamera
  126231. */
  126232. getClassName(): string;
  126233. }
  126234. }
  126235. declare module BABYLON {
  126236. /**
  126237. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  126238. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126239. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126240. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126241. */
  126242. export class VirtualJoysticksCamera extends FreeCamera {
  126243. /**
  126244. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  126245. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126246. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126247. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126248. * @param name Define the name of the camera in the scene
  126249. * @param position Define the start position of the camera in the scene
  126250. * @param scene Define the scene the camera belongs to
  126251. */
  126252. constructor(name: string, position: Vector3, scene: Scene);
  126253. /**
  126254. * Gets the current object class name.
  126255. * @return the class name
  126256. */
  126257. getClassName(): string;
  126258. }
  126259. }
  126260. declare module BABYLON {
  126261. /**
  126262. * This represents all the required metrics to create a VR camera.
  126263. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  126264. */
  126265. export class VRCameraMetrics {
  126266. /**
  126267. * Define the horizontal resolution off the screen.
  126268. */
  126269. hResolution: number;
  126270. /**
  126271. * Define the vertical resolution off the screen.
  126272. */
  126273. vResolution: number;
  126274. /**
  126275. * Define the horizontal screen size.
  126276. */
  126277. hScreenSize: number;
  126278. /**
  126279. * Define the vertical screen size.
  126280. */
  126281. vScreenSize: number;
  126282. /**
  126283. * Define the vertical screen center position.
  126284. */
  126285. vScreenCenter: number;
  126286. /**
  126287. * Define the distance of the eyes to the screen.
  126288. */
  126289. eyeToScreenDistance: number;
  126290. /**
  126291. * Define the distance between both lenses
  126292. */
  126293. lensSeparationDistance: number;
  126294. /**
  126295. * Define the distance between both viewer's eyes.
  126296. */
  126297. interpupillaryDistance: number;
  126298. /**
  126299. * Define the distortion factor of the VR postprocess.
  126300. * Please, touch with care.
  126301. */
  126302. distortionK: number[];
  126303. /**
  126304. * Define the chromatic aberration correction factors for the VR post process.
  126305. */
  126306. chromaAbCorrection: number[];
  126307. /**
  126308. * Define the scale factor of the post process.
  126309. * The smaller the better but the slower.
  126310. */
  126311. postProcessScaleFactor: number;
  126312. /**
  126313. * Define an offset for the lens center.
  126314. */
  126315. lensCenterOffset: number;
  126316. /**
  126317. * Define if the current vr camera should compensate the distortion of the lense or not.
  126318. */
  126319. compensateDistortion: boolean;
  126320. /**
  126321. * Defines if multiview should be enabled when rendering (Default: false)
  126322. */
  126323. multiviewEnabled: boolean;
  126324. /**
  126325. * Gets the rendering aspect ratio based on the provided resolutions.
  126326. */
  126327. get aspectRatio(): number;
  126328. /**
  126329. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  126330. */
  126331. get aspectRatioFov(): number;
  126332. /**
  126333. * @hidden
  126334. */
  126335. get leftHMatrix(): Matrix;
  126336. /**
  126337. * @hidden
  126338. */
  126339. get rightHMatrix(): Matrix;
  126340. /**
  126341. * @hidden
  126342. */
  126343. get leftPreViewMatrix(): Matrix;
  126344. /**
  126345. * @hidden
  126346. */
  126347. get rightPreViewMatrix(): Matrix;
  126348. /**
  126349. * Get the default VRMetrics based on the most generic setup.
  126350. * @returns the default vr metrics
  126351. */
  126352. static GetDefault(): VRCameraMetrics;
  126353. }
  126354. }
  126355. declare module BABYLON {
  126356. /** @hidden */
  126357. export var vrDistortionCorrectionPixelShader: {
  126358. name: string;
  126359. shader: string;
  126360. };
  126361. }
  126362. declare module BABYLON {
  126363. /**
  126364. * VRDistortionCorrectionPostProcess used for mobile VR
  126365. */
  126366. export class VRDistortionCorrectionPostProcess extends PostProcess {
  126367. private _isRightEye;
  126368. private _distortionFactors;
  126369. private _postProcessScaleFactor;
  126370. private _lensCenterOffset;
  126371. private _scaleIn;
  126372. private _scaleFactor;
  126373. private _lensCenter;
  126374. /**
  126375. * Gets a string identifying the name of the class
  126376. * @returns "VRDistortionCorrectionPostProcess" string
  126377. */
  126378. getClassName(): string;
  126379. /**
  126380. * Initializes the VRDistortionCorrectionPostProcess
  126381. * @param name The name of the effect.
  126382. * @param camera The camera to apply the render pass to.
  126383. * @param isRightEye If this is for the right eye distortion
  126384. * @param vrMetrics All the required metrics for the VR camera
  126385. */
  126386. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  126387. }
  126388. }
  126389. declare module BABYLON {
  126390. /**
  126391. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  126392. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126393. */
  126394. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  126395. /**
  126396. * Creates a new VRDeviceOrientationArcRotateCamera
  126397. * @param name defines camera name
  126398. * @param alpha defines the camera rotation along the logitudinal axis
  126399. * @param beta defines the camera rotation along the latitudinal axis
  126400. * @param radius defines the camera distance from its target
  126401. * @param target defines the camera target
  126402. * @param scene defines the scene the camera belongs to
  126403. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126404. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126405. */
  126406. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126407. /**
  126408. * Gets camera class name
  126409. * @returns VRDeviceOrientationArcRotateCamera
  126410. */
  126411. getClassName(): string;
  126412. }
  126413. }
  126414. declare module BABYLON {
  126415. /**
  126416. * Camera used to simulate VR rendering (based on FreeCamera)
  126417. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126418. */
  126419. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  126420. /**
  126421. * Creates a new VRDeviceOrientationFreeCamera
  126422. * @param name defines camera name
  126423. * @param position defines the start position of the camera
  126424. * @param scene defines the scene the camera belongs to
  126425. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126426. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126427. */
  126428. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126429. /**
  126430. * Gets camera class name
  126431. * @returns VRDeviceOrientationFreeCamera
  126432. */
  126433. getClassName(): string;
  126434. }
  126435. }
  126436. declare module BABYLON {
  126437. /**
  126438. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  126439. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126440. */
  126441. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  126442. /**
  126443. * Creates a new VRDeviceOrientationGamepadCamera
  126444. * @param name defines camera name
  126445. * @param position defines the start position of the camera
  126446. * @param scene defines the scene the camera belongs to
  126447. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126448. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126449. */
  126450. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126451. /**
  126452. * Gets camera class name
  126453. * @returns VRDeviceOrientationGamepadCamera
  126454. */
  126455. getClassName(): string;
  126456. }
  126457. }
  126458. declare module BABYLON {
  126459. /**
  126460. * A class extending Texture allowing drawing on a texture
  126461. * @see https://doc.babylonjs.com/how_to/dynamictexture
  126462. */
  126463. export class DynamicTexture extends Texture {
  126464. private _generateMipMaps;
  126465. private _canvas;
  126466. private _context;
  126467. /**
  126468. * Creates a DynamicTexture
  126469. * @param name defines the name of the texture
  126470. * @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
  126471. * @param scene defines the scene where you want the texture
  126472. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  126473. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126474. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  126475. */
  126476. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  126477. /**
  126478. * Get the current class name of the texture useful for serialization or dynamic coding.
  126479. * @returns "DynamicTexture"
  126480. */
  126481. getClassName(): string;
  126482. /**
  126483. * Gets the current state of canRescale
  126484. */
  126485. get canRescale(): boolean;
  126486. private _recreate;
  126487. /**
  126488. * Scales the texture
  126489. * @param ratio the scale factor to apply to both width and height
  126490. */
  126491. scale(ratio: number): void;
  126492. /**
  126493. * Resizes the texture
  126494. * @param width the new width
  126495. * @param height the new height
  126496. */
  126497. scaleTo(width: number, height: number): void;
  126498. /**
  126499. * Gets the context of the canvas used by the texture
  126500. * @returns the canvas context of the dynamic texture
  126501. */
  126502. getContext(): CanvasRenderingContext2D;
  126503. /**
  126504. * Clears the texture
  126505. */
  126506. clear(): void;
  126507. /**
  126508. * Updates the texture
  126509. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126510. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  126511. */
  126512. update(invertY?: boolean, premulAlpha?: boolean): void;
  126513. /**
  126514. * Draws text onto the texture
  126515. * @param text defines the text to be drawn
  126516. * @param x defines the placement of the text from the left
  126517. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  126518. * @param font defines the font to be used with font-style, font-size, font-name
  126519. * @param color defines the color used for the text
  126520. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  126521. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126522. * @param update defines whether texture is immediately update (default is true)
  126523. */
  126524. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  126525. /**
  126526. * Clones the texture
  126527. * @returns the clone of the texture.
  126528. */
  126529. clone(): DynamicTexture;
  126530. /**
  126531. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  126532. * @returns a serialized dynamic texture object
  126533. */
  126534. serialize(): any;
  126535. private _IsCanvasElement;
  126536. /** @hidden */
  126537. _rebuild(): void;
  126538. }
  126539. }
  126540. declare module BABYLON {
  126541. /**
  126542. * Class containing static functions to help procedurally build meshes
  126543. */
  126544. export class GroundBuilder {
  126545. /**
  126546. * Creates a ground mesh
  126547. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  126548. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  126549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126550. * @param name defines the name of the mesh
  126551. * @param options defines the options used to create the mesh
  126552. * @param scene defines the hosting scene
  126553. * @returns the ground mesh
  126554. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  126555. */
  126556. static CreateGround(name: string, options: {
  126557. width?: number;
  126558. height?: number;
  126559. subdivisions?: number;
  126560. subdivisionsX?: number;
  126561. subdivisionsY?: number;
  126562. updatable?: boolean;
  126563. }, scene: any): Mesh;
  126564. /**
  126565. * Creates a tiled ground mesh
  126566. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  126567. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  126568. * * 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
  126569. * * 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
  126570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126571. * @param name defines the name of the mesh
  126572. * @param options defines the options used to create the mesh
  126573. * @param scene defines the hosting scene
  126574. * @returns the tiled ground mesh
  126575. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  126576. */
  126577. static CreateTiledGround(name: string, options: {
  126578. xmin: number;
  126579. zmin: number;
  126580. xmax: number;
  126581. zmax: number;
  126582. subdivisions?: {
  126583. w: number;
  126584. h: number;
  126585. };
  126586. precision?: {
  126587. w: number;
  126588. h: number;
  126589. };
  126590. updatable?: boolean;
  126591. }, scene?: Nullable<Scene>): Mesh;
  126592. /**
  126593. * Creates a ground mesh from a height map
  126594. * * The parameter `url` sets the URL of the height map image resource.
  126595. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  126596. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  126597. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  126598. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  126599. * * 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.
  126600. * * 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).
  126601. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  126602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126603. * @param name defines the name of the mesh
  126604. * @param url defines the url to the height map
  126605. * @param options defines the options used to create the mesh
  126606. * @param scene defines the hosting scene
  126607. * @returns the ground mesh
  126608. * @see https://doc.babylonjs.com/babylon101/height_map
  126609. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  126610. */
  126611. static CreateGroundFromHeightMap(name: string, url: string, options: {
  126612. width?: number;
  126613. height?: number;
  126614. subdivisions?: number;
  126615. minHeight?: number;
  126616. maxHeight?: number;
  126617. colorFilter?: Color3;
  126618. alphaFilter?: number;
  126619. updatable?: boolean;
  126620. onReady?: (mesh: GroundMesh) => void;
  126621. }, scene?: Nullable<Scene>): GroundMesh;
  126622. }
  126623. }
  126624. declare module BABYLON {
  126625. /**
  126626. * Class containing static functions to help procedurally build meshes
  126627. */
  126628. export class TorusBuilder {
  126629. /**
  126630. * Creates a torus mesh
  126631. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  126632. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  126633. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  126634. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126635. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126637. * @param name defines the name of the mesh
  126638. * @param options defines the options used to create the mesh
  126639. * @param scene defines the hosting scene
  126640. * @returns the torus mesh
  126641. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  126642. */
  126643. static CreateTorus(name: string, options: {
  126644. diameter?: number;
  126645. thickness?: number;
  126646. tessellation?: number;
  126647. updatable?: boolean;
  126648. sideOrientation?: number;
  126649. frontUVs?: Vector4;
  126650. backUVs?: Vector4;
  126651. }, scene: any): Mesh;
  126652. }
  126653. }
  126654. declare module BABYLON {
  126655. /**
  126656. * Class containing static functions to help procedurally build meshes
  126657. */
  126658. export class CylinderBuilder {
  126659. /**
  126660. * Creates a cylinder or a cone mesh
  126661. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  126662. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  126663. * * 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.
  126664. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  126665. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  126666. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  126667. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  126668. * * 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).
  126669. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  126670. * * 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).
  126671. * * 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
  126672. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  126673. * * 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
  126674. * * 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.
  126675. * * If `enclose` is false, a ring surface is one element.
  126676. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  126677. * * 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
  126678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126681. * @param name defines the name of the mesh
  126682. * @param options defines the options used to create the mesh
  126683. * @param scene defines the hosting scene
  126684. * @returns the cylinder mesh
  126685. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  126686. */
  126687. static CreateCylinder(name: string, options: {
  126688. height?: number;
  126689. diameterTop?: number;
  126690. diameterBottom?: number;
  126691. diameter?: number;
  126692. tessellation?: number;
  126693. subdivisions?: number;
  126694. arc?: number;
  126695. faceColors?: Color4[];
  126696. faceUV?: Vector4[];
  126697. updatable?: boolean;
  126698. hasRings?: boolean;
  126699. enclose?: boolean;
  126700. cap?: number;
  126701. sideOrientation?: number;
  126702. frontUVs?: Vector4;
  126703. backUVs?: Vector4;
  126704. }, scene: any): Mesh;
  126705. }
  126706. }
  126707. declare module BABYLON {
  126708. /**
  126709. * States of the webXR experience
  126710. */
  126711. export enum WebXRState {
  126712. /**
  126713. * Transitioning to being in XR mode
  126714. */
  126715. ENTERING_XR = 0,
  126716. /**
  126717. * Transitioning to non XR mode
  126718. */
  126719. EXITING_XR = 1,
  126720. /**
  126721. * In XR mode and presenting
  126722. */
  126723. IN_XR = 2,
  126724. /**
  126725. * Not entered XR mode
  126726. */
  126727. NOT_IN_XR = 3
  126728. }
  126729. /**
  126730. * Abstraction of the XR render target
  126731. */
  126732. export interface WebXRRenderTarget extends IDisposable {
  126733. /**
  126734. * xrpresent context of the canvas which can be used to display/mirror xr content
  126735. */
  126736. canvasContext: WebGLRenderingContext;
  126737. /**
  126738. * xr layer for the canvas
  126739. */
  126740. xrLayer: Nullable<XRWebGLLayer>;
  126741. /**
  126742. * Initializes the xr layer for the session
  126743. * @param xrSession xr session
  126744. * @returns a promise that will resolve once the XR Layer has been created
  126745. */
  126746. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  126747. }
  126748. }
  126749. declare module BABYLON {
  126750. /**
  126751. * COnfiguration object for WebXR output canvas
  126752. */
  126753. export class WebXRManagedOutputCanvasOptions {
  126754. /**
  126755. * An optional canvas in case you wish to create it yourself and provide it here.
  126756. * If not provided, a new canvas will be created
  126757. */
  126758. canvasElement?: HTMLCanvasElement;
  126759. /**
  126760. * Options for this XR Layer output
  126761. */
  126762. canvasOptions?: XRWebGLLayerOptions;
  126763. /**
  126764. * CSS styling for a newly created canvas (if not provided)
  126765. */
  126766. newCanvasCssStyle?: string;
  126767. /**
  126768. * Get the default values of the configuration object
  126769. * @param engine defines the engine to use (can be null)
  126770. * @returns default values of this configuration object
  126771. */
  126772. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  126773. }
  126774. /**
  126775. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  126776. */
  126777. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  126778. private _options;
  126779. private _canvas;
  126780. private _engine;
  126781. private _originalCanvasSize;
  126782. /**
  126783. * Rendering context of the canvas which can be used to display/mirror xr content
  126784. */
  126785. canvasContext: WebGLRenderingContext;
  126786. /**
  126787. * xr layer for the canvas
  126788. */
  126789. xrLayer: Nullable<XRWebGLLayer>;
  126790. /**
  126791. * Obseervers registered here will be triggered when the xr layer was initialized
  126792. */
  126793. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  126794. /**
  126795. * Initializes the canvas to be added/removed upon entering/exiting xr
  126796. * @param _xrSessionManager The XR Session manager
  126797. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  126798. */
  126799. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  126800. /**
  126801. * Disposes of the object
  126802. */
  126803. dispose(): void;
  126804. /**
  126805. * Initializes the xr layer for the session
  126806. * @param xrSession xr session
  126807. * @returns a promise that will resolve once the XR Layer has been created
  126808. */
  126809. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  126810. private _addCanvas;
  126811. private _removeCanvas;
  126812. private _setCanvasSize;
  126813. private _setManagedOutputCanvas;
  126814. }
  126815. }
  126816. declare module BABYLON {
  126817. /**
  126818. * Manages an XRSession to work with Babylon's engine
  126819. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  126820. */
  126821. export class WebXRSessionManager implements IDisposable {
  126822. /** The scene which the session should be created for */
  126823. scene: Scene;
  126824. private _referenceSpace;
  126825. private _rttProvider;
  126826. private _sessionEnded;
  126827. private _xrNavigator;
  126828. private baseLayer;
  126829. /**
  126830. * The base reference space from which the session started. good if you want to reset your
  126831. * reference space
  126832. */
  126833. baseReferenceSpace: XRReferenceSpace;
  126834. /**
  126835. * Current XR frame
  126836. */
  126837. currentFrame: Nullable<XRFrame>;
  126838. /** WebXR timestamp updated every frame */
  126839. currentTimestamp: number;
  126840. /**
  126841. * Used just in case of a failure to initialize an immersive session.
  126842. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  126843. */
  126844. defaultHeightCompensation: number;
  126845. /**
  126846. * Fires every time a new xrFrame arrives which can be used to update the camera
  126847. */
  126848. onXRFrameObservable: Observable<XRFrame>;
  126849. /**
  126850. * Fires when the reference space changed
  126851. */
  126852. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  126853. /**
  126854. * Fires when the xr session is ended either by the device or manually done
  126855. */
  126856. onXRSessionEnded: Observable<any>;
  126857. /**
  126858. * Fires when the xr session is ended either by the device or manually done
  126859. */
  126860. onXRSessionInit: Observable<XRSession>;
  126861. /**
  126862. * Underlying xr session
  126863. */
  126864. session: XRSession;
  126865. /**
  126866. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  126867. * or get the offset the player is currently at.
  126868. */
  126869. viewerReferenceSpace: XRReferenceSpace;
  126870. /**
  126871. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  126872. * @param scene The scene which the session should be created for
  126873. */
  126874. constructor(
  126875. /** The scene which the session should be created for */
  126876. scene: Scene);
  126877. /**
  126878. * The current reference space used in this session. This reference space can constantly change!
  126879. * It is mainly used to offset the camera's position.
  126880. */
  126881. get referenceSpace(): XRReferenceSpace;
  126882. /**
  126883. * Set a new reference space and triggers the observable
  126884. */
  126885. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  126886. /**
  126887. * Disposes of the session manager
  126888. */
  126889. dispose(): void;
  126890. /**
  126891. * Stops the xrSession and restores the render loop
  126892. * @returns Promise which resolves after it exits XR
  126893. */
  126894. exitXRAsync(): Promise<void>;
  126895. /**
  126896. * Gets the correct render target texture to be rendered this frame for this eye
  126897. * @param eye the eye for which to get the render target
  126898. * @returns the render target for the specified eye
  126899. */
  126900. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  126901. /**
  126902. * Creates a WebXRRenderTarget object for the XR session
  126903. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  126904. * @param options optional options to provide when creating a new render target
  126905. * @returns a WebXR render target to which the session can render
  126906. */
  126907. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  126908. /**
  126909. * Initializes the manager
  126910. * After initialization enterXR can be called to start an XR session
  126911. * @returns Promise which resolves after it is initialized
  126912. */
  126913. initializeAsync(): Promise<void>;
  126914. /**
  126915. * Initializes an xr session
  126916. * @param xrSessionMode mode to initialize
  126917. * @param xrSessionInit defines optional and required values to pass to the session builder
  126918. * @returns a promise which will resolve once the session has been initialized
  126919. */
  126920. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  126921. /**
  126922. * Checks if a session would be supported for the creation options specified
  126923. * @param sessionMode session mode to check if supported eg. immersive-vr
  126924. * @returns A Promise that resolves to true if supported and false if not
  126925. */
  126926. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  126927. /**
  126928. * Resets the reference space to the one started the session
  126929. */
  126930. resetReferenceSpace(): void;
  126931. /**
  126932. * Starts rendering to the xr layer
  126933. */
  126934. runXRRenderLoop(): void;
  126935. /**
  126936. * Sets the reference space on the xr session
  126937. * @param referenceSpaceType space to set
  126938. * @returns a promise that will resolve once the reference space has been set
  126939. */
  126940. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  126941. /**
  126942. * Updates the render state of the session
  126943. * @param state state to set
  126944. * @returns a promise that resolves once the render state has been updated
  126945. */
  126946. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  126947. /**
  126948. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  126949. * @param sessionMode defines the session to test
  126950. * @returns a promise with boolean as final value
  126951. */
  126952. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  126953. private _createRenderTargetTexture;
  126954. }
  126955. }
  126956. declare module BABYLON {
  126957. /**
  126958. * WebXR Camera which holds the views for the xrSession
  126959. * @see https://doc.babylonjs.com/how_to/webxr_camera
  126960. */
  126961. export class WebXRCamera extends FreeCamera {
  126962. private _xrSessionManager;
  126963. private _firstFrame;
  126964. private _referenceQuaternion;
  126965. private _referencedPosition;
  126966. private _xrInvPositionCache;
  126967. private _xrInvQuaternionCache;
  126968. /**
  126969. * Observable raised before camera teleportation
  126970. */
  126971. onBeforeCameraTeleport: Observable<Vector3>;
  126972. /**
  126973. * Observable raised after camera teleportation
  126974. */
  126975. onAfterCameraTeleport: Observable<Vector3>;
  126976. /**
  126977. * Should position compensation execute on first frame.
  126978. * This is used when copying the position from a native (non XR) camera
  126979. */
  126980. compensateOnFirstFrame: boolean;
  126981. /**
  126982. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  126983. * @param name the name of the camera
  126984. * @param scene the scene to add the camera to
  126985. * @param _xrSessionManager a constructed xr session manager
  126986. */
  126987. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  126988. /**
  126989. * Return the user's height, unrelated to the current ground.
  126990. * This will be the y position of this camera, when ground level is 0.
  126991. */
  126992. get realWorldHeight(): number;
  126993. /** @hidden */
  126994. _updateForDualEyeDebugging(): void;
  126995. /**
  126996. * Sets this camera's transformation based on a non-vr camera
  126997. * @param otherCamera the non-vr camera to copy the transformation from
  126998. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  126999. */
  127000. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  127001. /**
  127002. * Gets the current instance class name ("WebXRCamera").
  127003. * @returns the class name
  127004. */
  127005. getClassName(): string;
  127006. private _rotate180;
  127007. private _updateFromXRSession;
  127008. private _updateNumberOfRigCameras;
  127009. private _updateReferenceSpace;
  127010. private _updateReferenceSpaceOffset;
  127011. }
  127012. }
  127013. declare module BABYLON {
  127014. /**
  127015. * Defining the interface required for a (webxr) feature
  127016. */
  127017. export interface IWebXRFeature extends IDisposable {
  127018. /**
  127019. * Is this feature attached
  127020. */
  127021. attached: boolean;
  127022. /**
  127023. * Should auto-attach be disabled?
  127024. */
  127025. disableAutoAttach: boolean;
  127026. /**
  127027. * Attach the feature to the session
  127028. * Will usually be called by the features manager
  127029. *
  127030. * @param force should attachment be forced (even when already attached)
  127031. * @returns true if successful.
  127032. */
  127033. attach(force?: boolean): boolean;
  127034. /**
  127035. * Detach the feature from the session
  127036. * Will usually be called by the features manager
  127037. *
  127038. * @returns true if successful.
  127039. */
  127040. detach(): boolean;
  127041. /**
  127042. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127043. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127044. *
  127045. * @returns whether or not the feature is compatible in this environment
  127046. */
  127047. isCompatible(): boolean;
  127048. /**
  127049. * Was this feature disposed;
  127050. */
  127051. isDisposed: boolean;
  127052. /**
  127053. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  127054. */
  127055. xrNativeFeatureName?: string;
  127056. /**
  127057. * A list of (Babylon WebXR) features this feature depends on
  127058. */
  127059. dependsOn?: string[];
  127060. }
  127061. /**
  127062. * A list of the currently available features without referencing them
  127063. */
  127064. export class WebXRFeatureName {
  127065. /**
  127066. * The name of the anchor system feature
  127067. */
  127068. static readonly ANCHOR_SYSTEM: string;
  127069. /**
  127070. * The name of the background remover feature
  127071. */
  127072. static readonly BACKGROUND_REMOVER: string;
  127073. /**
  127074. * The name of the hit test feature
  127075. */
  127076. static readonly HIT_TEST: string;
  127077. /**
  127078. * physics impostors for xr controllers feature
  127079. */
  127080. static readonly PHYSICS_CONTROLLERS: string;
  127081. /**
  127082. * The name of the plane detection feature
  127083. */
  127084. static readonly PLANE_DETECTION: string;
  127085. /**
  127086. * The name of the pointer selection feature
  127087. */
  127088. static readonly POINTER_SELECTION: string;
  127089. /**
  127090. * The name of the teleportation feature
  127091. */
  127092. static readonly TELEPORTATION: string;
  127093. /**
  127094. * The name of the feature points feature.
  127095. */
  127096. static readonly FEATURE_POINTS: string;
  127097. /**
  127098. * The name of the hand tracking feature.
  127099. */
  127100. static readonly HAND_TRACKING: string;
  127101. }
  127102. /**
  127103. * Defining the constructor of a feature. Used to register the modules.
  127104. */
  127105. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  127106. /**
  127107. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  127108. * It is mainly used in AR sessions.
  127109. *
  127110. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  127111. */
  127112. export class WebXRFeaturesManager implements IDisposable {
  127113. private _xrSessionManager;
  127114. private static readonly _AvailableFeatures;
  127115. private _features;
  127116. /**
  127117. * constructs a new features manages.
  127118. *
  127119. * @param _xrSessionManager an instance of WebXRSessionManager
  127120. */
  127121. constructor(_xrSessionManager: WebXRSessionManager);
  127122. /**
  127123. * Used to register a module. After calling this function a developer can use this feature in the scene.
  127124. * Mainly used internally.
  127125. *
  127126. * @param featureName the name of the feature to register
  127127. * @param constructorFunction the function used to construct the module
  127128. * @param version the (babylon) version of the module
  127129. * @param stable is that a stable version of this module
  127130. */
  127131. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  127132. /**
  127133. * Returns a constructor of a specific feature.
  127134. *
  127135. * @param featureName the name of the feature to construct
  127136. * @param version the version of the feature to load
  127137. * @param xrSessionManager the xrSessionManager. Used to construct the module
  127138. * @param options optional options provided to the module.
  127139. * @returns a function that, when called, will return a new instance of this feature
  127140. */
  127141. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  127142. /**
  127143. * Can be used to return the list of features currently registered
  127144. *
  127145. * @returns an Array of available features
  127146. */
  127147. static GetAvailableFeatures(): string[];
  127148. /**
  127149. * Gets the versions available for a specific feature
  127150. * @param featureName the name of the feature
  127151. * @returns an array with the available versions
  127152. */
  127153. static GetAvailableVersions(featureName: string): string[];
  127154. /**
  127155. * Return the latest unstable version of this feature
  127156. * @param featureName the name of the feature to search
  127157. * @returns the version number. if not found will return -1
  127158. */
  127159. static GetLatestVersionOfFeature(featureName: string): number;
  127160. /**
  127161. * Return the latest stable version of this feature
  127162. * @param featureName the name of the feature to search
  127163. * @returns the version number. if not found will return -1
  127164. */
  127165. static GetStableVersionOfFeature(featureName: string): number;
  127166. /**
  127167. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  127168. * Can be used during a session to start a feature
  127169. * @param featureName the name of feature to attach
  127170. */
  127171. attachFeature(featureName: string): void;
  127172. /**
  127173. * Can be used inside a session or when the session ends to detach a specific feature
  127174. * @param featureName the name of the feature to detach
  127175. */
  127176. detachFeature(featureName: string): void;
  127177. /**
  127178. * Used to disable an already-enabled feature
  127179. * The feature will be disposed and will be recreated once enabled.
  127180. * @param featureName the feature to disable
  127181. * @returns true if disable was successful
  127182. */
  127183. disableFeature(featureName: string | {
  127184. Name: string;
  127185. }): boolean;
  127186. /**
  127187. * dispose this features manager
  127188. */
  127189. dispose(): void;
  127190. /**
  127191. * 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.
  127192. * 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.
  127193. *
  127194. * @param featureName the name of the feature to load or the class of the feature
  127195. * @param version optional version to load. if not provided the latest version will be enabled
  127196. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  127197. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  127198. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  127199. * @returns a new constructed feature or throws an error if feature not found.
  127200. */
  127201. enableFeature(featureName: string | {
  127202. Name: string;
  127203. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  127204. /**
  127205. * get the implementation of an enabled feature.
  127206. * @param featureName the name of the feature to load
  127207. * @returns the feature class, if found
  127208. */
  127209. getEnabledFeature(featureName: string): IWebXRFeature;
  127210. /**
  127211. * Get the list of enabled features
  127212. * @returns an array of enabled features
  127213. */
  127214. getEnabledFeatures(): string[];
  127215. /**
  127216. * This function will exten the session creation configuration object with enabled features.
  127217. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  127218. * according to the defined "required" variable, provided during enableFeature call
  127219. * @param xrSessionInit the xr Session init object to extend
  127220. *
  127221. * @returns an extended XRSessionInit object
  127222. */
  127223. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  127224. }
  127225. }
  127226. declare module BABYLON {
  127227. /**
  127228. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  127229. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  127230. */
  127231. export class WebXRExperienceHelper implements IDisposable {
  127232. private scene;
  127233. private _nonVRCamera;
  127234. private _originalSceneAutoClear;
  127235. private _supported;
  127236. /**
  127237. * Camera used to render xr content
  127238. */
  127239. camera: WebXRCamera;
  127240. /** A features manager for this xr session */
  127241. featuresManager: WebXRFeaturesManager;
  127242. /**
  127243. * Observers registered here will be triggered after the camera's initial transformation is set
  127244. * This can be used to set a different ground level or an extra rotation.
  127245. *
  127246. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  127247. * to the position set after this observable is done executing.
  127248. */
  127249. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  127250. /**
  127251. * Fires when the state of the experience helper has changed
  127252. */
  127253. onStateChangedObservable: Observable<WebXRState>;
  127254. /** Session manager used to keep track of xr session */
  127255. sessionManager: WebXRSessionManager;
  127256. /**
  127257. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  127258. */
  127259. state: WebXRState;
  127260. /**
  127261. * Creates a WebXRExperienceHelper
  127262. * @param scene The scene the helper should be created in
  127263. */
  127264. private constructor();
  127265. /**
  127266. * Creates the experience helper
  127267. * @param scene the scene to attach the experience helper to
  127268. * @returns a promise for the experience helper
  127269. */
  127270. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  127271. /**
  127272. * Disposes of the experience helper
  127273. */
  127274. dispose(): void;
  127275. /**
  127276. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  127277. * @param sessionMode options for the XR session
  127278. * @param referenceSpaceType frame of reference of the XR session
  127279. * @param renderTarget the output canvas that will be used to enter XR mode
  127280. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  127281. * @returns promise that resolves after xr mode has entered
  127282. */
  127283. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  127284. /**
  127285. * Exits XR mode and returns the scene to its original state
  127286. * @returns promise that resolves after xr mode has exited
  127287. */
  127288. exitXRAsync(): Promise<void>;
  127289. private _nonXRToXRCamera;
  127290. private _setState;
  127291. }
  127292. }
  127293. declare module BABYLON {
  127294. /**
  127295. * X-Y values for axes in WebXR
  127296. */
  127297. export interface IWebXRMotionControllerAxesValue {
  127298. /**
  127299. * The value of the x axis
  127300. */
  127301. x: number;
  127302. /**
  127303. * The value of the y-axis
  127304. */
  127305. y: number;
  127306. }
  127307. /**
  127308. * changed / previous values for the values of this component
  127309. */
  127310. export interface IWebXRMotionControllerComponentChangesValues<T> {
  127311. /**
  127312. * current (this frame) value
  127313. */
  127314. current: T;
  127315. /**
  127316. * previous (last change) value
  127317. */
  127318. previous: T;
  127319. }
  127320. /**
  127321. * Represents changes in the component between current frame and last values recorded
  127322. */
  127323. export interface IWebXRMotionControllerComponentChanges {
  127324. /**
  127325. * will be populated with previous and current values if axes changed
  127326. */
  127327. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  127328. /**
  127329. * will be populated with previous and current values if pressed changed
  127330. */
  127331. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127332. /**
  127333. * will be populated with previous and current values if touched changed
  127334. */
  127335. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127336. /**
  127337. * will be populated with previous and current values if value changed
  127338. */
  127339. value?: IWebXRMotionControllerComponentChangesValues<number>;
  127340. }
  127341. /**
  127342. * This class represents a single component (for example button or thumbstick) of a motion controller
  127343. */
  127344. export class WebXRControllerComponent implements IDisposable {
  127345. /**
  127346. * the id of this component
  127347. */
  127348. id: string;
  127349. /**
  127350. * the type of the component
  127351. */
  127352. type: MotionControllerComponentType;
  127353. private _buttonIndex;
  127354. private _axesIndices;
  127355. private _axes;
  127356. private _changes;
  127357. private _currentValue;
  127358. private _hasChanges;
  127359. private _pressed;
  127360. private _touched;
  127361. /**
  127362. * button component type
  127363. */
  127364. static BUTTON_TYPE: MotionControllerComponentType;
  127365. /**
  127366. * squeeze component type
  127367. */
  127368. static SQUEEZE_TYPE: MotionControllerComponentType;
  127369. /**
  127370. * Thumbstick component type
  127371. */
  127372. static THUMBSTICK_TYPE: MotionControllerComponentType;
  127373. /**
  127374. * Touchpad component type
  127375. */
  127376. static TOUCHPAD_TYPE: MotionControllerComponentType;
  127377. /**
  127378. * trigger component type
  127379. */
  127380. static TRIGGER_TYPE: MotionControllerComponentType;
  127381. /**
  127382. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  127383. * the axes data changes
  127384. */
  127385. onAxisValueChangedObservable: Observable<{
  127386. x: number;
  127387. y: number;
  127388. }>;
  127389. /**
  127390. * Observers registered here will be triggered when the state of a button changes
  127391. * State change is either pressed / touched / value
  127392. */
  127393. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  127394. /**
  127395. * Creates a new component for a motion controller.
  127396. * It is created by the motion controller itself
  127397. *
  127398. * @param id the id of this component
  127399. * @param type the type of the component
  127400. * @param _buttonIndex index in the buttons array of the gamepad
  127401. * @param _axesIndices indices of the values in the axes array of the gamepad
  127402. */
  127403. constructor(
  127404. /**
  127405. * the id of this component
  127406. */
  127407. id: string,
  127408. /**
  127409. * the type of the component
  127410. */
  127411. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  127412. /**
  127413. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  127414. */
  127415. get axes(): IWebXRMotionControllerAxesValue;
  127416. /**
  127417. * Get the changes. Elements will be populated only if they changed with their previous and current value
  127418. */
  127419. get changes(): IWebXRMotionControllerComponentChanges;
  127420. /**
  127421. * Return whether or not the component changed the last frame
  127422. */
  127423. get hasChanges(): boolean;
  127424. /**
  127425. * is the button currently pressed
  127426. */
  127427. get pressed(): boolean;
  127428. /**
  127429. * is the button currently touched
  127430. */
  127431. get touched(): boolean;
  127432. /**
  127433. * Get the current value of this component
  127434. */
  127435. get value(): number;
  127436. /**
  127437. * Dispose this component
  127438. */
  127439. dispose(): void;
  127440. /**
  127441. * Are there axes correlating to this component
  127442. * @return true is axes data is available
  127443. */
  127444. isAxes(): boolean;
  127445. /**
  127446. * Is this component a button (hence - pressable)
  127447. * @returns true if can be pressed
  127448. */
  127449. isButton(): boolean;
  127450. /**
  127451. * update this component using the gamepad object it is in. Called on every frame
  127452. * @param nativeController the native gamepad controller object
  127453. */
  127454. update(nativeController: IMinimalMotionControllerObject): void;
  127455. }
  127456. }
  127457. declare module BABYLON {
  127458. /**
  127459. * Interface used to represent data loading progression
  127460. */
  127461. export interface ISceneLoaderProgressEvent {
  127462. /**
  127463. * Defines if data length to load can be evaluated
  127464. */
  127465. readonly lengthComputable: boolean;
  127466. /**
  127467. * Defines the loaded data length
  127468. */
  127469. readonly loaded: number;
  127470. /**
  127471. * Defines the data length to load
  127472. */
  127473. readonly total: number;
  127474. }
  127475. /**
  127476. * Interface used by SceneLoader plugins to define supported file extensions
  127477. */
  127478. export interface ISceneLoaderPluginExtensions {
  127479. /**
  127480. * Defines the list of supported extensions
  127481. */
  127482. [extension: string]: {
  127483. isBinary: boolean;
  127484. };
  127485. }
  127486. /**
  127487. * Interface used by SceneLoader plugin factory
  127488. */
  127489. export interface ISceneLoaderPluginFactory {
  127490. /**
  127491. * Defines the name of the factory
  127492. */
  127493. name: string;
  127494. /**
  127495. * Function called to create a new plugin
  127496. * @return the new plugin
  127497. */
  127498. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  127499. /**
  127500. * The callback that returns true if the data can be directly loaded.
  127501. * @param data string containing the file data
  127502. * @returns if the data can be loaded directly
  127503. */
  127504. canDirectLoad?(data: string): boolean;
  127505. }
  127506. /**
  127507. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  127508. */
  127509. export interface ISceneLoaderPluginBase {
  127510. /**
  127511. * The friendly name of this plugin.
  127512. */
  127513. name: string;
  127514. /**
  127515. * The file extensions supported by this plugin.
  127516. */
  127517. extensions: string | ISceneLoaderPluginExtensions;
  127518. /**
  127519. * The callback called when loading from a url.
  127520. * @param scene scene loading this url
  127521. * @param url url to load
  127522. * @param onSuccess callback called when the file successfully loads
  127523. * @param onProgress callback called while file is loading (if the server supports this mode)
  127524. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  127525. * @param onError callback called when the file fails to load
  127526. * @returns a file request object
  127527. */
  127528. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  127529. /**
  127530. * The callback called when loading from a file object.
  127531. * @param scene scene loading this file
  127532. * @param file defines the file to load
  127533. * @param onSuccess defines the callback to call when data is loaded
  127534. * @param onProgress defines the callback to call during loading process
  127535. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  127536. * @param onError defines the callback to call when an error occurs
  127537. * @returns a file request object
  127538. */
  127539. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  127540. /**
  127541. * The callback that returns true if the data can be directly loaded.
  127542. * @param data string containing the file data
  127543. * @returns if the data can be loaded directly
  127544. */
  127545. canDirectLoad?(data: string): boolean;
  127546. /**
  127547. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  127548. * @param scene scene loading this data
  127549. * @param data string containing the data
  127550. * @returns data to pass to the plugin
  127551. */
  127552. directLoad?(scene: Scene, data: string): any;
  127553. /**
  127554. * The callback that allows custom handling of the root url based on the response url.
  127555. * @param rootUrl the original root url
  127556. * @param responseURL the response url if available
  127557. * @returns the new root url
  127558. */
  127559. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  127560. }
  127561. /**
  127562. * Interface used to define a SceneLoader plugin
  127563. */
  127564. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  127565. /**
  127566. * Import meshes into a scene.
  127567. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127568. * @param scene The scene to import into
  127569. * @param data The data to import
  127570. * @param rootUrl The root url for scene and resources
  127571. * @param meshes The meshes array to import into
  127572. * @param particleSystems The particle systems array to import into
  127573. * @param skeletons The skeletons array to import into
  127574. * @param onError The callback when import fails
  127575. * @returns True if successful or false otherwise
  127576. */
  127577. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  127578. /**
  127579. * Load into a scene.
  127580. * @param scene The scene to load into
  127581. * @param data The data to import
  127582. * @param rootUrl The root url for scene and resources
  127583. * @param onError The callback when import fails
  127584. * @returns True if successful or false otherwise
  127585. */
  127586. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  127587. /**
  127588. * Load into an asset container.
  127589. * @param scene The scene to load into
  127590. * @param data The data to import
  127591. * @param rootUrl The root url for scene and resources
  127592. * @param onError The callback when import fails
  127593. * @returns The loaded asset container
  127594. */
  127595. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  127596. }
  127597. /**
  127598. * Interface used to define an async SceneLoader plugin
  127599. */
  127600. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  127601. /**
  127602. * Import meshes into a scene.
  127603. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127604. * @param scene The scene to import into
  127605. * @param data The data to import
  127606. * @param rootUrl The root url for scene and resources
  127607. * @param onProgress The callback when the load progresses
  127608. * @param fileName Defines the name of the file to load
  127609. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  127610. */
  127611. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  127612. meshes: AbstractMesh[];
  127613. particleSystems: IParticleSystem[];
  127614. skeletons: Skeleton[];
  127615. animationGroups: AnimationGroup[];
  127616. }>;
  127617. /**
  127618. * Load into a scene.
  127619. * @param scene The scene to load into
  127620. * @param data The data to import
  127621. * @param rootUrl The root url for scene and resources
  127622. * @param onProgress The callback when the load progresses
  127623. * @param fileName Defines the name of the file to load
  127624. * @returns Nothing
  127625. */
  127626. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  127627. /**
  127628. * Load into an asset container.
  127629. * @param scene The scene to load into
  127630. * @param data The data to import
  127631. * @param rootUrl The root url for scene and resources
  127632. * @param onProgress The callback when the load progresses
  127633. * @param fileName Defines the name of the file to load
  127634. * @returns The loaded asset container
  127635. */
  127636. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  127637. }
  127638. /**
  127639. * Mode that determines how to handle old animation groups before loading new ones.
  127640. */
  127641. export enum SceneLoaderAnimationGroupLoadingMode {
  127642. /**
  127643. * Reset all old animations to initial state then dispose them.
  127644. */
  127645. Clean = 0,
  127646. /**
  127647. * Stop all old animations.
  127648. */
  127649. Stop = 1,
  127650. /**
  127651. * Restart old animations from first frame.
  127652. */
  127653. Sync = 2,
  127654. /**
  127655. * Old animations remains untouched.
  127656. */
  127657. NoSync = 3
  127658. }
  127659. /**
  127660. * Defines a plugin registered by the SceneLoader
  127661. */
  127662. interface IRegisteredPlugin {
  127663. /**
  127664. * Defines the plugin to use
  127665. */
  127666. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  127667. /**
  127668. * Defines if the plugin supports binary data
  127669. */
  127670. isBinary: boolean;
  127671. }
  127672. /**
  127673. * Class used to load scene from various file formats using registered plugins
  127674. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  127675. */
  127676. export class SceneLoader {
  127677. /**
  127678. * No logging while loading
  127679. */
  127680. static readonly NO_LOGGING: number;
  127681. /**
  127682. * Minimal logging while loading
  127683. */
  127684. static readonly MINIMAL_LOGGING: number;
  127685. /**
  127686. * Summary logging while loading
  127687. */
  127688. static readonly SUMMARY_LOGGING: number;
  127689. /**
  127690. * Detailled logging while loading
  127691. */
  127692. static readonly DETAILED_LOGGING: number;
  127693. /**
  127694. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  127695. */
  127696. static get ForceFullSceneLoadingForIncremental(): boolean;
  127697. static set ForceFullSceneLoadingForIncremental(value: boolean);
  127698. /**
  127699. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  127700. */
  127701. static get ShowLoadingScreen(): boolean;
  127702. static set ShowLoadingScreen(value: boolean);
  127703. /**
  127704. * Defines the current logging level (while loading the scene)
  127705. * @ignorenaming
  127706. */
  127707. static get loggingLevel(): number;
  127708. static set loggingLevel(value: number);
  127709. /**
  127710. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  127711. */
  127712. static get CleanBoneMatrixWeights(): boolean;
  127713. static set CleanBoneMatrixWeights(value: boolean);
  127714. /**
  127715. * Event raised when a plugin is used to load a scene
  127716. */
  127717. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  127718. private static _registeredPlugins;
  127719. private static _showingLoadingScreen;
  127720. /**
  127721. * Gets the default plugin (used to load Babylon files)
  127722. * @returns the .babylon plugin
  127723. */
  127724. static GetDefaultPlugin(): IRegisteredPlugin;
  127725. private static _GetPluginForExtension;
  127726. private static _GetPluginForDirectLoad;
  127727. private static _GetPluginForFilename;
  127728. private static _GetDirectLoad;
  127729. private static _LoadData;
  127730. private static _GetFileInfo;
  127731. /**
  127732. * Gets a plugin that can load the given extension
  127733. * @param extension defines the extension to load
  127734. * @returns a plugin or null if none works
  127735. */
  127736. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  127737. /**
  127738. * Gets a boolean indicating that the given extension can be loaded
  127739. * @param extension defines the extension to load
  127740. * @returns true if the extension is supported
  127741. */
  127742. static IsPluginForExtensionAvailable(extension: string): boolean;
  127743. /**
  127744. * Adds a new plugin to the list of registered plugins
  127745. * @param plugin defines the plugin to add
  127746. */
  127747. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  127748. /**
  127749. * Import meshes into a scene
  127750. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127751. * @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)
  127752. * @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)
  127753. * @param scene the instance of BABYLON.Scene to append to
  127754. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  127755. * @param onProgress a callback with a progress event for each file being loaded
  127756. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127757. * @param pluginExtension the extension used to determine the plugin
  127758. * @returns The loaded plugin
  127759. */
  127760. 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>;
  127761. /**
  127762. * Import meshes into a scene
  127763. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127764. * @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)
  127765. * @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)
  127766. * @param scene the instance of BABYLON.Scene to append to
  127767. * @param onProgress a callback with a progress event for each file being loaded
  127768. * @param pluginExtension the extension used to determine the plugin
  127769. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  127770. */
  127771. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  127772. meshes: AbstractMesh[];
  127773. particleSystems: IParticleSystem[];
  127774. skeletons: Skeleton[];
  127775. animationGroups: AnimationGroup[];
  127776. }>;
  127777. /**
  127778. * Load a scene
  127779. * @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)
  127780. * @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)
  127781. * @param engine is the instance of BABYLON.Engine to use to create the scene
  127782. * @param onSuccess a callback with the scene when import succeeds
  127783. * @param onProgress a callback with a progress event for each file being loaded
  127784. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127785. * @param pluginExtension the extension used to determine the plugin
  127786. * @returns The loaded plugin
  127787. */
  127788. 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>;
  127789. /**
  127790. * Load a scene
  127791. * @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)
  127792. * @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)
  127793. * @param engine is the instance of BABYLON.Engine to use to create the scene
  127794. * @param onProgress a callback with a progress event for each file being loaded
  127795. * @param pluginExtension the extension used to determine the plugin
  127796. * @returns The loaded scene
  127797. */
  127798. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  127799. /**
  127800. * Append a scene
  127801. * @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)
  127802. * @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)
  127803. * @param scene is the instance of BABYLON.Scene to append to
  127804. * @param onSuccess a callback with the scene when import succeeds
  127805. * @param onProgress a callback with a progress event for each file being loaded
  127806. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127807. * @param pluginExtension the extension used to determine the plugin
  127808. * @returns The loaded plugin
  127809. */
  127810. 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>;
  127811. /**
  127812. * Append a scene
  127813. * @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)
  127814. * @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)
  127815. * @param scene is the instance of BABYLON.Scene to append to
  127816. * @param onProgress a callback with a progress event for each file being loaded
  127817. * @param pluginExtension the extension used to determine the plugin
  127818. * @returns The given scene
  127819. */
  127820. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  127821. /**
  127822. * Load a scene into an asset container
  127823. * @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)
  127824. * @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)
  127825. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127826. * @param onSuccess a callback with the scene when import succeeds
  127827. * @param onProgress a callback with a progress event for each file being loaded
  127828. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127829. * @param pluginExtension the extension used to determine the plugin
  127830. * @returns The loaded plugin
  127831. */
  127832. 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>;
  127833. /**
  127834. * Load a scene into an asset container
  127835. * @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)
  127836. * @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)
  127837. * @param scene is the instance of Scene to append to
  127838. * @param onProgress a callback with a progress event for each file being loaded
  127839. * @param pluginExtension the extension used to determine the plugin
  127840. * @returns The loaded asset container
  127841. */
  127842. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  127843. /**
  127844. * Import animations from a file into a scene
  127845. * @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)
  127846. * @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)
  127847. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127848. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  127849. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  127850. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  127851. * @param onSuccess a callback with the scene when import succeeds
  127852. * @param onProgress a callback with a progress event for each file being loaded
  127853. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127854. * @param pluginExtension the extension used to determine the plugin
  127855. */
  127856. 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;
  127857. /**
  127858. * Import animations from a file into a scene
  127859. * @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)
  127860. * @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)
  127861. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127862. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  127863. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  127864. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  127865. * @param onSuccess a callback with the scene when import succeeds
  127866. * @param onProgress a callback with a progress event for each file being loaded
  127867. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127868. * @param pluginExtension the extension used to determine the plugin
  127869. * @returns the updated scene with imported animations
  127870. */
  127871. 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>;
  127872. }
  127873. }
  127874. declare module BABYLON {
  127875. /**
  127876. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  127877. */
  127878. export type MotionControllerHandedness = "none" | "left" | "right";
  127879. /**
  127880. * The type of components available in motion controllers.
  127881. * This is not the name of the component.
  127882. */
  127883. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  127884. /**
  127885. * The state of a controller component
  127886. */
  127887. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  127888. /**
  127889. * The schema of motion controller layout.
  127890. * No object will be initialized using this interface
  127891. * This is used just to define the profile.
  127892. */
  127893. export interface IMotionControllerLayout {
  127894. /**
  127895. * Path to load the assets. Usually relative to the base path
  127896. */
  127897. assetPath: string;
  127898. /**
  127899. * Available components (unsorted)
  127900. */
  127901. components: {
  127902. /**
  127903. * A map of component Ids
  127904. */
  127905. [componentId: string]: {
  127906. /**
  127907. * The type of input the component outputs
  127908. */
  127909. type: MotionControllerComponentType;
  127910. /**
  127911. * The indices of this component in the gamepad object
  127912. */
  127913. gamepadIndices: {
  127914. /**
  127915. * Index of button
  127916. */
  127917. button?: number;
  127918. /**
  127919. * If available, index of x-axis
  127920. */
  127921. xAxis?: number;
  127922. /**
  127923. * If available, index of y-axis
  127924. */
  127925. yAxis?: number;
  127926. };
  127927. /**
  127928. * The mesh's root node name
  127929. */
  127930. rootNodeName: string;
  127931. /**
  127932. * Animation definitions for this model
  127933. */
  127934. visualResponses: {
  127935. [stateKey: string]: {
  127936. /**
  127937. * What property will be animated
  127938. */
  127939. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  127940. /**
  127941. * What states influence this visual response
  127942. */
  127943. states: MotionControllerComponentStateType[];
  127944. /**
  127945. * Type of animation - movement or visibility
  127946. */
  127947. valueNodeProperty: "transform" | "visibility";
  127948. /**
  127949. * Base node name to move. Its position will be calculated according to the min and max nodes
  127950. */
  127951. valueNodeName?: string;
  127952. /**
  127953. * Minimum movement node
  127954. */
  127955. minNodeName?: string;
  127956. /**
  127957. * Max movement node
  127958. */
  127959. maxNodeName?: string;
  127960. };
  127961. };
  127962. /**
  127963. * If touch enabled, what is the name of node to display user feedback
  127964. */
  127965. touchPointNodeName?: string;
  127966. };
  127967. };
  127968. /**
  127969. * Is it xr standard mapping or not
  127970. */
  127971. gamepadMapping: "" | "xr-standard";
  127972. /**
  127973. * Base root node of this entire model
  127974. */
  127975. rootNodeName: string;
  127976. /**
  127977. * Defines the main button component id
  127978. */
  127979. selectComponentId: string;
  127980. }
  127981. /**
  127982. * A definition for the layout map in the input profile
  127983. */
  127984. export interface IMotionControllerLayoutMap {
  127985. /**
  127986. * Layouts with handedness type as a key
  127987. */
  127988. [handedness: string]: IMotionControllerLayout;
  127989. }
  127990. /**
  127991. * The XR Input profile schema
  127992. * Profiles can be found here:
  127993. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  127994. */
  127995. export interface IMotionControllerProfile {
  127996. /**
  127997. * fallback profiles for this profileId
  127998. */
  127999. fallbackProfileIds: string[];
  128000. /**
  128001. * The layout map, with handedness as key
  128002. */
  128003. layouts: IMotionControllerLayoutMap;
  128004. /**
  128005. * The id of this profile
  128006. * correlates to the profile(s) in the xrInput.profiles array
  128007. */
  128008. profileId: string;
  128009. }
  128010. /**
  128011. * A helper-interface for the 3 meshes needed for controller button animation
  128012. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  128013. */
  128014. export interface IMotionControllerButtonMeshMap {
  128015. /**
  128016. * the mesh that defines the pressed value mesh position.
  128017. * This is used to find the max-position of this button
  128018. */
  128019. pressedMesh: AbstractMesh;
  128020. /**
  128021. * the mesh that defines the unpressed value mesh position.
  128022. * This is used to find the min (or initial) position of this button
  128023. */
  128024. unpressedMesh: AbstractMesh;
  128025. /**
  128026. * The mesh that will be changed when value changes
  128027. */
  128028. valueMesh: AbstractMesh;
  128029. }
  128030. /**
  128031. * A helper-interface for the 3 meshes needed for controller axis animation.
  128032. * This will be expanded when touchpad animations are fully supported
  128033. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  128034. */
  128035. export interface IMotionControllerMeshMap {
  128036. /**
  128037. * the mesh that defines the maximum value mesh position.
  128038. */
  128039. maxMesh?: AbstractMesh;
  128040. /**
  128041. * the mesh that defines the minimum value mesh position.
  128042. */
  128043. minMesh?: AbstractMesh;
  128044. /**
  128045. * The mesh that will be changed when axis value changes
  128046. */
  128047. valueMesh?: AbstractMesh;
  128048. }
  128049. /**
  128050. * The elements needed for change-detection of the gamepad objects in motion controllers
  128051. */
  128052. export interface IMinimalMotionControllerObject {
  128053. /**
  128054. * Available axes of this controller
  128055. */
  128056. axes: number[];
  128057. /**
  128058. * An array of available buttons
  128059. */
  128060. buttons: Array<{
  128061. /**
  128062. * Value of the button/trigger
  128063. */
  128064. value: number;
  128065. /**
  128066. * If the button/trigger is currently touched
  128067. */
  128068. touched: boolean;
  128069. /**
  128070. * If the button/trigger is currently pressed
  128071. */
  128072. pressed: boolean;
  128073. }>;
  128074. /**
  128075. * EXPERIMENTAL haptic support.
  128076. */
  128077. hapticActuators?: Array<{
  128078. pulse: (value: number, duration: number) => Promise<boolean>;
  128079. }>;
  128080. }
  128081. /**
  128082. * An Abstract Motion controller
  128083. * This class receives an xrInput and a profile layout and uses those to initialize the components
  128084. * Each component has an observable to check for changes in value and state
  128085. */
  128086. export abstract class WebXRAbstractMotionController implements IDisposable {
  128087. protected scene: Scene;
  128088. protected layout: IMotionControllerLayout;
  128089. /**
  128090. * The gamepad object correlating to this controller
  128091. */
  128092. gamepadObject: IMinimalMotionControllerObject;
  128093. /**
  128094. * handedness (left/right/none) of this controller
  128095. */
  128096. handedness: MotionControllerHandedness;
  128097. private _initComponent;
  128098. private _modelReady;
  128099. /**
  128100. * A map of components (WebXRControllerComponent) in this motion controller
  128101. * Components have a ComponentType and can also have both button and axis definitions
  128102. */
  128103. readonly components: {
  128104. [id: string]: WebXRControllerComponent;
  128105. };
  128106. /**
  128107. * Disable the model's animation. Can be set at any time.
  128108. */
  128109. disableAnimation: boolean;
  128110. /**
  128111. * Observers registered here will be triggered when the model of this controller is done loading
  128112. */
  128113. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  128114. /**
  128115. * The profile id of this motion controller
  128116. */
  128117. abstract profileId: string;
  128118. /**
  128119. * The root mesh of the model. It is null if the model was not yet initialized
  128120. */
  128121. rootMesh: Nullable<AbstractMesh>;
  128122. /**
  128123. * constructs a new abstract motion controller
  128124. * @param scene the scene to which the model of the controller will be added
  128125. * @param layout The profile layout to load
  128126. * @param gamepadObject The gamepad object correlating to this controller
  128127. * @param handedness handedness (left/right/none) of this controller
  128128. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  128129. */
  128130. constructor(scene: Scene, layout: IMotionControllerLayout,
  128131. /**
  128132. * The gamepad object correlating to this controller
  128133. */
  128134. gamepadObject: IMinimalMotionControllerObject,
  128135. /**
  128136. * handedness (left/right/none) of this controller
  128137. */
  128138. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  128139. /**
  128140. * Dispose this controller, the model mesh and all its components
  128141. */
  128142. dispose(): void;
  128143. /**
  128144. * Returns all components of specific type
  128145. * @param type the type to search for
  128146. * @return an array of components with this type
  128147. */
  128148. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  128149. /**
  128150. * get a component based an its component id as defined in layout.components
  128151. * @param id the id of the component
  128152. * @returns the component correlates to the id or undefined if not found
  128153. */
  128154. getComponent(id: string): WebXRControllerComponent;
  128155. /**
  128156. * Get the list of components available in this motion controller
  128157. * @returns an array of strings correlating to available components
  128158. */
  128159. getComponentIds(): string[];
  128160. /**
  128161. * Get the first component of specific type
  128162. * @param type type of component to find
  128163. * @return a controller component or null if not found
  128164. */
  128165. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  128166. /**
  128167. * Get the main (Select) component of this controller as defined in the layout
  128168. * @returns the main component of this controller
  128169. */
  128170. getMainComponent(): WebXRControllerComponent;
  128171. /**
  128172. * Loads the model correlating to this controller
  128173. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  128174. * @returns A promise fulfilled with the result of the model loading
  128175. */
  128176. loadModel(): Promise<boolean>;
  128177. /**
  128178. * Update this model using the current XRFrame
  128179. * @param xrFrame the current xr frame to use and update the model
  128180. */
  128181. updateFromXRFrame(xrFrame: XRFrame): void;
  128182. /**
  128183. * Backwards compatibility due to a deeply-integrated typo
  128184. */
  128185. get handness(): XREye;
  128186. /**
  128187. * Pulse (vibrate) this controller
  128188. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  128189. * Consecutive calls to this function will cancel the last pulse call
  128190. *
  128191. * @param value the strength of the pulse in 0.0...1.0 range
  128192. * @param duration Duration of the pulse in milliseconds
  128193. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  128194. * @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
  128195. */
  128196. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  128197. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128198. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128199. /**
  128200. * Moves the axis on the controller mesh based on its current state
  128201. * @param axis the index of the axis
  128202. * @param axisValue the value of the axis which determines the meshes new position
  128203. * @hidden
  128204. */
  128205. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  128206. /**
  128207. * Update the model itself with the current frame data
  128208. * @param xrFrame the frame to use for updating the model mesh
  128209. */
  128210. protected updateModel(xrFrame: XRFrame): void;
  128211. /**
  128212. * Get the filename and path for this controller's model
  128213. * @returns a map of filename and path
  128214. */
  128215. protected abstract _getFilenameAndPath(): {
  128216. filename: string;
  128217. path: string;
  128218. };
  128219. /**
  128220. * This function is called before the mesh is loaded. It checks for loading constraints.
  128221. * For example, this function can check if the GLB loader is available
  128222. * If this function returns false, the generic controller will be loaded instead
  128223. * @returns Is the client ready to load the mesh
  128224. */
  128225. protected abstract _getModelLoadingConstraints(): boolean;
  128226. /**
  128227. * This function will be called after the model was successfully loaded and can be used
  128228. * for mesh transformations before it is available for the user
  128229. * @param meshes the loaded meshes
  128230. */
  128231. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  128232. /**
  128233. * Set the root mesh for this controller. Important for the WebXR controller class
  128234. * @param meshes the loaded meshes
  128235. */
  128236. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  128237. /**
  128238. * A function executed each frame that updates the mesh (if needed)
  128239. * @param xrFrame the current xrFrame
  128240. */
  128241. protected abstract _updateModel(xrFrame: XRFrame): void;
  128242. private _getGenericFilenameAndPath;
  128243. private _getGenericParentMesh;
  128244. }
  128245. }
  128246. declare module BABYLON {
  128247. /**
  128248. * A generic trigger-only motion controller for WebXR
  128249. */
  128250. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  128251. /**
  128252. * Static version of the profile id of this controller
  128253. */
  128254. static ProfileId: string;
  128255. profileId: string;
  128256. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  128257. protected _getFilenameAndPath(): {
  128258. filename: string;
  128259. path: string;
  128260. };
  128261. protected _getModelLoadingConstraints(): boolean;
  128262. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  128263. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128264. protected _updateModel(): void;
  128265. }
  128266. }
  128267. declare module BABYLON {
  128268. /**
  128269. * Class containing static functions to help procedurally build meshes
  128270. */
  128271. export class SphereBuilder {
  128272. /**
  128273. * Creates a sphere mesh
  128274. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  128275. * * 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`)
  128276. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  128277. * * 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
  128278. * * 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)
  128279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128280. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128282. * @param name defines the name of the mesh
  128283. * @param options defines the options used to create the mesh
  128284. * @param scene defines the hosting scene
  128285. * @returns the sphere mesh
  128286. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  128287. */
  128288. static CreateSphere(name: string, options: {
  128289. segments?: number;
  128290. diameter?: number;
  128291. diameterX?: number;
  128292. diameterY?: number;
  128293. diameterZ?: number;
  128294. arc?: number;
  128295. slice?: number;
  128296. sideOrientation?: number;
  128297. frontUVs?: Vector4;
  128298. backUVs?: Vector4;
  128299. updatable?: boolean;
  128300. }, scene?: Nullable<Scene>): Mesh;
  128301. }
  128302. }
  128303. declare module BABYLON {
  128304. /**
  128305. * A profiled motion controller has its profile loaded from an online repository.
  128306. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  128307. */
  128308. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  128309. private _repositoryUrl;
  128310. private _buttonMeshMapping;
  128311. private _touchDots;
  128312. /**
  128313. * The profile ID of this controller. Will be populated when the controller initializes.
  128314. */
  128315. profileId: string;
  128316. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  128317. dispose(): void;
  128318. protected _getFilenameAndPath(): {
  128319. filename: string;
  128320. path: string;
  128321. };
  128322. protected _getModelLoadingConstraints(): boolean;
  128323. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  128324. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128325. protected _updateModel(_xrFrame: XRFrame): void;
  128326. }
  128327. }
  128328. declare module BABYLON {
  128329. /**
  128330. * A construction function type to create a new controller based on an xrInput object
  128331. */
  128332. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  128333. /**
  128334. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  128335. *
  128336. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  128337. * it should be replaced with auto-loaded controllers.
  128338. *
  128339. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  128340. */
  128341. export class WebXRMotionControllerManager {
  128342. private static _AvailableControllers;
  128343. private static _Fallbacks;
  128344. private static _ProfileLoadingPromises;
  128345. private static _ProfilesList;
  128346. /**
  128347. * The base URL of the online controller repository. Can be changed at any time.
  128348. */
  128349. static BaseRepositoryUrl: string;
  128350. /**
  128351. * Which repository gets priority - local or online
  128352. */
  128353. static PrioritizeOnlineRepository: boolean;
  128354. /**
  128355. * Use the online repository, or use only locally-defined controllers
  128356. */
  128357. static UseOnlineRepository: boolean;
  128358. /**
  128359. * Clear the cache used for profile loading and reload when requested again
  128360. */
  128361. static ClearProfilesCache(): void;
  128362. /**
  128363. * Register the default fallbacks.
  128364. * This function is called automatically when this file is imported.
  128365. */
  128366. static DefaultFallbacks(): void;
  128367. /**
  128368. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  128369. * @param profileId the profile to which a fallback needs to be found
  128370. * @return an array with corresponding fallback profiles
  128371. */
  128372. static FindFallbackWithProfileId(profileId: string): string[];
  128373. /**
  128374. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  128375. * The order of search:
  128376. *
  128377. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  128378. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  128379. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  128380. * 4) return the generic trigger controller if none were found
  128381. *
  128382. * @param xrInput the xrInput to which a new controller is initialized
  128383. * @param scene the scene to which the model will be added
  128384. * @param forceProfile force a certain profile for this controller
  128385. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  128386. */
  128387. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  128388. /**
  128389. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  128390. *
  128391. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  128392. *
  128393. * @param type the profile type to register
  128394. * @param constructFunction the function to be called when loading this profile
  128395. */
  128396. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  128397. /**
  128398. * Register a fallback to a specific profile.
  128399. * @param profileId the profileId that will receive the fallbacks
  128400. * @param fallbacks A list of fallback profiles
  128401. */
  128402. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  128403. /**
  128404. * Will update the list of profiles available in the repository
  128405. * @return a promise that resolves to a map of profiles available online
  128406. */
  128407. static UpdateProfilesList(): Promise<{
  128408. [profile: string]: string;
  128409. }>;
  128410. private static _LoadProfileFromRepository;
  128411. private static _LoadProfilesFromAvailableControllers;
  128412. }
  128413. }
  128414. declare module BABYLON {
  128415. /**
  128416. * Configuration options for the WebXR controller creation
  128417. */
  128418. export interface IWebXRControllerOptions {
  128419. /**
  128420. * Should the controller mesh be animated when a user interacts with it
  128421. * The pressed buttons / thumbstick and touchpad animations will be disabled
  128422. */
  128423. disableMotionControllerAnimation?: boolean;
  128424. /**
  128425. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  128426. */
  128427. doNotLoadControllerMesh?: boolean;
  128428. /**
  128429. * Force a specific controller type for this controller.
  128430. * This can be used when creating your own profile or when testing different controllers
  128431. */
  128432. forceControllerProfile?: string;
  128433. /**
  128434. * Defines a rendering group ID for meshes that will be loaded.
  128435. * This is for the default controllers only.
  128436. */
  128437. renderingGroupId?: number;
  128438. }
  128439. /**
  128440. * Represents an XR controller
  128441. */
  128442. export class WebXRInputSource {
  128443. private _scene;
  128444. /** The underlying input source for the controller */
  128445. inputSource: XRInputSource;
  128446. private _options;
  128447. private _tmpVector;
  128448. private _uniqueId;
  128449. private _disposed;
  128450. /**
  128451. * 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
  128452. */
  128453. grip?: AbstractMesh;
  128454. /**
  128455. * If available, this is the gamepad object related to this controller.
  128456. * Using this object it is possible to get click events and trackpad changes of the
  128457. * webxr controller that is currently being used.
  128458. */
  128459. motionController?: WebXRAbstractMotionController;
  128460. /**
  128461. * Event that fires when the controller is removed/disposed.
  128462. * The object provided as event data is this controller, after associated assets were disposed.
  128463. * uniqueId is still available.
  128464. */
  128465. onDisposeObservable: Observable<WebXRInputSource>;
  128466. /**
  128467. * Will be triggered when the mesh associated with the motion controller is done loading.
  128468. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  128469. * A shortened version of controller -> motion controller -> on mesh loaded.
  128470. */
  128471. onMeshLoadedObservable: Observable<AbstractMesh>;
  128472. /**
  128473. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  128474. */
  128475. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  128476. /**
  128477. * Pointer which can be used to select objects or attach a visible laser to
  128478. */
  128479. pointer: AbstractMesh;
  128480. /**
  128481. * Creates the input source object
  128482. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  128483. * @param _scene the scene which the controller should be associated to
  128484. * @param inputSource the underlying input source for the controller
  128485. * @param _options options for this controller creation
  128486. */
  128487. constructor(_scene: Scene,
  128488. /** The underlying input source for the controller */
  128489. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  128490. /**
  128491. * Get this controllers unique id
  128492. */
  128493. get uniqueId(): string;
  128494. /**
  128495. * Disposes of the object
  128496. */
  128497. dispose(): void;
  128498. /**
  128499. * Gets a world space ray coming from the pointer or grip
  128500. * @param result the resulting ray
  128501. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  128502. */
  128503. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  128504. /**
  128505. * Updates the controller pose based on the given XRFrame
  128506. * @param xrFrame xr frame to update the pose with
  128507. * @param referenceSpace reference space to use
  128508. */
  128509. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  128510. }
  128511. }
  128512. declare module BABYLON {
  128513. /**
  128514. * The schema for initialization options of the XR Input class
  128515. */
  128516. export interface IWebXRInputOptions {
  128517. /**
  128518. * If set to true no model will be automatically loaded
  128519. */
  128520. doNotLoadControllerMeshes?: boolean;
  128521. /**
  128522. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  128523. * If not found, the xr input profile data will be used.
  128524. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  128525. */
  128526. forceInputProfile?: string;
  128527. /**
  128528. * Do not send a request to the controller repository to load the profile.
  128529. *
  128530. * Instead, use the controllers available in babylon itself.
  128531. */
  128532. disableOnlineControllerRepository?: boolean;
  128533. /**
  128534. * A custom URL for the controllers repository
  128535. */
  128536. customControllersRepositoryURL?: string;
  128537. /**
  128538. * Should the controller model's components not move according to the user input
  128539. */
  128540. disableControllerAnimation?: boolean;
  128541. /**
  128542. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  128543. */
  128544. controllerOptions?: IWebXRControllerOptions;
  128545. }
  128546. /**
  128547. * XR input used to track XR inputs such as controllers/rays
  128548. */
  128549. export class WebXRInput implements IDisposable {
  128550. /**
  128551. * the xr session manager for this session
  128552. */
  128553. xrSessionManager: WebXRSessionManager;
  128554. /**
  128555. * the WebXR camera for this session. Mainly used for teleportation
  128556. */
  128557. xrCamera: WebXRCamera;
  128558. private readonly options;
  128559. /**
  128560. * XR controllers being tracked
  128561. */
  128562. controllers: Array<WebXRInputSource>;
  128563. private _frameObserver;
  128564. private _sessionEndedObserver;
  128565. private _sessionInitObserver;
  128566. /**
  128567. * Event when a controller has been connected/added
  128568. */
  128569. onControllerAddedObservable: Observable<WebXRInputSource>;
  128570. /**
  128571. * Event when a controller has been removed/disconnected
  128572. */
  128573. onControllerRemovedObservable: Observable<WebXRInputSource>;
  128574. /**
  128575. * Initializes the WebXRInput
  128576. * @param xrSessionManager the xr session manager for this session
  128577. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  128578. * @param options = initialization options for this xr input
  128579. */
  128580. constructor(
  128581. /**
  128582. * the xr session manager for this session
  128583. */
  128584. xrSessionManager: WebXRSessionManager,
  128585. /**
  128586. * the WebXR camera for this session. Mainly used for teleportation
  128587. */
  128588. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  128589. private _onInputSourcesChange;
  128590. private _addAndRemoveControllers;
  128591. /**
  128592. * Disposes of the object
  128593. */
  128594. dispose(): void;
  128595. }
  128596. }
  128597. declare module BABYLON {
  128598. /**
  128599. * This is the base class for all WebXR features.
  128600. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  128601. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  128602. */
  128603. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  128604. protected _xrSessionManager: WebXRSessionManager;
  128605. private _attached;
  128606. private _removeOnDetach;
  128607. /**
  128608. * Is this feature disposed?
  128609. */
  128610. isDisposed: boolean;
  128611. /**
  128612. * Should auto-attach be disabled?
  128613. */
  128614. disableAutoAttach: boolean;
  128615. /**
  128616. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  128617. */
  128618. xrNativeFeatureName: string;
  128619. /**
  128620. * Construct a new (abstract) WebXR feature
  128621. * @param _xrSessionManager the xr session manager for this feature
  128622. */
  128623. constructor(_xrSessionManager: WebXRSessionManager);
  128624. /**
  128625. * Is this feature attached
  128626. */
  128627. get attached(): boolean;
  128628. /**
  128629. * attach this feature
  128630. *
  128631. * @param force should attachment be forced (even when already attached)
  128632. * @returns true if successful, false is failed or already attached
  128633. */
  128634. attach(force?: boolean): boolean;
  128635. /**
  128636. * detach this feature.
  128637. *
  128638. * @returns true if successful, false if failed or already detached
  128639. */
  128640. detach(): boolean;
  128641. /**
  128642. * Dispose this feature and all of the resources attached
  128643. */
  128644. dispose(): void;
  128645. /**
  128646. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  128647. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  128648. *
  128649. * @returns whether or not the feature is compatible in this environment
  128650. */
  128651. isCompatible(): boolean;
  128652. /**
  128653. * This is used to register callbacks that will automatically be removed when detach is called.
  128654. * @param observable the observable to which the observer will be attached
  128655. * @param callback the callback to register
  128656. */
  128657. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  128658. /**
  128659. * Code in this function will be executed on each xrFrame received from the browser.
  128660. * This function will not execute after the feature is detached.
  128661. * @param _xrFrame the current frame
  128662. */
  128663. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  128664. }
  128665. }
  128666. declare module BABYLON {
  128667. /**
  128668. * Renders a layer on top of an existing scene
  128669. */
  128670. export class UtilityLayerRenderer implements IDisposable {
  128671. /** the original scene that will be rendered on top of */
  128672. originalScene: Scene;
  128673. private _pointerCaptures;
  128674. private _lastPointerEvents;
  128675. private static _DefaultUtilityLayer;
  128676. private static _DefaultKeepDepthUtilityLayer;
  128677. private _sharedGizmoLight;
  128678. private _renderCamera;
  128679. /**
  128680. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  128681. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  128682. * @returns the camera that is used when rendering the utility layer
  128683. */
  128684. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  128685. /**
  128686. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  128687. * @param cam the camera that should be used when rendering the utility layer
  128688. */
  128689. setRenderCamera(cam: Nullable<Camera>): void;
  128690. /**
  128691. * @hidden
  128692. * Light which used by gizmos to get light shading
  128693. */
  128694. _getSharedGizmoLight(): HemisphericLight;
  128695. /**
  128696. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  128697. */
  128698. pickUtilitySceneFirst: boolean;
  128699. /**
  128700. * 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)
  128701. */
  128702. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  128703. /**
  128704. * 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)
  128705. */
  128706. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  128707. /**
  128708. * The scene that is rendered on top of the original scene
  128709. */
  128710. utilityLayerScene: Scene;
  128711. /**
  128712. * If the utility layer should automatically be rendered on top of existing scene
  128713. */
  128714. shouldRender: boolean;
  128715. /**
  128716. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  128717. */
  128718. onlyCheckPointerDownEvents: boolean;
  128719. /**
  128720. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  128721. */
  128722. processAllEvents: boolean;
  128723. /**
  128724. * Observable raised when the pointer move from the utility layer scene to the main scene
  128725. */
  128726. onPointerOutObservable: Observable<number>;
  128727. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  128728. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  128729. private _afterRenderObserver;
  128730. private _sceneDisposeObserver;
  128731. private _originalPointerObserver;
  128732. /**
  128733. * Instantiates a UtilityLayerRenderer
  128734. * @param originalScene the original scene that will be rendered on top of
  128735. * @param handleEvents boolean indicating if the utility layer should handle events
  128736. */
  128737. constructor(
  128738. /** the original scene that will be rendered on top of */
  128739. originalScene: Scene, handleEvents?: boolean);
  128740. private _notifyObservers;
  128741. /**
  128742. * Renders the utility layers scene on top of the original scene
  128743. */
  128744. render(): void;
  128745. /**
  128746. * Disposes of the renderer
  128747. */
  128748. dispose(): void;
  128749. private _updateCamera;
  128750. }
  128751. }
  128752. declare module BABYLON {
  128753. /**
  128754. * Options interface for the pointer selection module
  128755. */
  128756. export interface IWebXRControllerPointerSelectionOptions {
  128757. /**
  128758. * if provided, this scene will be used to render meshes.
  128759. */
  128760. customUtilityLayerScene?: Scene;
  128761. /**
  128762. * 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)
  128763. * If not disabled, the last picked point will be used to execute a pointer up event
  128764. * If disabled, pointer up event will be triggered right after the pointer down event.
  128765. * Used in screen and gaze target ray mode only
  128766. */
  128767. disablePointerUpOnTouchOut: boolean;
  128768. /**
  128769. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  128770. */
  128771. forceGazeMode: boolean;
  128772. /**
  128773. * 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
  128774. * to start a new countdown to the pointer down event.
  128775. * Defaults to 1.
  128776. */
  128777. gazeModePointerMovedFactor?: number;
  128778. /**
  128779. * Different button type to use instead of the main component
  128780. */
  128781. overrideButtonId?: string;
  128782. /**
  128783. * use this rendering group id for the meshes (optional)
  128784. */
  128785. renderingGroupId?: number;
  128786. /**
  128787. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  128788. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  128789. * 3000 means 3 seconds between pointing at something and selecting it
  128790. */
  128791. timeToSelect?: number;
  128792. /**
  128793. * Should meshes created here be added to a utility layer or the main scene
  128794. */
  128795. useUtilityLayer?: boolean;
  128796. /**
  128797. * Optional WebXR camera to be used for gaze selection
  128798. */
  128799. gazeCamera?: WebXRCamera;
  128800. /**
  128801. * the xr input to use with this pointer selection
  128802. */
  128803. xrInput: WebXRInput;
  128804. }
  128805. /**
  128806. * A module that will enable pointer selection for motion controllers of XR Input Sources
  128807. */
  128808. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  128809. private readonly _options;
  128810. private static _idCounter;
  128811. private _attachController;
  128812. private _controllers;
  128813. private _scene;
  128814. private _tmpVectorForPickCompare;
  128815. /**
  128816. * The module's name
  128817. */
  128818. static readonly Name: string;
  128819. /**
  128820. * The (Babylon) version of this module.
  128821. * This is an integer representing the implementation version.
  128822. * This number does not correspond to the WebXR specs version
  128823. */
  128824. static readonly Version: number;
  128825. /**
  128826. * Disable lighting on the laser pointer (so it will always be visible)
  128827. */
  128828. disablePointerLighting: boolean;
  128829. /**
  128830. * Disable lighting on the selection mesh (so it will always be visible)
  128831. */
  128832. disableSelectionMeshLighting: boolean;
  128833. /**
  128834. * Should the laser pointer be displayed
  128835. */
  128836. displayLaserPointer: boolean;
  128837. /**
  128838. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  128839. */
  128840. displaySelectionMesh: boolean;
  128841. /**
  128842. * This color will be set to the laser pointer when selection is triggered
  128843. */
  128844. laserPointerPickedColor: Color3;
  128845. /**
  128846. * Default color of the laser pointer
  128847. */
  128848. laserPointerDefaultColor: Color3;
  128849. /**
  128850. * default color of the selection ring
  128851. */
  128852. selectionMeshDefaultColor: Color3;
  128853. /**
  128854. * This color will be applied to the selection ring when selection is triggered
  128855. */
  128856. selectionMeshPickedColor: Color3;
  128857. /**
  128858. * Optional filter to be used for ray selection. This predicate shares behavior with
  128859. * scene.pointerMovePredicate which takes priority if it is also assigned.
  128860. */
  128861. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  128862. /**
  128863. * constructs a new background remover module
  128864. * @param _xrSessionManager the session manager for this module
  128865. * @param _options read-only options to be used in this module
  128866. */
  128867. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  128868. /**
  128869. * attach this feature
  128870. * Will usually be called by the features manager
  128871. *
  128872. * @returns true if successful.
  128873. */
  128874. attach(): boolean;
  128875. /**
  128876. * detach this feature.
  128877. * Will usually be called by the features manager
  128878. *
  128879. * @returns true if successful.
  128880. */
  128881. detach(): boolean;
  128882. /**
  128883. * Will get the mesh under a specific pointer.
  128884. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  128885. * @param controllerId the controllerId to check
  128886. * @returns The mesh under pointer or null if no mesh is under the pointer
  128887. */
  128888. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  128889. /**
  128890. * Get the xr controller that correlates to the pointer id in the pointer event
  128891. *
  128892. * @param id the pointer id to search for
  128893. * @returns the controller that correlates to this id or null if not found
  128894. */
  128895. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  128896. protected _onXRFrame(_xrFrame: XRFrame): void;
  128897. private _attachGazeMode;
  128898. private _attachScreenRayMode;
  128899. private _attachTrackedPointerRayMode;
  128900. private _convertNormalToDirectionOfRay;
  128901. private _detachController;
  128902. private _generateNewMeshPair;
  128903. private _pickingMoved;
  128904. private _updatePointerDistance;
  128905. /** @hidden */
  128906. get lasterPointerDefaultColor(): Color3;
  128907. }
  128908. }
  128909. declare module BABYLON {
  128910. /**
  128911. * Button which can be used to enter a different mode of XR
  128912. */
  128913. export class WebXREnterExitUIButton {
  128914. /** button element */
  128915. element: HTMLElement;
  128916. /** XR initialization options for the button */
  128917. sessionMode: XRSessionMode;
  128918. /** Reference space type */
  128919. referenceSpaceType: XRReferenceSpaceType;
  128920. /**
  128921. * Creates a WebXREnterExitUIButton
  128922. * @param element button element
  128923. * @param sessionMode XR initialization session mode
  128924. * @param referenceSpaceType the type of reference space to be used
  128925. */
  128926. constructor(
  128927. /** button element */
  128928. element: HTMLElement,
  128929. /** XR initialization options for the button */
  128930. sessionMode: XRSessionMode,
  128931. /** Reference space type */
  128932. referenceSpaceType: XRReferenceSpaceType);
  128933. /**
  128934. * Extendable function which can be used to update the button's visuals when the state changes
  128935. * @param activeButton the current active button in the UI
  128936. */
  128937. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  128938. }
  128939. /**
  128940. * Options to create the webXR UI
  128941. */
  128942. export class WebXREnterExitUIOptions {
  128943. /**
  128944. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  128945. */
  128946. customButtons?: Array<WebXREnterExitUIButton>;
  128947. /**
  128948. * A reference space type to use when creating the default button.
  128949. * Default is local-floor
  128950. */
  128951. referenceSpaceType?: XRReferenceSpaceType;
  128952. /**
  128953. * Context to enter xr with
  128954. */
  128955. renderTarget?: Nullable<WebXRRenderTarget>;
  128956. /**
  128957. * A session mode to use when creating the default button.
  128958. * Default is immersive-vr
  128959. */
  128960. sessionMode?: XRSessionMode;
  128961. /**
  128962. * A list of optional features to init the session with
  128963. */
  128964. optionalFeatures?: string[];
  128965. /**
  128966. * A list of optional features to init the session with
  128967. */
  128968. requiredFeatures?: string[];
  128969. }
  128970. /**
  128971. * UI to allow the user to enter/exit XR mode
  128972. */
  128973. export class WebXREnterExitUI implements IDisposable {
  128974. private scene;
  128975. /** version of the options passed to this UI */
  128976. options: WebXREnterExitUIOptions;
  128977. private _activeButton;
  128978. private _buttons;
  128979. /**
  128980. * The HTML Div Element to which buttons are added.
  128981. */
  128982. readonly overlay: HTMLDivElement;
  128983. /**
  128984. * Fired every time the active button is changed.
  128985. *
  128986. * When xr is entered via a button that launches xr that button will be the callback parameter
  128987. *
  128988. * When exiting xr the callback parameter will be null)
  128989. */
  128990. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  128991. /**
  128992. *
  128993. * @param scene babylon scene object to use
  128994. * @param options (read-only) version of the options passed to this UI
  128995. */
  128996. private constructor();
  128997. /**
  128998. * Creates UI to allow the user to enter/exit XR mode
  128999. * @param scene the scene to add the ui to
  129000. * @param helper the xr experience helper to enter/exit xr with
  129001. * @param options options to configure the UI
  129002. * @returns the created ui
  129003. */
  129004. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  129005. /**
  129006. * Disposes of the XR UI component
  129007. */
  129008. dispose(): void;
  129009. private _updateButtons;
  129010. }
  129011. }
  129012. declare module BABYLON {
  129013. /**
  129014. * Class containing static functions to help procedurally build meshes
  129015. */
  129016. export class LinesBuilder {
  129017. /**
  129018. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  129019. * * 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
  129020. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  129021. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  129022. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  129023. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  129024. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129025. * * 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
  129026. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  129027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129028. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  129029. * @param name defines the name of the new line system
  129030. * @param options defines the options used to create the line system
  129031. * @param scene defines the hosting scene
  129032. * @returns a new line system mesh
  129033. */
  129034. static CreateLineSystem(name: string, options: {
  129035. lines: Vector3[][];
  129036. updatable?: boolean;
  129037. instance?: Nullable<LinesMesh>;
  129038. colors?: Nullable<Color4[][]>;
  129039. useVertexAlpha?: boolean;
  129040. }, scene: Nullable<Scene>): LinesMesh;
  129041. /**
  129042. * Creates a line mesh
  129043. * 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
  129044. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129045. * * The parameter `points` is an array successive Vector3
  129046. * * 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
  129047. * * The optional parameter `colors` is an array of successive Color4, one per line point
  129048. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  129049. * * When updating an instance, remember that only point positions can change, not the number of points
  129050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129051. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  129052. * @param name defines the name of the new line system
  129053. * @param options defines the options used to create the line system
  129054. * @param scene defines the hosting scene
  129055. * @returns a new line mesh
  129056. */
  129057. static CreateLines(name: string, options: {
  129058. points: Vector3[];
  129059. updatable?: boolean;
  129060. instance?: Nullable<LinesMesh>;
  129061. colors?: Color4[];
  129062. useVertexAlpha?: boolean;
  129063. }, scene?: Nullable<Scene>): LinesMesh;
  129064. /**
  129065. * Creates a dashed line mesh
  129066. * * 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
  129067. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129068. * * The parameter `points` is an array successive Vector3
  129069. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  129070. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  129071. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  129072. * * 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
  129073. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129074. * * When updating an instance, remember that only point positions can change, not the number of points
  129075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129076. * @param name defines the name of the mesh
  129077. * @param options defines the options used to create the mesh
  129078. * @param scene defines the hosting scene
  129079. * @returns the dashed line mesh
  129080. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  129081. */
  129082. static CreateDashedLines(name: string, options: {
  129083. points: Vector3[];
  129084. dashSize?: number;
  129085. gapSize?: number;
  129086. dashNb?: number;
  129087. updatable?: boolean;
  129088. instance?: LinesMesh;
  129089. useVertexAlpha?: boolean;
  129090. }, scene?: Nullable<Scene>): LinesMesh;
  129091. }
  129092. }
  129093. declare module BABYLON {
  129094. /**
  129095. * Construction options for a timer
  129096. */
  129097. export interface ITimerOptions<T> {
  129098. /**
  129099. * Time-to-end
  129100. */
  129101. timeout: number;
  129102. /**
  129103. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  129104. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  129105. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  129106. */
  129107. contextObservable: Observable<T>;
  129108. /**
  129109. * Optional parameters when adding an observer to the observable
  129110. */
  129111. observableParameters?: {
  129112. mask?: number;
  129113. insertFirst?: boolean;
  129114. scope?: any;
  129115. };
  129116. /**
  129117. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  129118. */
  129119. breakCondition?: (data?: ITimerData<T>) => boolean;
  129120. /**
  129121. * Will be triggered when the time condition has met
  129122. */
  129123. onEnded?: (data: ITimerData<any>) => void;
  129124. /**
  129125. * Will be triggered when the break condition has met (prematurely ended)
  129126. */
  129127. onAborted?: (data: ITimerData<any>) => void;
  129128. /**
  129129. * Optional function to execute on each tick (or count)
  129130. */
  129131. onTick?: (data: ITimerData<any>) => void;
  129132. }
  129133. /**
  129134. * An interface defining the data sent by the timer
  129135. */
  129136. export interface ITimerData<T> {
  129137. /**
  129138. * When did it start
  129139. */
  129140. startTime: number;
  129141. /**
  129142. * Time now
  129143. */
  129144. currentTime: number;
  129145. /**
  129146. * Time passed since started
  129147. */
  129148. deltaTime: number;
  129149. /**
  129150. * How much is completed, in [0.0...1.0].
  129151. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  129152. */
  129153. completeRate: number;
  129154. /**
  129155. * What the registered observable sent in the last count
  129156. */
  129157. payload: T;
  129158. }
  129159. /**
  129160. * The current state of the timer
  129161. */
  129162. export enum TimerState {
  129163. /**
  129164. * Timer initialized, not yet started
  129165. */
  129166. INIT = 0,
  129167. /**
  129168. * Timer started and counting
  129169. */
  129170. STARTED = 1,
  129171. /**
  129172. * Timer ended (whether aborted or time reached)
  129173. */
  129174. ENDED = 2
  129175. }
  129176. /**
  129177. * A simple version of the timer. Will take options and start the timer immediately after calling it
  129178. *
  129179. * @param options options with which to initialize this timer
  129180. */
  129181. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  129182. /**
  129183. * An advanced implementation of a timer class
  129184. */
  129185. export class AdvancedTimer<T = any> implements IDisposable {
  129186. /**
  129187. * Will notify each time the timer calculates the remaining time
  129188. */
  129189. onEachCountObservable: Observable<ITimerData<T>>;
  129190. /**
  129191. * Will trigger when the timer was aborted due to the break condition
  129192. */
  129193. onTimerAbortedObservable: Observable<ITimerData<T>>;
  129194. /**
  129195. * Will trigger when the timer ended successfully
  129196. */
  129197. onTimerEndedObservable: Observable<ITimerData<T>>;
  129198. /**
  129199. * Will trigger when the timer state has changed
  129200. */
  129201. onStateChangedObservable: Observable<TimerState>;
  129202. private _observer;
  129203. private _contextObservable;
  129204. private _observableParameters;
  129205. private _startTime;
  129206. private _timer;
  129207. private _state;
  129208. private _breakCondition;
  129209. private _timeToEnd;
  129210. private _breakOnNextTick;
  129211. /**
  129212. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  129213. * @param options construction options for this advanced timer
  129214. */
  129215. constructor(options: ITimerOptions<T>);
  129216. /**
  129217. * set a breaking condition for this timer. Default is to never break during count
  129218. * @param predicate the new break condition. Returns true to break, false otherwise
  129219. */
  129220. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  129221. /**
  129222. * Reset ALL associated observables in this advanced timer
  129223. */
  129224. clearObservables(): void;
  129225. /**
  129226. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  129227. *
  129228. * @param timeToEnd how much time to measure until timer ended
  129229. */
  129230. start(timeToEnd?: number): void;
  129231. /**
  129232. * Will force a stop on the next tick.
  129233. */
  129234. stop(): void;
  129235. /**
  129236. * Dispose this timer, clearing all resources
  129237. */
  129238. dispose(): void;
  129239. private _setState;
  129240. private _tick;
  129241. private _stop;
  129242. }
  129243. }
  129244. declare module BABYLON {
  129245. /**
  129246. * The options container for the teleportation module
  129247. */
  129248. export interface IWebXRTeleportationOptions {
  129249. /**
  129250. * if provided, this scene will be used to render meshes.
  129251. */
  129252. customUtilityLayerScene?: Scene;
  129253. /**
  129254. * Values to configure the default target mesh
  129255. */
  129256. defaultTargetMeshOptions?: {
  129257. /**
  129258. * Fill color of the teleportation area
  129259. */
  129260. teleportationFillColor?: string;
  129261. /**
  129262. * Border color for the teleportation area
  129263. */
  129264. teleportationBorderColor?: string;
  129265. /**
  129266. * Disable the mesh's animation sequence
  129267. */
  129268. disableAnimation?: boolean;
  129269. /**
  129270. * Disable lighting on the material or the ring and arrow
  129271. */
  129272. disableLighting?: boolean;
  129273. /**
  129274. * Override the default material of the torus and arrow
  129275. */
  129276. torusArrowMaterial?: Material;
  129277. };
  129278. /**
  129279. * A list of meshes to use as floor meshes.
  129280. * Meshes can be added and removed after initializing the feature using the
  129281. * addFloorMesh and removeFloorMesh functions
  129282. * If empty, rotation will still work
  129283. */
  129284. floorMeshes?: AbstractMesh[];
  129285. /**
  129286. * use this rendering group id for the meshes (optional)
  129287. */
  129288. renderingGroupId?: number;
  129289. /**
  129290. * Should teleportation move only to snap points
  129291. */
  129292. snapPointsOnly?: boolean;
  129293. /**
  129294. * An array of points to which the teleportation will snap to.
  129295. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  129296. */
  129297. snapPositions?: Vector3[];
  129298. /**
  129299. * How close should the teleportation ray be in order to snap to position.
  129300. * Default to 0.8 units (meters)
  129301. */
  129302. snapToPositionRadius?: number;
  129303. /**
  129304. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  129305. * If you want to support rotation, make sure your mesh has a direction indicator.
  129306. *
  129307. * When left untouched, the default mesh will be initialized.
  129308. */
  129309. teleportationTargetMesh?: AbstractMesh;
  129310. /**
  129311. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  129312. */
  129313. timeToTeleport?: number;
  129314. /**
  129315. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  129316. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  129317. */
  129318. useMainComponentOnly?: boolean;
  129319. /**
  129320. * Should meshes created here be added to a utility layer or the main scene
  129321. */
  129322. useUtilityLayer?: boolean;
  129323. /**
  129324. * Babylon XR Input class for controller
  129325. */
  129326. xrInput: WebXRInput;
  129327. /**
  129328. * Meshes that the teleportation ray cannot go through
  129329. */
  129330. pickBlockerMeshes?: AbstractMesh[];
  129331. }
  129332. /**
  129333. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  129334. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  129335. * the input of the attached controllers.
  129336. */
  129337. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  129338. private _options;
  129339. private _controllers;
  129340. private _currentTeleportationControllerId;
  129341. private _floorMeshes;
  129342. private _quadraticBezierCurve;
  129343. private _selectionFeature;
  129344. private _snapToPositions;
  129345. private _snappedToPoint;
  129346. private _teleportationRingMaterial?;
  129347. private _tmpRay;
  129348. private _tmpVector;
  129349. private _tmpQuaternion;
  129350. /**
  129351. * The module's name
  129352. */
  129353. static readonly Name: string;
  129354. /**
  129355. * The (Babylon) version of this module.
  129356. * This is an integer representing the implementation version.
  129357. * This number does not correspond to the webxr specs version
  129358. */
  129359. static readonly Version: number;
  129360. /**
  129361. * Is movement backwards enabled
  129362. */
  129363. backwardsMovementEnabled: boolean;
  129364. /**
  129365. * Distance to travel when moving backwards
  129366. */
  129367. backwardsTeleportationDistance: number;
  129368. /**
  129369. * The distance from the user to the inspection point in the direction of the controller
  129370. * A higher number will allow the user to move further
  129371. * defaults to 5 (meters, in xr units)
  129372. */
  129373. parabolicCheckRadius: number;
  129374. /**
  129375. * Should the module support parabolic ray on top of direct ray
  129376. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  129377. * Very helpful when moving between floors / different heights
  129378. */
  129379. parabolicRayEnabled: boolean;
  129380. /**
  129381. * How much rotation should be applied when rotating right and left
  129382. */
  129383. rotationAngle: number;
  129384. /**
  129385. * Is rotation enabled when moving forward?
  129386. * Disabling this feature will prevent the user from deciding the direction when teleporting
  129387. */
  129388. rotationEnabled: boolean;
  129389. /**
  129390. * constructs a new anchor system
  129391. * @param _xrSessionManager an instance of WebXRSessionManager
  129392. * @param _options configuration object for this feature
  129393. */
  129394. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  129395. /**
  129396. * Get the snapPointsOnly flag
  129397. */
  129398. get snapPointsOnly(): boolean;
  129399. /**
  129400. * Sets the snapPointsOnly flag
  129401. * @param snapToPoints should teleportation be exclusively to snap points
  129402. */
  129403. set snapPointsOnly(snapToPoints: boolean);
  129404. /**
  129405. * Add a new mesh to the floor meshes array
  129406. * @param mesh the mesh to use as floor mesh
  129407. */
  129408. addFloorMesh(mesh: AbstractMesh): void;
  129409. /**
  129410. * Add a new snap-to point to fix teleportation to this position
  129411. * @param newSnapPoint The new Snap-To point
  129412. */
  129413. addSnapPoint(newSnapPoint: Vector3): void;
  129414. attach(): boolean;
  129415. detach(): boolean;
  129416. dispose(): void;
  129417. /**
  129418. * Remove a mesh from the floor meshes array
  129419. * @param mesh the mesh to remove
  129420. */
  129421. removeFloorMesh(mesh: AbstractMesh): void;
  129422. /**
  129423. * Remove a mesh from the floor meshes array using its name
  129424. * @param name the mesh name to remove
  129425. */
  129426. removeFloorMeshByName(name: string): void;
  129427. /**
  129428. * 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
  129429. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  129430. * @returns was the point found and removed or not
  129431. */
  129432. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  129433. /**
  129434. * This function sets a selection feature that will be disabled when
  129435. * the forward ray is shown and will be reattached when hidden.
  129436. * This is used to remove the selection rays when moving.
  129437. * @param selectionFeature the feature to disable when forward movement is enabled
  129438. */
  129439. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  129440. protected _onXRFrame(_xrFrame: XRFrame): void;
  129441. private _attachController;
  129442. private _createDefaultTargetMesh;
  129443. private _detachController;
  129444. private _findClosestSnapPointWithRadius;
  129445. private _setTargetMeshPosition;
  129446. private _setTargetMeshVisibility;
  129447. private _showParabolicPath;
  129448. private _teleportForward;
  129449. }
  129450. }
  129451. declare module BABYLON {
  129452. /**
  129453. * Options for the default xr helper
  129454. */
  129455. export class WebXRDefaultExperienceOptions {
  129456. /**
  129457. * Enable or disable default UI to enter XR
  129458. */
  129459. disableDefaultUI?: boolean;
  129460. /**
  129461. * Should teleportation not initialize. defaults to false.
  129462. */
  129463. disableTeleportation?: boolean;
  129464. /**
  129465. * Floor meshes that will be used for teleport
  129466. */
  129467. floorMeshes?: Array<AbstractMesh>;
  129468. /**
  129469. * If set to true, the first frame will not be used to reset position
  129470. * The first frame is mainly used when copying transformation from the old camera
  129471. * Mainly used in AR
  129472. */
  129473. ignoreNativeCameraTransformation?: boolean;
  129474. /**
  129475. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  129476. */
  129477. inputOptions?: IWebXRInputOptions;
  129478. /**
  129479. * optional configuration for the output canvas
  129480. */
  129481. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  129482. /**
  129483. * optional UI options. This can be used among other to change session mode and reference space type
  129484. */
  129485. uiOptions?: WebXREnterExitUIOptions;
  129486. /**
  129487. * When loading teleportation and pointer select, use stable versions instead of latest.
  129488. */
  129489. useStablePlugins?: boolean;
  129490. /**
  129491. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  129492. */
  129493. renderingGroupId?: number;
  129494. /**
  129495. * A list of optional features to init the session with
  129496. * If set to true, all features we support will be added
  129497. */
  129498. optionalFeatures?: boolean | string[];
  129499. }
  129500. /**
  129501. * Default experience which provides a similar setup to the previous webVRExperience
  129502. */
  129503. export class WebXRDefaultExperience {
  129504. /**
  129505. * Base experience
  129506. */
  129507. baseExperience: WebXRExperienceHelper;
  129508. /**
  129509. * Enables ui for entering/exiting xr
  129510. */
  129511. enterExitUI: WebXREnterExitUI;
  129512. /**
  129513. * Input experience extension
  129514. */
  129515. input: WebXRInput;
  129516. /**
  129517. * Enables laser pointer and selection
  129518. */
  129519. pointerSelection: WebXRControllerPointerSelection;
  129520. /**
  129521. * Default target xr should render to
  129522. */
  129523. renderTarget: WebXRRenderTarget;
  129524. /**
  129525. * Enables teleportation
  129526. */
  129527. teleportation: WebXRMotionControllerTeleportation;
  129528. private constructor();
  129529. /**
  129530. * Creates the default xr experience
  129531. * @param scene scene
  129532. * @param options options for basic configuration
  129533. * @returns resulting WebXRDefaultExperience
  129534. */
  129535. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  129536. /**
  129537. * DIsposes of the experience helper
  129538. */
  129539. dispose(): void;
  129540. }
  129541. }
  129542. declare module BABYLON {
  129543. /**
  129544. * Options to modify the vr teleportation behavior.
  129545. */
  129546. export interface VRTeleportationOptions {
  129547. /**
  129548. * The name of the mesh which should be used as the teleportation floor. (default: null)
  129549. */
  129550. floorMeshName?: string;
  129551. /**
  129552. * A list of meshes to be used as the teleportation floor. (default: empty)
  129553. */
  129554. floorMeshes?: Mesh[];
  129555. /**
  129556. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  129557. */
  129558. teleportationMode?: number;
  129559. /**
  129560. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  129561. */
  129562. teleportationTime?: number;
  129563. /**
  129564. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  129565. */
  129566. teleportationSpeed?: number;
  129567. /**
  129568. * The easing function used in the animation or null for Linear. (default CircleEase)
  129569. */
  129570. easingFunction?: EasingFunction;
  129571. }
  129572. /**
  129573. * Options to modify the vr experience helper's behavior.
  129574. */
  129575. export interface VRExperienceHelperOptions extends WebVROptions {
  129576. /**
  129577. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  129578. */
  129579. createDeviceOrientationCamera?: boolean;
  129580. /**
  129581. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  129582. */
  129583. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  129584. /**
  129585. * Uses the main button on the controller to toggle the laser casted. (default: true)
  129586. */
  129587. laserToggle?: boolean;
  129588. /**
  129589. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  129590. */
  129591. floorMeshes?: Mesh[];
  129592. /**
  129593. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  129594. */
  129595. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  129596. /**
  129597. * Defines if WebXR should be used instead of WebVR (if available)
  129598. */
  129599. useXR?: boolean;
  129600. }
  129601. /**
  129602. * Event containing information after VR has been entered
  129603. */
  129604. export class OnAfterEnteringVRObservableEvent {
  129605. /**
  129606. * If entering vr was successful
  129607. */
  129608. success: boolean;
  129609. }
  129610. /**
  129611. * Helps to quickly add VR support to an existing scene.
  129612. * See https://doc.babylonjs.com/how_to/webvr_helper
  129613. */
  129614. export class VRExperienceHelper {
  129615. /** Options to modify the vr experience helper's behavior. */
  129616. webVROptions: VRExperienceHelperOptions;
  129617. private _scene;
  129618. private _position;
  129619. private _btnVR;
  129620. private _btnVRDisplayed;
  129621. private _webVRsupported;
  129622. private _webVRready;
  129623. private _webVRrequesting;
  129624. private _webVRpresenting;
  129625. private _hasEnteredVR;
  129626. private _fullscreenVRpresenting;
  129627. private _inputElement;
  129628. private _webVRCamera;
  129629. private _vrDeviceOrientationCamera;
  129630. private _deviceOrientationCamera;
  129631. private _existingCamera;
  129632. private _onKeyDown;
  129633. private _onVrDisplayPresentChange;
  129634. private _onVRDisplayChanged;
  129635. private _onVRRequestPresentStart;
  129636. private _onVRRequestPresentComplete;
  129637. /**
  129638. * 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)
  129639. */
  129640. enableGazeEvenWhenNoPointerLock: boolean;
  129641. /**
  129642. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  129643. */
  129644. exitVROnDoubleTap: boolean;
  129645. /**
  129646. * Observable raised right before entering VR.
  129647. */
  129648. onEnteringVRObservable: Observable<VRExperienceHelper>;
  129649. /**
  129650. * Observable raised when entering VR has completed.
  129651. */
  129652. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  129653. /**
  129654. * Observable raised when exiting VR.
  129655. */
  129656. onExitingVRObservable: Observable<VRExperienceHelper>;
  129657. /**
  129658. * Observable raised when controller mesh is loaded.
  129659. */
  129660. onControllerMeshLoadedObservable: Observable<WebVRController>;
  129661. /** Return this.onEnteringVRObservable
  129662. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  129663. */
  129664. get onEnteringVR(): Observable<VRExperienceHelper>;
  129665. /** Return this.onExitingVRObservable
  129666. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  129667. */
  129668. get onExitingVR(): Observable<VRExperienceHelper>;
  129669. /** Return this.onControllerMeshLoadedObservable
  129670. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  129671. */
  129672. get onControllerMeshLoaded(): Observable<WebVRController>;
  129673. private _rayLength;
  129674. private _useCustomVRButton;
  129675. private _teleportationRequested;
  129676. private _teleportActive;
  129677. private _floorMeshName;
  129678. private _floorMeshesCollection;
  129679. private _teleportationMode;
  129680. private _teleportationTime;
  129681. private _teleportationSpeed;
  129682. private _teleportationEasing;
  129683. private _rotationAllowed;
  129684. private _teleportBackwardsVector;
  129685. private _teleportationTarget;
  129686. private _isDefaultTeleportationTarget;
  129687. private _postProcessMove;
  129688. private _teleportationFillColor;
  129689. private _teleportationBorderColor;
  129690. private _rotationAngle;
  129691. private _haloCenter;
  129692. private _cameraGazer;
  129693. private _padSensibilityUp;
  129694. private _padSensibilityDown;
  129695. private _leftController;
  129696. private _rightController;
  129697. private _gazeColor;
  129698. private _laserColor;
  129699. private _pickedLaserColor;
  129700. private _pickedGazeColor;
  129701. /**
  129702. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  129703. */
  129704. onNewMeshSelected: Observable<AbstractMesh>;
  129705. /**
  129706. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  129707. * This observable will provide the mesh and the controller used to select the mesh
  129708. */
  129709. onMeshSelectedWithController: Observable<{
  129710. mesh: AbstractMesh;
  129711. controller: WebVRController;
  129712. }>;
  129713. /**
  129714. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  129715. */
  129716. onNewMeshPicked: Observable<PickingInfo>;
  129717. private _circleEase;
  129718. /**
  129719. * Observable raised before camera teleportation
  129720. */
  129721. onBeforeCameraTeleport: Observable<Vector3>;
  129722. /**
  129723. * Observable raised after camera teleportation
  129724. */
  129725. onAfterCameraTeleport: Observable<Vector3>;
  129726. /**
  129727. * Observable raised when current selected mesh gets unselected
  129728. */
  129729. onSelectedMeshUnselected: Observable<AbstractMesh>;
  129730. private _raySelectionPredicate;
  129731. /**
  129732. * To be optionaly changed by user to define custom ray selection
  129733. */
  129734. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129735. /**
  129736. * To be optionaly changed by user to define custom selection logic (after ray selection)
  129737. */
  129738. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  129739. /**
  129740. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  129741. */
  129742. teleportationEnabled: boolean;
  129743. private _defaultHeight;
  129744. private _teleportationInitialized;
  129745. private _interactionsEnabled;
  129746. private _interactionsRequested;
  129747. private _displayGaze;
  129748. private _displayLaserPointer;
  129749. /**
  129750. * The mesh used to display where the user is going to teleport.
  129751. */
  129752. get teleportationTarget(): Mesh;
  129753. /**
  129754. * Sets the mesh to be used to display where the user is going to teleport.
  129755. */
  129756. set teleportationTarget(value: Mesh);
  129757. /**
  129758. * 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
  129759. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  129760. * See https://doc.babylonjs.com/resources/baking_transformations
  129761. */
  129762. get gazeTrackerMesh(): Mesh;
  129763. set gazeTrackerMesh(value: Mesh);
  129764. /**
  129765. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  129766. */
  129767. updateGazeTrackerScale: boolean;
  129768. /**
  129769. * If the gaze trackers color should be updated when selecting meshes
  129770. */
  129771. updateGazeTrackerColor: boolean;
  129772. /**
  129773. * If the controller laser color should be updated when selecting meshes
  129774. */
  129775. updateControllerLaserColor: boolean;
  129776. /**
  129777. * The gaze tracking mesh corresponding to the left controller
  129778. */
  129779. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  129780. /**
  129781. * The gaze tracking mesh corresponding to the right controller
  129782. */
  129783. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  129784. /**
  129785. * If the ray of the gaze should be displayed.
  129786. */
  129787. get displayGaze(): boolean;
  129788. /**
  129789. * Sets if the ray of the gaze should be displayed.
  129790. */
  129791. set displayGaze(value: boolean);
  129792. /**
  129793. * If the ray of the LaserPointer should be displayed.
  129794. */
  129795. get displayLaserPointer(): boolean;
  129796. /**
  129797. * Sets if the ray of the LaserPointer should be displayed.
  129798. */
  129799. set displayLaserPointer(value: boolean);
  129800. /**
  129801. * The deviceOrientationCamera used as the camera when not in VR.
  129802. */
  129803. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  129804. /**
  129805. * Based on the current WebVR support, returns the current VR camera used.
  129806. */
  129807. get currentVRCamera(): Nullable<Camera>;
  129808. /**
  129809. * The webVRCamera which is used when in VR.
  129810. */
  129811. get webVRCamera(): WebVRFreeCamera;
  129812. /**
  129813. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  129814. */
  129815. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  129816. /**
  129817. * The html button that is used to trigger entering into VR.
  129818. */
  129819. get vrButton(): Nullable<HTMLButtonElement>;
  129820. private get _teleportationRequestInitiated();
  129821. /**
  129822. * Defines whether or not Pointer lock should be requested when switching to
  129823. * full screen.
  129824. */
  129825. requestPointerLockOnFullScreen: boolean;
  129826. /**
  129827. * If asking to force XR, this will be populated with the default xr experience
  129828. */
  129829. xr: WebXRDefaultExperience;
  129830. /**
  129831. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  129832. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  129833. */
  129834. xrTestDone: boolean;
  129835. /**
  129836. * Instantiates a VRExperienceHelper.
  129837. * Helps to quickly add VR support to an existing scene.
  129838. * @param scene The scene the VRExperienceHelper belongs to.
  129839. * @param webVROptions Options to modify the vr experience helper's behavior.
  129840. */
  129841. constructor(scene: Scene,
  129842. /** Options to modify the vr experience helper's behavior. */
  129843. webVROptions?: VRExperienceHelperOptions);
  129844. private completeVRInit;
  129845. private _onDefaultMeshLoaded;
  129846. private _onResize;
  129847. private _onFullscreenChange;
  129848. /**
  129849. * Gets a value indicating if we are currently in VR mode.
  129850. */
  129851. get isInVRMode(): boolean;
  129852. private onVrDisplayPresentChange;
  129853. private onVRDisplayChanged;
  129854. private moveButtonToBottomRight;
  129855. private displayVRButton;
  129856. private updateButtonVisibility;
  129857. private _cachedAngularSensibility;
  129858. /**
  129859. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  129860. * Otherwise, will use the fullscreen API.
  129861. */
  129862. enterVR(): void;
  129863. /**
  129864. * Attempt to exit VR, or fullscreen.
  129865. */
  129866. exitVR(): void;
  129867. /**
  129868. * The position of the vr experience helper.
  129869. */
  129870. get position(): Vector3;
  129871. /**
  129872. * Sets the position of the vr experience helper.
  129873. */
  129874. set position(value: Vector3);
  129875. /**
  129876. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  129877. */
  129878. enableInteractions(): void;
  129879. private get _noControllerIsActive();
  129880. private beforeRender;
  129881. private _isTeleportationFloor;
  129882. /**
  129883. * Adds a floor mesh to be used for teleportation.
  129884. * @param floorMesh the mesh to be used for teleportation.
  129885. */
  129886. addFloorMesh(floorMesh: Mesh): void;
  129887. /**
  129888. * Removes a floor mesh from being used for teleportation.
  129889. * @param floorMesh the mesh to be removed.
  129890. */
  129891. removeFloorMesh(floorMesh: Mesh): void;
  129892. /**
  129893. * Enables interactions and teleportation using the VR controllers and gaze.
  129894. * @param vrTeleportationOptions options to modify teleportation behavior.
  129895. */
  129896. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  129897. private _onNewGamepadConnected;
  129898. private _tryEnableInteractionOnController;
  129899. private _onNewGamepadDisconnected;
  129900. private _enableInteractionOnController;
  129901. private _checkTeleportWithRay;
  129902. private _checkRotate;
  129903. private _checkTeleportBackwards;
  129904. private _enableTeleportationOnController;
  129905. private _createTeleportationCircles;
  129906. private _displayTeleportationTarget;
  129907. private _hideTeleportationTarget;
  129908. private _rotateCamera;
  129909. private _moveTeleportationSelectorTo;
  129910. private _workingVector;
  129911. private _workingQuaternion;
  129912. private _workingMatrix;
  129913. /**
  129914. * Time Constant Teleportation Mode
  129915. */
  129916. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  129917. /**
  129918. * Speed Constant Teleportation Mode
  129919. */
  129920. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  129921. /**
  129922. * Teleports the users feet to the desired location
  129923. * @param location The location where the user's feet should be placed
  129924. */
  129925. teleportCamera(location: Vector3): void;
  129926. private _convertNormalToDirectionOfRay;
  129927. private _castRayAndSelectObject;
  129928. private _notifySelectedMeshUnselected;
  129929. /**
  129930. * Permanently set new colors for the laser pointer
  129931. * @param color the new laser color
  129932. * @param pickedColor the new laser color when picked mesh detected
  129933. */
  129934. setLaserColor(color: Color3, pickedColor?: Color3): void;
  129935. /**
  129936. * Set lighting enabled / disabled on the laser pointer of both controllers
  129937. * @param enabled should the lighting be enabled on the laser pointer
  129938. */
  129939. setLaserLightingState(enabled?: boolean): void;
  129940. /**
  129941. * Permanently set new colors for the gaze pointer
  129942. * @param color the new gaze color
  129943. * @param pickedColor the new gaze color when picked mesh detected
  129944. */
  129945. setGazeColor(color: Color3, pickedColor?: Color3): void;
  129946. /**
  129947. * Sets the color of the laser ray from the vr controllers.
  129948. * @param color new color for the ray.
  129949. */
  129950. changeLaserColor(color: Color3): void;
  129951. /**
  129952. * Sets the color of the ray from the vr headsets gaze.
  129953. * @param color new color for the ray.
  129954. */
  129955. changeGazeColor(color: Color3): void;
  129956. /**
  129957. * Exits VR and disposes of the vr experience helper
  129958. */
  129959. dispose(): void;
  129960. /**
  129961. * Gets the name of the VRExperienceHelper class
  129962. * @returns "VRExperienceHelper"
  129963. */
  129964. getClassName(): string;
  129965. }
  129966. }
  129967. declare module BABYLON {
  129968. /**
  129969. * Contains an array of blocks representing the octree
  129970. */
  129971. export interface IOctreeContainer<T> {
  129972. /**
  129973. * Blocks within the octree
  129974. */
  129975. blocks: Array<OctreeBlock<T>>;
  129976. }
  129977. /**
  129978. * Class used to store a cell in an octree
  129979. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129980. */
  129981. export class OctreeBlock<T> {
  129982. /**
  129983. * Gets the content of the current block
  129984. */
  129985. entries: T[];
  129986. /**
  129987. * Gets the list of block children
  129988. */
  129989. blocks: Array<OctreeBlock<T>>;
  129990. private _depth;
  129991. private _maxDepth;
  129992. private _capacity;
  129993. private _minPoint;
  129994. private _maxPoint;
  129995. private _boundingVectors;
  129996. private _creationFunc;
  129997. /**
  129998. * Creates a new block
  129999. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  130000. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  130001. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130002. * @param depth defines the current depth of this block in the octree
  130003. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  130004. * @param creationFunc defines a callback to call when an element is added to the block
  130005. */
  130006. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  130007. /**
  130008. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130009. */
  130010. get capacity(): number;
  130011. /**
  130012. * Gets the minimum vector (in world space) of the block's bounding box
  130013. */
  130014. get minPoint(): Vector3;
  130015. /**
  130016. * Gets the maximum vector (in world space) of the block's bounding box
  130017. */
  130018. get maxPoint(): Vector3;
  130019. /**
  130020. * Add a new element to this block
  130021. * @param entry defines the element to add
  130022. */
  130023. addEntry(entry: T): void;
  130024. /**
  130025. * Remove an element from this block
  130026. * @param entry defines the element to remove
  130027. */
  130028. removeEntry(entry: T): void;
  130029. /**
  130030. * Add an array of elements to this block
  130031. * @param entries defines the array of elements to add
  130032. */
  130033. addEntries(entries: T[]): void;
  130034. /**
  130035. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  130036. * @param frustumPlanes defines the frustum planes to test
  130037. * @param selection defines the array to store current content if selection is positive
  130038. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130039. */
  130040. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130041. /**
  130042. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  130043. * @param sphereCenter defines the bounding sphere center
  130044. * @param sphereRadius defines the bounding sphere radius
  130045. * @param selection defines the array to store current content if selection is positive
  130046. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130047. */
  130048. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130049. /**
  130050. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  130051. * @param ray defines the ray to test with
  130052. * @param selection defines the array to store current content if selection is positive
  130053. */
  130054. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  130055. /**
  130056. * Subdivide the content into child blocks (this block will then be empty)
  130057. */
  130058. createInnerBlocks(): void;
  130059. /**
  130060. * @hidden
  130061. */
  130062. 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;
  130063. }
  130064. }
  130065. declare module BABYLON {
  130066. /**
  130067. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  130068. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130069. */
  130070. export class Octree<T> {
  130071. /** 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.) */
  130072. maxDepth: number;
  130073. /**
  130074. * Blocks within the octree containing objects
  130075. */
  130076. blocks: Array<OctreeBlock<T>>;
  130077. /**
  130078. * Content stored in the octree
  130079. */
  130080. dynamicContent: T[];
  130081. private _maxBlockCapacity;
  130082. private _selectionContent;
  130083. private _creationFunc;
  130084. /**
  130085. * Creates a octree
  130086. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130087. * @param creationFunc function to be used to instatiate the octree
  130088. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  130089. * @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.)
  130090. */
  130091. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  130092. /** 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.) */
  130093. maxDepth?: number);
  130094. /**
  130095. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  130096. * @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);
  130097. * @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);
  130098. * @param entries meshes to be added to the octree blocks
  130099. */
  130100. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  130101. /**
  130102. * Adds a mesh to the octree
  130103. * @param entry Mesh to add to the octree
  130104. */
  130105. addMesh(entry: T): void;
  130106. /**
  130107. * Remove an element from the octree
  130108. * @param entry defines the element to remove
  130109. */
  130110. removeMesh(entry: T): void;
  130111. /**
  130112. * Selects an array of meshes within the frustum
  130113. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  130114. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  130115. * @returns array of meshes within the frustum
  130116. */
  130117. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  130118. /**
  130119. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  130120. * @param sphereCenter defines the bounding sphere center
  130121. * @param sphereRadius defines the bounding sphere radius
  130122. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130123. * @returns an array of objects that intersect the sphere
  130124. */
  130125. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  130126. /**
  130127. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  130128. * @param ray defines the ray to test with
  130129. * @returns array of intersected objects
  130130. */
  130131. intersectsRay(ray: Ray): SmartArray<T>;
  130132. /**
  130133. * Adds a mesh into the octree block if it intersects the block
  130134. */
  130135. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  130136. /**
  130137. * Adds a submesh into the octree block if it intersects the block
  130138. */
  130139. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  130140. }
  130141. }
  130142. declare module BABYLON {
  130143. interface Scene {
  130144. /**
  130145. * @hidden
  130146. * Backing Filed
  130147. */
  130148. _selectionOctree: Octree<AbstractMesh>;
  130149. /**
  130150. * Gets the octree used to boost mesh selection (picking)
  130151. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130152. */
  130153. selectionOctree: Octree<AbstractMesh>;
  130154. /**
  130155. * Creates or updates the octree used to boost selection (picking)
  130156. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130157. * @param maxCapacity defines the maximum capacity per leaf
  130158. * @param maxDepth defines the maximum depth of the octree
  130159. * @returns an octree of AbstractMesh
  130160. */
  130161. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  130162. }
  130163. interface AbstractMesh {
  130164. /**
  130165. * @hidden
  130166. * Backing Field
  130167. */
  130168. _submeshesOctree: Octree<SubMesh>;
  130169. /**
  130170. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  130171. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  130172. * @param maxCapacity defines the maximum size of each block (64 by default)
  130173. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  130174. * @returns the new octree
  130175. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  130176. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130177. */
  130178. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  130179. }
  130180. /**
  130181. * Defines the octree scene component responsible to manage any octrees
  130182. * in a given scene.
  130183. */
  130184. export class OctreeSceneComponent {
  130185. /**
  130186. * The component name help to identify the component in the list of scene components.
  130187. */
  130188. readonly name: string;
  130189. /**
  130190. * The scene the component belongs to.
  130191. */
  130192. scene: Scene;
  130193. /**
  130194. * Indicates if the meshes have been checked to make sure they are isEnabled()
  130195. */
  130196. readonly checksIsEnabled: boolean;
  130197. /**
  130198. * Creates a new instance of the component for the given scene
  130199. * @param scene Defines the scene to register the component in
  130200. */
  130201. constructor(scene: Scene);
  130202. /**
  130203. * Registers the component in a given scene
  130204. */
  130205. register(): void;
  130206. /**
  130207. * Return the list of active meshes
  130208. * @returns the list of active meshes
  130209. */
  130210. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  130211. /**
  130212. * Return the list of active sub meshes
  130213. * @param mesh The mesh to get the candidates sub meshes from
  130214. * @returns the list of active sub meshes
  130215. */
  130216. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  130217. private _tempRay;
  130218. /**
  130219. * Return the list of sub meshes intersecting with a given local ray
  130220. * @param mesh defines the mesh to find the submesh for
  130221. * @param localRay defines the ray in local space
  130222. * @returns the list of intersecting sub meshes
  130223. */
  130224. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  130225. /**
  130226. * Return the list of sub meshes colliding with a collider
  130227. * @param mesh defines the mesh to find the submesh for
  130228. * @param collider defines the collider to evaluate the collision against
  130229. * @returns the list of colliding sub meshes
  130230. */
  130231. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  130232. /**
  130233. * Rebuilds the elements related to this component in case of
  130234. * context lost for instance.
  130235. */
  130236. rebuild(): void;
  130237. /**
  130238. * Disposes the component and the associated ressources.
  130239. */
  130240. dispose(): void;
  130241. }
  130242. }
  130243. declare module BABYLON {
  130244. /**
  130245. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  130246. */
  130247. export class Gizmo implements IDisposable {
  130248. /** The utility layer the gizmo will be added to */
  130249. gizmoLayer: UtilityLayerRenderer;
  130250. /**
  130251. * The root mesh of the gizmo
  130252. */
  130253. _rootMesh: Mesh;
  130254. private _attachedMesh;
  130255. private _attachedNode;
  130256. /**
  130257. * Ratio for the scale of the gizmo (Default: 1)
  130258. */
  130259. protected _scaleRatio: number;
  130260. /**
  130261. * Ratio for the scale of the gizmo (Default: 1)
  130262. */
  130263. set scaleRatio(value: number);
  130264. get scaleRatio(): number;
  130265. /**
  130266. * If a custom mesh has been set (Default: false)
  130267. */
  130268. protected _customMeshSet: boolean;
  130269. /**
  130270. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  130271. * * When set, interactions will be enabled
  130272. */
  130273. get attachedMesh(): Nullable<AbstractMesh>;
  130274. set attachedMesh(value: Nullable<AbstractMesh>);
  130275. /**
  130276. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  130277. * * When set, interactions will be enabled
  130278. */
  130279. get attachedNode(): Nullable<Node>;
  130280. set attachedNode(value: Nullable<Node>);
  130281. /**
  130282. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130283. * @param mesh The mesh to replace the default mesh of the gizmo
  130284. */
  130285. setCustomMesh(mesh: Mesh): void;
  130286. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  130287. /**
  130288. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  130289. */
  130290. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130291. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130292. /**
  130293. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  130294. */
  130295. updateGizmoPositionToMatchAttachedMesh: boolean;
  130296. /**
  130297. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  130298. */
  130299. updateScale: boolean;
  130300. protected _interactionsEnabled: boolean;
  130301. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130302. private _beforeRenderObserver;
  130303. private _tempQuaternion;
  130304. private _tempVector;
  130305. private _tempVector2;
  130306. private _tempMatrix1;
  130307. private _tempMatrix2;
  130308. private _rightHandtoLeftHandMatrix;
  130309. /**
  130310. * Creates a gizmo
  130311. * @param gizmoLayer The utility layer the gizmo will be added to
  130312. */
  130313. constructor(
  130314. /** The utility layer the gizmo will be added to */
  130315. gizmoLayer?: UtilityLayerRenderer);
  130316. /**
  130317. * Updates the gizmo to match the attached mesh's position/rotation
  130318. */
  130319. protected _update(): void;
  130320. /**
  130321. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  130322. * @param value Node, TransformNode or mesh
  130323. */
  130324. protected _matrixChanged(): void;
  130325. /**
  130326. * Disposes of the gizmo
  130327. */
  130328. dispose(): void;
  130329. }
  130330. }
  130331. declare module BABYLON {
  130332. /**
  130333. * Single plane drag gizmo
  130334. */
  130335. export class PlaneDragGizmo extends Gizmo {
  130336. /**
  130337. * Drag behavior responsible for the gizmos dragging interactions
  130338. */
  130339. dragBehavior: PointerDragBehavior;
  130340. private _pointerObserver;
  130341. /**
  130342. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130343. */
  130344. snapDistance: number;
  130345. /**
  130346. * Event that fires each time the gizmo snaps to a new location.
  130347. * * snapDistance is the the change in distance
  130348. */
  130349. onSnapObservable: Observable<{
  130350. snapDistance: number;
  130351. }>;
  130352. private _plane;
  130353. private _coloredMaterial;
  130354. private _hoverMaterial;
  130355. private _isEnabled;
  130356. private _parent;
  130357. /** @hidden */
  130358. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  130359. /** @hidden */
  130360. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130361. /**
  130362. * Creates a PlaneDragGizmo
  130363. * @param gizmoLayer The utility layer the gizmo will be added to
  130364. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  130365. * @param color The color of the gizmo
  130366. */
  130367. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  130368. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130369. /**
  130370. * If the gizmo is enabled
  130371. */
  130372. set isEnabled(value: boolean);
  130373. get isEnabled(): boolean;
  130374. /**
  130375. * Disposes of the gizmo
  130376. */
  130377. dispose(): void;
  130378. }
  130379. }
  130380. declare module BABYLON {
  130381. /**
  130382. * Gizmo that enables dragging a mesh along 3 axis
  130383. */
  130384. export class PositionGizmo extends Gizmo {
  130385. /**
  130386. * Internal gizmo used for interactions on the x axis
  130387. */
  130388. xGizmo: AxisDragGizmo;
  130389. /**
  130390. * Internal gizmo used for interactions on the y axis
  130391. */
  130392. yGizmo: AxisDragGizmo;
  130393. /**
  130394. * Internal gizmo used for interactions on the z axis
  130395. */
  130396. zGizmo: AxisDragGizmo;
  130397. /**
  130398. * Internal gizmo used for interactions on the yz plane
  130399. */
  130400. xPlaneGizmo: PlaneDragGizmo;
  130401. /**
  130402. * Internal gizmo used for interactions on the xz plane
  130403. */
  130404. yPlaneGizmo: PlaneDragGizmo;
  130405. /**
  130406. * Internal gizmo used for interactions on the xy plane
  130407. */
  130408. zPlaneGizmo: PlaneDragGizmo;
  130409. /**
  130410. * private variables
  130411. */
  130412. private _meshAttached;
  130413. private _nodeAttached;
  130414. private _snapDistance;
  130415. /** Fires an event when any of it's sub gizmos are dragged */
  130416. onDragStartObservable: Observable<unknown>;
  130417. /** Fires an event when any of it's sub gizmos are released from dragging */
  130418. onDragEndObservable: Observable<unknown>;
  130419. /**
  130420. * If set to true, planar drag is enabled
  130421. */
  130422. private _planarGizmoEnabled;
  130423. get attachedMesh(): Nullable<AbstractMesh>;
  130424. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130425. get attachedNode(): Nullable<Node>;
  130426. set attachedNode(node: Nullable<Node>);
  130427. /**
  130428. * Creates a PositionGizmo
  130429. * @param gizmoLayer The utility layer the gizmo will be added to
  130430. @param thickness display gizmo axis thickness
  130431. */
  130432. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  130433. /**
  130434. * If the planar drag gizmo is enabled
  130435. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  130436. */
  130437. set planarGizmoEnabled(value: boolean);
  130438. get planarGizmoEnabled(): boolean;
  130439. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130440. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130441. /**
  130442. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130443. */
  130444. set snapDistance(value: number);
  130445. get snapDistance(): number;
  130446. /**
  130447. * Ratio for the scale of the gizmo (Default: 1)
  130448. */
  130449. set scaleRatio(value: number);
  130450. get scaleRatio(): number;
  130451. /**
  130452. * Disposes of the gizmo
  130453. */
  130454. dispose(): void;
  130455. /**
  130456. * CustomMeshes are not supported by this gizmo
  130457. * @param mesh The mesh to replace the default mesh of the gizmo
  130458. */
  130459. setCustomMesh(mesh: Mesh): void;
  130460. }
  130461. }
  130462. declare module BABYLON {
  130463. /**
  130464. * Single axis drag gizmo
  130465. */
  130466. export class AxisDragGizmo extends Gizmo {
  130467. /**
  130468. * Drag behavior responsible for the gizmos dragging interactions
  130469. */
  130470. dragBehavior: PointerDragBehavior;
  130471. private _pointerObserver;
  130472. /**
  130473. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130474. */
  130475. snapDistance: number;
  130476. /**
  130477. * Event that fires each time the gizmo snaps to a new location.
  130478. * * snapDistance is the the change in distance
  130479. */
  130480. onSnapObservable: Observable<{
  130481. snapDistance: number;
  130482. }>;
  130483. private _isEnabled;
  130484. private _parent;
  130485. private _arrow;
  130486. private _coloredMaterial;
  130487. private _hoverMaterial;
  130488. /** @hidden */
  130489. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  130490. /** @hidden */
  130491. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130492. /**
  130493. * Creates an AxisDragGizmo
  130494. * @param gizmoLayer The utility layer the gizmo will be added to
  130495. * @param dragAxis The axis which the gizmo will be able to drag on
  130496. * @param color The color of the gizmo
  130497. * @param thickness display gizmo axis thickness
  130498. */
  130499. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  130500. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130501. /**
  130502. * If the gizmo is enabled
  130503. */
  130504. set isEnabled(value: boolean);
  130505. get isEnabled(): boolean;
  130506. /**
  130507. * Disposes of the gizmo
  130508. */
  130509. dispose(): void;
  130510. }
  130511. }
  130512. declare module BABYLON.Debug {
  130513. /**
  130514. * The Axes viewer will show 3 axes in a specific point in space
  130515. */
  130516. export class AxesViewer {
  130517. private _xAxis;
  130518. private _yAxis;
  130519. private _zAxis;
  130520. private _scaleLinesFactor;
  130521. private _instanced;
  130522. /**
  130523. * Gets the hosting scene
  130524. */
  130525. scene: Nullable<Scene>;
  130526. /**
  130527. * Gets or sets a number used to scale line length
  130528. */
  130529. scaleLines: number;
  130530. /** Gets the node hierarchy used to render x-axis */
  130531. get xAxis(): TransformNode;
  130532. /** Gets the node hierarchy used to render y-axis */
  130533. get yAxis(): TransformNode;
  130534. /** Gets the node hierarchy used to render z-axis */
  130535. get zAxis(): TransformNode;
  130536. /**
  130537. * Creates a new AxesViewer
  130538. * @param scene defines the hosting scene
  130539. * @param scaleLines defines a number used to scale line length (1 by default)
  130540. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  130541. * @param xAxis defines the node hierarchy used to render the x-axis
  130542. * @param yAxis defines the node hierarchy used to render the y-axis
  130543. * @param zAxis defines the node hierarchy used to render the z-axis
  130544. */
  130545. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  130546. /**
  130547. * Force the viewer to update
  130548. * @param position defines the position of the viewer
  130549. * @param xaxis defines the x axis of the viewer
  130550. * @param yaxis defines the y axis of the viewer
  130551. * @param zaxis defines the z axis of the viewer
  130552. */
  130553. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  130554. /**
  130555. * Creates an instance of this axes viewer.
  130556. * @returns a new axes viewer with instanced meshes
  130557. */
  130558. createInstance(): AxesViewer;
  130559. /** Releases resources */
  130560. dispose(): void;
  130561. private static _SetRenderingGroupId;
  130562. }
  130563. }
  130564. declare module BABYLON.Debug {
  130565. /**
  130566. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  130567. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  130568. */
  130569. export class BoneAxesViewer extends AxesViewer {
  130570. /**
  130571. * Gets or sets the target mesh where to display the axes viewer
  130572. */
  130573. mesh: Nullable<Mesh>;
  130574. /**
  130575. * Gets or sets the target bone where to display the axes viewer
  130576. */
  130577. bone: Nullable<Bone>;
  130578. /** Gets current position */
  130579. pos: Vector3;
  130580. /** Gets direction of X axis */
  130581. xaxis: Vector3;
  130582. /** Gets direction of Y axis */
  130583. yaxis: Vector3;
  130584. /** Gets direction of Z axis */
  130585. zaxis: Vector3;
  130586. /**
  130587. * Creates a new BoneAxesViewer
  130588. * @param scene defines the hosting scene
  130589. * @param bone defines the target bone
  130590. * @param mesh defines the target mesh
  130591. * @param scaleLines defines a scaling factor for line length (1 by default)
  130592. */
  130593. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  130594. /**
  130595. * Force the viewer to update
  130596. */
  130597. update(): void;
  130598. /** Releases resources */
  130599. dispose(): void;
  130600. }
  130601. }
  130602. declare module BABYLON {
  130603. /**
  130604. * Interface used to define scene explorer extensibility option
  130605. */
  130606. export interface IExplorerExtensibilityOption {
  130607. /**
  130608. * Define the option label
  130609. */
  130610. label: string;
  130611. /**
  130612. * Defines the action to execute on click
  130613. */
  130614. action: (entity: any) => void;
  130615. }
  130616. /**
  130617. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  130618. */
  130619. export interface IExplorerExtensibilityGroup {
  130620. /**
  130621. * Defines a predicate to test if a given type mut be extended
  130622. */
  130623. predicate: (entity: any) => boolean;
  130624. /**
  130625. * Gets the list of options added to a type
  130626. */
  130627. entries: IExplorerExtensibilityOption[];
  130628. }
  130629. /**
  130630. * Interface used to define the options to use to create the Inspector
  130631. */
  130632. export interface IInspectorOptions {
  130633. /**
  130634. * Display in overlay mode (default: false)
  130635. */
  130636. overlay?: boolean;
  130637. /**
  130638. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  130639. */
  130640. globalRoot?: HTMLElement;
  130641. /**
  130642. * Display the Scene explorer
  130643. */
  130644. showExplorer?: boolean;
  130645. /**
  130646. * Display the property inspector
  130647. */
  130648. showInspector?: boolean;
  130649. /**
  130650. * Display in embed mode (both panes on the right)
  130651. */
  130652. embedMode?: boolean;
  130653. /**
  130654. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  130655. */
  130656. handleResize?: boolean;
  130657. /**
  130658. * Allow the panes to popup (default: true)
  130659. */
  130660. enablePopup?: boolean;
  130661. /**
  130662. * Allow the panes to be closed by users (default: true)
  130663. */
  130664. enableClose?: boolean;
  130665. /**
  130666. * Optional list of extensibility entries
  130667. */
  130668. explorerExtensibility?: IExplorerExtensibilityGroup[];
  130669. /**
  130670. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  130671. */
  130672. inspectorURL?: string;
  130673. /**
  130674. * Optional initial tab (default to DebugLayerTab.Properties)
  130675. */
  130676. initialTab?: DebugLayerTab;
  130677. }
  130678. interface Scene {
  130679. /**
  130680. * @hidden
  130681. * Backing field
  130682. */
  130683. _debugLayer: DebugLayer;
  130684. /**
  130685. * Gets the debug layer (aka Inspector) associated with the scene
  130686. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130687. */
  130688. debugLayer: DebugLayer;
  130689. }
  130690. /**
  130691. * Enum of inspector action tab
  130692. */
  130693. export enum DebugLayerTab {
  130694. /**
  130695. * Properties tag (default)
  130696. */
  130697. Properties = 0,
  130698. /**
  130699. * Debug tab
  130700. */
  130701. Debug = 1,
  130702. /**
  130703. * Statistics tab
  130704. */
  130705. Statistics = 2,
  130706. /**
  130707. * Tools tab
  130708. */
  130709. Tools = 3,
  130710. /**
  130711. * Settings tab
  130712. */
  130713. Settings = 4
  130714. }
  130715. /**
  130716. * The debug layer (aka Inspector) is the go to tool in order to better understand
  130717. * what is happening in your scene
  130718. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130719. */
  130720. export class DebugLayer {
  130721. /**
  130722. * Define the url to get the inspector script from.
  130723. * By default it uses the babylonjs CDN.
  130724. * @ignoreNaming
  130725. */
  130726. static InspectorURL: string;
  130727. private _scene;
  130728. private BJSINSPECTOR;
  130729. private _onPropertyChangedObservable?;
  130730. /**
  130731. * Observable triggered when a property is changed through the inspector.
  130732. */
  130733. get onPropertyChangedObservable(): any;
  130734. /**
  130735. * Instantiates a new debug layer.
  130736. * The debug layer (aka Inspector) is the go to tool in order to better understand
  130737. * what is happening in your scene
  130738. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130739. * @param scene Defines the scene to inspect
  130740. */
  130741. constructor(scene: Scene);
  130742. /** Creates the inspector window. */
  130743. private _createInspector;
  130744. /**
  130745. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  130746. * @param entity defines the entity to select
  130747. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  130748. */
  130749. select(entity: any, lineContainerTitles?: string | string[]): void;
  130750. /** Get the inspector from bundle or global */
  130751. private _getGlobalInspector;
  130752. /**
  130753. * Get if the inspector is visible or not.
  130754. * @returns true if visible otherwise, false
  130755. */
  130756. isVisible(): boolean;
  130757. /**
  130758. * Hide the inspector and close its window.
  130759. */
  130760. hide(): void;
  130761. /**
  130762. * Update the scene in the inspector
  130763. */
  130764. setAsActiveScene(): void;
  130765. /**
  130766. * Launch the debugLayer.
  130767. * @param config Define the configuration of the inspector
  130768. * @return a promise fulfilled when the debug layer is visible
  130769. */
  130770. show(config?: IInspectorOptions): Promise<DebugLayer>;
  130771. }
  130772. }
  130773. declare module BABYLON {
  130774. /**
  130775. * Class containing static functions to help procedurally build meshes
  130776. */
  130777. export class BoxBuilder {
  130778. /**
  130779. * Creates a box mesh
  130780. * * The parameter `size` sets the size (float) of each box side (default 1)
  130781. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  130782. * * 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)
  130783. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130787. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  130788. * @param name defines the name of the mesh
  130789. * @param options defines the options used to create the mesh
  130790. * @param scene defines the hosting scene
  130791. * @returns the box mesh
  130792. */
  130793. static CreateBox(name: string, options: {
  130794. size?: number;
  130795. width?: number;
  130796. height?: number;
  130797. depth?: number;
  130798. faceUV?: Vector4[];
  130799. faceColors?: Color4[];
  130800. sideOrientation?: number;
  130801. frontUVs?: Vector4;
  130802. backUVs?: Vector4;
  130803. wrap?: boolean;
  130804. topBaseAt?: number;
  130805. bottomBaseAt?: number;
  130806. updatable?: boolean;
  130807. }, scene?: Nullable<Scene>): Mesh;
  130808. }
  130809. }
  130810. declare module BABYLON.Debug {
  130811. /**
  130812. * Used to show the physics impostor around the specific mesh
  130813. */
  130814. export class PhysicsViewer {
  130815. /** @hidden */
  130816. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  130817. /** @hidden */
  130818. protected _meshes: Array<Nullable<AbstractMesh>>;
  130819. /** @hidden */
  130820. protected _scene: Nullable<Scene>;
  130821. /** @hidden */
  130822. protected _numMeshes: number;
  130823. /** @hidden */
  130824. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  130825. private _renderFunction;
  130826. private _utilityLayer;
  130827. private _debugBoxMesh;
  130828. private _debugSphereMesh;
  130829. private _debugCylinderMesh;
  130830. private _debugMaterial;
  130831. private _debugMeshMeshes;
  130832. /**
  130833. * Creates a new PhysicsViewer
  130834. * @param scene defines the hosting scene
  130835. */
  130836. constructor(scene: Scene);
  130837. /** @hidden */
  130838. protected _updateDebugMeshes(): void;
  130839. /**
  130840. * Renders a specified physic impostor
  130841. * @param impostor defines the impostor to render
  130842. * @param targetMesh defines the mesh represented by the impostor
  130843. * @returns the new debug mesh used to render the impostor
  130844. */
  130845. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  130846. /**
  130847. * Hides a specified physic impostor
  130848. * @param impostor defines the impostor to hide
  130849. */
  130850. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  130851. private _getDebugMaterial;
  130852. private _getDebugBoxMesh;
  130853. private _getDebugSphereMesh;
  130854. private _getDebugCylinderMesh;
  130855. private _getDebugMeshMesh;
  130856. private _getDebugMesh;
  130857. /** Releases all resources */
  130858. dispose(): void;
  130859. }
  130860. }
  130861. declare module BABYLON {
  130862. /**
  130863. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  130864. * in order to better appreciate the issue one might have.
  130865. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  130866. */
  130867. export class RayHelper {
  130868. /**
  130869. * Defines the ray we are currently tryin to visualize.
  130870. */
  130871. ray: Nullable<Ray>;
  130872. private _renderPoints;
  130873. private _renderLine;
  130874. private _renderFunction;
  130875. private _scene;
  130876. private _onAfterRenderObserver;
  130877. private _onAfterStepObserver;
  130878. private _attachedToMesh;
  130879. private _meshSpaceDirection;
  130880. private _meshSpaceOrigin;
  130881. /**
  130882. * Helper function to create a colored helper in a scene in one line.
  130883. * @param ray Defines the ray we are currently tryin to visualize
  130884. * @param scene Defines the scene the ray is used in
  130885. * @param color Defines the color we want to see the ray in
  130886. * @returns The newly created ray helper.
  130887. */
  130888. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  130889. /**
  130890. * Instantiate a new ray helper.
  130891. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  130892. * in order to better appreciate the issue one might have.
  130893. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  130894. * @param ray Defines the ray we are currently tryin to visualize
  130895. */
  130896. constructor(ray: Ray);
  130897. /**
  130898. * Shows the ray we are willing to debug.
  130899. * @param scene Defines the scene the ray needs to be rendered in
  130900. * @param color Defines the color the ray needs to be rendered in
  130901. */
  130902. show(scene: Scene, color?: Color3): void;
  130903. /**
  130904. * Hides the ray we are debugging.
  130905. */
  130906. hide(): void;
  130907. private _render;
  130908. /**
  130909. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  130910. * @param mesh Defines the mesh we want the helper attached to
  130911. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  130912. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  130913. * @param length Defines the length of the ray
  130914. */
  130915. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  130916. /**
  130917. * Detach the ray helper from the mesh it has previously been attached to.
  130918. */
  130919. detachFromMesh(): void;
  130920. private _updateToMesh;
  130921. /**
  130922. * Dispose the helper and release its associated resources.
  130923. */
  130924. dispose(): void;
  130925. }
  130926. }
  130927. declare module BABYLON {
  130928. /**
  130929. * Defines the options associated with the creation of a SkeletonViewer.
  130930. */
  130931. export interface ISkeletonViewerOptions {
  130932. /** Should the system pause animations before building the Viewer? */
  130933. pauseAnimations: boolean;
  130934. /** Should the system return the skeleton to rest before building? */
  130935. returnToRest: boolean;
  130936. /** public Display Mode of the Viewer */
  130937. displayMode: number;
  130938. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  130939. displayOptions: ISkeletonViewerDisplayOptions;
  130940. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  130941. computeBonesUsingShaders: boolean;
  130942. /** Flag ignore non weighted bones */
  130943. useAllBones: boolean;
  130944. }
  130945. /**
  130946. * Defines how to display the various bone meshes for the viewer.
  130947. */
  130948. export interface ISkeletonViewerDisplayOptions {
  130949. /** How far down to start tapering the bone spurs */
  130950. midStep?: number;
  130951. /** How big is the midStep? */
  130952. midStepFactor?: number;
  130953. /** Base for the Sphere Size */
  130954. sphereBaseSize?: number;
  130955. /** The ratio of the sphere to the longest bone in units */
  130956. sphereScaleUnit?: number;
  130957. /** Ratio for the Sphere Size */
  130958. sphereFactor?: number;
  130959. }
  130960. /**
  130961. * Defines the constructor options for the BoneWeight Shader.
  130962. */
  130963. export interface IBoneWeightShaderOptions {
  130964. /** Skeleton to Map */
  130965. skeleton: Skeleton;
  130966. /** Colors for Uninfluenced bones */
  130967. colorBase?: Color3;
  130968. /** Colors for 0.0-0.25 Weight bones */
  130969. colorZero?: Color3;
  130970. /** Color for 0.25-0.5 Weight Influence */
  130971. colorQuarter?: Color3;
  130972. /** Color for 0.5-0.75 Weight Influence */
  130973. colorHalf?: Color3;
  130974. /** Color for 0.75-1 Weight Influence */
  130975. colorFull?: Color3;
  130976. /** Color for Zero Weight Influence */
  130977. targetBoneIndex?: number;
  130978. }
  130979. /**
  130980. * Simple structure of the gradient steps for the Color Map.
  130981. */
  130982. export interface ISkeletonMapShaderColorMapKnot {
  130983. /** Color of the Knot */
  130984. color: Color3;
  130985. /** Location of the Knot */
  130986. location: number;
  130987. }
  130988. /**
  130989. * Defines the constructor options for the SkeletonMap Shader.
  130990. */
  130991. export interface ISkeletonMapShaderOptions {
  130992. /** Skeleton to Map */
  130993. skeleton: Skeleton;
  130994. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  130995. colorMap?: ISkeletonMapShaderColorMapKnot[];
  130996. }
  130997. }
  130998. declare module BABYLON {
  130999. /**
  131000. * Class containing static functions to help procedurally build meshes
  131001. */
  131002. export class RibbonBuilder {
  131003. /**
  131004. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131005. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131006. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131007. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131008. * * 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
  131009. * * 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
  131010. * * 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
  131011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131013. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131014. * * 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
  131015. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131016. * * 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
  131017. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131019. * @param name defines the name of the mesh
  131020. * @param options defines the options used to create the mesh
  131021. * @param scene defines the hosting scene
  131022. * @returns the ribbon mesh
  131023. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131024. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131025. */
  131026. static CreateRibbon(name: string, options: {
  131027. pathArray: Vector3[][];
  131028. closeArray?: boolean;
  131029. closePath?: boolean;
  131030. offset?: number;
  131031. updatable?: boolean;
  131032. sideOrientation?: number;
  131033. frontUVs?: Vector4;
  131034. backUVs?: Vector4;
  131035. instance?: Mesh;
  131036. invertUV?: boolean;
  131037. uvs?: Vector2[];
  131038. colors?: Color4[];
  131039. }, scene?: Nullable<Scene>): Mesh;
  131040. }
  131041. }
  131042. declare module BABYLON {
  131043. /**
  131044. * Class containing static functions to help procedurally build meshes
  131045. */
  131046. export class ShapeBuilder {
  131047. /**
  131048. * 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.
  131049. * * 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.
  131050. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131051. * * 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.
  131052. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131053. * * 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
  131054. * * 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
  131055. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131058. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131060. * @param name defines the name of the mesh
  131061. * @param options defines the options used to create the mesh
  131062. * @param scene defines the hosting scene
  131063. * @returns the extruded shape mesh
  131064. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131065. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131066. */
  131067. static ExtrudeShape(name: string, options: {
  131068. shape: Vector3[];
  131069. path: Vector3[];
  131070. scale?: number;
  131071. rotation?: number;
  131072. cap?: number;
  131073. updatable?: boolean;
  131074. sideOrientation?: number;
  131075. frontUVs?: Vector4;
  131076. backUVs?: Vector4;
  131077. instance?: Mesh;
  131078. invertUV?: boolean;
  131079. }, scene?: Nullable<Scene>): Mesh;
  131080. /**
  131081. * Creates an custom extruded shape mesh.
  131082. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131083. * * 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.
  131084. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131085. * * 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
  131086. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131087. * * 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
  131088. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131089. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131090. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131091. * * 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
  131092. * * 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
  131093. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131095. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131096. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131098. * @param name defines the name of the mesh
  131099. * @param options defines the options used to create the mesh
  131100. * @param scene defines the hosting scene
  131101. * @returns the custom extruded shape mesh
  131102. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131103. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131104. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131105. */
  131106. static ExtrudeShapeCustom(name: string, options: {
  131107. shape: Vector3[];
  131108. path: Vector3[];
  131109. scaleFunction?: any;
  131110. rotationFunction?: any;
  131111. ribbonCloseArray?: boolean;
  131112. ribbonClosePath?: boolean;
  131113. cap?: number;
  131114. updatable?: boolean;
  131115. sideOrientation?: number;
  131116. frontUVs?: Vector4;
  131117. backUVs?: Vector4;
  131118. instance?: Mesh;
  131119. invertUV?: boolean;
  131120. }, scene?: Nullable<Scene>): Mesh;
  131121. private static _ExtrudeShapeGeneric;
  131122. }
  131123. }
  131124. declare module BABYLON.Debug {
  131125. /**
  131126. * Class used to render a debug view of a given skeleton
  131127. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  131128. */
  131129. export class SkeletonViewer {
  131130. /** defines the skeleton to render */
  131131. skeleton: Skeleton;
  131132. /** defines the mesh attached to the skeleton */
  131133. mesh: AbstractMesh;
  131134. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131135. autoUpdateBonesMatrices: boolean;
  131136. /** defines the rendering group id to use with the viewer */
  131137. renderingGroupId: number;
  131138. /** is the options for the viewer */
  131139. options: Partial<ISkeletonViewerOptions>;
  131140. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  131141. static readonly DISPLAY_LINES: number;
  131142. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  131143. static readonly DISPLAY_SPHERES: number;
  131144. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  131145. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  131146. /** public static method to create a BoneWeight Shader
  131147. * @param options The constructor options
  131148. * @param scene The scene that the shader is scoped to
  131149. * @returns The created ShaderMaterial
  131150. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  131151. */
  131152. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  131153. /** public static method to create a BoneWeight Shader
  131154. * @param options The constructor options
  131155. * @param scene The scene that the shader is scoped to
  131156. * @returns The created ShaderMaterial
  131157. */
  131158. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  131159. /** private static method to create a BoneWeight Shader
  131160. * @param size The size of the buffer to create (usually the bone count)
  131161. * @param colorMap The gradient data to generate
  131162. * @param scene The scene that the shader is scoped to
  131163. * @returns an Array of floats from the color gradient values
  131164. */
  131165. private static _CreateBoneMapColorBuffer;
  131166. /** If SkeletonViewer scene scope. */
  131167. private _scene;
  131168. /** Gets or sets the color used to render the skeleton */
  131169. color: Color3;
  131170. /** Array of the points of the skeleton fo the line view. */
  131171. private _debugLines;
  131172. /** The SkeletonViewers Mesh. */
  131173. private _debugMesh;
  131174. /** If SkeletonViewer is enabled. */
  131175. private _isEnabled;
  131176. /** If SkeletonViewer is ready. */
  131177. private _ready;
  131178. /** SkeletonViewer render observable. */
  131179. private _obs;
  131180. /** The Utility Layer to render the gizmos in. */
  131181. private _utilityLayer;
  131182. private _boneIndices;
  131183. /** Gets the Scene. */
  131184. get scene(): Scene;
  131185. /** Gets the utilityLayer. */
  131186. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  131187. /** Checks Ready Status. */
  131188. get isReady(): Boolean;
  131189. /** Sets Ready Status. */
  131190. set ready(value: boolean);
  131191. /** Gets the debugMesh */
  131192. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  131193. /** Sets the debugMesh */
  131194. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  131195. /** Gets the displayMode */
  131196. get displayMode(): number;
  131197. /** Sets the displayMode */
  131198. set displayMode(value: number);
  131199. /**
  131200. * Creates a new SkeletonViewer
  131201. * @param skeleton defines the skeleton to render
  131202. * @param mesh defines the mesh attached to the skeleton
  131203. * @param scene defines the hosting scene
  131204. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  131205. * @param renderingGroupId defines the rendering group id to use with the viewer
  131206. * @param options All of the extra constructor options for the SkeletonViewer
  131207. */
  131208. constructor(
  131209. /** defines the skeleton to render */
  131210. skeleton: Skeleton,
  131211. /** defines the mesh attached to the skeleton */
  131212. mesh: AbstractMesh,
  131213. /** The Scene scope*/
  131214. scene: Scene,
  131215. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131216. autoUpdateBonesMatrices?: boolean,
  131217. /** defines the rendering group id to use with the viewer */
  131218. renderingGroupId?: number,
  131219. /** is the options for the viewer */
  131220. options?: Partial<ISkeletonViewerOptions>);
  131221. /** The Dynamic bindings for the update functions */
  131222. private _bindObs;
  131223. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  131224. update(): void;
  131225. /** Gets or sets a boolean indicating if the viewer is enabled */
  131226. set isEnabled(value: boolean);
  131227. get isEnabled(): boolean;
  131228. private _getBonePosition;
  131229. private _getLinesForBonesWithLength;
  131230. private _getLinesForBonesNoLength;
  131231. /** function to revert the mesh and scene back to the initial state. */
  131232. private _revert;
  131233. /** function to build and bind sphere joint points and spur bone representations. */
  131234. private _buildSpheresAndSpurs;
  131235. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  131236. private _displayLinesUpdate;
  131237. /** Changes the displayMode of the skeleton viewer
  131238. * @param mode The displayMode numerical value
  131239. */
  131240. changeDisplayMode(mode: number): void;
  131241. /** Changes the displayMode of the skeleton viewer
  131242. * @param option String of the option name
  131243. * @param value The numerical option value
  131244. */
  131245. changeDisplayOptions(option: string, value: number): void;
  131246. /** Release associated resources */
  131247. dispose(): void;
  131248. }
  131249. }
  131250. declare module BABYLON {
  131251. /**
  131252. * Enum for Device Types
  131253. */
  131254. export enum DeviceType {
  131255. /** Generic */
  131256. Generic = 0,
  131257. /** Keyboard */
  131258. Keyboard = 1,
  131259. /** Mouse */
  131260. Mouse = 2,
  131261. /** Touch Pointers */
  131262. Touch = 3,
  131263. /** PS4 Dual Shock */
  131264. DualShock = 4,
  131265. /** Xbox */
  131266. Xbox = 5,
  131267. /** Switch Controller */
  131268. Switch = 6
  131269. }
  131270. /**
  131271. * Enum for All Pointers (Touch/Mouse)
  131272. */
  131273. export enum PointerInput {
  131274. /** Horizontal Axis */
  131275. Horizontal = 0,
  131276. /** Vertical Axis */
  131277. Vertical = 1,
  131278. /** Left Click or Touch */
  131279. LeftClick = 2,
  131280. /** Middle Click */
  131281. MiddleClick = 3,
  131282. /** Right Click */
  131283. RightClick = 4,
  131284. /** Browser Back */
  131285. BrowserBack = 5,
  131286. /** Browser Forward */
  131287. BrowserForward = 6
  131288. }
  131289. /**
  131290. * Enum for Dual Shock Gamepad
  131291. */
  131292. export enum DualShockInput {
  131293. /** Cross */
  131294. Cross = 0,
  131295. /** Circle */
  131296. Circle = 1,
  131297. /** Square */
  131298. Square = 2,
  131299. /** Triangle */
  131300. Triangle = 3,
  131301. /** L1 */
  131302. L1 = 4,
  131303. /** R1 */
  131304. R1 = 5,
  131305. /** L2 */
  131306. L2 = 6,
  131307. /** R2 */
  131308. R2 = 7,
  131309. /** Share */
  131310. Share = 8,
  131311. /** Options */
  131312. Options = 9,
  131313. /** L3 */
  131314. L3 = 10,
  131315. /** R3 */
  131316. R3 = 11,
  131317. /** DPadUp */
  131318. DPadUp = 12,
  131319. /** DPadDown */
  131320. DPadDown = 13,
  131321. /** DPadLeft */
  131322. DPadLeft = 14,
  131323. /** DRight */
  131324. DPadRight = 15,
  131325. /** Home */
  131326. Home = 16,
  131327. /** TouchPad */
  131328. TouchPad = 17,
  131329. /** LStickXAxis */
  131330. LStickXAxis = 18,
  131331. /** LStickYAxis */
  131332. LStickYAxis = 19,
  131333. /** RStickXAxis */
  131334. RStickXAxis = 20,
  131335. /** RStickYAxis */
  131336. RStickYAxis = 21
  131337. }
  131338. /**
  131339. * Enum for Xbox Gamepad
  131340. */
  131341. export enum XboxInput {
  131342. /** A */
  131343. A = 0,
  131344. /** B */
  131345. B = 1,
  131346. /** X */
  131347. X = 2,
  131348. /** Y */
  131349. Y = 3,
  131350. /** LB */
  131351. LB = 4,
  131352. /** RB */
  131353. RB = 5,
  131354. /** LT */
  131355. LT = 6,
  131356. /** RT */
  131357. RT = 7,
  131358. /** Back */
  131359. Back = 8,
  131360. /** Start */
  131361. Start = 9,
  131362. /** LS */
  131363. LS = 10,
  131364. /** RS */
  131365. RS = 11,
  131366. /** DPadUp */
  131367. DPadUp = 12,
  131368. /** DPadDown */
  131369. DPadDown = 13,
  131370. /** DPadLeft */
  131371. DPadLeft = 14,
  131372. /** DRight */
  131373. DPadRight = 15,
  131374. /** Home */
  131375. Home = 16,
  131376. /** LStickXAxis */
  131377. LStickXAxis = 17,
  131378. /** LStickYAxis */
  131379. LStickYAxis = 18,
  131380. /** RStickXAxis */
  131381. RStickXAxis = 19,
  131382. /** RStickYAxis */
  131383. RStickYAxis = 20
  131384. }
  131385. /**
  131386. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  131387. */
  131388. export enum SwitchInput {
  131389. /** B */
  131390. B = 0,
  131391. /** A */
  131392. A = 1,
  131393. /** Y */
  131394. Y = 2,
  131395. /** X */
  131396. X = 3,
  131397. /** L */
  131398. L = 4,
  131399. /** R */
  131400. R = 5,
  131401. /** ZL */
  131402. ZL = 6,
  131403. /** ZR */
  131404. ZR = 7,
  131405. /** Minus */
  131406. Minus = 8,
  131407. /** Plus */
  131408. Plus = 9,
  131409. /** LS */
  131410. LS = 10,
  131411. /** RS */
  131412. RS = 11,
  131413. /** DPadUp */
  131414. DPadUp = 12,
  131415. /** DPadDown */
  131416. DPadDown = 13,
  131417. /** DPadLeft */
  131418. DPadLeft = 14,
  131419. /** DRight */
  131420. DPadRight = 15,
  131421. /** Home */
  131422. Home = 16,
  131423. /** Capture */
  131424. Capture = 17,
  131425. /** LStickXAxis */
  131426. LStickXAxis = 18,
  131427. /** LStickYAxis */
  131428. LStickYAxis = 19,
  131429. /** RStickXAxis */
  131430. RStickXAxis = 20,
  131431. /** RStickYAxis */
  131432. RStickYAxis = 21
  131433. }
  131434. }
  131435. declare module BABYLON {
  131436. /**
  131437. * This class will take all inputs from Keyboard, Pointer, and
  131438. * any Gamepads and provide a polling system that all devices
  131439. * will use. This class assumes that there will only be one
  131440. * pointer device and one keyboard.
  131441. */
  131442. export class DeviceInputSystem implements IDisposable {
  131443. /**
  131444. * Callback to be triggered when a device is connected
  131445. */
  131446. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131447. /**
  131448. * Callback to be triggered when a device is disconnected
  131449. */
  131450. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131451. /**
  131452. * Callback to be triggered when event driven input is updated
  131453. */
  131454. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  131455. private _inputs;
  131456. private _gamepads;
  131457. private _keyboardActive;
  131458. private _pointerActive;
  131459. private _elementToAttachTo;
  131460. private _keyboardDownEvent;
  131461. private _keyboardUpEvent;
  131462. private _pointerMoveEvent;
  131463. private _pointerDownEvent;
  131464. private _pointerUpEvent;
  131465. private _gamepadConnectedEvent;
  131466. private _gamepadDisconnectedEvent;
  131467. private static _MAX_KEYCODES;
  131468. private static _MAX_POINTER_INPUTS;
  131469. private constructor();
  131470. /**
  131471. * Creates a new DeviceInputSystem instance
  131472. * @param engine Engine to pull input element from
  131473. * @returns The new instance
  131474. */
  131475. static Create(engine: Engine): DeviceInputSystem;
  131476. /**
  131477. * Checks for current device input value, given an id and input index
  131478. * @param deviceName Id of connected device
  131479. * @param inputIndex Index of device input
  131480. * @returns Current value of input
  131481. */
  131482. /**
  131483. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  131484. * @param deviceType Enum specifiying device type
  131485. * @param deviceSlot "Slot" or index that device is referenced in
  131486. * @param inputIndex Id of input to be checked
  131487. * @returns Current value of input
  131488. */
  131489. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  131490. /**
  131491. * Dispose of all the eventlisteners
  131492. */
  131493. dispose(): void;
  131494. /**
  131495. * Add device and inputs to device array
  131496. * @param deviceType Enum specifiying device type
  131497. * @param deviceSlot "Slot" or index that device is referenced in
  131498. * @param numberOfInputs Number of input entries to create for given device
  131499. */
  131500. private _registerDevice;
  131501. /**
  131502. * Given a specific device name, remove that device from the device map
  131503. * @param deviceType Enum specifiying device type
  131504. * @param deviceSlot "Slot" or index that device is referenced in
  131505. */
  131506. private _unregisterDevice;
  131507. /**
  131508. * Handle all actions that come from keyboard interaction
  131509. */
  131510. private _handleKeyActions;
  131511. /**
  131512. * Handle all actions that come from pointer interaction
  131513. */
  131514. private _handlePointerActions;
  131515. /**
  131516. * Handle all actions that come from gamepad interaction
  131517. */
  131518. private _handleGamepadActions;
  131519. /**
  131520. * Update all non-event based devices with each frame
  131521. * @param deviceType Enum specifiying device type
  131522. * @param deviceSlot "Slot" or index that device is referenced in
  131523. * @param inputIndex Id of input to be checked
  131524. */
  131525. private _updateDevice;
  131526. /**
  131527. * Gets DeviceType from the device name
  131528. * @param deviceName Name of Device from DeviceInputSystem
  131529. * @returns DeviceType enum value
  131530. */
  131531. private _getGamepadDeviceType;
  131532. }
  131533. }
  131534. declare module BABYLON {
  131535. /**
  131536. * Type to handle enforcement of inputs
  131537. */
  131538. 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;
  131539. }
  131540. declare module BABYLON {
  131541. /**
  131542. * Class that handles all input for a specific device
  131543. */
  131544. export class DeviceSource<T extends DeviceType> {
  131545. /** Type of device */
  131546. readonly deviceType: DeviceType;
  131547. /** "Slot" or index that device is referenced in */
  131548. readonly deviceSlot: number;
  131549. /**
  131550. * Observable to handle device input changes per device
  131551. */
  131552. readonly onInputChangedObservable: Observable<{
  131553. inputIndex: DeviceInput<T>;
  131554. previousState: Nullable<number>;
  131555. currentState: Nullable<number>;
  131556. }>;
  131557. private readonly _deviceInputSystem;
  131558. /**
  131559. * Default Constructor
  131560. * @param deviceInputSystem Reference to DeviceInputSystem
  131561. * @param deviceType Type of device
  131562. * @param deviceSlot "Slot" or index that device is referenced in
  131563. */
  131564. constructor(deviceInputSystem: DeviceInputSystem,
  131565. /** Type of device */
  131566. deviceType: DeviceType,
  131567. /** "Slot" or index that device is referenced in */
  131568. deviceSlot?: number);
  131569. /**
  131570. * Get input for specific input
  131571. * @param inputIndex index of specific input on device
  131572. * @returns Input value from DeviceInputSystem
  131573. */
  131574. getInput(inputIndex: DeviceInput<T>): number;
  131575. }
  131576. /**
  131577. * Class to keep track of devices
  131578. */
  131579. export class DeviceSourceManager implements IDisposable {
  131580. /**
  131581. * Observable to be triggered when before a device is connected
  131582. */
  131583. readonly onBeforeDeviceConnectedObservable: Observable<{
  131584. deviceType: DeviceType;
  131585. deviceSlot: number;
  131586. }>;
  131587. /**
  131588. * Observable to be triggered when before a device is disconnected
  131589. */
  131590. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  131591. deviceType: DeviceType;
  131592. deviceSlot: number;
  131593. }>;
  131594. /**
  131595. * Observable to be triggered when after a device is connected
  131596. */
  131597. readonly onAfterDeviceConnectedObservable: Observable<{
  131598. deviceType: DeviceType;
  131599. deviceSlot: number;
  131600. }>;
  131601. /**
  131602. * Observable to be triggered when after a device is disconnected
  131603. */
  131604. readonly onAfterDeviceDisconnectedObservable: Observable<{
  131605. deviceType: DeviceType;
  131606. deviceSlot: number;
  131607. }>;
  131608. private readonly _devices;
  131609. private readonly _firstDevice;
  131610. private readonly _deviceInputSystem;
  131611. /**
  131612. * Default Constructor
  131613. * @param engine engine to pull input element from
  131614. */
  131615. constructor(engine: Engine);
  131616. /**
  131617. * Gets a DeviceSource, given a type and slot
  131618. * @param deviceType Enum specifying device type
  131619. * @param deviceSlot "Slot" or index that device is referenced in
  131620. * @returns DeviceSource object
  131621. */
  131622. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  131623. /**
  131624. * Gets an array of DeviceSource objects for a given device type
  131625. * @param deviceType Enum specifying device type
  131626. * @returns Array of DeviceSource objects
  131627. */
  131628. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  131629. /**
  131630. * Dispose of DeviceInputSystem and other parts
  131631. */
  131632. dispose(): void;
  131633. /**
  131634. * Function to add device name to device list
  131635. * @param deviceType Enum specifying device type
  131636. * @param deviceSlot "Slot" or index that device is referenced in
  131637. */
  131638. private _addDevice;
  131639. /**
  131640. * Function to remove device name to device list
  131641. * @param deviceType Enum specifying device type
  131642. * @param deviceSlot "Slot" or index that device is referenced in
  131643. */
  131644. private _removeDevice;
  131645. /**
  131646. * Updates array storing first connected device of each type
  131647. * @param type Type of Device
  131648. */
  131649. private _updateFirstDevices;
  131650. }
  131651. }
  131652. declare module BABYLON {
  131653. /**
  131654. * Options to create the null engine
  131655. */
  131656. export class NullEngineOptions {
  131657. /**
  131658. * Render width (Default: 512)
  131659. */
  131660. renderWidth: number;
  131661. /**
  131662. * Render height (Default: 256)
  131663. */
  131664. renderHeight: number;
  131665. /**
  131666. * Texture size (Default: 512)
  131667. */
  131668. textureSize: number;
  131669. /**
  131670. * If delta time between frames should be constant
  131671. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131672. */
  131673. deterministicLockstep: boolean;
  131674. /**
  131675. * Maximum about of steps between frames (Default: 4)
  131676. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131677. */
  131678. lockstepMaxSteps: number;
  131679. /**
  131680. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  131681. */
  131682. useHighPrecisionMatrix?: boolean;
  131683. }
  131684. /**
  131685. * The null engine class provides support for headless version of babylon.js.
  131686. * This can be used in server side scenario or for testing purposes
  131687. */
  131688. export class NullEngine extends Engine {
  131689. private _options;
  131690. /**
  131691. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  131692. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131693. * @returns true if engine is in deterministic lock step mode
  131694. */
  131695. isDeterministicLockStep(): boolean;
  131696. /**
  131697. * Gets the max steps when engine is running in deterministic lock step
  131698. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131699. * @returns the max steps
  131700. */
  131701. getLockstepMaxSteps(): number;
  131702. /**
  131703. * Gets the current hardware scaling level.
  131704. * By default the hardware scaling level is computed from the window device ratio.
  131705. * 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.
  131706. * @returns a number indicating the current hardware scaling level
  131707. */
  131708. getHardwareScalingLevel(): number;
  131709. constructor(options?: NullEngineOptions);
  131710. /**
  131711. * Creates a vertex buffer
  131712. * @param vertices the data for the vertex buffer
  131713. * @returns the new WebGL static buffer
  131714. */
  131715. createVertexBuffer(vertices: FloatArray): DataBuffer;
  131716. /**
  131717. * Creates a new index buffer
  131718. * @param indices defines the content of the index buffer
  131719. * @param updatable defines if the index buffer must be updatable
  131720. * @returns a new webGL buffer
  131721. */
  131722. createIndexBuffer(indices: IndicesArray): DataBuffer;
  131723. /**
  131724. * Clear the current render buffer or the current render target (if any is set up)
  131725. * @param color defines the color to use
  131726. * @param backBuffer defines if the back buffer must be cleared
  131727. * @param depth defines if the depth buffer must be cleared
  131728. * @param stencil defines if the stencil buffer must be cleared
  131729. */
  131730. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  131731. /**
  131732. * Gets the current render width
  131733. * @param useScreen defines if screen size must be used (or the current render target if any)
  131734. * @returns a number defining the current render width
  131735. */
  131736. getRenderWidth(useScreen?: boolean): number;
  131737. /**
  131738. * Gets the current render height
  131739. * @param useScreen defines if screen size must be used (or the current render target if any)
  131740. * @returns a number defining the current render height
  131741. */
  131742. getRenderHeight(useScreen?: boolean): number;
  131743. /**
  131744. * Set the WebGL's viewport
  131745. * @param viewport defines the viewport element to be used
  131746. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  131747. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  131748. */
  131749. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  131750. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  131751. /**
  131752. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  131753. * @param pipelineContext defines the pipeline context to use
  131754. * @param uniformsNames defines the list of uniform names
  131755. * @returns an array of webGL uniform locations
  131756. */
  131757. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  131758. /**
  131759. * Gets the lsit of active attributes for a given webGL program
  131760. * @param pipelineContext defines the pipeline context to use
  131761. * @param attributesNames defines the list of attribute names to get
  131762. * @returns an array of indices indicating the offset of each attribute
  131763. */
  131764. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  131765. /**
  131766. * Binds an effect to the webGL context
  131767. * @param effect defines the effect to bind
  131768. */
  131769. bindSamplers(effect: Effect): void;
  131770. /**
  131771. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  131772. * @param effect defines the effect to activate
  131773. */
  131774. enableEffect(effect: Effect): void;
  131775. /**
  131776. * Set various states to the webGL context
  131777. * @param culling defines backface culling state
  131778. * @param zOffset defines the value to apply to zOffset (0 by default)
  131779. * @param force defines if states must be applied even if cache is up to date
  131780. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  131781. */
  131782. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  131783. /**
  131784. * Set the value of an uniform to an array of int32
  131785. * @param uniform defines the webGL uniform location where to store the value
  131786. * @param array defines the array of int32 to store
  131787. */
  131788. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  131789. /**
  131790. * Set the value of an uniform to an array of int32 (stored as vec2)
  131791. * @param uniform defines the webGL uniform location where to store the value
  131792. * @param array defines the array of int32 to store
  131793. */
  131794. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  131795. /**
  131796. * Set the value of an uniform to an array of int32 (stored as vec3)
  131797. * @param uniform defines the webGL uniform location where to store the value
  131798. * @param array defines the array of int32 to store
  131799. */
  131800. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  131801. /**
  131802. * Set the value of an uniform to an array of int32 (stored as vec4)
  131803. * @param uniform defines the webGL uniform location where to store the value
  131804. * @param array defines the array of int32 to store
  131805. */
  131806. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  131807. /**
  131808. * Set the value of an uniform to an array of float32
  131809. * @param uniform defines the webGL uniform location where to store the value
  131810. * @param array defines the array of float32 to store
  131811. */
  131812. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  131813. /**
  131814. * Set the value of an uniform to an array of float32 (stored as vec2)
  131815. * @param uniform defines the webGL uniform location where to store the value
  131816. * @param array defines the array of float32 to store
  131817. */
  131818. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  131819. /**
  131820. * Set the value of an uniform to an array of float32 (stored as vec3)
  131821. * @param uniform defines the webGL uniform location where to store the value
  131822. * @param array defines the array of float32 to store
  131823. */
  131824. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  131825. /**
  131826. * Set the value of an uniform to an array of float32 (stored as vec4)
  131827. * @param uniform defines the webGL uniform location where to store the value
  131828. * @param array defines the array of float32 to store
  131829. */
  131830. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  131831. /**
  131832. * Set the value of an uniform to an array of number
  131833. * @param uniform defines the webGL uniform location where to store the value
  131834. * @param array defines the array of number to store
  131835. */
  131836. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  131837. /**
  131838. * Set the value of an uniform to an array of number (stored as vec2)
  131839. * @param uniform defines the webGL uniform location where to store the value
  131840. * @param array defines the array of number to store
  131841. */
  131842. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  131843. /**
  131844. * Set the value of an uniform to an array of number (stored as vec3)
  131845. * @param uniform defines the webGL uniform location where to store the value
  131846. * @param array defines the array of number to store
  131847. */
  131848. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  131849. /**
  131850. * Set the value of an uniform to an array of number (stored as vec4)
  131851. * @param uniform defines the webGL uniform location where to store the value
  131852. * @param array defines the array of number to store
  131853. */
  131854. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  131855. /**
  131856. * Set the value of an uniform to an array of float32 (stored as matrices)
  131857. * @param uniform defines the webGL uniform location where to store the value
  131858. * @param matrices defines the array of float32 to store
  131859. */
  131860. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  131861. /**
  131862. * Set the value of an uniform to a matrix (3x3)
  131863. * @param uniform defines the webGL uniform location where to store the value
  131864. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  131865. */
  131866. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131867. /**
  131868. * Set the value of an uniform to a matrix (2x2)
  131869. * @param uniform defines the webGL uniform location where to store the value
  131870. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  131871. */
  131872. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131873. /**
  131874. * Set the value of an uniform to a number (float)
  131875. * @param uniform defines the webGL uniform location where to store the value
  131876. * @param value defines the float number to store
  131877. */
  131878. setFloat(uniform: WebGLUniformLocation, value: number): void;
  131879. /**
  131880. * Set the value of an uniform to a vec2
  131881. * @param uniform defines the webGL uniform location where to store the value
  131882. * @param x defines the 1st component of the value
  131883. * @param y defines the 2nd component of the value
  131884. */
  131885. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  131886. /**
  131887. * Set the value of an uniform to a vec3
  131888. * @param uniform defines the webGL uniform location where to store the value
  131889. * @param x defines the 1st component of the value
  131890. * @param y defines the 2nd component of the value
  131891. * @param z defines the 3rd component of the value
  131892. */
  131893. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  131894. /**
  131895. * Set the value of an uniform to a boolean
  131896. * @param uniform defines the webGL uniform location where to store the value
  131897. * @param bool defines the boolean to store
  131898. */
  131899. setBool(uniform: WebGLUniformLocation, bool: number): void;
  131900. /**
  131901. * Set the value of an uniform to a vec4
  131902. * @param uniform defines the webGL uniform location where to store the value
  131903. * @param x defines the 1st component of the value
  131904. * @param y defines the 2nd component of the value
  131905. * @param z defines the 3rd component of the value
  131906. * @param w defines the 4th component of the value
  131907. */
  131908. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  131909. /**
  131910. * Sets the current alpha mode
  131911. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  131912. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  131913. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131914. */
  131915. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  131916. /**
  131917. * Bind webGl buffers directly to the webGL context
  131918. * @param vertexBuffers defines the vertex buffer to bind
  131919. * @param indexBuffer defines the index buffer to bind
  131920. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  131921. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  131922. * @param effect defines the effect associated with the vertex buffer
  131923. */
  131924. bindBuffers(vertexBuffers: {
  131925. [key: string]: VertexBuffer;
  131926. }, indexBuffer: DataBuffer, effect: Effect): void;
  131927. /**
  131928. * Force the entire cache to be cleared
  131929. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  131930. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  131931. */
  131932. wipeCaches(bruteForce?: boolean): void;
  131933. /**
  131934. * Send a draw order
  131935. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  131936. * @param indexStart defines the starting index
  131937. * @param indexCount defines the number of index to draw
  131938. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131939. */
  131940. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  131941. /**
  131942. * Draw a list of indexed primitives
  131943. * @param fillMode defines the primitive to use
  131944. * @param indexStart defines the starting index
  131945. * @param indexCount defines the number of index to draw
  131946. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131947. */
  131948. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  131949. /**
  131950. * Draw a list of unindexed primitives
  131951. * @param fillMode defines the primitive to use
  131952. * @param verticesStart defines the index of first vertex to draw
  131953. * @param verticesCount defines the count of vertices to draw
  131954. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131955. */
  131956. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  131957. /** @hidden */
  131958. _createTexture(): WebGLTexture;
  131959. /** @hidden */
  131960. _releaseTexture(texture: InternalTexture): void;
  131961. /**
  131962. * Usually called from Texture.ts.
  131963. * Passed information to create a WebGLTexture
  131964. * @param urlArg defines a value which contains one of the following:
  131965. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  131966. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  131967. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  131968. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  131969. * @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)
  131970. * @param scene needed for loading to the correct scene
  131971. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  131972. * @param onLoad optional callback to be called upon successful completion
  131973. * @param onError optional callback to be called upon failure
  131974. * @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
  131975. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  131976. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  131977. * @param forcedExtension defines the extension to use to pick the right loader
  131978. * @param mimeType defines an optional mime type
  131979. * @returns a InternalTexture for assignment back into BABYLON.Texture
  131980. */
  131981. 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;
  131982. /**
  131983. * Creates a new render target texture
  131984. * @param size defines the size of the texture
  131985. * @param options defines the options used to create the texture
  131986. * @returns a new render target texture stored in an InternalTexture
  131987. */
  131988. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  131989. /**
  131990. * Update the sampling mode of a given texture
  131991. * @param samplingMode defines the required sampling mode
  131992. * @param texture defines the texture to update
  131993. */
  131994. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  131995. /**
  131996. * Binds the frame buffer to the specified texture.
  131997. * @param texture The texture to render to or null for the default canvas
  131998. * @param faceIndex The face of the texture to render to in case of cube texture
  131999. * @param requiredWidth The width of the target to render to
  132000. * @param requiredHeight The height of the target to render to
  132001. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  132002. * @param lodLevel defines le lod level to bind to the frame buffer
  132003. */
  132004. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132005. /**
  132006. * Unbind the current render target texture from the webGL context
  132007. * @param texture defines the render target texture to unbind
  132008. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  132009. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  132010. */
  132011. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132012. /**
  132013. * Creates a dynamic vertex buffer
  132014. * @param vertices the data for the dynamic vertex buffer
  132015. * @returns the new WebGL dynamic buffer
  132016. */
  132017. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  132018. /**
  132019. * Update the content of a dynamic texture
  132020. * @param texture defines the texture to update
  132021. * @param canvas defines the canvas containing the source
  132022. * @param invertY defines if data must be stored with Y axis inverted
  132023. * @param premulAlpha defines if alpha is stored as premultiplied
  132024. * @param format defines the format of the data
  132025. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  132026. */
  132027. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  132028. /**
  132029. * Gets a boolean indicating if all created effects are ready
  132030. * @returns true if all effects are ready
  132031. */
  132032. areAllEffectsReady(): boolean;
  132033. /**
  132034. * @hidden
  132035. * Get the current error code of the webGL context
  132036. * @returns the error code
  132037. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  132038. */
  132039. getError(): number;
  132040. /** @hidden */
  132041. _getUnpackAlignement(): number;
  132042. /** @hidden */
  132043. _unpackFlipY(value: boolean): void;
  132044. /**
  132045. * Update a dynamic index buffer
  132046. * @param indexBuffer defines the target index buffer
  132047. * @param indices defines the data to update
  132048. * @param offset defines the offset in the target index buffer where update should start
  132049. */
  132050. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  132051. /**
  132052. * Updates a dynamic vertex buffer.
  132053. * @param vertexBuffer the vertex buffer to update
  132054. * @param vertices the data used to update the vertex buffer
  132055. * @param byteOffset the byte offset of the data (optional)
  132056. * @param byteLength the byte length of the data (optional)
  132057. */
  132058. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  132059. /** @hidden */
  132060. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  132061. /** @hidden */
  132062. _bindTexture(channel: number, texture: InternalTexture): void;
  132063. protected _deleteBuffer(buffer: WebGLBuffer): void;
  132064. /**
  132065. * 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
  132066. */
  132067. releaseEffects(): void;
  132068. displayLoadingUI(): void;
  132069. hideLoadingUI(): void;
  132070. /** @hidden */
  132071. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132072. /** @hidden */
  132073. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132074. /** @hidden */
  132075. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132076. /** @hidden */
  132077. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132078. }
  132079. }
  132080. declare module BABYLON {
  132081. /**
  132082. * @hidden
  132083. **/
  132084. export class _TimeToken {
  132085. _startTimeQuery: Nullable<WebGLQuery>;
  132086. _endTimeQuery: Nullable<WebGLQuery>;
  132087. _timeElapsedQuery: Nullable<WebGLQuery>;
  132088. _timeElapsedQueryEnded: boolean;
  132089. }
  132090. }
  132091. declare module BABYLON {
  132092. /** @hidden */
  132093. export class _OcclusionDataStorage {
  132094. /** @hidden */
  132095. occlusionInternalRetryCounter: number;
  132096. /** @hidden */
  132097. isOcclusionQueryInProgress: boolean;
  132098. /** @hidden */
  132099. isOccluded: boolean;
  132100. /** @hidden */
  132101. occlusionRetryCount: number;
  132102. /** @hidden */
  132103. occlusionType: number;
  132104. /** @hidden */
  132105. occlusionQueryAlgorithmType: number;
  132106. }
  132107. interface Engine {
  132108. /**
  132109. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  132110. * @return the new query
  132111. */
  132112. createQuery(): WebGLQuery;
  132113. /**
  132114. * Delete and release a webGL query
  132115. * @param query defines the query to delete
  132116. * @return the current engine
  132117. */
  132118. deleteQuery(query: WebGLQuery): Engine;
  132119. /**
  132120. * Check if a given query has resolved and got its value
  132121. * @param query defines the query to check
  132122. * @returns true if the query got its value
  132123. */
  132124. isQueryResultAvailable(query: WebGLQuery): boolean;
  132125. /**
  132126. * Gets the value of a given query
  132127. * @param query defines the query to check
  132128. * @returns the value of the query
  132129. */
  132130. getQueryResult(query: WebGLQuery): number;
  132131. /**
  132132. * Initiates an occlusion query
  132133. * @param algorithmType defines the algorithm to use
  132134. * @param query defines the query to use
  132135. * @returns the current engine
  132136. * @see https://doc.babylonjs.com/features/occlusionquery
  132137. */
  132138. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  132139. /**
  132140. * Ends an occlusion query
  132141. * @see https://doc.babylonjs.com/features/occlusionquery
  132142. * @param algorithmType defines the algorithm to use
  132143. * @returns the current engine
  132144. */
  132145. endOcclusionQuery(algorithmType: number): Engine;
  132146. /**
  132147. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  132148. * Please note that only one query can be issued at a time
  132149. * @returns a time token used to track the time span
  132150. */
  132151. startTimeQuery(): Nullable<_TimeToken>;
  132152. /**
  132153. * Ends a time query
  132154. * @param token defines the token used to measure the time span
  132155. * @returns the time spent (in ns)
  132156. */
  132157. endTimeQuery(token: _TimeToken): int;
  132158. /** @hidden */
  132159. _currentNonTimestampToken: Nullable<_TimeToken>;
  132160. /** @hidden */
  132161. _createTimeQuery(): WebGLQuery;
  132162. /** @hidden */
  132163. _deleteTimeQuery(query: WebGLQuery): void;
  132164. /** @hidden */
  132165. _getGlAlgorithmType(algorithmType: number): number;
  132166. /** @hidden */
  132167. _getTimeQueryResult(query: WebGLQuery): any;
  132168. /** @hidden */
  132169. _getTimeQueryAvailability(query: WebGLQuery): any;
  132170. }
  132171. interface AbstractMesh {
  132172. /**
  132173. * Backing filed
  132174. * @hidden
  132175. */
  132176. __occlusionDataStorage: _OcclusionDataStorage;
  132177. /**
  132178. * Access property
  132179. * @hidden
  132180. */
  132181. _occlusionDataStorage: _OcclusionDataStorage;
  132182. /**
  132183. * 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.
  132184. * The default value is -1 which means don't break the query and wait till the result
  132185. * @see https://doc.babylonjs.com/features/occlusionquery
  132186. */
  132187. occlusionRetryCount: number;
  132188. /**
  132189. * 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:
  132190. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  132191. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  132192. * * 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.
  132193. * @see https://doc.babylonjs.com/features/occlusionquery
  132194. */
  132195. occlusionType: number;
  132196. /**
  132197. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  132198. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  132199. * * 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.
  132200. * @see https://doc.babylonjs.com/features/occlusionquery
  132201. */
  132202. occlusionQueryAlgorithmType: number;
  132203. /**
  132204. * 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
  132205. * @see https://doc.babylonjs.com/features/occlusionquery
  132206. */
  132207. isOccluded: boolean;
  132208. /**
  132209. * Flag to check the progress status of the query
  132210. * @see https://doc.babylonjs.com/features/occlusionquery
  132211. */
  132212. isOcclusionQueryInProgress: boolean;
  132213. }
  132214. }
  132215. declare module BABYLON {
  132216. /** @hidden */
  132217. export var _forceTransformFeedbackToBundle: boolean;
  132218. interface Engine {
  132219. /**
  132220. * Creates a webGL transform feedback object
  132221. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  132222. * @returns the webGL transform feedback object
  132223. */
  132224. createTransformFeedback(): WebGLTransformFeedback;
  132225. /**
  132226. * Delete a webGL transform feedback object
  132227. * @param value defines the webGL transform feedback object to delete
  132228. */
  132229. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  132230. /**
  132231. * Bind a webGL transform feedback object to the webgl context
  132232. * @param value defines the webGL transform feedback object to bind
  132233. */
  132234. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  132235. /**
  132236. * Begins a transform feedback operation
  132237. * @param usePoints defines if points or triangles must be used
  132238. */
  132239. beginTransformFeedback(usePoints: boolean): void;
  132240. /**
  132241. * Ends a transform feedback operation
  132242. */
  132243. endTransformFeedback(): void;
  132244. /**
  132245. * Specify the varyings to use with transform feedback
  132246. * @param program defines the associated webGL program
  132247. * @param value defines the list of strings representing the varying names
  132248. */
  132249. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  132250. /**
  132251. * Bind a webGL buffer for a transform feedback operation
  132252. * @param value defines the webGL buffer to bind
  132253. */
  132254. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  132255. }
  132256. }
  132257. declare module BABYLON {
  132258. /**
  132259. * Class used to define an additional view for the engine
  132260. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132261. */
  132262. export class EngineView {
  132263. /** Defines the canvas where to render the view */
  132264. target: HTMLCanvasElement;
  132265. /** Defines an optional camera used to render the view (will use active camera else) */
  132266. camera?: Camera;
  132267. }
  132268. interface Engine {
  132269. /**
  132270. * Gets or sets the HTML element to use for attaching events
  132271. */
  132272. inputElement: Nullable<HTMLElement>;
  132273. /**
  132274. * Gets the current engine view
  132275. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132276. */
  132277. activeView: Nullable<EngineView>;
  132278. /** Gets or sets the list of views */
  132279. views: EngineView[];
  132280. /**
  132281. * Register a new child canvas
  132282. * @param canvas defines the canvas to register
  132283. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  132284. * @returns the associated view
  132285. */
  132286. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  132287. /**
  132288. * Remove a registered child canvas
  132289. * @param canvas defines the canvas to remove
  132290. * @returns the current engine
  132291. */
  132292. unRegisterView(canvas: HTMLCanvasElement): Engine;
  132293. }
  132294. }
  132295. declare module BABYLON {
  132296. interface Engine {
  132297. /** @hidden */
  132298. _excludedCompressedTextures: string[];
  132299. /** @hidden */
  132300. _textureFormatInUse: string;
  132301. /**
  132302. * Gets the list of texture formats supported
  132303. */
  132304. readonly texturesSupported: Array<string>;
  132305. /**
  132306. * Gets the texture format in use
  132307. */
  132308. readonly textureFormatInUse: Nullable<string>;
  132309. /**
  132310. * Set the compressed texture extensions or file names to skip.
  132311. *
  132312. * @param skippedFiles defines the list of those texture files you want to skip
  132313. * Example: [".dds", ".env", "myfile.png"]
  132314. */
  132315. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  132316. /**
  132317. * Set the compressed texture format to use, based on the formats you have, and the formats
  132318. * supported by the hardware / browser.
  132319. *
  132320. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  132321. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  132322. * to API arguments needed to compressed textures. This puts the burden on the container
  132323. * generator to house the arcane code for determining these for current & future formats.
  132324. *
  132325. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  132326. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  132327. *
  132328. * Note: The result of this call is not taken into account when a texture is base64.
  132329. *
  132330. * @param formatsAvailable defines the list of those format families you have created
  132331. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  132332. *
  132333. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  132334. * @returns The extension selected.
  132335. */
  132336. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  132337. }
  132338. }
  132339. declare module BABYLON {
  132340. /**
  132341. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  132342. */
  132343. export interface CubeMapInfo {
  132344. /**
  132345. * The pixel array for the front face.
  132346. * This is stored in format, left to right, up to down format.
  132347. */
  132348. front: Nullable<ArrayBufferView>;
  132349. /**
  132350. * The pixel array for the back face.
  132351. * This is stored in format, left to right, up to down format.
  132352. */
  132353. back: Nullable<ArrayBufferView>;
  132354. /**
  132355. * The pixel array for the left face.
  132356. * This is stored in format, left to right, up to down format.
  132357. */
  132358. left: Nullable<ArrayBufferView>;
  132359. /**
  132360. * The pixel array for the right face.
  132361. * This is stored in format, left to right, up to down format.
  132362. */
  132363. right: Nullable<ArrayBufferView>;
  132364. /**
  132365. * The pixel array for the up face.
  132366. * This is stored in format, left to right, up to down format.
  132367. */
  132368. up: Nullable<ArrayBufferView>;
  132369. /**
  132370. * The pixel array for the down face.
  132371. * This is stored in format, left to right, up to down format.
  132372. */
  132373. down: Nullable<ArrayBufferView>;
  132374. /**
  132375. * The size of the cubemap stored.
  132376. *
  132377. * Each faces will be size * size pixels.
  132378. */
  132379. size: number;
  132380. /**
  132381. * The format of the texture.
  132382. *
  132383. * RGBA, RGB.
  132384. */
  132385. format: number;
  132386. /**
  132387. * The type of the texture data.
  132388. *
  132389. * UNSIGNED_INT, FLOAT.
  132390. */
  132391. type: number;
  132392. /**
  132393. * Specifies whether the texture is in gamma space.
  132394. */
  132395. gammaSpace: boolean;
  132396. }
  132397. /**
  132398. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  132399. */
  132400. export class PanoramaToCubeMapTools {
  132401. private static FACE_LEFT;
  132402. private static FACE_RIGHT;
  132403. private static FACE_FRONT;
  132404. private static FACE_BACK;
  132405. private static FACE_DOWN;
  132406. private static FACE_UP;
  132407. /**
  132408. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  132409. *
  132410. * @param float32Array The source data.
  132411. * @param inputWidth The width of the input panorama.
  132412. * @param inputHeight The height of the input panorama.
  132413. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  132414. * @return The cubemap data
  132415. */
  132416. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  132417. private static CreateCubemapTexture;
  132418. private static CalcProjectionSpherical;
  132419. }
  132420. }
  132421. declare module BABYLON {
  132422. /**
  132423. * Helper class dealing with the extraction of spherical polynomial dataArray
  132424. * from a cube map.
  132425. */
  132426. export class CubeMapToSphericalPolynomialTools {
  132427. private static FileFaces;
  132428. /**
  132429. * Converts a texture to the according Spherical Polynomial data.
  132430. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132431. *
  132432. * @param texture The texture to extract the information from.
  132433. * @return The Spherical Polynomial data.
  132434. */
  132435. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  132436. /**
  132437. * Converts a cubemap to the according Spherical Polynomial data.
  132438. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132439. *
  132440. * @param cubeInfo The Cube map to extract the information from.
  132441. * @return The Spherical Polynomial data.
  132442. */
  132443. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  132444. }
  132445. }
  132446. declare module BABYLON {
  132447. interface BaseTexture {
  132448. /**
  132449. * Get the polynomial representation of the texture data.
  132450. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  132451. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  132452. */
  132453. sphericalPolynomial: Nullable<SphericalPolynomial>;
  132454. }
  132455. }
  132456. declare module BABYLON {
  132457. /** @hidden */
  132458. export var rgbdEncodePixelShader: {
  132459. name: string;
  132460. shader: string;
  132461. };
  132462. }
  132463. declare module BABYLON {
  132464. /** @hidden */
  132465. export var rgbdDecodePixelShader: {
  132466. name: string;
  132467. shader: string;
  132468. };
  132469. }
  132470. declare module BABYLON {
  132471. /**
  132472. * Raw texture data and descriptor sufficient for WebGL texture upload
  132473. */
  132474. export interface EnvironmentTextureInfo {
  132475. /**
  132476. * Version of the environment map
  132477. */
  132478. version: number;
  132479. /**
  132480. * Width of image
  132481. */
  132482. width: number;
  132483. /**
  132484. * Irradiance information stored in the file.
  132485. */
  132486. irradiance: any;
  132487. /**
  132488. * Specular information stored in the file.
  132489. */
  132490. specular: any;
  132491. }
  132492. /**
  132493. * Defines One Image in the file. It requires only the position in the file
  132494. * as well as the length.
  132495. */
  132496. interface BufferImageData {
  132497. /**
  132498. * Length of the image data.
  132499. */
  132500. length: number;
  132501. /**
  132502. * Position of the data from the null terminator delimiting the end of the JSON.
  132503. */
  132504. position: number;
  132505. }
  132506. /**
  132507. * Defines the specular data enclosed in the file.
  132508. * This corresponds to the version 1 of the data.
  132509. */
  132510. export interface EnvironmentTextureSpecularInfoV1 {
  132511. /**
  132512. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  132513. */
  132514. specularDataPosition?: number;
  132515. /**
  132516. * This contains all the images data needed to reconstruct the cubemap.
  132517. */
  132518. mipmaps: Array<BufferImageData>;
  132519. /**
  132520. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  132521. */
  132522. lodGenerationScale: number;
  132523. }
  132524. /**
  132525. * Sets of helpers addressing the serialization and deserialization of environment texture
  132526. * stored in a BabylonJS env file.
  132527. * Those files are usually stored as .env files.
  132528. */
  132529. export class EnvironmentTextureTools {
  132530. /**
  132531. * Magic number identifying the env file.
  132532. */
  132533. private static _MagicBytes;
  132534. /**
  132535. * Gets the environment info from an env file.
  132536. * @param data The array buffer containing the .env bytes.
  132537. * @returns the environment file info (the json header) if successfully parsed.
  132538. */
  132539. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  132540. /**
  132541. * Creates an environment texture from a loaded cube texture.
  132542. * @param texture defines the cube texture to convert in env file
  132543. * @return a promise containing the environment data if succesfull.
  132544. */
  132545. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  132546. /**
  132547. * Creates a JSON representation of the spherical data.
  132548. * @param texture defines the texture containing the polynomials
  132549. * @return the JSON representation of the spherical info
  132550. */
  132551. private static _CreateEnvTextureIrradiance;
  132552. /**
  132553. * Creates the ArrayBufferViews used for initializing environment texture image data.
  132554. * @param data the image data
  132555. * @param info parameters that determine what views will be created for accessing the underlying buffer
  132556. * @return the views described by info providing access to the underlying buffer
  132557. */
  132558. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  132559. /**
  132560. * Uploads the texture info contained in the env file to the GPU.
  132561. * @param texture defines the internal texture to upload to
  132562. * @param data defines the data to load
  132563. * @param info defines the texture info retrieved through the GetEnvInfo method
  132564. * @returns a promise
  132565. */
  132566. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  132567. private static _OnImageReadyAsync;
  132568. /**
  132569. * Uploads the levels of image data to the GPU.
  132570. * @param texture defines the internal texture to upload to
  132571. * @param imageData defines the array buffer views of image data [mipmap][face]
  132572. * @returns a promise
  132573. */
  132574. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  132575. /**
  132576. * Uploads spherical polynomials information to the texture.
  132577. * @param texture defines the texture we are trying to upload the information to
  132578. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  132579. */
  132580. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  132581. /** @hidden */
  132582. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  132583. }
  132584. }
  132585. declare module BABYLON {
  132586. /**
  132587. * Class used to inline functions in shader code
  132588. */
  132589. export class ShaderCodeInliner {
  132590. private static readonly _RegexpFindFunctionNameAndType;
  132591. private _sourceCode;
  132592. private _functionDescr;
  132593. private _numMaxIterations;
  132594. /** Gets or sets the token used to mark the functions to inline */
  132595. inlineToken: string;
  132596. /** Gets or sets the debug mode */
  132597. debug: boolean;
  132598. /** Gets the code after the inlining process */
  132599. get code(): string;
  132600. /**
  132601. * Initializes the inliner
  132602. * @param sourceCode shader code source to inline
  132603. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  132604. */
  132605. constructor(sourceCode: string, numMaxIterations?: number);
  132606. /**
  132607. * Start the processing of the shader code
  132608. */
  132609. processCode(): void;
  132610. private _collectFunctions;
  132611. private _processInlining;
  132612. private _extractBetweenMarkers;
  132613. private _skipWhitespaces;
  132614. private _removeComments;
  132615. private _replaceFunctionCallsByCode;
  132616. private _findBackward;
  132617. private _escapeRegExp;
  132618. private _replaceNames;
  132619. }
  132620. }
  132621. declare module BABYLON {
  132622. /**
  132623. * Container for accessors for natively-stored mesh data buffers.
  132624. */
  132625. class NativeDataBuffer extends DataBuffer {
  132626. /**
  132627. * Accessor value used to identify/retrieve a natively-stored index buffer.
  132628. */
  132629. nativeIndexBuffer?: any;
  132630. /**
  132631. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  132632. */
  132633. nativeVertexBuffer?: any;
  132634. }
  132635. /** @hidden */
  132636. class NativeTexture extends InternalTexture {
  132637. getInternalTexture(): InternalTexture;
  132638. getViewCount(): number;
  132639. }
  132640. /** @hidden */
  132641. export class NativeEngine extends Engine {
  132642. private readonly _native;
  132643. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  132644. private readonly INVALID_HANDLE;
  132645. private _boundBuffersVertexArray;
  132646. getHardwareScalingLevel(): number;
  132647. constructor();
  132648. dispose(): void;
  132649. /**
  132650. * Can be used to override the current requestAnimationFrame requester.
  132651. * @hidden
  132652. */
  132653. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  132654. /**
  132655. * Override default engine behavior.
  132656. * @param color
  132657. * @param backBuffer
  132658. * @param depth
  132659. * @param stencil
  132660. */
  132661. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  132662. /**
  132663. * Gets host document
  132664. * @returns the host document object
  132665. */
  132666. getHostDocument(): Nullable<Document>;
  132667. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  132668. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  132669. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  132670. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  132671. [key: string]: VertexBuffer;
  132672. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  132673. bindBuffers(vertexBuffers: {
  132674. [key: string]: VertexBuffer;
  132675. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  132676. recordVertexArrayObject(vertexBuffers: {
  132677. [key: string]: VertexBuffer;
  132678. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  132679. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  132680. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  132681. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  132682. /**
  132683. * Draw a list of indexed primitives
  132684. * @param fillMode defines the primitive to use
  132685. * @param indexStart defines the starting index
  132686. * @param indexCount defines the number of index to draw
  132687. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132688. */
  132689. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132690. /**
  132691. * Draw a list of unindexed primitives
  132692. * @param fillMode defines the primitive to use
  132693. * @param verticesStart defines the index of first vertex to draw
  132694. * @param verticesCount defines the count of vertices to draw
  132695. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132696. */
  132697. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132698. createPipelineContext(): IPipelineContext;
  132699. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  132700. /** @hidden */
  132701. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  132702. /** @hidden */
  132703. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  132704. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  132705. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  132706. protected _setProgram(program: WebGLProgram): void;
  132707. _releaseEffect(effect: Effect): void;
  132708. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  132709. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  132710. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  132711. bindSamplers(effect: Effect): void;
  132712. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  132713. getRenderWidth(useScreen?: boolean): number;
  132714. getRenderHeight(useScreen?: boolean): number;
  132715. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  132716. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  132717. /**
  132718. * Set the z offset to apply to current rendering
  132719. * @param value defines the offset to apply
  132720. */
  132721. setZOffset(value: number): void;
  132722. /**
  132723. * Gets the current value of the zOffset
  132724. * @returns the current zOffset state
  132725. */
  132726. getZOffset(): number;
  132727. /**
  132728. * Enable or disable depth buffering
  132729. * @param enable defines the state to set
  132730. */
  132731. setDepthBuffer(enable: boolean): void;
  132732. /**
  132733. * Gets a boolean indicating if depth writing is enabled
  132734. * @returns the current depth writing state
  132735. */
  132736. getDepthWrite(): boolean;
  132737. /**
  132738. * Enable or disable depth writing
  132739. * @param enable defines the state to set
  132740. */
  132741. setDepthWrite(enable: boolean): void;
  132742. /**
  132743. * Enable or disable color writing
  132744. * @param enable defines the state to set
  132745. */
  132746. setColorWrite(enable: boolean): void;
  132747. /**
  132748. * Gets a boolean indicating if color writing is enabled
  132749. * @returns the current color writing state
  132750. */
  132751. getColorWrite(): boolean;
  132752. /**
  132753. * Sets alpha constants used by some alpha blending modes
  132754. * @param r defines the red component
  132755. * @param g defines the green component
  132756. * @param b defines the blue component
  132757. * @param a defines the alpha component
  132758. */
  132759. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  132760. /**
  132761. * Sets the current alpha mode
  132762. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  132763. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132764. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132765. */
  132766. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132767. /**
  132768. * Gets the current alpha mode
  132769. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132770. * @returns the current alpha mode
  132771. */
  132772. getAlphaMode(): number;
  132773. setInt(uniform: WebGLUniformLocation, int: number): void;
  132774. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  132775. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  132776. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  132777. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  132778. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  132779. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  132780. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  132781. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  132782. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  132783. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  132784. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  132785. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  132786. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  132787. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  132788. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  132789. setFloat(uniform: WebGLUniformLocation, value: number): void;
  132790. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  132791. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  132792. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  132793. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  132794. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  132795. wipeCaches(bruteForce?: boolean): void;
  132796. _createTexture(): WebGLTexture;
  132797. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  132798. /**
  132799. * Usually called from Texture.ts.
  132800. * Passed information to create a WebGLTexture
  132801. * @param url defines a value which contains one of the following:
  132802. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132803. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132804. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132805. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132806. * @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)
  132807. * @param scene needed for loading to the correct scene
  132808. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132809. * @param onLoad optional callback to be called upon successful completion
  132810. * @param onError optional callback to be called upon failure
  132811. * @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
  132812. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132813. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132814. * @param forcedExtension defines the extension to use to pick the right loader
  132815. * @param mimeType defines an optional mime type
  132816. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132817. */
  132818. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  132819. /**
  132820. * Creates a cube texture
  132821. * @param rootUrl defines the url where the files to load is located
  132822. * @param scene defines the current scene
  132823. * @param files defines the list of files to load (1 per face)
  132824. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  132825. * @param onLoad defines an optional callback raised when the texture is loaded
  132826. * @param onError defines an optional callback raised if there is an issue to load the texture
  132827. * @param format defines the format of the data
  132828. * @param forcedExtension defines the extension to use to pick the right loader
  132829. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  132830. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  132831. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  132832. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  132833. * @returns the cube texture as an InternalTexture
  132834. */
  132835. 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;
  132836. private _getSamplingFilter;
  132837. private static _GetNativeTextureFormat;
  132838. createRenderTargetTexture(size: number | {
  132839. width: number;
  132840. height: number;
  132841. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  132842. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132843. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132844. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132845. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  132846. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  132847. /**
  132848. * Updates a dynamic vertex buffer.
  132849. * @param vertexBuffer the vertex buffer to update
  132850. * @param data the data used to update the vertex buffer
  132851. * @param byteOffset the byte offset of the data (optional)
  132852. * @param byteLength the byte length of the data (optional)
  132853. */
  132854. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  132855. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  132856. private _updateAnisotropicLevel;
  132857. private _getAddressMode;
  132858. /** @hidden */
  132859. _bindTexture(channel: number, texture: InternalTexture): void;
  132860. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  132861. releaseEffects(): void;
  132862. /** @hidden */
  132863. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132864. /** @hidden */
  132865. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132866. /** @hidden */
  132867. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132868. /** @hidden */
  132869. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132870. }
  132871. }
  132872. declare module BABYLON {
  132873. /**
  132874. * Gather the list of clipboard event types as constants.
  132875. */
  132876. export class ClipboardEventTypes {
  132877. /**
  132878. * The clipboard event is fired when a copy command is active (pressed).
  132879. */
  132880. static readonly COPY: number;
  132881. /**
  132882. * The clipboard event is fired when a cut command is active (pressed).
  132883. */
  132884. static readonly CUT: number;
  132885. /**
  132886. * The clipboard event is fired when a paste command is active (pressed).
  132887. */
  132888. static readonly PASTE: number;
  132889. }
  132890. /**
  132891. * This class is used to store clipboard related info for the onClipboardObservable event.
  132892. */
  132893. export class ClipboardInfo {
  132894. /**
  132895. * Defines the type of event (BABYLON.ClipboardEventTypes)
  132896. */
  132897. type: number;
  132898. /**
  132899. * Defines the related dom event
  132900. */
  132901. event: ClipboardEvent;
  132902. /**
  132903. *Creates an instance of ClipboardInfo.
  132904. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  132905. * @param event Defines the related dom event
  132906. */
  132907. constructor(
  132908. /**
  132909. * Defines the type of event (BABYLON.ClipboardEventTypes)
  132910. */
  132911. type: number,
  132912. /**
  132913. * Defines the related dom event
  132914. */
  132915. event: ClipboardEvent);
  132916. /**
  132917. * Get the clipboard event's type from the keycode.
  132918. * @param keyCode Defines the keyCode for the current keyboard event.
  132919. * @return {number}
  132920. */
  132921. static GetTypeFromCharacter(keyCode: number): number;
  132922. }
  132923. }
  132924. declare module BABYLON {
  132925. /**
  132926. * Google Daydream controller
  132927. */
  132928. export class DaydreamController extends WebVRController {
  132929. /**
  132930. * Base Url for the controller model.
  132931. */
  132932. static MODEL_BASE_URL: string;
  132933. /**
  132934. * File name for the controller model.
  132935. */
  132936. static MODEL_FILENAME: string;
  132937. /**
  132938. * Gamepad Id prefix used to identify Daydream Controller.
  132939. */
  132940. static readonly GAMEPAD_ID_PREFIX: string;
  132941. /**
  132942. * Creates a new DaydreamController from a gamepad
  132943. * @param vrGamepad the gamepad that the controller should be created from
  132944. */
  132945. constructor(vrGamepad: any);
  132946. /**
  132947. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132948. * @param scene scene in which to add meshes
  132949. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132950. */
  132951. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132952. /**
  132953. * Called once for each button that changed state since the last frame
  132954. * @param buttonIdx Which button index changed
  132955. * @param state New state of the button
  132956. * @param changes Which properties on the state changed since last frame
  132957. */
  132958. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132959. }
  132960. }
  132961. declare module BABYLON {
  132962. /**
  132963. * Gear VR Controller
  132964. */
  132965. export class GearVRController extends WebVRController {
  132966. /**
  132967. * Base Url for the controller model.
  132968. */
  132969. static MODEL_BASE_URL: string;
  132970. /**
  132971. * File name for the controller model.
  132972. */
  132973. static MODEL_FILENAME: string;
  132974. /**
  132975. * Gamepad Id prefix used to identify this controller.
  132976. */
  132977. static readonly GAMEPAD_ID_PREFIX: string;
  132978. private readonly _buttonIndexToObservableNameMap;
  132979. /**
  132980. * Creates a new GearVRController from a gamepad
  132981. * @param vrGamepad the gamepad that the controller should be created from
  132982. */
  132983. constructor(vrGamepad: any);
  132984. /**
  132985. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132986. * @param scene scene in which to add meshes
  132987. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132988. */
  132989. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132990. /**
  132991. * Called once for each button that changed state since the last frame
  132992. * @param buttonIdx Which button index changed
  132993. * @param state New state of the button
  132994. * @param changes Which properties on the state changed since last frame
  132995. */
  132996. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132997. }
  132998. }
  132999. declare module BABYLON {
  133000. /**
  133001. * Generic Controller
  133002. */
  133003. export class GenericController extends WebVRController {
  133004. /**
  133005. * Base Url for the controller model.
  133006. */
  133007. static readonly MODEL_BASE_URL: string;
  133008. /**
  133009. * File name for the controller model.
  133010. */
  133011. static readonly MODEL_FILENAME: string;
  133012. /**
  133013. * Creates a new GenericController from a gamepad
  133014. * @param vrGamepad the gamepad that the controller should be created from
  133015. */
  133016. constructor(vrGamepad: any);
  133017. /**
  133018. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133019. * @param scene scene in which to add meshes
  133020. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133021. */
  133022. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133023. /**
  133024. * Called once for each button that changed state since the last frame
  133025. * @param buttonIdx Which button index changed
  133026. * @param state New state of the button
  133027. * @param changes Which properties on the state changed since last frame
  133028. */
  133029. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133030. }
  133031. }
  133032. declare module BABYLON {
  133033. /**
  133034. * Oculus Touch Controller
  133035. */
  133036. export class OculusTouchController extends WebVRController {
  133037. /**
  133038. * Base Url for the controller model.
  133039. */
  133040. static MODEL_BASE_URL: string;
  133041. /**
  133042. * File name for the left controller model.
  133043. */
  133044. static MODEL_LEFT_FILENAME: string;
  133045. /**
  133046. * File name for the right controller model.
  133047. */
  133048. static MODEL_RIGHT_FILENAME: string;
  133049. /**
  133050. * Base Url for the Quest controller model.
  133051. */
  133052. static QUEST_MODEL_BASE_URL: string;
  133053. /**
  133054. * @hidden
  133055. * If the controllers are running on a device that needs the updated Quest controller models
  133056. */
  133057. static _IsQuest: boolean;
  133058. /**
  133059. * Fired when the secondary trigger on this controller is modified
  133060. */
  133061. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  133062. /**
  133063. * Fired when the thumb rest on this controller is modified
  133064. */
  133065. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  133066. /**
  133067. * Creates a new OculusTouchController from a gamepad
  133068. * @param vrGamepad the gamepad that the controller should be created from
  133069. */
  133070. constructor(vrGamepad: any);
  133071. /**
  133072. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133073. * @param scene scene in which to add meshes
  133074. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133075. */
  133076. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133077. /**
  133078. * Fired when the A button on this controller is modified
  133079. */
  133080. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133081. /**
  133082. * Fired when the B button on this controller is modified
  133083. */
  133084. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133085. /**
  133086. * Fired when the X button on this controller is modified
  133087. */
  133088. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133089. /**
  133090. * Fired when the Y button on this controller is modified
  133091. */
  133092. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133093. /**
  133094. * Called once for each button that changed state since the last frame
  133095. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  133096. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  133097. * 2) secondary trigger (same)
  133098. * 3) A (right) X (left), touch, pressed = value
  133099. * 4) B / Y
  133100. * 5) thumb rest
  133101. * @param buttonIdx Which button index changed
  133102. * @param state New state of the button
  133103. * @param changes Which properties on the state changed since last frame
  133104. */
  133105. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133106. }
  133107. }
  133108. declare module BABYLON {
  133109. /**
  133110. * Vive Controller
  133111. */
  133112. export class ViveController extends WebVRController {
  133113. /**
  133114. * Base Url for the controller model.
  133115. */
  133116. static MODEL_BASE_URL: string;
  133117. /**
  133118. * File name for the controller model.
  133119. */
  133120. static MODEL_FILENAME: string;
  133121. /**
  133122. * Creates a new ViveController from a gamepad
  133123. * @param vrGamepad the gamepad that the controller should be created from
  133124. */
  133125. constructor(vrGamepad: any);
  133126. /**
  133127. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133128. * @param scene scene in which to add meshes
  133129. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133130. */
  133131. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133132. /**
  133133. * Fired when the left button on this controller is modified
  133134. */
  133135. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133136. /**
  133137. * Fired when the right button on this controller is modified
  133138. */
  133139. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133140. /**
  133141. * Fired when the menu button on this controller is modified
  133142. */
  133143. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133144. /**
  133145. * Called once for each button that changed state since the last frame
  133146. * Vive mapping:
  133147. * 0: touchpad
  133148. * 1: trigger
  133149. * 2: left AND right buttons
  133150. * 3: menu button
  133151. * @param buttonIdx Which button index changed
  133152. * @param state New state of the button
  133153. * @param changes Which properties on the state changed since last frame
  133154. */
  133155. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133156. }
  133157. }
  133158. declare module BABYLON {
  133159. /**
  133160. * Defines the WindowsMotionController object that the state of the windows motion controller
  133161. */
  133162. export class WindowsMotionController extends WebVRController {
  133163. /**
  133164. * The base url used to load the left and right controller models
  133165. */
  133166. static MODEL_BASE_URL: string;
  133167. /**
  133168. * The name of the left controller model file
  133169. */
  133170. static MODEL_LEFT_FILENAME: string;
  133171. /**
  133172. * The name of the right controller model file
  133173. */
  133174. static MODEL_RIGHT_FILENAME: string;
  133175. /**
  133176. * The controller name prefix for this controller type
  133177. */
  133178. static readonly GAMEPAD_ID_PREFIX: string;
  133179. /**
  133180. * The controller id pattern for this controller type
  133181. */
  133182. private static readonly GAMEPAD_ID_PATTERN;
  133183. private _loadedMeshInfo;
  133184. protected readonly _mapping: {
  133185. buttons: string[];
  133186. buttonMeshNames: {
  133187. trigger: string;
  133188. menu: string;
  133189. grip: string;
  133190. thumbstick: string;
  133191. trackpad: string;
  133192. };
  133193. buttonObservableNames: {
  133194. trigger: string;
  133195. menu: string;
  133196. grip: string;
  133197. thumbstick: string;
  133198. trackpad: string;
  133199. };
  133200. axisMeshNames: string[];
  133201. pointingPoseMeshName: string;
  133202. };
  133203. /**
  133204. * Fired when the trackpad on this controller is clicked
  133205. */
  133206. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133207. /**
  133208. * Fired when the trackpad on this controller is modified
  133209. */
  133210. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133211. /**
  133212. * The current x and y values of this controller's trackpad
  133213. */
  133214. trackpad: StickValues;
  133215. /**
  133216. * Creates a new WindowsMotionController from a gamepad
  133217. * @param vrGamepad the gamepad that the controller should be created from
  133218. */
  133219. constructor(vrGamepad: any);
  133220. /**
  133221. * Fired when the trigger on this controller is modified
  133222. */
  133223. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133224. /**
  133225. * Fired when the menu button on this controller is modified
  133226. */
  133227. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133228. /**
  133229. * Fired when the grip button on this controller is modified
  133230. */
  133231. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133232. /**
  133233. * Fired when the thumbstick button on this controller is modified
  133234. */
  133235. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133236. /**
  133237. * Fired when the touchpad button on this controller is modified
  133238. */
  133239. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133240. /**
  133241. * Fired when the touchpad values on this controller are modified
  133242. */
  133243. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  133244. protected _updateTrackpad(): void;
  133245. /**
  133246. * Called once per frame by the engine.
  133247. */
  133248. update(): void;
  133249. /**
  133250. * Called once for each button that changed state since the last frame
  133251. * @param buttonIdx Which button index changed
  133252. * @param state New state of the button
  133253. * @param changes Which properties on the state changed since last frame
  133254. */
  133255. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133256. /**
  133257. * Moves the buttons on the controller mesh based on their current state
  133258. * @param buttonName the name of the button to move
  133259. * @param buttonValue the value of the button which determines the buttons new position
  133260. */
  133261. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  133262. /**
  133263. * Moves the axis on the controller mesh based on its current state
  133264. * @param axis the index of the axis
  133265. * @param axisValue the value of the axis which determines the meshes new position
  133266. * @hidden
  133267. */
  133268. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  133269. /**
  133270. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133271. * @param scene scene in which to add meshes
  133272. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133273. */
  133274. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  133275. /**
  133276. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  133277. * can be transformed by button presses and axes values, based on this._mapping.
  133278. *
  133279. * @param scene scene in which the meshes exist
  133280. * @param meshes list of meshes that make up the controller model to process
  133281. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  133282. */
  133283. private processModel;
  133284. private createMeshInfo;
  133285. /**
  133286. * Gets the ray of the controller in the direction the controller is pointing
  133287. * @param length the length the resulting ray should be
  133288. * @returns a ray in the direction the controller is pointing
  133289. */
  133290. getForwardRay(length?: number): Ray;
  133291. /**
  133292. * Disposes of the controller
  133293. */
  133294. dispose(): void;
  133295. }
  133296. /**
  133297. * This class represents a new windows motion controller in XR.
  133298. */
  133299. export class XRWindowsMotionController extends WindowsMotionController {
  133300. /**
  133301. * Changing the original WIndowsMotionController mapping to fir the new mapping
  133302. */
  133303. protected readonly _mapping: {
  133304. buttons: string[];
  133305. buttonMeshNames: {
  133306. trigger: string;
  133307. menu: string;
  133308. grip: string;
  133309. thumbstick: string;
  133310. trackpad: string;
  133311. };
  133312. buttonObservableNames: {
  133313. trigger: string;
  133314. menu: string;
  133315. grip: string;
  133316. thumbstick: string;
  133317. trackpad: string;
  133318. };
  133319. axisMeshNames: string[];
  133320. pointingPoseMeshName: string;
  133321. };
  133322. /**
  133323. * Construct a new XR-Based windows motion controller
  133324. *
  133325. * @param gamepadInfo the gamepad object from the browser
  133326. */
  133327. constructor(gamepadInfo: any);
  133328. /**
  133329. * holds the thumbstick values (X,Y)
  133330. */
  133331. thumbstickValues: StickValues;
  133332. /**
  133333. * Fired when the thumbstick on this controller is clicked
  133334. */
  133335. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  133336. /**
  133337. * Fired when the thumbstick on this controller is modified
  133338. */
  133339. onThumbstickValuesChangedObservable: Observable<StickValues>;
  133340. /**
  133341. * Fired when the touchpad button on this controller is modified
  133342. */
  133343. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133344. /**
  133345. * Fired when the touchpad values on this controller are modified
  133346. */
  133347. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133348. /**
  133349. * Fired when the thumbstick button on this controller is modified
  133350. * here to prevent breaking changes
  133351. */
  133352. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133353. /**
  133354. * updating the thumbstick(!) and not the trackpad.
  133355. * This is named this way due to the difference between WebVR and XR and to avoid
  133356. * changing the parent class.
  133357. */
  133358. protected _updateTrackpad(): void;
  133359. /**
  133360. * Disposes the class with joy
  133361. */
  133362. dispose(): void;
  133363. }
  133364. }
  133365. declare module BABYLON {
  133366. /**
  133367. * Class containing static functions to help procedurally build meshes
  133368. */
  133369. export class PolyhedronBuilder {
  133370. /**
  133371. * Creates a polyhedron mesh
  133372. * * 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
  133373. * * The parameter `size` (positive float, default 1) sets the polygon size
  133374. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  133375. * * 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`
  133376. * * 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
  133377. * * 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)`)
  133378. * * 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
  133379. * * 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
  133380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133381. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133383. * @param name defines the name of the mesh
  133384. * @param options defines the options used to create the mesh
  133385. * @param scene defines the hosting scene
  133386. * @returns the polyhedron mesh
  133387. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  133388. */
  133389. static CreatePolyhedron(name: string, options: {
  133390. type?: number;
  133391. size?: number;
  133392. sizeX?: number;
  133393. sizeY?: number;
  133394. sizeZ?: number;
  133395. custom?: any;
  133396. faceUV?: Vector4[];
  133397. faceColors?: Color4[];
  133398. flat?: boolean;
  133399. updatable?: boolean;
  133400. sideOrientation?: number;
  133401. frontUVs?: Vector4;
  133402. backUVs?: Vector4;
  133403. }, scene?: Nullable<Scene>): Mesh;
  133404. }
  133405. }
  133406. declare module BABYLON {
  133407. /**
  133408. * Gizmo that enables scaling a mesh along 3 axis
  133409. */
  133410. export class ScaleGizmo extends Gizmo {
  133411. /**
  133412. * Internal gizmo used for interactions on the x axis
  133413. */
  133414. xGizmo: AxisScaleGizmo;
  133415. /**
  133416. * Internal gizmo used for interactions on the y axis
  133417. */
  133418. yGizmo: AxisScaleGizmo;
  133419. /**
  133420. * Internal gizmo used for interactions on the z axis
  133421. */
  133422. zGizmo: AxisScaleGizmo;
  133423. /**
  133424. * Internal gizmo used to scale all axis equally
  133425. */
  133426. uniformScaleGizmo: AxisScaleGizmo;
  133427. private _meshAttached;
  133428. private _nodeAttached;
  133429. private _snapDistance;
  133430. private _uniformScalingMesh;
  133431. private _octahedron;
  133432. private _sensitivity;
  133433. /** Fires an event when any of it's sub gizmos are dragged */
  133434. onDragStartObservable: Observable<unknown>;
  133435. /** Fires an event when any of it's sub gizmos are released from dragging */
  133436. onDragEndObservable: Observable<unknown>;
  133437. get attachedMesh(): Nullable<AbstractMesh>;
  133438. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133439. get attachedNode(): Nullable<Node>;
  133440. set attachedNode(node: Nullable<Node>);
  133441. /**
  133442. * Creates a ScaleGizmo
  133443. * @param gizmoLayer The utility layer the gizmo will be added to
  133444. * @param thickness display gizmo axis thickness
  133445. */
  133446. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  133447. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133448. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133449. /**
  133450. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133451. */
  133452. set snapDistance(value: number);
  133453. get snapDistance(): number;
  133454. /**
  133455. * Ratio for the scale of the gizmo (Default: 1)
  133456. */
  133457. set scaleRatio(value: number);
  133458. get scaleRatio(): number;
  133459. /**
  133460. * Sensitivity factor for dragging (Default: 1)
  133461. */
  133462. set sensitivity(value: number);
  133463. get sensitivity(): number;
  133464. /**
  133465. * Disposes of the gizmo
  133466. */
  133467. dispose(): void;
  133468. }
  133469. }
  133470. declare module BABYLON {
  133471. /**
  133472. * Single axis scale gizmo
  133473. */
  133474. export class AxisScaleGizmo extends Gizmo {
  133475. /**
  133476. * Drag behavior responsible for the gizmos dragging interactions
  133477. */
  133478. dragBehavior: PointerDragBehavior;
  133479. private _pointerObserver;
  133480. /**
  133481. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133482. */
  133483. snapDistance: number;
  133484. /**
  133485. * Event that fires each time the gizmo snaps to a new location.
  133486. * * snapDistance is the the change in distance
  133487. */
  133488. onSnapObservable: Observable<{
  133489. snapDistance: number;
  133490. }>;
  133491. /**
  133492. * If the scaling operation should be done on all axis (default: false)
  133493. */
  133494. uniformScaling: boolean;
  133495. /**
  133496. * Custom sensitivity value for the drag strength
  133497. */
  133498. sensitivity: number;
  133499. private _isEnabled;
  133500. private _parent;
  133501. private _arrow;
  133502. private _coloredMaterial;
  133503. private _hoverMaterial;
  133504. /**
  133505. * Creates an AxisScaleGizmo
  133506. * @param gizmoLayer The utility layer the gizmo will be added to
  133507. * @param dragAxis The axis which the gizmo will be able to scale on
  133508. * @param color The color of the gizmo
  133509. * @param thickness display gizmo axis thickness
  133510. */
  133511. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  133512. protected _attachedNodeChanged(value: Nullable<Node>): void;
  133513. /**
  133514. * If the gizmo is enabled
  133515. */
  133516. set isEnabled(value: boolean);
  133517. get isEnabled(): boolean;
  133518. /**
  133519. * Disposes of the gizmo
  133520. */
  133521. dispose(): void;
  133522. /**
  133523. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  133524. * @param mesh The mesh to replace the default mesh of the gizmo
  133525. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  133526. */
  133527. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  133528. }
  133529. }
  133530. declare module BABYLON {
  133531. /**
  133532. * Bounding box gizmo
  133533. */
  133534. export class BoundingBoxGizmo extends Gizmo {
  133535. private _lineBoundingBox;
  133536. private _rotateSpheresParent;
  133537. private _scaleBoxesParent;
  133538. private _boundingDimensions;
  133539. private _renderObserver;
  133540. private _pointerObserver;
  133541. private _scaleDragSpeed;
  133542. private _tmpQuaternion;
  133543. private _tmpVector;
  133544. private _tmpRotationMatrix;
  133545. /**
  133546. * 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)
  133547. */
  133548. ignoreChildren: boolean;
  133549. /**
  133550. * 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)
  133551. */
  133552. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  133553. /**
  133554. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  133555. */
  133556. rotationSphereSize: number;
  133557. /**
  133558. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  133559. */
  133560. scaleBoxSize: number;
  133561. /**
  133562. * 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)
  133563. */
  133564. fixedDragMeshScreenSize: boolean;
  133565. /**
  133566. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  133567. */
  133568. fixedDragMeshScreenSizeDistanceFactor: number;
  133569. /**
  133570. * Fired when a rotation sphere or scale box is dragged
  133571. */
  133572. onDragStartObservable: Observable<{}>;
  133573. /**
  133574. * Fired when a scale box is dragged
  133575. */
  133576. onScaleBoxDragObservable: Observable<{}>;
  133577. /**
  133578. * Fired when a scale box drag is ended
  133579. */
  133580. onScaleBoxDragEndObservable: Observable<{}>;
  133581. /**
  133582. * Fired when a rotation sphere is dragged
  133583. */
  133584. onRotationSphereDragObservable: Observable<{}>;
  133585. /**
  133586. * Fired when a rotation sphere drag is ended
  133587. */
  133588. onRotationSphereDragEndObservable: Observable<{}>;
  133589. /**
  133590. * 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)
  133591. */
  133592. scalePivot: Nullable<Vector3>;
  133593. /**
  133594. * Mesh used as a pivot to rotate the attached node
  133595. */
  133596. private _anchorMesh;
  133597. private _existingMeshScale;
  133598. private _dragMesh;
  133599. private pointerDragBehavior;
  133600. private coloredMaterial;
  133601. private hoverColoredMaterial;
  133602. /**
  133603. * Sets the color of the bounding box gizmo
  133604. * @param color the color to set
  133605. */
  133606. setColor(color: Color3): void;
  133607. /**
  133608. * Creates an BoundingBoxGizmo
  133609. * @param gizmoLayer The utility layer the gizmo will be added to
  133610. * @param color The color of the gizmo
  133611. */
  133612. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  133613. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  133614. private _selectNode;
  133615. /**
  133616. * Updates the bounding box information for the Gizmo
  133617. */
  133618. updateBoundingBox(): void;
  133619. private _updateRotationSpheres;
  133620. private _updateScaleBoxes;
  133621. /**
  133622. * Enables rotation on the specified axis and disables rotation on the others
  133623. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  133624. */
  133625. setEnabledRotationAxis(axis: string): void;
  133626. /**
  133627. * Enables/disables scaling
  133628. * @param enable if scaling should be enabled
  133629. * @param homogeneousScaling defines if scaling should only be homogeneous
  133630. */
  133631. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  133632. private _updateDummy;
  133633. /**
  133634. * Enables a pointer drag behavior on the bounding box of the gizmo
  133635. */
  133636. enableDragBehavior(): void;
  133637. /**
  133638. * Disposes of the gizmo
  133639. */
  133640. dispose(): void;
  133641. /**
  133642. * 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)
  133643. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  133644. * @returns the bounding box mesh with the passed in mesh as a child
  133645. */
  133646. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  133647. /**
  133648. * CustomMeshes are not supported by this gizmo
  133649. * @param mesh The mesh to replace the default mesh of the gizmo
  133650. */
  133651. setCustomMesh(mesh: Mesh): void;
  133652. }
  133653. }
  133654. declare module BABYLON {
  133655. /**
  133656. * Single plane rotation gizmo
  133657. */
  133658. export class PlaneRotationGizmo extends Gizmo {
  133659. /**
  133660. * Drag behavior responsible for the gizmos dragging interactions
  133661. */
  133662. dragBehavior: PointerDragBehavior;
  133663. private _pointerObserver;
  133664. /**
  133665. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  133666. */
  133667. snapDistance: number;
  133668. /**
  133669. * Event that fires each time the gizmo snaps to a new location.
  133670. * * snapDistance is the the change in distance
  133671. */
  133672. onSnapObservable: Observable<{
  133673. snapDistance: number;
  133674. }>;
  133675. private _isEnabled;
  133676. private _parent;
  133677. /**
  133678. * Creates a PlaneRotationGizmo
  133679. * @param gizmoLayer The utility layer the gizmo will be added to
  133680. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  133681. * @param color The color of the gizmo
  133682. * @param tessellation Amount of tessellation to be used when creating rotation circles
  133683. * @param useEulerRotation Use and update Euler angle instead of quaternion
  133684. * @param thickness display gizmo axis thickness
  133685. */
  133686. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  133687. protected _attachedNodeChanged(value: Nullable<Node>): void;
  133688. /**
  133689. * If the gizmo is enabled
  133690. */
  133691. set isEnabled(value: boolean);
  133692. get isEnabled(): boolean;
  133693. /**
  133694. * Disposes of the gizmo
  133695. */
  133696. dispose(): void;
  133697. }
  133698. }
  133699. declare module BABYLON {
  133700. /**
  133701. * Gizmo that enables rotating a mesh along 3 axis
  133702. */
  133703. export class RotationGizmo extends Gizmo {
  133704. /**
  133705. * Internal gizmo used for interactions on the x axis
  133706. */
  133707. xGizmo: PlaneRotationGizmo;
  133708. /**
  133709. * Internal gizmo used for interactions on the y axis
  133710. */
  133711. yGizmo: PlaneRotationGizmo;
  133712. /**
  133713. * Internal gizmo used for interactions on the z axis
  133714. */
  133715. zGizmo: PlaneRotationGizmo;
  133716. /** Fires an event when any of it's sub gizmos are dragged */
  133717. onDragStartObservable: Observable<unknown>;
  133718. /** Fires an event when any of it's sub gizmos are released from dragging */
  133719. onDragEndObservable: Observable<unknown>;
  133720. private _meshAttached;
  133721. private _nodeAttached;
  133722. get attachedMesh(): Nullable<AbstractMesh>;
  133723. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133724. get attachedNode(): Nullable<Node>;
  133725. set attachedNode(node: Nullable<Node>);
  133726. /**
  133727. * Creates a RotationGizmo
  133728. * @param gizmoLayer The utility layer the gizmo will be added to
  133729. * @param tessellation Amount of tessellation to be used when creating rotation circles
  133730. * @param useEulerRotation Use and update Euler angle instead of quaternion
  133731. * @param thickness display gizmo axis thickness
  133732. */
  133733. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  133734. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133735. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133736. /**
  133737. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133738. */
  133739. set snapDistance(value: number);
  133740. get snapDistance(): number;
  133741. /**
  133742. * Ratio for the scale of the gizmo (Default: 1)
  133743. */
  133744. set scaleRatio(value: number);
  133745. get scaleRatio(): number;
  133746. /**
  133747. * Disposes of the gizmo
  133748. */
  133749. dispose(): void;
  133750. /**
  133751. * CustomMeshes are not supported by this gizmo
  133752. * @param mesh The mesh to replace the default mesh of the gizmo
  133753. */
  133754. setCustomMesh(mesh: Mesh): void;
  133755. }
  133756. }
  133757. declare module BABYLON {
  133758. /**
  133759. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  133760. */
  133761. export class GizmoManager implements IDisposable {
  133762. private scene;
  133763. /**
  133764. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  133765. */
  133766. gizmos: {
  133767. positionGizmo: Nullable<PositionGizmo>;
  133768. rotationGizmo: Nullable<RotationGizmo>;
  133769. scaleGizmo: Nullable<ScaleGizmo>;
  133770. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  133771. };
  133772. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  133773. clearGizmoOnEmptyPointerEvent: boolean;
  133774. /** Fires an event when the manager is attached to a mesh */
  133775. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  133776. /** Fires an event when the manager is attached to a node */
  133777. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  133778. private _gizmosEnabled;
  133779. private _pointerObserver;
  133780. private _attachedMesh;
  133781. private _attachedNode;
  133782. private _boundingBoxColor;
  133783. private _defaultUtilityLayer;
  133784. private _defaultKeepDepthUtilityLayer;
  133785. private _thickness;
  133786. /**
  133787. * When bounding box gizmo is enabled, this can be used to track drag/end events
  133788. */
  133789. boundingBoxDragBehavior: SixDofDragBehavior;
  133790. /**
  133791. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  133792. */
  133793. attachableMeshes: Nullable<Array<AbstractMesh>>;
  133794. /**
  133795. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  133796. */
  133797. attachableNodes: Nullable<Array<Node>>;
  133798. /**
  133799. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  133800. */
  133801. usePointerToAttachGizmos: boolean;
  133802. /**
  133803. * Utility layer that the bounding box gizmo belongs to
  133804. */
  133805. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  133806. /**
  133807. * Utility layer that all gizmos besides bounding box belong to
  133808. */
  133809. get utilityLayer(): UtilityLayerRenderer;
  133810. /**
  133811. * Instatiates a gizmo manager
  133812. * @param scene the scene to overlay the gizmos on top of
  133813. * @param thickness display gizmo axis thickness
  133814. */
  133815. constructor(scene: Scene, thickness?: number);
  133816. /**
  133817. * Attaches a set of gizmos to the specified mesh
  133818. * @param mesh The mesh the gizmo's should be attached to
  133819. */
  133820. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  133821. /**
  133822. * Attaches a set of gizmos to the specified node
  133823. * @param node The node the gizmo's should be attached to
  133824. */
  133825. attachToNode(node: Nullable<Node>): void;
  133826. /**
  133827. * If the position gizmo is enabled
  133828. */
  133829. set positionGizmoEnabled(value: boolean);
  133830. get positionGizmoEnabled(): boolean;
  133831. /**
  133832. * If the rotation gizmo is enabled
  133833. */
  133834. set rotationGizmoEnabled(value: boolean);
  133835. get rotationGizmoEnabled(): boolean;
  133836. /**
  133837. * If the scale gizmo is enabled
  133838. */
  133839. set scaleGizmoEnabled(value: boolean);
  133840. get scaleGizmoEnabled(): boolean;
  133841. /**
  133842. * If the boundingBox gizmo is enabled
  133843. */
  133844. set boundingBoxGizmoEnabled(value: boolean);
  133845. get boundingBoxGizmoEnabled(): boolean;
  133846. /**
  133847. * Disposes of the gizmo manager
  133848. */
  133849. dispose(): void;
  133850. }
  133851. }
  133852. declare module BABYLON {
  133853. /**
  133854. * A directional light is defined by a direction (what a surprise!).
  133855. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  133856. * 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.
  133857. * Documentation: https://doc.babylonjs.com/babylon101/lights
  133858. */
  133859. export class DirectionalLight extends ShadowLight {
  133860. private _shadowFrustumSize;
  133861. /**
  133862. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  133863. */
  133864. get shadowFrustumSize(): number;
  133865. /**
  133866. * Specifies a fix frustum size for the shadow generation.
  133867. */
  133868. set shadowFrustumSize(value: number);
  133869. private _shadowOrthoScale;
  133870. /**
  133871. * Gets the shadow projection scale against the optimal computed one.
  133872. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  133873. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  133874. */
  133875. get shadowOrthoScale(): number;
  133876. /**
  133877. * Sets the shadow projection scale against the optimal computed one.
  133878. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  133879. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  133880. */
  133881. set shadowOrthoScale(value: number);
  133882. /**
  133883. * Automatically compute the projection matrix to best fit (including all the casters)
  133884. * on each frame.
  133885. */
  133886. autoUpdateExtends: boolean;
  133887. /**
  133888. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  133889. * on each frame. autoUpdateExtends must be set to true for this to work
  133890. */
  133891. autoCalcShadowZBounds: boolean;
  133892. private _orthoLeft;
  133893. private _orthoRight;
  133894. private _orthoTop;
  133895. private _orthoBottom;
  133896. /**
  133897. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  133898. * The directional light is emitted from everywhere in the given direction.
  133899. * It can cast shadows.
  133900. * Documentation : https://doc.babylonjs.com/babylon101/lights
  133901. * @param name The friendly name of the light
  133902. * @param direction The direction of the light
  133903. * @param scene The scene the light belongs to
  133904. */
  133905. constructor(name: string, direction: Vector3, scene: Scene);
  133906. /**
  133907. * Returns the string "DirectionalLight".
  133908. * @return The class name
  133909. */
  133910. getClassName(): string;
  133911. /**
  133912. * Returns the integer 1.
  133913. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  133914. */
  133915. getTypeID(): number;
  133916. /**
  133917. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  133918. * Returns the DirectionalLight Shadow projection matrix.
  133919. */
  133920. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133921. /**
  133922. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  133923. * Returns the DirectionalLight Shadow projection matrix.
  133924. */
  133925. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  133926. /**
  133927. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  133928. * Returns the DirectionalLight Shadow projection matrix.
  133929. */
  133930. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133931. protected _buildUniformLayout(): void;
  133932. /**
  133933. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  133934. * @param effect The effect to update
  133935. * @param lightIndex The index of the light in the effect to update
  133936. * @returns The directional light
  133937. */
  133938. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  133939. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  133940. /**
  133941. * Gets the minZ used for shadow according to both the scene and the light.
  133942. *
  133943. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  133944. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  133945. * @param activeCamera The camera we are returning the min for
  133946. * @returns the depth min z
  133947. */
  133948. getDepthMinZ(activeCamera: Camera): number;
  133949. /**
  133950. * Gets the maxZ used for shadow according to both the scene and the light.
  133951. *
  133952. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  133953. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  133954. * @param activeCamera The camera we are returning the max for
  133955. * @returns the depth max z
  133956. */
  133957. getDepthMaxZ(activeCamera: Camera): number;
  133958. /**
  133959. * Prepares the list of defines specific to the light type.
  133960. * @param defines the list of defines
  133961. * @param lightIndex defines the index of the light for the effect
  133962. */
  133963. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  133964. }
  133965. }
  133966. declare module BABYLON {
  133967. /**
  133968. * Class containing static functions to help procedurally build meshes
  133969. */
  133970. export class HemisphereBuilder {
  133971. /**
  133972. * Creates a hemisphere mesh
  133973. * @param name defines the name of the mesh
  133974. * @param options defines the options used to create the mesh
  133975. * @param scene defines the hosting scene
  133976. * @returns the hemisphere mesh
  133977. */
  133978. static CreateHemisphere(name: string, options: {
  133979. segments?: number;
  133980. diameter?: number;
  133981. sideOrientation?: number;
  133982. }, scene: any): Mesh;
  133983. }
  133984. }
  133985. declare module BABYLON {
  133986. /**
  133987. * A spot light is defined by a position, a direction, an angle, and an exponent.
  133988. * These values define a cone of light starting from the position, emitting toward the direction.
  133989. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  133990. * and the exponent defines the speed of the decay of the light with distance (reach).
  133991. * Documentation: https://doc.babylonjs.com/babylon101/lights
  133992. */
  133993. export class SpotLight extends ShadowLight {
  133994. private _angle;
  133995. private _innerAngle;
  133996. private _cosHalfAngle;
  133997. private _lightAngleScale;
  133998. private _lightAngleOffset;
  133999. /**
  134000. * Gets the cone angle of the spot light in Radians.
  134001. */
  134002. get angle(): number;
  134003. /**
  134004. * Sets the cone angle of the spot light in Radians.
  134005. */
  134006. set angle(value: number);
  134007. /**
  134008. * Only used in gltf falloff mode, this defines the angle where
  134009. * the directional falloff will start before cutting at angle which could be seen
  134010. * as outer angle.
  134011. */
  134012. get innerAngle(): number;
  134013. /**
  134014. * Only used in gltf falloff mode, this defines the angle where
  134015. * the directional falloff will start before cutting at angle which could be seen
  134016. * as outer angle.
  134017. */
  134018. set innerAngle(value: number);
  134019. private _shadowAngleScale;
  134020. /**
  134021. * Allows scaling the angle of the light for shadow generation only.
  134022. */
  134023. get shadowAngleScale(): number;
  134024. /**
  134025. * Allows scaling the angle of the light for shadow generation only.
  134026. */
  134027. set shadowAngleScale(value: number);
  134028. /**
  134029. * The light decay speed with the distance from the emission spot.
  134030. */
  134031. exponent: number;
  134032. private _projectionTextureMatrix;
  134033. /**
  134034. * Allows reading the projecton texture
  134035. */
  134036. get projectionTextureMatrix(): Matrix;
  134037. protected _projectionTextureLightNear: number;
  134038. /**
  134039. * Gets the near clip of the Spotlight for texture projection.
  134040. */
  134041. get projectionTextureLightNear(): number;
  134042. /**
  134043. * Sets the near clip of the Spotlight for texture projection.
  134044. */
  134045. set projectionTextureLightNear(value: number);
  134046. protected _projectionTextureLightFar: number;
  134047. /**
  134048. * Gets the far clip of the Spotlight for texture projection.
  134049. */
  134050. get projectionTextureLightFar(): number;
  134051. /**
  134052. * Sets the far clip of the Spotlight for texture projection.
  134053. */
  134054. set projectionTextureLightFar(value: number);
  134055. protected _projectionTextureUpDirection: Vector3;
  134056. /**
  134057. * Gets the Up vector of the Spotlight for texture projection.
  134058. */
  134059. get projectionTextureUpDirection(): Vector3;
  134060. /**
  134061. * Sets the Up vector of the Spotlight for texture projection.
  134062. */
  134063. set projectionTextureUpDirection(value: Vector3);
  134064. private _projectionTexture;
  134065. /**
  134066. * Gets the projection texture of the light.
  134067. */
  134068. get projectionTexture(): Nullable<BaseTexture>;
  134069. /**
  134070. * Sets the projection texture of the light.
  134071. */
  134072. set projectionTexture(value: Nullable<BaseTexture>);
  134073. private _projectionTextureViewLightDirty;
  134074. private _projectionTextureProjectionLightDirty;
  134075. private _projectionTextureDirty;
  134076. private _projectionTextureViewTargetVector;
  134077. private _projectionTextureViewLightMatrix;
  134078. private _projectionTextureProjectionLightMatrix;
  134079. private _projectionTextureScalingMatrix;
  134080. /**
  134081. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  134082. * It can cast shadows.
  134083. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134084. * @param name The light friendly name
  134085. * @param position The position of the spot light in the scene
  134086. * @param direction The direction of the light in the scene
  134087. * @param angle The cone angle of the light in Radians
  134088. * @param exponent The light decay speed with the distance from the emission spot
  134089. * @param scene The scene the lights belongs to
  134090. */
  134091. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  134092. /**
  134093. * Returns the string "SpotLight".
  134094. * @returns the class name
  134095. */
  134096. getClassName(): string;
  134097. /**
  134098. * Returns the integer 2.
  134099. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134100. */
  134101. getTypeID(): number;
  134102. /**
  134103. * Overrides the direction setter to recompute the projection texture view light Matrix.
  134104. */
  134105. protected _setDirection(value: Vector3): void;
  134106. /**
  134107. * Overrides the position setter to recompute the projection texture view light Matrix.
  134108. */
  134109. protected _setPosition(value: Vector3): void;
  134110. /**
  134111. * 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.
  134112. * Returns the SpotLight.
  134113. */
  134114. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134115. protected _computeProjectionTextureViewLightMatrix(): void;
  134116. protected _computeProjectionTextureProjectionLightMatrix(): void;
  134117. /**
  134118. * Main function for light texture projection matrix computing.
  134119. */
  134120. protected _computeProjectionTextureMatrix(): void;
  134121. protected _buildUniformLayout(): void;
  134122. private _computeAngleValues;
  134123. /**
  134124. * Sets the passed Effect "effect" with the Light textures.
  134125. * @param effect The effect to update
  134126. * @param lightIndex The index of the light in the effect to update
  134127. * @returns The light
  134128. */
  134129. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  134130. /**
  134131. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  134132. * @param effect The effect to update
  134133. * @param lightIndex The index of the light in the effect to update
  134134. * @returns The spot light
  134135. */
  134136. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  134137. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  134138. /**
  134139. * Disposes the light and the associated resources.
  134140. */
  134141. dispose(): void;
  134142. /**
  134143. * Prepares the list of defines specific to the light type.
  134144. * @param defines the list of defines
  134145. * @param lightIndex defines the index of the light for the effect
  134146. */
  134147. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134148. }
  134149. }
  134150. declare module BABYLON {
  134151. /**
  134152. * Gizmo that enables viewing a light
  134153. */
  134154. export class LightGizmo extends Gizmo {
  134155. private _lightMesh;
  134156. private _material;
  134157. private _cachedPosition;
  134158. private _cachedForward;
  134159. private _attachedMeshParent;
  134160. private _pointerObserver;
  134161. /**
  134162. * Event that fires each time the gizmo is clicked
  134163. */
  134164. onClickedObservable: Observable<Light>;
  134165. /**
  134166. * Creates a LightGizmo
  134167. * @param gizmoLayer The utility layer the gizmo will be added to
  134168. */
  134169. constructor(gizmoLayer?: UtilityLayerRenderer);
  134170. private _light;
  134171. /**
  134172. * The light that the gizmo is attached to
  134173. */
  134174. set light(light: Nullable<Light>);
  134175. get light(): Nullable<Light>;
  134176. /**
  134177. * Gets the material used to render the light gizmo
  134178. */
  134179. get material(): StandardMaterial;
  134180. /**
  134181. * @hidden
  134182. * Updates the gizmo to match the attached mesh's position/rotation
  134183. */
  134184. protected _update(): void;
  134185. private static _Scale;
  134186. /**
  134187. * Creates the lines for a light mesh
  134188. */
  134189. private static _CreateLightLines;
  134190. /**
  134191. * Disposes of the light gizmo
  134192. */
  134193. dispose(): void;
  134194. private static _CreateHemisphericLightMesh;
  134195. private static _CreatePointLightMesh;
  134196. private static _CreateSpotLightMesh;
  134197. private static _CreateDirectionalLightMesh;
  134198. }
  134199. }
  134200. declare module BABYLON {
  134201. /**
  134202. * Gizmo that enables viewing a camera
  134203. */
  134204. export class CameraGizmo extends Gizmo {
  134205. private _cameraMesh;
  134206. private _cameraLinesMesh;
  134207. private _material;
  134208. private _pointerObserver;
  134209. /**
  134210. * Event that fires each time the gizmo is clicked
  134211. */
  134212. onClickedObservable: Observable<Camera>;
  134213. /**
  134214. * Creates a CameraGizmo
  134215. * @param gizmoLayer The utility layer the gizmo will be added to
  134216. */
  134217. constructor(gizmoLayer?: UtilityLayerRenderer);
  134218. private _camera;
  134219. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  134220. get displayFrustum(): boolean;
  134221. set displayFrustum(value: boolean);
  134222. /**
  134223. * The camera that the gizmo is attached to
  134224. */
  134225. set camera(camera: Nullable<Camera>);
  134226. get camera(): Nullable<Camera>;
  134227. /**
  134228. * Gets the material used to render the camera gizmo
  134229. */
  134230. get material(): StandardMaterial;
  134231. /**
  134232. * @hidden
  134233. * Updates the gizmo to match the attached mesh's position/rotation
  134234. */
  134235. protected _update(): void;
  134236. private static _Scale;
  134237. private _invProjection;
  134238. /**
  134239. * Disposes of the camera gizmo
  134240. */
  134241. dispose(): void;
  134242. private static _CreateCameraMesh;
  134243. private static _CreateCameraFrustum;
  134244. }
  134245. }
  134246. declare module BABYLON {
  134247. /** @hidden */
  134248. export var backgroundFragmentDeclaration: {
  134249. name: string;
  134250. shader: string;
  134251. };
  134252. }
  134253. declare module BABYLON {
  134254. /** @hidden */
  134255. export var backgroundUboDeclaration: {
  134256. name: string;
  134257. shader: string;
  134258. };
  134259. }
  134260. declare module BABYLON {
  134261. /** @hidden */
  134262. export var backgroundPixelShader: {
  134263. name: string;
  134264. shader: string;
  134265. };
  134266. }
  134267. declare module BABYLON {
  134268. /** @hidden */
  134269. export var backgroundVertexDeclaration: {
  134270. name: string;
  134271. shader: string;
  134272. };
  134273. }
  134274. declare module BABYLON {
  134275. /** @hidden */
  134276. export var backgroundVertexShader: {
  134277. name: string;
  134278. shader: string;
  134279. };
  134280. }
  134281. declare module BABYLON {
  134282. /**
  134283. * Background material used to create an efficient environement around your scene.
  134284. */
  134285. export class BackgroundMaterial extends PushMaterial {
  134286. /**
  134287. * Standard reflectance value at parallel view angle.
  134288. */
  134289. static StandardReflectance0: number;
  134290. /**
  134291. * Standard reflectance value at grazing angle.
  134292. */
  134293. static StandardReflectance90: number;
  134294. protected _primaryColor: Color3;
  134295. /**
  134296. * Key light Color (multiply against the environement texture)
  134297. */
  134298. primaryColor: Color3;
  134299. protected __perceptualColor: Nullable<Color3>;
  134300. /**
  134301. * Experimental Internal Use Only.
  134302. *
  134303. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  134304. * This acts as a helper to set the primary color to a more "human friendly" value.
  134305. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  134306. * output color as close as possible from the chosen value.
  134307. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  134308. * part of lighting setup.)
  134309. */
  134310. get _perceptualColor(): Nullable<Color3>;
  134311. set _perceptualColor(value: Nullable<Color3>);
  134312. protected _primaryColorShadowLevel: float;
  134313. /**
  134314. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  134315. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  134316. */
  134317. get primaryColorShadowLevel(): float;
  134318. set primaryColorShadowLevel(value: float);
  134319. protected _primaryColorHighlightLevel: float;
  134320. /**
  134321. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  134322. * The primary color is used at the level chosen to define what the white area would look.
  134323. */
  134324. get primaryColorHighlightLevel(): float;
  134325. set primaryColorHighlightLevel(value: float);
  134326. protected _reflectionTexture: Nullable<BaseTexture>;
  134327. /**
  134328. * Reflection Texture used in the material.
  134329. * Should be author in a specific way for the best result (refer to the documentation).
  134330. */
  134331. reflectionTexture: Nullable<BaseTexture>;
  134332. protected _reflectionBlur: float;
  134333. /**
  134334. * Reflection Texture level of blur.
  134335. *
  134336. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  134337. * texture twice.
  134338. */
  134339. reflectionBlur: float;
  134340. protected _diffuseTexture: Nullable<BaseTexture>;
  134341. /**
  134342. * Diffuse Texture used in the material.
  134343. * Should be author in a specific way for the best result (refer to the documentation).
  134344. */
  134345. diffuseTexture: Nullable<BaseTexture>;
  134346. protected _shadowLights: Nullable<IShadowLight[]>;
  134347. /**
  134348. * Specify the list of lights casting shadow on the material.
  134349. * All scene shadow lights will be included if null.
  134350. */
  134351. shadowLights: Nullable<IShadowLight[]>;
  134352. protected _shadowLevel: float;
  134353. /**
  134354. * Helps adjusting the shadow to a softer level if required.
  134355. * 0 means black shadows and 1 means no shadows.
  134356. */
  134357. shadowLevel: float;
  134358. protected _sceneCenter: Vector3;
  134359. /**
  134360. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  134361. * It is usually zero but might be interesting to modify according to your setup.
  134362. */
  134363. sceneCenter: Vector3;
  134364. protected _opacityFresnel: boolean;
  134365. /**
  134366. * This helps specifying that the material is falling off to the sky box at grazing angle.
  134367. * This helps ensuring a nice transition when the camera goes under the ground.
  134368. */
  134369. opacityFresnel: boolean;
  134370. protected _reflectionFresnel: boolean;
  134371. /**
  134372. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  134373. * This helps adding a mirror texture on the ground.
  134374. */
  134375. reflectionFresnel: boolean;
  134376. protected _reflectionFalloffDistance: number;
  134377. /**
  134378. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  134379. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  134380. */
  134381. reflectionFalloffDistance: number;
  134382. protected _reflectionAmount: number;
  134383. /**
  134384. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  134385. */
  134386. reflectionAmount: number;
  134387. protected _reflectionReflectance0: number;
  134388. /**
  134389. * This specifies the weight of the reflection at grazing angle.
  134390. */
  134391. reflectionReflectance0: number;
  134392. protected _reflectionReflectance90: number;
  134393. /**
  134394. * This specifies the weight of the reflection at a perpendicular point of view.
  134395. */
  134396. reflectionReflectance90: number;
  134397. /**
  134398. * Sets the reflection reflectance fresnel values according to the default standard
  134399. * empirically know to work well :-)
  134400. */
  134401. set reflectionStandardFresnelWeight(value: number);
  134402. protected _useRGBColor: boolean;
  134403. /**
  134404. * Helps to directly use the maps channels instead of their level.
  134405. */
  134406. useRGBColor: boolean;
  134407. protected _enableNoise: boolean;
  134408. /**
  134409. * This helps reducing the banding effect that could occur on the background.
  134410. */
  134411. enableNoise: boolean;
  134412. /**
  134413. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134414. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  134415. * Recommended to be keep at 1.0 except for special cases.
  134416. */
  134417. get fovMultiplier(): number;
  134418. set fovMultiplier(value: number);
  134419. private _fovMultiplier;
  134420. /**
  134421. * Enable the FOV adjustment feature controlled by fovMultiplier.
  134422. */
  134423. useEquirectangularFOV: boolean;
  134424. private _maxSimultaneousLights;
  134425. /**
  134426. * Number of Simultaneous lights allowed on the material.
  134427. */
  134428. maxSimultaneousLights: int;
  134429. private _shadowOnly;
  134430. /**
  134431. * Make the material only render shadows
  134432. */
  134433. shadowOnly: boolean;
  134434. /**
  134435. * Default configuration related to image processing available in the Background Material.
  134436. */
  134437. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134438. /**
  134439. * Keep track of the image processing observer to allow dispose and replace.
  134440. */
  134441. private _imageProcessingObserver;
  134442. /**
  134443. * Attaches a new image processing configuration to the PBR Material.
  134444. * @param configuration (if null the scene configuration will be use)
  134445. */
  134446. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134447. /**
  134448. * Gets the image processing configuration used either in this material.
  134449. */
  134450. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  134451. /**
  134452. * Sets the Default image processing configuration used either in the this material.
  134453. *
  134454. * If sets to null, the scene one is in use.
  134455. */
  134456. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  134457. /**
  134458. * Gets wether the color curves effect is enabled.
  134459. */
  134460. get cameraColorCurvesEnabled(): boolean;
  134461. /**
  134462. * Sets wether the color curves effect is enabled.
  134463. */
  134464. set cameraColorCurvesEnabled(value: boolean);
  134465. /**
  134466. * Gets wether the color grading effect is enabled.
  134467. */
  134468. get cameraColorGradingEnabled(): boolean;
  134469. /**
  134470. * Gets wether the color grading effect is enabled.
  134471. */
  134472. set cameraColorGradingEnabled(value: boolean);
  134473. /**
  134474. * Gets wether tonemapping is enabled or not.
  134475. */
  134476. get cameraToneMappingEnabled(): boolean;
  134477. /**
  134478. * Sets wether tonemapping is enabled or not
  134479. */
  134480. set cameraToneMappingEnabled(value: boolean);
  134481. /**
  134482. * The camera exposure used on this material.
  134483. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134484. * This corresponds to a photographic exposure.
  134485. */
  134486. get cameraExposure(): float;
  134487. /**
  134488. * The camera exposure used on this material.
  134489. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134490. * This corresponds to a photographic exposure.
  134491. */
  134492. set cameraExposure(value: float);
  134493. /**
  134494. * Gets The camera contrast used on this material.
  134495. */
  134496. get cameraContrast(): float;
  134497. /**
  134498. * Sets The camera contrast used on this material.
  134499. */
  134500. set cameraContrast(value: float);
  134501. /**
  134502. * Gets the Color Grading 2D Lookup Texture.
  134503. */
  134504. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  134505. /**
  134506. * Sets the Color Grading 2D Lookup Texture.
  134507. */
  134508. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  134509. /**
  134510. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134511. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134512. * 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;
  134513. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134514. */
  134515. get cameraColorCurves(): Nullable<ColorCurves>;
  134516. /**
  134517. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134518. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134519. * 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;
  134520. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134521. */
  134522. set cameraColorCurves(value: Nullable<ColorCurves>);
  134523. /**
  134524. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  134525. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  134526. */
  134527. switchToBGR: boolean;
  134528. private _renderTargets;
  134529. private _reflectionControls;
  134530. private _white;
  134531. private _primaryShadowColor;
  134532. private _primaryHighlightColor;
  134533. /**
  134534. * Instantiates a Background Material in the given scene
  134535. * @param name The friendly name of the material
  134536. * @param scene The scene to add the material to
  134537. */
  134538. constructor(name: string, scene: Scene);
  134539. /**
  134540. * Gets a boolean indicating that current material needs to register RTT
  134541. */
  134542. get hasRenderTargetTextures(): boolean;
  134543. /**
  134544. * The entire material has been created in order to prevent overdraw.
  134545. * @returns false
  134546. */
  134547. needAlphaTesting(): boolean;
  134548. /**
  134549. * The entire material has been created in order to prevent overdraw.
  134550. * @returns true if blending is enable
  134551. */
  134552. needAlphaBlending(): boolean;
  134553. /**
  134554. * Checks wether the material is ready to be rendered for a given mesh.
  134555. * @param mesh The mesh to render
  134556. * @param subMesh The submesh to check against
  134557. * @param useInstances Specify wether or not the material is used with instances
  134558. * @returns true if all the dependencies are ready (Textures, Effects...)
  134559. */
  134560. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  134561. /**
  134562. * Compute the primary color according to the chosen perceptual color.
  134563. */
  134564. private _computePrimaryColorFromPerceptualColor;
  134565. /**
  134566. * Compute the highlights and shadow colors according to their chosen levels.
  134567. */
  134568. private _computePrimaryColors;
  134569. /**
  134570. * Build the uniform buffer used in the material.
  134571. */
  134572. buildUniformLayout(): void;
  134573. /**
  134574. * Unbind the material.
  134575. */
  134576. unbind(): void;
  134577. /**
  134578. * Bind only the world matrix to the material.
  134579. * @param world The world matrix to bind.
  134580. */
  134581. bindOnlyWorldMatrix(world: Matrix): void;
  134582. /**
  134583. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  134584. * @param world The world matrix to bind.
  134585. * @param subMesh The submesh to bind for.
  134586. */
  134587. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134588. /**
  134589. * Checks to see if a texture is used in the material.
  134590. * @param texture - Base texture to use.
  134591. * @returns - Boolean specifying if a texture is used in the material.
  134592. */
  134593. hasTexture(texture: BaseTexture): boolean;
  134594. /**
  134595. * Dispose the material.
  134596. * @param forceDisposeEffect Force disposal of the associated effect.
  134597. * @param forceDisposeTextures Force disposal of the associated textures.
  134598. */
  134599. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  134600. /**
  134601. * Clones the material.
  134602. * @param name The cloned name.
  134603. * @returns The cloned material.
  134604. */
  134605. clone(name: string): BackgroundMaterial;
  134606. /**
  134607. * Serializes the current material to its JSON representation.
  134608. * @returns The JSON representation.
  134609. */
  134610. serialize(): any;
  134611. /**
  134612. * Gets the class name of the material
  134613. * @returns "BackgroundMaterial"
  134614. */
  134615. getClassName(): string;
  134616. /**
  134617. * Parse a JSON input to create back a background material.
  134618. * @param source The JSON data to parse
  134619. * @param scene The scene to create the parsed material in
  134620. * @param rootUrl The root url of the assets the material depends upon
  134621. * @returns the instantiated BackgroundMaterial.
  134622. */
  134623. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  134624. }
  134625. }
  134626. declare module BABYLON {
  134627. /**
  134628. * Represents the different options available during the creation of
  134629. * a Environment helper.
  134630. *
  134631. * This can control the default ground, skybox and image processing setup of your scene.
  134632. */
  134633. export interface IEnvironmentHelperOptions {
  134634. /**
  134635. * Specifies whether or not to create a ground.
  134636. * True by default.
  134637. */
  134638. createGround: boolean;
  134639. /**
  134640. * Specifies the ground size.
  134641. * 15 by default.
  134642. */
  134643. groundSize: number;
  134644. /**
  134645. * The texture used on the ground for the main color.
  134646. * Comes from the BabylonJS CDN by default.
  134647. *
  134648. * Remarks: Can be either a texture or a url.
  134649. */
  134650. groundTexture: string | BaseTexture;
  134651. /**
  134652. * The color mixed in the ground texture by default.
  134653. * BabylonJS clearColor by default.
  134654. */
  134655. groundColor: Color3;
  134656. /**
  134657. * Specifies the ground opacity.
  134658. * 1 by default.
  134659. */
  134660. groundOpacity: number;
  134661. /**
  134662. * Enables the ground to receive shadows.
  134663. * True by default.
  134664. */
  134665. enableGroundShadow: boolean;
  134666. /**
  134667. * Helps preventing the shadow to be fully black on the ground.
  134668. * 0.5 by default.
  134669. */
  134670. groundShadowLevel: number;
  134671. /**
  134672. * Creates a mirror texture attach to the ground.
  134673. * false by default.
  134674. */
  134675. enableGroundMirror: boolean;
  134676. /**
  134677. * Specifies the ground mirror size ratio.
  134678. * 0.3 by default as the default kernel is 64.
  134679. */
  134680. groundMirrorSizeRatio: number;
  134681. /**
  134682. * Specifies the ground mirror blur kernel size.
  134683. * 64 by default.
  134684. */
  134685. groundMirrorBlurKernel: number;
  134686. /**
  134687. * Specifies the ground mirror visibility amount.
  134688. * 1 by default
  134689. */
  134690. groundMirrorAmount: number;
  134691. /**
  134692. * Specifies the ground mirror reflectance weight.
  134693. * This uses the standard weight of the background material to setup the fresnel effect
  134694. * of the mirror.
  134695. * 1 by default.
  134696. */
  134697. groundMirrorFresnelWeight: number;
  134698. /**
  134699. * Specifies the ground mirror Falloff distance.
  134700. * This can helps reducing the size of the reflection.
  134701. * 0 by Default.
  134702. */
  134703. groundMirrorFallOffDistance: number;
  134704. /**
  134705. * Specifies the ground mirror texture type.
  134706. * Unsigned Int by Default.
  134707. */
  134708. groundMirrorTextureType: number;
  134709. /**
  134710. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  134711. * the shown objects.
  134712. */
  134713. groundYBias: number;
  134714. /**
  134715. * Specifies whether or not to create a skybox.
  134716. * True by default.
  134717. */
  134718. createSkybox: boolean;
  134719. /**
  134720. * Specifies the skybox size.
  134721. * 20 by default.
  134722. */
  134723. skyboxSize: number;
  134724. /**
  134725. * The texture used on the skybox for the main color.
  134726. * Comes from the BabylonJS CDN by default.
  134727. *
  134728. * Remarks: Can be either a texture or a url.
  134729. */
  134730. skyboxTexture: string | BaseTexture;
  134731. /**
  134732. * The color mixed in the skybox texture by default.
  134733. * BabylonJS clearColor by default.
  134734. */
  134735. skyboxColor: Color3;
  134736. /**
  134737. * The background rotation around the Y axis of the scene.
  134738. * This helps aligning the key lights of your scene with the background.
  134739. * 0 by default.
  134740. */
  134741. backgroundYRotation: number;
  134742. /**
  134743. * Compute automatically the size of the elements to best fit with the scene.
  134744. */
  134745. sizeAuto: boolean;
  134746. /**
  134747. * Default position of the rootMesh if autoSize is not true.
  134748. */
  134749. rootPosition: Vector3;
  134750. /**
  134751. * Sets up the image processing in the scene.
  134752. * true by default.
  134753. */
  134754. setupImageProcessing: boolean;
  134755. /**
  134756. * The texture used as your environment texture in the scene.
  134757. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  134758. *
  134759. * Remarks: Can be either a texture or a url.
  134760. */
  134761. environmentTexture: string | BaseTexture;
  134762. /**
  134763. * The value of the exposure to apply to the scene.
  134764. * 0.6 by default if setupImageProcessing is true.
  134765. */
  134766. cameraExposure: number;
  134767. /**
  134768. * The value of the contrast to apply to the scene.
  134769. * 1.6 by default if setupImageProcessing is true.
  134770. */
  134771. cameraContrast: number;
  134772. /**
  134773. * Specifies whether or not tonemapping should be enabled in the scene.
  134774. * true by default if setupImageProcessing is true.
  134775. */
  134776. toneMappingEnabled: boolean;
  134777. }
  134778. /**
  134779. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  134780. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  134781. * It also helps with the default setup of your imageProcessing configuration.
  134782. */
  134783. export class EnvironmentHelper {
  134784. /**
  134785. * Default ground texture URL.
  134786. */
  134787. private static _groundTextureCDNUrl;
  134788. /**
  134789. * Default skybox texture URL.
  134790. */
  134791. private static _skyboxTextureCDNUrl;
  134792. /**
  134793. * Default environment texture URL.
  134794. */
  134795. private static _environmentTextureCDNUrl;
  134796. /**
  134797. * Creates the default options for the helper.
  134798. */
  134799. private static _getDefaultOptions;
  134800. private _rootMesh;
  134801. /**
  134802. * Gets the root mesh created by the helper.
  134803. */
  134804. get rootMesh(): Mesh;
  134805. private _skybox;
  134806. /**
  134807. * Gets the skybox created by the helper.
  134808. */
  134809. get skybox(): Nullable<Mesh>;
  134810. private _skyboxTexture;
  134811. /**
  134812. * Gets the skybox texture created by the helper.
  134813. */
  134814. get skyboxTexture(): Nullable<BaseTexture>;
  134815. private _skyboxMaterial;
  134816. /**
  134817. * Gets the skybox material created by the helper.
  134818. */
  134819. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  134820. private _ground;
  134821. /**
  134822. * Gets the ground mesh created by the helper.
  134823. */
  134824. get ground(): Nullable<Mesh>;
  134825. private _groundTexture;
  134826. /**
  134827. * Gets the ground texture created by the helper.
  134828. */
  134829. get groundTexture(): Nullable<BaseTexture>;
  134830. private _groundMirror;
  134831. /**
  134832. * Gets the ground mirror created by the helper.
  134833. */
  134834. get groundMirror(): Nullable<MirrorTexture>;
  134835. /**
  134836. * Gets the ground mirror render list to helps pushing the meshes
  134837. * you wish in the ground reflection.
  134838. */
  134839. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  134840. private _groundMaterial;
  134841. /**
  134842. * Gets the ground material created by the helper.
  134843. */
  134844. get groundMaterial(): Nullable<BackgroundMaterial>;
  134845. /**
  134846. * Stores the creation options.
  134847. */
  134848. private readonly _scene;
  134849. private _options;
  134850. /**
  134851. * This observable will be notified with any error during the creation of the environment,
  134852. * mainly texture creation errors.
  134853. */
  134854. onErrorObservable: Observable<{
  134855. message?: string;
  134856. exception?: any;
  134857. }>;
  134858. /**
  134859. * constructor
  134860. * @param options Defines the options we want to customize the helper
  134861. * @param scene The scene to add the material to
  134862. */
  134863. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  134864. /**
  134865. * Updates the background according to the new options
  134866. * @param options
  134867. */
  134868. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  134869. /**
  134870. * Sets the primary color of all the available elements.
  134871. * @param color the main color to affect to the ground and the background
  134872. */
  134873. setMainColor(color: Color3): void;
  134874. /**
  134875. * Setup the image processing according to the specified options.
  134876. */
  134877. private _setupImageProcessing;
  134878. /**
  134879. * Setup the environment texture according to the specified options.
  134880. */
  134881. private _setupEnvironmentTexture;
  134882. /**
  134883. * Setup the background according to the specified options.
  134884. */
  134885. private _setupBackground;
  134886. /**
  134887. * Get the scene sizes according to the setup.
  134888. */
  134889. private _getSceneSize;
  134890. /**
  134891. * Setup the ground according to the specified options.
  134892. */
  134893. private _setupGround;
  134894. /**
  134895. * Setup the ground material according to the specified options.
  134896. */
  134897. private _setupGroundMaterial;
  134898. /**
  134899. * Setup the ground diffuse texture according to the specified options.
  134900. */
  134901. private _setupGroundDiffuseTexture;
  134902. /**
  134903. * Setup the ground mirror texture according to the specified options.
  134904. */
  134905. private _setupGroundMirrorTexture;
  134906. /**
  134907. * Setup the ground to receive the mirror texture.
  134908. */
  134909. private _setupMirrorInGroundMaterial;
  134910. /**
  134911. * Setup the skybox according to the specified options.
  134912. */
  134913. private _setupSkybox;
  134914. /**
  134915. * Setup the skybox material according to the specified options.
  134916. */
  134917. private _setupSkyboxMaterial;
  134918. /**
  134919. * Setup the skybox reflection texture according to the specified options.
  134920. */
  134921. private _setupSkyboxReflectionTexture;
  134922. private _errorHandler;
  134923. /**
  134924. * Dispose all the elements created by the Helper.
  134925. */
  134926. dispose(): void;
  134927. }
  134928. }
  134929. declare module BABYLON {
  134930. /**
  134931. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  134932. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  134933. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  134934. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134935. */
  134936. export abstract class TextureDome<T extends Texture> extends TransformNode {
  134937. protected onError: Nullable<(message?: string, exception?: any) => void>;
  134938. /**
  134939. * Define the source as a Monoscopic panoramic 360/180.
  134940. */
  134941. static readonly MODE_MONOSCOPIC: number;
  134942. /**
  134943. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  134944. */
  134945. static readonly MODE_TOPBOTTOM: number;
  134946. /**
  134947. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  134948. */
  134949. static readonly MODE_SIDEBYSIDE: number;
  134950. private _halfDome;
  134951. protected _useDirectMapping: boolean;
  134952. /**
  134953. * The texture being displayed on the sphere
  134954. */
  134955. protected _texture: T;
  134956. /**
  134957. * Gets the texture being displayed on the sphere
  134958. */
  134959. get texture(): T;
  134960. /**
  134961. * Sets the texture being displayed on the sphere
  134962. */
  134963. set texture(newTexture: T);
  134964. /**
  134965. * The skybox material
  134966. */
  134967. protected _material: BackgroundMaterial;
  134968. /**
  134969. * The surface used for the dome
  134970. */
  134971. protected _mesh: Mesh;
  134972. /**
  134973. * Gets the mesh used for the dome.
  134974. */
  134975. get mesh(): Mesh;
  134976. /**
  134977. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  134978. */
  134979. private _halfDomeMask;
  134980. /**
  134981. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134982. * Also see the options.resolution property.
  134983. */
  134984. get fovMultiplier(): number;
  134985. set fovMultiplier(value: number);
  134986. protected _textureMode: number;
  134987. /**
  134988. * Gets or set the current texture mode for the texture. It can be:
  134989. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  134990. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  134991. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  134992. */
  134993. get textureMode(): number;
  134994. /**
  134995. * Sets the current texture mode for the texture. It can be:
  134996. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  134997. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  134998. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  134999. */
  135000. set textureMode(value: number);
  135001. /**
  135002. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  135003. */
  135004. get halfDome(): boolean;
  135005. /**
  135006. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  135007. */
  135008. set halfDome(enabled: boolean);
  135009. /**
  135010. * Oberserver used in Stereoscopic VR Mode.
  135011. */
  135012. private _onBeforeCameraRenderObserver;
  135013. /**
  135014. * Observable raised when an error occured while loading the 360 image
  135015. */
  135016. onLoadErrorObservable: Observable<string>;
  135017. /**
  135018. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  135019. * @param name Element's name, child elements will append suffixes for their own names.
  135020. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  135021. * @param options An object containing optional or exposed sub element properties
  135022. */
  135023. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  135024. resolution?: number;
  135025. clickToPlay?: boolean;
  135026. autoPlay?: boolean;
  135027. loop?: boolean;
  135028. size?: number;
  135029. poster?: string;
  135030. faceForward?: boolean;
  135031. useDirectMapping?: boolean;
  135032. halfDomeMode?: boolean;
  135033. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  135034. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  135035. protected _changeTextureMode(value: number): void;
  135036. /**
  135037. * Releases resources associated with this node.
  135038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  135039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  135040. */
  135041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  135042. }
  135043. }
  135044. declare module BABYLON {
  135045. /**
  135046. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  135047. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  135048. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135049. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135050. */
  135051. export class PhotoDome extends TextureDome<Texture> {
  135052. /**
  135053. * Define the image as a Monoscopic panoramic 360 image.
  135054. */
  135055. static readonly MODE_MONOSCOPIC: number;
  135056. /**
  135057. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  135058. */
  135059. static readonly MODE_TOPBOTTOM: number;
  135060. /**
  135061. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  135062. */
  135063. static readonly MODE_SIDEBYSIDE: number;
  135064. /**
  135065. * Gets or sets the texture being displayed on the sphere
  135066. */
  135067. get photoTexture(): Texture;
  135068. /**
  135069. * sets the texture being displayed on the sphere
  135070. */
  135071. set photoTexture(value: Texture);
  135072. /**
  135073. * Gets the current video mode for the video. It can be:
  135074. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135075. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135076. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135077. */
  135078. get imageMode(): number;
  135079. /**
  135080. * Sets the current video mode for the video. It can be:
  135081. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135082. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135083. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135084. */
  135085. set imageMode(value: number);
  135086. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  135087. }
  135088. }
  135089. declare module BABYLON {
  135090. /**
  135091. * Class used to host RGBD texture specific utilities
  135092. */
  135093. export class RGBDTextureTools {
  135094. /**
  135095. * Expand the RGBD Texture from RGBD to Half Float if possible.
  135096. * @param texture the texture to expand.
  135097. */
  135098. static ExpandRGBDTexture(texture: Texture): void;
  135099. }
  135100. }
  135101. declare module BABYLON {
  135102. /**
  135103. * Class used to host texture specific utilities
  135104. */
  135105. export class BRDFTextureTools {
  135106. /**
  135107. * Prevents texture cache collision
  135108. */
  135109. private static _instanceNumber;
  135110. /**
  135111. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  135112. * @param scene defines the hosting scene
  135113. * @returns the environment BRDF texture
  135114. */
  135115. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  135116. private static _environmentBRDFBase64Texture;
  135117. }
  135118. }
  135119. declare module BABYLON {
  135120. /**
  135121. * @hidden
  135122. */
  135123. export interface IMaterialClearCoatDefines {
  135124. CLEARCOAT: boolean;
  135125. CLEARCOAT_DEFAULTIOR: boolean;
  135126. CLEARCOAT_TEXTURE: boolean;
  135127. CLEARCOAT_TEXTUREDIRECTUV: number;
  135128. CLEARCOAT_BUMP: boolean;
  135129. CLEARCOAT_BUMPDIRECTUV: number;
  135130. CLEARCOAT_TINT: boolean;
  135131. CLEARCOAT_TINT_TEXTURE: boolean;
  135132. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  135133. /** @hidden */
  135134. _areTexturesDirty: boolean;
  135135. }
  135136. /**
  135137. * Define the code related to the clear coat parameters of the pbr material.
  135138. */
  135139. export class PBRClearCoatConfiguration {
  135140. /**
  135141. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135142. * The default fits with a polyurethane material.
  135143. */
  135144. private static readonly _DefaultIndexOfRefraction;
  135145. private _isEnabled;
  135146. /**
  135147. * Defines if the clear coat is enabled in the material.
  135148. */
  135149. isEnabled: boolean;
  135150. /**
  135151. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  135152. */
  135153. intensity: number;
  135154. /**
  135155. * Defines the clear coat layer roughness.
  135156. */
  135157. roughness: number;
  135158. private _indexOfRefraction;
  135159. /**
  135160. * Defines the index of refraction of the clear coat.
  135161. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135162. * The default fits with a polyurethane material.
  135163. * Changing the default value is more performance intensive.
  135164. */
  135165. indexOfRefraction: number;
  135166. private _texture;
  135167. /**
  135168. * Stores the clear coat values in a texture.
  135169. */
  135170. texture: Nullable<BaseTexture>;
  135171. private _bumpTexture;
  135172. /**
  135173. * Define the clear coat specific bump texture.
  135174. */
  135175. bumpTexture: Nullable<BaseTexture>;
  135176. private _isTintEnabled;
  135177. /**
  135178. * Defines if the clear coat tint is enabled in the material.
  135179. */
  135180. isTintEnabled: boolean;
  135181. /**
  135182. * Defines the clear coat tint of the material.
  135183. * This is only use if tint is enabled
  135184. */
  135185. tintColor: Color3;
  135186. /**
  135187. * Defines the distance at which the tint color should be found in the
  135188. * clear coat media.
  135189. * This is only use if tint is enabled
  135190. */
  135191. tintColorAtDistance: number;
  135192. /**
  135193. * Defines the clear coat layer thickness.
  135194. * This is only use if tint is enabled
  135195. */
  135196. tintThickness: number;
  135197. private _tintTexture;
  135198. /**
  135199. * Stores the clear tint values in a texture.
  135200. * rgb is tint
  135201. * a is a thickness factor
  135202. */
  135203. tintTexture: Nullable<BaseTexture>;
  135204. /** @hidden */
  135205. private _internalMarkAllSubMeshesAsTexturesDirty;
  135206. /** @hidden */
  135207. _markAllSubMeshesAsTexturesDirty(): void;
  135208. /**
  135209. * Instantiate a new istance of clear coat configuration.
  135210. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135211. */
  135212. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135213. /**
  135214. * Gets wehter the submesh is ready to be used or not.
  135215. * @param defines the list of "defines" to update.
  135216. * @param scene defines the scene the material belongs to.
  135217. * @param engine defines the engine the material belongs to.
  135218. * @param disableBumpMap defines wether the material disables bump or not.
  135219. * @returns - boolean indicating that the submesh is ready or not.
  135220. */
  135221. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  135222. /**
  135223. * Checks to see if a texture is used in the material.
  135224. * @param defines the list of "defines" to update.
  135225. * @param scene defines the scene to the material belongs to.
  135226. */
  135227. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  135228. /**
  135229. * Binds the material data.
  135230. * @param uniformBuffer defines the Uniform buffer to fill in.
  135231. * @param scene defines the scene the material belongs to.
  135232. * @param engine defines the engine the material belongs to.
  135233. * @param disableBumpMap defines wether the material disables bump or not.
  135234. * @param isFrozen defines wether the material is frozen or not.
  135235. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135236. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135237. */
  135238. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  135239. /**
  135240. * Checks to see if a texture is used in the material.
  135241. * @param texture - Base texture to use.
  135242. * @returns - Boolean specifying if a texture is used in the material.
  135243. */
  135244. hasTexture(texture: BaseTexture): boolean;
  135245. /**
  135246. * Returns an array of the actively used textures.
  135247. * @param activeTextures Array of BaseTextures
  135248. */
  135249. getActiveTextures(activeTextures: BaseTexture[]): void;
  135250. /**
  135251. * Returns the animatable textures.
  135252. * @param animatables Array of animatable textures.
  135253. */
  135254. getAnimatables(animatables: IAnimatable[]): void;
  135255. /**
  135256. * Disposes the resources of the material.
  135257. * @param forceDisposeTextures - Forces the disposal of all textures.
  135258. */
  135259. dispose(forceDisposeTextures?: boolean): void;
  135260. /**
  135261. * Get the current class name of the texture useful for serialization or dynamic coding.
  135262. * @returns "PBRClearCoatConfiguration"
  135263. */
  135264. getClassName(): string;
  135265. /**
  135266. * Add fallbacks to the effect fallbacks list.
  135267. * @param defines defines the Base texture to use.
  135268. * @param fallbacks defines the current fallback list.
  135269. * @param currentRank defines the current fallback rank.
  135270. * @returns the new fallback rank.
  135271. */
  135272. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135273. /**
  135274. * Add the required uniforms to the current list.
  135275. * @param uniforms defines the current uniform list.
  135276. */
  135277. static AddUniforms(uniforms: string[]): void;
  135278. /**
  135279. * Add the required samplers to the current list.
  135280. * @param samplers defines the current sampler list.
  135281. */
  135282. static AddSamplers(samplers: string[]): void;
  135283. /**
  135284. * Add the required uniforms to the current buffer.
  135285. * @param uniformBuffer defines the current uniform buffer.
  135286. */
  135287. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135288. /**
  135289. * Makes a duplicate of the current configuration into another one.
  135290. * @param clearCoatConfiguration define the config where to copy the info
  135291. */
  135292. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  135293. /**
  135294. * Serializes this clear coat configuration.
  135295. * @returns - An object with the serialized config.
  135296. */
  135297. serialize(): any;
  135298. /**
  135299. * Parses a anisotropy Configuration from a serialized object.
  135300. * @param source - Serialized object.
  135301. * @param scene Defines the scene we are parsing for
  135302. * @param rootUrl Defines the rootUrl to load from
  135303. */
  135304. parse(source: any, scene: Scene, rootUrl: string): void;
  135305. }
  135306. }
  135307. declare module BABYLON {
  135308. /**
  135309. * @hidden
  135310. */
  135311. export interface IMaterialAnisotropicDefines {
  135312. ANISOTROPIC: boolean;
  135313. ANISOTROPIC_TEXTURE: boolean;
  135314. ANISOTROPIC_TEXTUREDIRECTUV: number;
  135315. MAINUV1: boolean;
  135316. _areTexturesDirty: boolean;
  135317. _needUVs: boolean;
  135318. }
  135319. /**
  135320. * Define the code related to the anisotropic parameters of the pbr material.
  135321. */
  135322. export class PBRAnisotropicConfiguration {
  135323. private _isEnabled;
  135324. /**
  135325. * Defines if the anisotropy is enabled in the material.
  135326. */
  135327. isEnabled: boolean;
  135328. /**
  135329. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  135330. */
  135331. intensity: number;
  135332. /**
  135333. * Defines if the effect is along the tangents, bitangents or in between.
  135334. * By default, the effect is "strectching" the highlights along the tangents.
  135335. */
  135336. direction: Vector2;
  135337. private _texture;
  135338. /**
  135339. * Stores the anisotropy values in a texture.
  135340. * rg is direction (like normal from -1 to 1)
  135341. * b is a intensity
  135342. */
  135343. texture: Nullable<BaseTexture>;
  135344. /** @hidden */
  135345. private _internalMarkAllSubMeshesAsTexturesDirty;
  135346. /** @hidden */
  135347. _markAllSubMeshesAsTexturesDirty(): void;
  135348. /**
  135349. * Instantiate a new istance of anisotropy configuration.
  135350. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135351. */
  135352. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135353. /**
  135354. * Specifies that the submesh is ready to be used.
  135355. * @param defines the list of "defines" to update.
  135356. * @param scene defines the scene the material belongs to.
  135357. * @returns - boolean indicating that the submesh is ready or not.
  135358. */
  135359. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  135360. /**
  135361. * Checks to see if a texture is used in the material.
  135362. * @param defines the list of "defines" to update.
  135363. * @param mesh the mesh we are preparing the defines for.
  135364. * @param scene defines the scene the material belongs to.
  135365. */
  135366. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  135367. /**
  135368. * Binds the material data.
  135369. * @param uniformBuffer defines the Uniform buffer to fill in.
  135370. * @param scene defines the scene the material belongs to.
  135371. * @param isFrozen defines wether the material is frozen or not.
  135372. */
  135373. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135374. /**
  135375. * Checks to see if a texture is used in the material.
  135376. * @param texture - Base texture to use.
  135377. * @returns - Boolean specifying if a texture is used in the material.
  135378. */
  135379. hasTexture(texture: BaseTexture): boolean;
  135380. /**
  135381. * Returns an array of the actively used textures.
  135382. * @param activeTextures Array of BaseTextures
  135383. */
  135384. getActiveTextures(activeTextures: BaseTexture[]): void;
  135385. /**
  135386. * Returns the animatable textures.
  135387. * @param animatables Array of animatable textures.
  135388. */
  135389. getAnimatables(animatables: IAnimatable[]): void;
  135390. /**
  135391. * Disposes the resources of the material.
  135392. * @param forceDisposeTextures - Forces the disposal of all textures.
  135393. */
  135394. dispose(forceDisposeTextures?: boolean): void;
  135395. /**
  135396. * Get the current class name of the texture useful for serialization or dynamic coding.
  135397. * @returns "PBRAnisotropicConfiguration"
  135398. */
  135399. getClassName(): string;
  135400. /**
  135401. * Add fallbacks to the effect fallbacks list.
  135402. * @param defines defines the Base texture to use.
  135403. * @param fallbacks defines the current fallback list.
  135404. * @param currentRank defines the current fallback rank.
  135405. * @returns the new fallback rank.
  135406. */
  135407. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135408. /**
  135409. * Add the required uniforms to the current list.
  135410. * @param uniforms defines the current uniform list.
  135411. */
  135412. static AddUniforms(uniforms: string[]): void;
  135413. /**
  135414. * Add the required uniforms to the current buffer.
  135415. * @param uniformBuffer defines the current uniform buffer.
  135416. */
  135417. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135418. /**
  135419. * Add the required samplers to the current list.
  135420. * @param samplers defines the current sampler list.
  135421. */
  135422. static AddSamplers(samplers: string[]): void;
  135423. /**
  135424. * Makes a duplicate of the current configuration into another one.
  135425. * @param anisotropicConfiguration define the config where to copy the info
  135426. */
  135427. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  135428. /**
  135429. * Serializes this anisotropy configuration.
  135430. * @returns - An object with the serialized config.
  135431. */
  135432. serialize(): any;
  135433. /**
  135434. * Parses a anisotropy Configuration from a serialized object.
  135435. * @param source - Serialized object.
  135436. * @param scene Defines the scene we are parsing for
  135437. * @param rootUrl Defines the rootUrl to load from
  135438. */
  135439. parse(source: any, scene: Scene, rootUrl: string): void;
  135440. }
  135441. }
  135442. declare module BABYLON {
  135443. /**
  135444. * @hidden
  135445. */
  135446. export interface IMaterialBRDFDefines {
  135447. BRDF_V_HEIGHT_CORRELATED: boolean;
  135448. MS_BRDF_ENERGY_CONSERVATION: boolean;
  135449. SPHERICAL_HARMONICS: boolean;
  135450. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  135451. /** @hidden */
  135452. _areMiscDirty: boolean;
  135453. }
  135454. /**
  135455. * Define the code related to the BRDF parameters of the pbr material.
  135456. */
  135457. export class PBRBRDFConfiguration {
  135458. /**
  135459. * Default value used for the energy conservation.
  135460. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135461. */
  135462. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  135463. /**
  135464. * Default value used for the Smith Visibility Height Correlated mode.
  135465. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135466. */
  135467. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  135468. /**
  135469. * Default value used for the IBL diffuse part.
  135470. * This can help switching back to the polynomials mode globally which is a tiny bit
  135471. * less GPU intensive at the drawback of a lower quality.
  135472. */
  135473. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  135474. /**
  135475. * Default value used for activating energy conservation for the specular workflow.
  135476. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  135477. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  135478. */
  135479. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  135480. private _useEnergyConservation;
  135481. /**
  135482. * Defines if the material uses energy conservation.
  135483. */
  135484. useEnergyConservation: boolean;
  135485. private _useSmithVisibilityHeightCorrelated;
  135486. /**
  135487. * LEGACY Mode set to false
  135488. * Defines if the material uses height smith correlated visibility term.
  135489. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  135490. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  135491. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  135492. * Not relying on height correlated will also disable energy conservation.
  135493. */
  135494. useSmithVisibilityHeightCorrelated: boolean;
  135495. private _useSphericalHarmonics;
  135496. /**
  135497. * LEGACY Mode set to false
  135498. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  135499. * diffuse part of the IBL.
  135500. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  135501. * to the ground truth.
  135502. */
  135503. useSphericalHarmonics: boolean;
  135504. private _useSpecularGlossinessInputEnergyConservation;
  135505. /**
  135506. * Defines if the material uses energy conservation, when the specular workflow is active.
  135507. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  135508. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  135509. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  135510. */
  135511. useSpecularGlossinessInputEnergyConservation: boolean;
  135512. /** @hidden */
  135513. private _internalMarkAllSubMeshesAsMiscDirty;
  135514. /** @hidden */
  135515. _markAllSubMeshesAsMiscDirty(): void;
  135516. /**
  135517. * Instantiate a new istance of clear coat configuration.
  135518. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  135519. */
  135520. constructor(markAllSubMeshesAsMiscDirty: () => void);
  135521. /**
  135522. * Checks to see if a texture is used in the material.
  135523. * @param defines the list of "defines" to update.
  135524. */
  135525. prepareDefines(defines: IMaterialBRDFDefines): void;
  135526. /**
  135527. * Get the current class name of the texture useful for serialization or dynamic coding.
  135528. * @returns "PBRClearCoatConfiguration"
  135529. */
  135530. getClassName(): string;
  135531. /**
  135532. * Makes a duplicate of the current configuration into another one.
  135533. * @param brdfConfiguration define the config where to copy the info
  135534. */
  135535. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  135536. /**
  135537. * Serializes this BRDF configuration.
  135538. * @returns - An object with the serialized config.
  135539. */
  135540. serialize(): any;
  135541. /**
  135542. * Parses a anisotropy Configuration from a serialized object.
  135543. * @param source - Serialized object.
  135544. * @param scene Defines the scene we are parsing for
  135545. * @param rootUrl Defines the rootUrl to load from
  135546. */
  135547. parse(source: any, scene: Scene, rootUrl: string): void;
  135548. }
  135549. }
  135550. declare module BABYLON {
  135551. /**
  135552. * @hidden
  135553. */
  135554. export interface IMaterialSheenDefines {
  135555. SHEEN: boolean;
  135556. SHEEN_TEXTURE: boolean;
  135557. SHEEN_TEXTUREDIRECTUV: number;
  135558. SHEEN_LINKWITHALBEDO: boolean;
  135559. SHEEN_ROUGHNESS: boolean;
  135560. SHEEN_ALBEDOSCALING: boolean;
  135561. /** @hidden */
  135562. _areTexturesDirty: boolean;
  135563. }
  135564. /**
  135565. * Define the code related to the Sheen parameters of the pbr material.
  135566. */
  135567. export class PBRSheenConfiguration {
  135568. private _isEnabled;
  135569. /**
  135570. * Defines if the material uses sheen.
  135571. */
  135572. isEnabled: boolean;
  135573. private _linkSheenWithAlbedo;
  135574. /**
  135575. * Defines if the sheen is linked to the sheen color.
  135576. */
  135577. linkSheenWithAlbedo: boolean;
  135578. /**
  135579. * Defines the sheen intensity.
  135580. */
  135581. intensity: number;
  135582. /**
  135583. * Defines the sheen color.
  135584. */
  135585. color: Color3;
  135586. private _texture;
  135587. /**
  135588. * Stores the sheen tint values in a texture.
  135589. * rgb is tint
  135590. * a is a intensity or roughness if roughness has been defined
  135591. */
  135592. texture: Nullable<BaseTexture>;
  135593. private _roughness;
  135594. /**
  135595. * Defines the sheen roughness.
  135596. * It is not taken into account if linkSheenWithAlbedo is true.
  135597. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  135598. */
  135599. roughness: Nullable<number>;
  135600. private _albedoScaling;
  135601. /**
  135602. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  135603. * It allows the strength of the sheen effect to not depend on the base color of the material,
  135604. * making it easier to setup and tweak the effect
  135605. */
  135606. albedoScaling: boolean;
  135607. /** @hidden */
  135608. private _internalMarkAllSubMeshesAsTexturesDirty;
  135609. /** @hidden */
  135610. _markAllSubMeshesAsTexturesDirty(): void;
  135611. /**
  135612. * Instantiate a new istance of clear coat configuration.
  135613. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135614. */
  135615. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135616. /**
  135617. * Specifies that the submesh is ready to be used.
  135618. * @param defines the list of "defines" to update.
  135619. * @param scene defines the scene the material belongs to.
  135620. * @returns - boolean indicating that the submesh is ready or not.
  135621. */
  135622. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  135623. /**
  135624. * Checks to see if a texture is used in the material.
  135625. * @param defines the list of "defines" to update.
  135626. * @param scene defines the scene the material belongs to.
  135627. */
  135628. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  135629. /**
  135630. * Binds the material data.
  135631. * @param uniformBuffer defines the Uniform buffer to fill in.
  135632. * @param scene defines the scene the material belongs to.
  135633. * @param isFrozen defines wether the material is frozen or not.
  135634. */
  135635. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135636. /**
  135637. * Checks to see if a texture is used in the material.
  135638. * @param texture - Base texture to use.
  135639. * @returns - Boolean specifying if a texture is used in the material.
  135640. */
  135641. hasTexture(texture: BaseTexture): boolean;
  135642. /**
  135643. * Returns an array of the actively used textures.
  135644. * @param activeTextures Array of BaseTextures
  135645. */
  135646. getActiveTextures(activeTextures: BaseTexture[]): void;
  135647. /**
  135648. * Returns the animatable textures.
  135649. * @param animatables Array of animatable textures.
  135650. */
  135651. getAnimatables(animatables: IAnimatable[]): void;
  135652. /**
  135653. * Disposes the resources of the material.
  135654. * @param forceDisposeTextures - Forces the disposal of all textures.
  135655. */
  135656. dispose(forceDisposeTextures?: boolean): void;
  135657. /**
  135658. * Get the current class name of the texture useful for serialization or dynamic coding.
  135659. * @returns "PBRSheenConfiguration"
  135660. */
  135661. getClassName(): string;
  135662. /**
  135663. * Add fallbacks to the effect fallbacks list.
  135664. * @param defines defines the Base texture to use.
  135665. * @param fallbacks defines the current fallback list.
  135666. * @param currentRank defines the current fallback rank.
  135667. * @returns the new fallback rank.
  135668. */
  135669. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135670. /**
  135671. * Add the required uniforms to the current list.
  135672. * @param uniforms defines the current uniform list.
  135673. */
  135674. static AddUniforms(uniforms: string[]): void;
  135675. /**
  135676. * Add the required uniforms to the current buffer.
  135677. * @param uniformBuffer defines the current uniform buffer.
  135678. */
  135679. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135680. /**
  135681. * Add the required samplers to the current list.
  135682. * @param samplers defines the current sampler list.
  135683. */
  135684. static AddSamplers(samplers: string[]): void;
  135685. /**
  135686. * Makes a duplicate of the current configuration into another one.
  135687. * @param sheenConfiguration define the config where to copy the info
  135688. */
  135689. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  135690. /**
  135691. * Serializes this BRDF configuration.
  135692. * @returns - An object with the serialized config.
  135693. */
  135694. serialize(): any;
  135695. /**
  135696. * Parses a anisotropy Configuration from a serialized object.
  135697. * @param source - Serialized object.
  135698. * @param scene Defines the scene we are parsing for
  135699. * @param rootUrl Defines the rootUrl to load from
  135700. */
  135701. parse(source: any, scene: Scene, rootUrl: string): void;
  135702. }
  135703. }
  135704. declare module BABYLON {
  135705. /**
  135706. * @hidden
  135707. */
  135708. export interface IMaterialSubSurfaceDefines {
  135709. SUBSURFACE: boolean;
  135710. SS_REFRACTION: boolean;
  135711. SS_TRANSLUCENCY: boolean;
  135712. SS_SCATTERING: boolean;
  135713. SS_THICKNESSANDMASK_TEXTURE: boolean;
  135714. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  135715. SS_REFRACTIONMAP_3D: boolean;
  135716. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  135717. SS_LODINREFRACTIONALPHA: boolean;
  135718. SS_GAMMAREFRACTION: boolean;
  135719. SS_RGBDREFRACTION: boolean;
  135720. SS_LINEARSPECULARREFRACTION: boolean;
  135721. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  135722. SS_ALBEDOFORREFRACTIONTINT: boolean;
  135723. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  135724. /** @hidden */
  135725. _areTexturesDirty: boolean;
  135726. }
  135727. /**
  135728. * Define the code related to the sub surface parameters of the pbr material.
  135729. */
  135730. export class PBRSubSurfaceConfiguration {
  135731. private _isRefractionEnabled;
  135732. /**
  135733. * Defines if the refraction is enabled in the material.
  135734. */
  135735. isRefractionEnabled: boolean;
  135736. private _isTranslucencyEnabled;
  135737. /**
  135738. * Defines if the translucency is enabled in the material.
  135739. */
  135740. isTranslucencyEnabled: boolean;
  135741. private _isScatteringEnabled;
  135742. /**
  135743. * Defines if the sub surface scattering is enabled in the material.
  135744. */
  135745. isScatteringEnabled: boolean;
  135746. private _scatteringDiffusionProfileIndex;
  135747. /**
  135748. * Diffusion profile for subsurface scattering.
  135749. * Useful for better scattering in the skins or foliages.
  135750. */
  135751. get scatteringDiffusionProfile(): Nullable<Color3>;
  135752. set scatteringDiffusionProfile(c: Nullable<Color3>);
  135753. /**
  135754. * Defines the refraction intensity of the material.
  135755. * The refraction when enabled replaces the Diffuse part of the material.
  135756. * The intensity helps transitionning between diffuse and refraction.
  135757. */
  135758. refractionIntensity: number;
  135759. /**
  135760. * Defines the translucency intensity of the material.
  135761. * When translucency has been enabled, this defines how much of the "translucency"
  135762. * is addded to the diffuse part of the material.
  135763. */
  135764. translucencyIntensity: number;
  135765. /**
  135766. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  135767. */
  135768. useAlbedoToTintRefraction: boolean;
  135769. private _thicknessTexture;
  135770. /**
  135771. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  135772. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  135773. * 0 would mean minimumThickness
  135774. * 1 would mean maximumThickness
  135775. * The other channels might be use as a mask to vary the different effects intensity.
  135776. */
  135777. thicknessTexture: Nullable<BaseTexture>;
  135778. private _refractionTexture;
  135779. /**
  135780. * Defines the texture to use for refraction.
  135781. */
  135782. refractionTexture: Nullable<BaseTexture>;
  135783. private _indexOfRefraction;
  135784. /**
  135785. * Index of refraction of the material base layer.
  135786. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135787. *
  135788. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  135789. *
  135790. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  135791. */
  135792. indexOfRefraction: number;
  135793. private _volumeIndexOfRefraction;
  135794. /**
  135795. * Index of refraction of the material's volume.
  135796. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135797. *
  135798. * This ONLY impacts refraction. If not provided or given a non-valid value,
  135799. * the volume will use the same IOR as the surface.
  135800. */
  135801. get volumeIndexOfRefraction(): number;
  135802. set volumeIndexOfRefraction(value: number);
  135803. private _invertRefractionY;
  135804. /**
  135805. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  135806. */
  135807. invertRefractionY: boolean;
  135808. private _linkRefractionWithTransparency;
  135809. /**
  135810. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  135811. * Materials half opaque for instance using refraction could benefit from this control.
  135812. */
  135813. linkRefractionWithTransparency: boolean;
  135814. /**
  135815. * Defines the minimum thickness stored in the thickness map.
  135816. * If no thickness map is defined, this value will be used to simulate thickness.
  135817. */
  135818. minimumThickness: number;
  135819. /**
  135820. * Defines the maximum thickness stored in the thickness map.
  135821. */
  135822. maximumThickness: number;
  135823. /**
  135824. * Defines the volume tint of the material.
  135825. * This is used for both translucency and scattering.
  135826. */
  135827. tintColor: Color3;
  135828. /**
  135829. * Defines the distance at which the tint color should be found in the media.
  135830. * This is used for refraction only.
  135831. */
  135832. tintColorAtDistance: number;
  135833. /**
  135834. * Defines how far each channel transmit through the media.
  135835. * It is defined as a color to simplify it selection.
  135836. */
  135837. diffusionDistance: Color3;
  135838. private _useMaskFromThicknessTexture;
  135839. /**
  135840. * Stores the intensity of the different subsurface effects in the thickness texture.
  135841. * * the green channel is the translucency intensity.
  135842. * * the blue channel is the scattering intensity.
  135843. * * the alpha channel is the refraction intensity.
  135844. */
  135845. useMaskFromThicknessTexture: boolean;
  135846. private _scene;
  135847. /** @hidden */
  135848. private _internalMarkAllSubMeshesAsTexturesDirty;
  135849. private _internalMarkScenePrePassDirty;
  135850. /** @hidden */
  135851. _markAllSubMeshesAsTexturesDirty(): void;
  135852. /** @hidden */
  135853. _markScenePrePassDirty(): void;
  135854. /**
  135855. * Instantiate a new istance of sub surface configuration.
  135856. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135857. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  135858. * @param scene The scene
  135859. */
  135860. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  135861. /**
  135862. * Gets wehter the submesh is ready to be used or not.
  135863. * @param defines the list of "defines" to update.
  135864. * @param scene defines the scene the material belongs to.
  135865. * @returns - boolean indicating that the submesh is ready or not.
  135866. */
  135867. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  135868. /**
  135869. * Checks to see if a texture is used in the material.
  135870. * @param defines the list of "defines" to update.
  135871. * @param scene defines the scene to the material belongs to.
  135872. */
  135873. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  135874. /**
  135875. * Binds the material data.
  135876. * @param uniformBuffer defines the Uniform buffer to fill in.
  135877. * @param scene defines the scene the material belongs to.
  135878. * @param engine defines the engine the material belongs to.
  135879. * @param isFrozen defines whether the material is frozen or not.
  135880. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  135881. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  135882. */
  135883. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  135884. /**
  135885. * Unbinds the material from the mesh.
  135886. * @param activeEffect defines the effect that should be unbound from.
  135887. * @returns true if unbound, otherwise false
  135888. */
  135889. unbind(activeEffect: Effect): boolean;
  135890. /**
  135891. * Returns the texture used for refraction or null if none is used.
  135892. * @param scene defines the scene the material belongs to.
  135893. * @returns - Refraction texture if present. If no refraction texture and refraction
  135894. * is linked with transparency, returns environment texture. Otherwise, returns null.
  135895. */
  135896. private _getRefractionTexture;
  135897. /**
  135898. * Returns true if alpha blending should be disabled.
  135899. */
  135900. get disableAlphaBlending(): boolean;
  135901. /**
  135902. * Fills the list of render target textures.
  135903. * @param renderTargets the list of render targets to update
  135904. */
  135905. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  135906. /**
  135907. * Checks to see if a texture is used in the material.
  135908. * @param texture - Base texture to use.
  135909. * @returns - Boolean specifying if a texture is used in the material.
  135910. */
  135911. hasTexture(texture: BaseTexture): boolean;
  135912. /**
  135913. * Gets a boolean indicating that current material needs to register RTT
  135914. * @returns true if this uses a render target otherwise false.
  135915. */
  135916. hasRenderTargetTextures(): boolean;
  135917. /**
  135918. * Returns an array of the actively used textures.
  135919. * @param activeTextures Array of BaseTextures
  135920. */
  135921. getActiveTextures(activeTextures: BaseTexture[]): void;
  135922. /**
  135923. * Returns the animatable textures.
  135924. * @param animatables Array of animatable textures.
  135925. */
  135926. getAnimatables(animatables: IAnimatable[]): void;
  135927. /**
  135928. * Disposes the resources of the material.
  135929. * @param forceDisposeTextures - Forces the disposal of all textures.
  135930. */
  135931. dispose(forceDisposeTextures?: boolean): void;
  135932. /**
  135933. * Get the current class name of the texture useful for serialization or dynamic coding.
  135934. * @returns "PBRSubSurfaceConfiguration"
  135935. */
  135936. getClassName(): string;
  135937. /**
  135938. * Add fallbacks to the effect fallbacks list.
  135939. * @param defines defines the Base texture to use.
  135940. * @param fallbacks defines the current fallback list.
  135941. * @param currentRank defines the current fallback rank.
  135942. * @returns the new fallback rank.
  135943. */
  135944. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135945. /**
  135946. * Add the required uniforms to the current list.
  135947. * @param uniforms defines the current uniform list.
  135948. */
  135949. static AddUniforms(uniforms: string[]): void;
  135950. /**
  135951. * Add the required samplers to the current list.
  135952. * @param samplers defines the current sampler list.
  135953. */
  135954. static AddSamplers(samplers: string[]): void;
  135955. /**
  135956. * Add the required uniforms to the current buffer.
  135957. * @param uniformBuffer defines the current uniform buffer.
  135958. */
  135959. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135960. /**
  135961. * Makes a duplicate of the current configuration into another one.
  135962. * @param configuration define the config where to copy the info
  135963. */
  135964. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  135965. /**
  135966. * Serializes this Sub Surface configuration.
  135967. * @returns - An object with the serialized config.
  135968. */
  135969. serialize(): any;
  135970. /**
  135971. * Parses a anisotropy Configuration from a serialized object.
  135972. * @param source - Serialized object.
  135973. * @param scene Defines the scene we are parsing for
  135974. * @param rootUrl Defines the rootUrl to load from
  135975. */
  135976. parse(source: any, scene: Scene, rootUrl: string): void;
  135977. }
  135978. }
  135979. declare module BABYLON {
  135980. /** @hidden */
  135981. export var pbrFragmentDeclaration: {
  135982. name: string;
  135983. shader: string;
  135984. };
  135985. }
  135986. declare module BABYLON {
  135987. /** @hidden */
  135988. export var pbrUboDeclaration: {
  135989. name: string;
  135990. shader: string;
  135991. };
  135992. }
  135993. declare module BABYLON {
  135994. /** @hidden */
  135995. export var pbrFragmentExtraDeclaration: {
  135996. name: string;
  135997. shader: string;
  135998. };
  135999. }
  136000. declare module BABYLON {
  136001. /** @hidden */
  136002. export var pbrFragmentSamplersDeclaration: {
  136003. name: string;
  136004. shader: string;
  136005. };
  136006. }
  136007. declare module BABYLON {
  136008. /** @hidden */
  136009. export var importanceSampling: {
  136010. name: string;
  136011. shader: string;
  136012. };
  136013. }
  136014. declare module BABYLON {
  136015. /** @hidden */
  136016. export var pbrHelperFunctions: {
  136017. name: string;
  136018. shader: string;
  136019. };
  136020. }
  136021. declare module BABYLON {
  136022. /** @hidden */
  136023. export var harmonicsFunctions: {
  136024. name: string;
  136025. shader: string;
  136026. };
  136027. }
  136028. declare module BABYLON {
  136029. /** @hidden */
  136030. export var pbrDirectLightingSetupFunctions: {
  136031. name: string;
  136032. shader: string;
  136033. };
  136034. }
  136035. declare module BABYLON {
  136036. /** @hidden */
  136037. export var pbrDirectLightingFalloffFunctions: {
  136038. name: string;
  136039. shader: string;
  136040. };
  136041. }
  136042. declare module BABYLON {
  136043. /** @hidden */
  136044. export var pbrBRDFFunctions: {
  136045. name: string;
  136046. shader: string;
  136047. };
  136048. }
  136049. declare module BABYLON {
  136050. /** @hidden */
  136051. export var hdrFilteringFunctions: {
  136052. name: string;
  136053. shader: string;
  136054. };
  136055. }
  136056. declare module BABYLON {
  136057. /** @hidden */
  136058. export var pbrDirectLightingFunctions: {
  136059. name: string;
  136060. shader: string;
  136061. };
  136062. }
  136063. declare module BABYLON {
  136064. /** @hidden */
  136065. export var pbrIBLFunctions: {
  136066. name: string;
  136067. shader: string;
  136068. };
  136069. }
  136070. declare module BABYLON {
  136071. /** @hidden */
  136072. export var pbrBlockAlbedoOpacity: {
  136073. name: string;
  136074. shader: string;
  136075. };
  136076. }
  136077. declare module BABYLON {
  136078. /** @hidden */
  136079. export var pbrBlockReflectivity: {
  136080. name: string;
  136081. shader: string;
  136082. };
  136083. }
  136084. declare module BABYLON {
  136085. /** @hidden */
  136086. export var pbrBlockAmbientOcclusion: {
  136087. name: string;
  136088. shader: string;
  136089. };
  136090. }
  136091. declare module BABYLON {
  136092. /** @hidden */
  136093. export var pbrBlockAlphaFresnel: {
  136094. name: string;
  136095. shader: string;
  136096. };
  136097. }
  136098. declare module BABYLON {
  136099. /** @hidden */
  136100. export var pbrBlockAnisotropic: {
  136101. name: string;
  136102. shader: string;
  136103. };
  136104. }
  136105. declare module BABYLON {
  136106. /** @hidden */
  136107. export var pbrBlockReflection: {
  136108. name: string;
  136109. shader: string;
  136110. };
  136111. }
  136112. declare module BABYLON {
  136113. /** @hidden */
  136114. export var pbrBlockSheen: {
  136115. name: string;
  136116. shader: string;
  136117. };
  136118. }
  136119. declare module BABYLON {
  136120. /** @hidden */
  136121. export var pbrBlockClearcoat: {
  136122. name: string;
  136123. shader: string;
  136124. };
  136125. }
  136126. declare module BABYLON {
  136127. /** @hidden */
  136128. export var pbrBlockSubSurface: {
  136129. name: string;
  136130. shader: string;
  136131. };
  136132. }
  136133. declare module BABYLON {
  136134. /** @hidden */
  136135. export var pbrBlockNormalGeometric: {
  136136. name: string;
  136137. shader: string;
  136138. };
  136139. }
  136140. declare module BABYLON {
  136141. /** @hidden */
  136142. export var pbrBlockNormalFinal: {
  136143. name: string;
  136144. shader: string;
  136145. };
  136146. }
  136147. declare module BABYLON {
  136148. /** @hidden */
  136149. export var pbrBlockLightmapInit: {
  136150. name: string;
  136151. shader: string;
  136152. };
  136153. }
  136154. declare module BABYLON {
  136155. /** @hidden */
  136156. export var pbrBlockGeometryInfo: {
  136157. name: string;
  136158. shader: string;
  136159. };
  136160. }
  136161. declare module BABYLON {
  136162. /** @hidden */
  136163. export var pbrBlockReflectance0: {
  136164. name: string;
  136165. shader: string;
  136166. };
  136167. }
  136168. declare module BABYLON {
  136169. /** @hidden */
  136170. export var pbrBlockReflectance: {
  136171. name: string;
  136172. shader: string;
  136173. };
  136174. }
  136175. declare module BABYLON {
  136176. /** @hidden */
  136177. export var pbrBlockDirectLighting: {
  136178. name: string;
  136179. shader: string;
  136180. };
  136181. }
  136182. declare module BABYLON {
  136183. /** @hidden */
  136184. export var pbrBlockFinalLitComponents: {
  136185. name: string;
  136186. shader: string;
  136187. };
  136188. }
  136189. declare module BABYLON {
  136190. /** @hidden */
  136191. export var pbrBlockFinalUnlitComponents: {
  136192. name: string;
  136193. shader: string;
  136194. };
  136195. }
  136196. declare module BABYLON {
  136197. /** @hidden */
  136198. export var pbrBlockFinalColorComposition: {
  136199. name: string;
  136200. shader: string;
  136201. };
  136202. }
  136203. declare module BABYLON {
  136204. /** @hidden */
  136205. export var pbrBlockImageProcessing: {
  136206. name: string;
  136207. shader: string;
  136208. };
  136209. }
  136210. declare module BABYLON {
  136211. /** @hidden */
  136212. export var pbrDebug: {
  136213. name: string;
  136214. shader: string;
  136215. };
  136216. }
  136217. declare module BABYLON {
  136218. /** @hidden */
  136219. export var pbrPixelShader: {
  136220. name: string;
  136221. shader: string;
  136222. };
  136223. }
  136224. declare module BABYLON {
  136225. /** @hidden */
  136226. export var pbrVertexDeclaration: {
  136227. name: string;
  136228. shader: string;
  136229. };
  136230. }
  136231. declare module BABYLON {
  136232. /** @hidden */
  136233. export var pbrVertexShader: {
  136234. name: string;
  136235. shader: string;
  136236. };
  136237. }
  136238. declare module BABYLON {
  136239. /**
  136240. * Manages the defines for the PBR Material.
  136241. * @hidden
  136242. */
  136243. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  136244. PBR: boolean;
  136245. NUM_SAMPLES: string;
  136246. REALTIME_FILTERING: boolean;
  136247. MAINUV1: boolean;
  136248. MAINUV2: boolean;
  136249. UV1: boolean;
  136250. UV2: boolean;
  136251. ALBEDO: boolean;
  136252. GAMMAALBEDO: boolean;
  136253. ALBEDODIRECTUV: number;
  136254. VERTEXCOLOR: boolean;
  136255. DETAIL: boolean;
  136256. DETAILDIRECTUV: number;
  136257. DETAIL_NORMALBLENDMETHOD: number;
  136258. AMBIENT: boolean;
  136259. AMBIENTDIRECTUV: number;
  136260. AMBIENTINGRAYSCALE: boolean;
  136261. OPACITY: boolean;
  136262. VERTEXALPHA: boolean;
  136263. OPACITYDIRECTUV: number;
  136264. OPACITYRGB: boolean;
  136265. ALPHATEST: boolean;
  136266. DEPTHPREPASS: boolean;
  136267. ALPHABLEND: boolean;
  136268. ALPHAFROMALBEDO: boolean;
  136269. ALPHATESTVALUE: string;
  136270. SPECULAROVERALPHA: boolean;
  136271. RADIANCEOVERALPHA: boolean;
  136272. ALPHAFRESNEL: boolean;
  136273. LINEARALPHAFRESNEL: boolean;
  136274. PREMULTIPLYALPHA: boolean;
  136275. EMISSIVE: boolean;
  136276. EMISSIVEDIRECTUV: number;
  136277. REFLECTIVITY: boolean;
  136278. REFLECTIVITYDIRECTUV: number;
  136279. SPECULARTERM: boolean;
  136280. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  136281. MICROSURFACEAUTOMATIC: boolean;
  136282. LODBASEDMICROSFURACE: boolean;
  136283. MICROSURFACEMAP: boolean;
  136284. MICROSURFACEMAPDIRECTUV: number;
  136285. METALLICWORKFLOW: boolean;
  136286. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  136287. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  136288. METALLNESSSTOREINMETALMAPBLUE: boolean;
  136289. AOSTOREINMETALMAPRED: boolean;
  136290. METALLIC_REFLECTANCE: boolean;
  136291. METALLIC_REFLECTANCEDIRECTUV: number;
  136292. ENVIRONMENTBRDF: boolean;
  136293. ENVIRONMENTBRDF_RGBD: boolean;
  136294. NORMAL: boolean;
  136295. TANGENT: boolean;
  136296. BUMP: boolean;
  136297. BUMPDIRECTUV: number;
  136298. OBJECTSPACE_NORMALMAP: boolean;
  136299. PARALLAX: boolean;
  136300. PARALLAXOCCLUSION: boolean;
  136301. NORMALXYSCALE: boolean;
  136302. LIGHTMAP: boolean;
  136303. LIGHTMAPDIRECTUV: number;
  136304. USELIGHTMAPASSHADOWMAP: boolean;
  136305. GAMMALIGHTMAP: boolean;
  136306. RGBDLIGHTMAP: boolean;
  136307. REFLECTION: boolean;
  136308. REFLECTIONMAP_3D: boolean;
  136309. REFLECTIONMAP_SPHERICAL: boolean;
  136310. REFLECTIONMAP_PLANAR: boolean;
  136311. REFLECTIONMAP_CUBIC: boolean;
  136312. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  136313. REFLECTIONMAP_PROJECTION: boolean;
  136314. REFLECTIONMAP_SKYBOX: boolean;
  136315. REFLECTIONMAP_EXPLICIT: boolean;
  136316. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  136317. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  136318. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  136319. INVERTCUBICMAP: boolean;
  136320. USESPHERICALFROMREFLECTIONMAP: boolean;
  136321. USEIRRADIANCEMAP: boolean;
  136322. SPHERICAL_HARMONICS: boolean;
  136323. USESPHERICALINVERTEX: boolean;
  136324. REFLECTIONMAP_OPPOSITEZ: boolean;
  136325. LODINREFLECTIONALPHA: boolean;
  136326. GAMMAREFLECTION: boolean;
  136327. RGBDREFLECTION: boolean;
  136328. LINEARSPECULARREFLECTION: boolean;
  136329. RADIANCEOCCLUSION: boolean;
  136330. HORIZONOCCLUSION: boolean;
  136331. INSTANCES: boolean;
  136332. THIN_INSTANCES: boolean;
  136333. PREPASS: boolean;
  136334. SCENE_MRT_COUNT: number;
  136335. NUM_BONE_INFLUENCERS: number;
  136336. BonesPerMesh: number;
  136337. BONETEXTURE: boolean;
  136338. NONUNIFORMSCALING: boolean;
  136339. MORPHTARGETS: boolean;
  136340. MORPHTARGETS_NORMAL: boolean;
  136341. MORPHTARGETS_TANGENT: boolean;
  136342. MORPHTARGETS_UV: boolean;
  136343. NUM_MORPH_INFLUENCERS: number;
  136344. IMAGEPROCESSING: boolean;
  136345. VIGNETTE: boolean;
  136346. VIGNETTEBLENDMODEMULTIPLY: boolean;
  136347. VIGNETTEBLENDMODEOPAQUE: boolean;
  136348. TONEMAPPING: boolean;
  136349. TONEMAPPING_ACES: boolean;
  136350. CONTRAST: boolean;
  136351. COLORCURVES: boolean;
  136352. COLORGRADING: boolean;
  136353. COLORGRADING3D: boolean;
  136354. SAMPLER3DGREENDEPTH: boolean;
  136355. SAMPLER3DBGRMAP: boolean;
  136356. IMAGEPROCESSINGPOSTPROCESS: boolean;
  136357. EXPOSURE: boolean;
  136358. MULTIVIEW: boolean;
  136359. USEPHYSICALLIGHTFALLOFF: boolean;
  136360. USEGLTFLIGHTFALLOFF: boolean;
  136361. TWOSIDEDLIGHTING: boolean;
  136362. SHADOWFLOAT: boolean;
  136363. CLIPPLANE: boolean;
  136364. CLIPPLANE2: boolean;
  136365. CLIPPLANE3: boolean;
  136366. CLIPPLANE4: boolean;
  136367. CLIPPLANE5: boolean;
  136368. CLIPPLANE6: boolean;
  136369. POINTSIZE: boolean;
  136370. FOG: boolean;
  136371. LOGARITHMICDEPTH: boolean;
  136372. FORCENORMALFORWARD: boolean;
  136373. SPECULARAA: boolean;
  136374. CLEARCOAT: boolean;
  136375. CLEARCOAT_DEFAULTIOR: boolean;
  136376. CLEARCOAT_TEXTURE: boolean;
  136377. CLEARCOAT_TEXTUREDIRECTUV: number;
  136378. CLEARCOAT_BUMP: boolean;
  136379. CLEARCOAT_BUMPDIRECTUV: number;
  136380. CLEARCOAT_TINT: boolean;
  136381. CLEARCOAT_TINT_TEXTURE: boolean;
  136382. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  136383. ANISOTROPIC: boolean;
  136384. ANISOTROPIC_TEXTURE: boolean;
  136385. ANISOTROPIC_TEXTUREDIRECTUV: number;
  136386. BRDF_V_HEIGHT_CORRELATED: boolean;
  136387. MS_BRDF_ENERGY_CONSERVATION: boolean;
  136388. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  136389. SHEEN: boolean;
  136390. SHEEN_TEXTURE: boolean;
  136391. SHEEN_TEXTUREDIRECTUV: number;
  136392. SHEEN_LINKWITHALBEDO: boolean;
  136393. SHEEN_ROUGHNESS: boolean;
  136394. SHEEN_ALBEDOSCALING: boolean;
  136395. SUBSURFACE: boolean;
  136396. SS_REFRACTION: boolean;
  136397. SS_TRANSLUCENCY: boolean;
  136398. SS_SCATTERING: boolean;
  136399. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136400. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136401. SS_REFRACTIONMAP_3D: boolean;
  136402. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136403. SS_LODINREFRACTIONALPHA: boolean;
  136404. SS_GAMMAREFRACTION: boolean;
  136405. SS_RGBDREFRACTION: boolean;
  136406. SS_LINEARSPECULARREFRACTION: boolean;
  136407. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136408. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136409. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136410. UNLIT: boolean;
  136411. DEBUGMODE: number;
  136412. /**
  136413. * Initializes the PBR Material defines.
  136414. */
  136415. constructor();
  136416. /**
  136417. * Resets the PBR Material defines.
  136418. */
  136419. reset(): void;
  136420. }
  136421. /**
  136422. * The Physically based material base class of BJS.
  136423. *
  136424. * This offers the main features of a standard PBR material.
  136425. * For more information, please refer to the documentation :
  136426. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136427. */
  136428. export abstract class PBRBaseMaterial extends PushMaterial {
  136429. /**
  136430. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136431. */
  136432. static readonly PBRMATERIAL_OPAQUE: number;
  136433. /**
  136434. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136435. */
  136436. static readonly PBRMATERIAL_ALPHATEST: number;
  136437. /**
  136438. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136439. */
  136440. static readonly PBRMATERIAL_ALPHABLEND: number;
  136441. /**
  136442. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136443. * They are also discarded below the alpha cutoff threshold to improve performances.
  136444. */
  136445. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  136446. /**
  136447. * Defines the default value of how much AO map is occluding the analytical lights
  136448. * (point spot...).
  136449. */
  136450. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  136451. /**
  136452. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  136453. */
  136454. static readonly LIGHTFALLOFF_PHYSICAL: number;
  136455. /**
  136456. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  136457. * to enhance interoperability with other engines.
  136458. */
  136459. static readonly LIGHTFALLOFF_GLTF: number;
  136460. /**
  136461. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  136462. * to enhance interoperability with other materials.
  136463. */
  136464. static readonly LIGHTFALLOFF_STANDARD: number;
  136465. /**
  136466. * Intensity of the direct lights e.g. the four lights available in your scene.
  136467. * This impacts both the direct diffuse and specular highlights.
  136468. */
  136469. protected _directIntensity: number;
  136470. /**
  136471. * Intensity of the emissive part of the material.
  136472. * This helps controlling the emissive effect without modifying the emissive color.
  136473. */
  136474. protected _emissiveIntensity: number;
  136475. /**
  136476. * Intensity of the environment e.g. how much the environment will light the object
  136477. * either through harmonics for rough material or through the refelction for shiny ones.
  136478. */
  136479. protected _environmentIntensity: number;
  136480. /**
  136481. * This is a special control allowing the reduction of the specular highlights coming from the
  136482. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  136483. */
  136484. protected _specularIntensity: number;
  136485. /**
  136486. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  136487. */
  136488. private _lightingInfos;
  136489. /**
  136490. * Debug Control allowing disabling the bump map on this material.
  136491. */
  136492. protected _disableBumpMap: boolean;
  136493. /**
  136494. * AKA Diffuse Texture in standard nomenclature.
  136495. */
  136496. protected _albedoTexture: Nullable<BaseTexture>;
  136497. /**
  136498. * AKA Occlusion Texture in other nomenclature.
  136499. */
  136500. protected _ambientTexture: Nullable<BaseTexture>;
  136501. /**
  136502. * AKA Occlusion Texture Intensity in other nomenclature.
  136503. */
  136504. protected _ambientTextureStrength: number;
  136505. /**
  136506. * Defines how much the AO map is occluding the analytical lights (point spot...).
  136507. * 1 means it completely occludes it
  136508. * 0 mean it has no impact
  136509. */
  136510. protected _ambientTextureImpactOnAnalyticalLights: number;
  136511. /**
  136512. * Stores the alpha values in a texture.
  136513. */
  136514. protected _opacityTexture: Nullable<BaseTexture>;
  136515. /**
  136516. * Stores the reflection values in a texture.
  136517. */
  136518. protected _reflectionTexture: Nullable<BaseTexture>;
  136519. /**
  136520. * Stores the emissive values in a texture.
  136521. */
  136522. protected _emissiveTexture: Nullable<BaseTexture>;
  136523. /**
  136524. * AKA Specular texture in other nomenclature.
  136525. */
  136526. protected _reflectivityTexture: Nullable<BaseTexture>;
  136527. /**
  136528. * Used to switch from specular/glossiness to metallic/roughness workflow.
  136529. */
  136530. protected _metallicTexture: Nullable<BaseTexture>;
  136531. /**
  136532. * Specifies the metallic scalar of the metallic/roughness workflow.
  136533. * Can also be used to scale the metalness values of the metallic texture.
  136534. */
  136535. protected _metallic: Nullable<number>;
  136536. /**
  136537. * Specifies the roughness scalar of the metallic/roughness workflow.
  136538. * Can also be used to scale the roughness values of the metallic texture.
  136539. */
  136540. protected _roughness: Nullable<number>;
  136541. /**
  136542. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  136543. * By default the indexOfrefraction is used to compute F0;
  136544. *
  136545. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  136546. *
  136547. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  136548. * F90 = metallicReflectanceColor;
  136549. */
  136550. protected _metallicF0Factor: number;
  136551. /**
  136552. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  136553. * By default the F90 is always 1;
  136554. *
  136555. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  136556. *
  136557. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  136558. * F90 = metallicReflectanceColor;
  136559. */
  136560. protected _metallicReflectanceColor: Color3;
  136561. /**
  136562. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  136563. * This is multiply against the scalar values defined in the material.
  136564. */
  136565. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  136566. /**
  136567. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  136568. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  136569. */
  136570. protected _microSurfaceTexture: Nullable<BaseTexture>;
  136571. /**
  136572. * Stores surface normal data used to displace a mesh in a texture.
  136573. */
  136574. protected _bumpTexture: Nullable<BaseTexture>;
  136575. /**
  136576. * Stores the pre-calculated light information of a mesh in a texture.
  136577. */
  136578. protected _lightmapTexture: Nullable<BaseTexture>;
  136579. /**
  136580. * The color of a material in ambient lighting.
  136581. */
  136582. protected _ambientColor: Color3;
  136583. /**
  136584. * AKA Diffuse Color in other nomenclature.
  136585. */
  136586. protected _albedoColor: Color3;
  136587. /**
  136588. * AKA Specular Color in other nomenclature.
  136589. */
  136590. protected _reflectivityColor: Color3;
  136591. /**
  136592. * The color applied when light is reflected from a material.
  136593. */
  136594. protected _reflectionColor: Color3;
  136595. /**
  136596. * The color applied when light is emitted from a material.
  136597. */
  136598. protected _emissiveColor: Color3;
  136599. /**
  136600. * AKA Glossiness in other nomenclature.
  136601. */
  136602. protected _microSurface: number;
  136603. /**
  136604. * Specifies that the material will use the light map as a show map.
  136605. */
  136606. protected _useLightmapAsShadowmap: boolean;
  136607. /**
  136608. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  136609. * makes the reflect vector face the model (under horizon).
  136610. */
  136611. protected _useHorizonOcclusion: boolean;
  136612. /**
  136613. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  136614. * too much the area relying on ambient texture to define their ambient occlusion.
  136615. */
  136616. protected _useRadianceOcclusion: boolean;
  136617. /**
  136618. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  136619. */
  136620. protected _useAlphaFromAlbedoTexture: boolean;
  136621. /**
  136622. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  136623. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  136624. */
  136625. protected _useSpecularOverAlpha: boolean;
  136626. /**
  136627. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  136628. */
  136629. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  136630. /**
  136631. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  136632. */
  136633. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  136634. /**
  136635. * Specifies if the metallic texture contains the roughness information in its green channel.
  136636. */
  136637. protected _useRoughnessFromMetallicTextureGreen: boolean;
  136638. /**
  136639. * Specifies if the metallic texture contains the metallness information in its blue channel.
  136640. */
  136641. protected _useMetallnessFromMetallicTextureBlue: boolean;
  136642. /**
  136643. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  136644. */
  136645. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  136646. /**
  136647. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  136648. */
  136649. protected _useAmbientInGrayScale: boolean;
  136650. /**
  136651. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  136652. * The material will try to infer what glossiness each pixel should be.
  136653. */
  136654. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  136655. /**
  136656. * Defines the falloff type used in this material.
  136657. * It by default is Physical.
  136658. */
  136659. protected _lightFalloff: number;
  136660. /**
  136661. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  136662. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  136663. */
  136664. protected _useRadianceOverAlpha: boolean;
  136665. /**
  136666. * Allows using an object space normal map (instead of tangent space).
  136667. */
  136668. protected _useObjectSpaceNormalMap: boolean;
  136669. /**
  136670. * Allows using the bump map in parallax mode.
  136671. */
  136672. protected _useParallax: boolean;
  136673. /**
  136674. * Allows using the bump map in parallax occlusion mode.
  136675. */
  136676. protected _useParallaxOcclusion: boolean;
  136677. /**
  136678. * Controls the scale bias of the parallax mode.
  136679. */
  136680. protected _parallaxScaleBias: number;
  136681. /**
  136682. * If sets to true, disables all the lights affecting the material.
  136683. */
  136684. protected _disableLighting: boolean;
  136685. /**
  136686. * Number of Simultaneous lights allowed on the material.
  136687. */
  136688. protected _maxSimultaneousLights: number;
  136689. /**
  136690. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  136691. */
  136692. protected _invertNormalMapX: boolean;
  136693. /**
  136694. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  136695. */
  136696. protected _invertNormalMapY: boolean;
  136697. /**
  136698. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  136699. */
  136700. protected _twoSidedLighting: boolean;
  136701. /**
  136702. * Defines the alpha limits in alpha test mode.
  136703. */
  136704. protected _alphaCutOff: number;
  136705. /**
  136706. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  136707. */
  136708. protected _forceAlphaTest: boolean;
  136709. /**
  136710. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136711. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  136712. */
  136713. protected _useAlphaFresnel: boolean;
  136714. /**
  136715. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136716. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  136717. */
  136718. protected _useLinearAlphaFresnel: boolean;
  136719. /**
  136720. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  136721. * from cos thetav and roughness:
  136722. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  136723. */
  136724. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  136725. /**
  136726. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  136727. */
  136728. protected _forceIrradianceInFragment: boolean;
  136729. private _realTimeFiltering;
  136730. /**
  136731. * Enables realtime filtering on the texture.
  136732. */
  136733. get realTimeFiltering(): boolean;
  136734. set realTimeFiltering(b: boolean);
  136735. private _realTimeFilteringQuality;
  136736. /**
  136737. * Quality switch for realtime filtering
  136738. */
  136739. get realTimeFilteringQuality(): number;
  136740. set realTimeFilteringQuality(n: number);
  136741. /**
  136742. * Can this material render to several textures at once
  136743. */
  136744. get canRenderToMRT(): boolean;
  136745. /**
  136746. * Force normal to face away from face.
  136747. */
  136748. protected _forceNormalForward: boolean;
  136749. /**
  136750. * Enables specular anti aliasing in the PBR shader.
  136751. * It will both interacts on the Geometry for analytical and IBL lighting.
  136752. * It also prefilter the roughness map based on the bump values.
  136753. */
  136754. protected _enableSpecularAntiAliasing: boolean;
  136755. /**
  136756. * Default configuration related to image processing available in the PBR Material.
  136757. */
  136758. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  136759. /**
  136760. * Keep track of the image processing observer to allow dispose and replace.
  136761. */
  136762. private _imageProcessingObserver;
  136763. /**
  136764. * Attaches a new image processing configuration to the PBR Material.
  136765. * @param configuration
  136766. */
  136767. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  136768. /**
  136769. * Stores the available render targets.
  136770. */
  136771. private _renderTargets;
  136772. /**
  136773. * Sets the global ambient color for the material used in lighting calculations.
  136774. */
  136775. private _globalAmbientColor;
  136776. /**
  136777. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  136778. */
  136779. private _useLogarithmicDepth;
  136780. /**
  136781. * If set to true, no lighting calculations will be applied.
  136782. */
  136783. private _unlit;
  136784. private _debugMode;
  136785. /**
  136786. * @hidden
  136787. * This is reserved for the inspector.
  136788. * Defines the material debug mode.
  136789. * It helps seeing only some components of the material while troubleshooting.
  136790. */
  136791. debugMode: number;
  136792. /**
  136793. * @hidden
  136794. * This is reserved for the inspector.
  136795. * Specify from where on screen the debug mode should start.
  136796. * The value goes from -1 (full screen) to 1 (not visible)
  136797. * It helps with side by side comparison against the final render
  136798. * This defaults to -1
  136799. */
  136800. private debugLimit;
  136801. /**
  136802. * @hidden
  136803. * This is reserved for the inspector.
  136804. * As the default viewing range might not be enough (if the ambient is really small for instance)
  136805. * You can use the factor to better multiply the final value.
  136806. */
  136807. private debugFactor;
  136808. /**
  136809. * Defines the clear coat layer parameters for the material.
  136810. */
  136811. readonly clearCoat: PBRClearCoatConfiguration;
  136812. /**
  136813. * Defines the anisotropic parameters for the material.
  136814. */
  136815. readonly anisotropy: PBRAnisotropicConfiguration;
  136816. /**
  136817. * Defines the BRDF parameters for the material.
  136818. */
  136819. readonly brdf: PBRBRDFConfiguration;
  136820. /**
  136821. * Defines the Sheen parameters for the material.
  136822. */
  136823. readonly sheen: PBRSheenConfiguration;
  136824. /**
  136825. * Defines the SubSurface parameters for the material.
  136826. */
  136827. readonly subSurface: PBRSubSurfaceConfiguration;
  136828. /**
  136829. * Defines the detail map parameters for the material.
  136830. */
  136831. readonly detailMap: DetailMapConfiguration;
  136832. protected _rebuildInParallel: boolean;
  136833. /**
  136834. * Instantiates a new PBRMaterial instance.
  136835. *
  136836. * @param name The material name
  136837. * @param scene The scene the material will be use in.
  136838. */
  136839. constructor(name: string, scene: Scene);
  136840. /**
  136841. * Gets a boolean indicating that current material needs to register RTT
  136842. */
  136843. get hasRenderTargetTextures(): boolean;
  136844. /**
  136845. * Gets the name of the material class.
  136846. */
  136847. getClassName(): string;
  136848. /**
  136849. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  136850. */
  136851. get useLogarithmicDepth(): boolean;
  136852. /**
  136853. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  136854. */
  136855. set useLogarithmicDepth(value: boolean);
  136856. /**
  136857. * Returns true if alpha blending should be disabled.
  136858. */
  136859. protected get _disableAlphaBlending(): boolean;
  136860. /**
  136861. * Specifies whether or not this material should be rendered in alpha blend mode.
  136862. */
  136863. needAlphaBlending(): boolean;
  136864. /**
  136865. * Specifies whether or not this material should be rendered in alpha test mode.
  136866. */
  136867. needAlphaTesting(): boolean;
  136868. /**
  136869. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  136870. */
  136871. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  136872. /**
  136873. * Gets the texture used for the alpha test.
  136874. */
  136875. getAlphaTestTexture(): Nullable<BaseTexture>;
  136876. /**
  136877. * Specifies that the submesh is ready to be used.
  136878. * @param mesh - BJS mesh.
  136879. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  136880. * @param useInstances - Specifies that instances should be used.
  136881. * @returns - boolean indicating that the submesh is ready or not.
  136882. */
  136883. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  136884. /**
  136885. * Specifies if the material uses metallic roughness workflow.
  136886. * @returns boolean specifiying if the material uses metallic roughness workflow.
  136887. */
  136888. isMetallicWorkflow(): boolean;
  136889. private _prepareEffect;
  136890. private _prepareDefines;
  136891. /**
  136892. * Force shader compilation
  136893. */
  136894. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  136895. /**
  136896. * Initializes the uniform buffer layout for the shader.
  136897. */
  136898. buildUniformLayout(): void;
  136899. /**
  136900. * Unbinds the material from the mesh
  136901. */
  136902. unbind(): void;
  136903. /**
  136904. * Binds the submesh data.
  136905. * @param world - The world matrix.
  136906. * @param mesh - The BJS mesh.
  136907. * @param subMesh - A submesh of the BJS mesh.
  136908. */
  136909. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  136910. /**
  136911. * Returns the animatable textures.
  136912. * @returns - Array of animatable textures.
  136913. */
  136914. getAnimatables(): IAnimatable[];
  136915. /**
  136916. * Returns the texture used for reflections.
  136917. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  136918. */
  136919. private _getReflectionTexture;
  136920. /**
  136921. * Returns an array of the actively used textures.
  136922. * @returns - Array of BaseTextures
  136923. */
  136924. getActiveTextures(): BaseTexture[];
  136925. /**
  136926. * Checks to see if a texture is used in the material.
  136927. * @param texture - Base texture to use.
  136928. * @returns - Boolean specifying if a texture is used in the material.
  136929. */
  136930. hasTexture(texture: BaseTexture): boolean;
  136931. /**
  136932. * Sets the required values to the prepass renderer.
  136933. * @param prePassRenderer defines the prepass renderer to setup
  136934. */
  136935. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  136936. /**
  136937. * Disposes the resources of the material.
  136938. * @param forceDisposeEffect - Forces the disposal of effects.
  136939. * @param forceDisposeTextures - Forces the disposal of all textures.
  136940. */
  136941. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  136942. }
  136943. }
  136944. declare module BABYLON {
  136945. /**
  136946. * The Physically based material of BJS.
  136947. *
  136948. * This offers the main features of a standard PBR material.
  136949. * For more information, please refer to the documentation :
  136950. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136951. */
  136952. export class PBRMaterial extends PBRBaseMaterial {
  136953. /**
  136954. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136955. */
  136956. static readonly PBRMATERIAL_OPAQUE: number;
  136957. /**
  136958. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136959. */
  136960. static readonly PBRMATERIAL_ALPHATEST: number;
  136961. /**
  136962. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136963. */
  136964. static readonly PBRMATERIAL_ALPHABLEND: number;
  136965. /**
  136966. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136967. * They are also discarded below the alpha cutoff threshold to improve performances.
  136968. */
  136969. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  136970. /**
  136971. * Defines the default value of how much AO map is occluding the analytical lights
  136972. * (point spot...).
  136973. */
  136974. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  136975. /**
  136976. * Intensity of the direct lights e.g. the four lights available in your scene.
  136977. * This impacts both the direct diffuse and specular highlights.
  136978. */
  136979. directIntensity: number;
  136980. /**
  136981. * Intensity of the emissive part of the material.
  136982. * This helps controlling the emissive effect without modifying the emissive color.
  136983. */
  136984. emissiveIntensity: number;
  136985. /**
  136986. * Intensity of the environment e.g. how much the environment will light the object
  136987. * either through harmonics for rough material or through the refelction for shiny ones.
  136988. */
  136989. environmentIntensity: number;
  136990. /**
  136991. * This is a special control allowing the reduction of the specular highlights coming from the
  136992. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  136993. */
  136994. specularIntensity: number;
  136995. /**
  136996. * Debug Control allowing disabling the bump map on this material.
  136997. */
  136998. disableBumpMap: boolean;
  136999. /**
  137000. * AKA Diffuse Texture in standard nomenclature.
  137001. */
  137002. albedoTexture: BaseTexture;
  137003. /**
  137004. * AKA Occlusion Texture in other nomenclature.
  137005. */
  137006. ambientTexture: BaseTexture;
  137007. /**
  137008. * AKA Occlusion Texture Intensity in other nomenclature.
  137009. */
  137010. ambientTextureStrength: number;
  137011. /**
  137012. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137013. * 1 means it completely occludes it
  137014. * 0 mean it has no impact
  137015. */
  137016. ambientTextureImpactOnAnalyticalLights: number;
  137017. /**
  137018. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  137019. */
  137020. opacityTexture: BaseTexture;
  137021. /**
  137022. * Stores the reflection values in a texture.
  137023. */
  137024. reflectionTexture: Nullable<BaseTexture>;
  137025. /**
  137026. * Stores the emissive values in a texture.
  137027. */
  137028. emissiveTexture: BaseTexture;
  137029. /**
  137030. * AKA Specular texture in other nomenclature.
  137031. */
  137032. reflectivityTexture: BaseTexture;
  137033. /**
  137034. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137035. */
  137036. metallicTexture: BaseTexture;
  137037. /**
  137038. * Specifies the metallic scalar of the metallic/roughness workflow.
  137039. * Can also be used to scale the metalness values of the metallic texture.
  137040. */
  137041. metallic: Nullable<number>;
  137042. /**
  137043. * Specifies the roughness scalar of the metallic/roughness workflow.
  137044. * Can also be used to scale the roughness values of the metallic texture.
  137045. */
  137046. roughness: Nullable<number>;
  137047. /**
  137048. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137049. * By default the indexOfrefraction is used to compute F0;
  137050. *
  137051. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137052. *
  137053. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137054. * F90 = metallicReflectanceColor;
  137055. */
  137056. metallicF0Factor: number;
  137057. /**
  137058. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137059. * By default the F90 is always 1;
  137060. *
  137061. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137062. *
  137063. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137064. * F90 = metallicReflectanceColor;
  137065. */
  137066. metallicReflectanceColor: Color3;
  137067. /**
  137068. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137069. * This is multiply against the scalar values defined in the material.
  137070. */
  137071. metallicReflectanceTexture: Nullable<BaseTexture>;
  137072. /**
  137073. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137074. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137075. */
  137076. microSurfaceTexture: BaseTexture;
  137077. /**
  137078. * Stores surface normal data used to displace a mesh in a texture.
  137079. */
  137080. bumpTexture: BaseTexture;
  137081. /**
  137082. * Stores the pre-calculated light information of a mesh in a texture.
  137083. */
  137084. lightmapTexture: BaseTexture;
  137085. /**
  137086. * Stores the refracted light information in a texture.
  137087. */
  137088. get refractionTexture(): Nullable<BaseTexture>;
  137089. set refractionTexture(value: Nullable<BaseTexture>);
  137090. /**
  137091. * The color of a material in ambient lighting.
  137092. */
  137093. ambientColor: Color3;
  137094. /**
  137095. * AKA Diffuse Color in other nomenclature.
  137096. */
  137097. albedoColor: Color3;
  137098. /**
  137099. * AKA Specular Color in other nomenclature.
  137100. */
  137101. reflectivityColor: Color3;
  137102. /**
  137103. * The color reflected from the material.
  137104. */
  137105. reflectionColor: Color3;
  137106. /**
  137107. * The color emitted from the material.
  137108. */
  137109. emissiveColor: Color3;
  137110. /**
  137111. * AKA Glossiness in other nomenclature.
  137112. */
  137113. microSurface: number;
  137114. /**
  137115. * Index of refraction of the material base layer.
  137116. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  137117. *
  137118. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  137119. *
  137120. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  137121. */
  137122. get indexOfRefraction(): number;
  137123. set indexOfRefraction(value: number);
  137124. /**
  137125. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  137126. */
  137127. get invertRefractionY(): boolean;
  137128. set invertRefractionY(value: boolean);
  137129. /**
  137130. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  137131. * Materials half opaque for instance using refraction could benefit from this control.
  137132. */
  137133. get linkRefractionWithTransparency(): boolean;
  137134. set linkRefractionWithTransparency(value: boolean);
  137135. /**
  137136. * If true, the light map contains occlusion information instead of lighting info.
  137137. */
  137138. useLightmapAsShadowmap: boolean;
  137139. /**
  137140. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137141. */
  137142. useAlphaFromAlbedoTexture: boolean;
  137143. /**
  137144. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137145. */
  137146. forceAlphaTest: boolean;
  137147. /**
  137148. * Defines the alpha limits in alpha test mode.
  137149. */
  137150. alphaCutOff: number;
  137151. /**
  137152. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  137153. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137154. */
  137155. useSpecularOverAlpha: boolean;
  137156. /**
  137157. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137158. */
  137159. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137160. /**
  137161. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137162. */
  137163. useRoughnessFromMetallicTextureAlpha: boolean;
  137164. /**
  137165. * Specifies if the metallic texture contains the roughness information in its green channel.
  137166. */
  137167. useRoughnessFromMetallicTextureGreen: boolean;
  137168. /**
  137169. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137170. */
  137171. useMetallnessFromMetallicTextureBlue: boolean;
  137172. /**
  137173. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137174. */
  137175. useAmbientOcclusionFromMetallicTextureRed: boolean;
  137176. /**
  137177. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137178. */
  137179. useAmbientInGrayScale: boolean;
  137180. /**
  137181. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137182. * The material will try to infer what glossiness each pixel should be.
  137183. */
  137184. useAutoMicroSurfaceFromReflectivityMap: boolean;
  137185. /**
  137186. * BJS is using an harcoded light falloff based on a manually sets up range.
  137187. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137188. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137189. */
  137190. get usePhysicalLightFalloff(): boolean;
  137191. /**
  137192. * BJS is using an harcoded light falloff based on a manually sets up range.
  137193. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137194. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137195. */
  137196. set usePhysicalLightFalloff(value: boolean);
  137197. /**
  137198. * In order to support the falloff compatibility with gltf, a special mode has been added
  137199. * to reproduce the gltf light falloff.
  137200. */
  137201. get useGLTFLightFalloff(): boolean;
  137202. /**
  137203. * In order to support the falloff compatibility with gltf, a special mode has been added
  137204. * to reproduce the gltf light falloff.
  137205. */
  137206. set useGLTFLightFalloff(value: boolean);
  137207. /**
  137208. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137209. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137210. */
  137211. useRadianceOverAlpha: boolean;
  137212. /**
  137213. * Allows using an object space normal map (instead of tangent space).
  137214. */
  137215. useObjectSpaceNormalMap: boolean;
  137216. /**
  137217. * Allows using the bump map in parallax mode.
  137218. */
  137219. useParallax: boolean;
  137220. /**
  137221. * Allows using the bump map in parallax occlusion mode.
  137222. */
  137223. useParallaxOcclusion: boolean;
  137224. /**
  137225. * Controls the scale bias of the parallax mode.
  137226. */
  137227. parallaxScaleBias: number;
  137228. /**
  137229. * If sets to true, disables all the lights affecting the material.
  137230. */
  137231. disableLighting: boolean;
  137232. /**
  137233. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137234. */
  137235. forceIrradianceInFragment: boolean;
  137236. /**
  137237. * Number of Simultaneous lights allowed on the material.
  137238. */
  137239. maxSimultaneousLights: number;
  137240. /**
  137241. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  137242. */
  137243. invertNormalMapX: boolean;
  137244. /**
  137245. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  137246. */
  137247. invertNormalMapY: boolean;
  137248. /**
  137249. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137250. */
  137251. twoSidedLighting: boolean;
  137252. /**
  137253. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137254. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137255. */
  137256. useAlphaFresnel: boolean;
  137257. /**
  137258. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137259. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137260. */
  137261. useLinearAlphaFresnel: boolean;
  137262. /**
  137263. * Let user defines the brdf lookup texture used for IBL.
  137264. * A default 8bit version is embedded but you could point at :
  137265. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  137266. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  137267. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  137268. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  137269. */
  137270. environmentBRDFTexture: Nullable<BaseTexture>;
  137271. /**
  137272. * Force normal to face away from face.
  137273. */
  137274. forceNormalForward: boolean;
  137275. /**
  137276. * Enables specular anti aliasing in the PBR shader.
  137277. * It will both interacts on the Geometry for analytical and IBL lighting.
  137278. * It also prefilter the roughness map based on the bump values.
  137279. */
  137280. enableSpecularAntiAliasing: boolean;
  137281. /**
  137282. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137283. * makes the reflect vector face the model (under horizon).
  137284. */
  137285. useHorizonOcclusion: boolean;
  137286. /**
  137287. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137288. * too much the area relying on ambient texture to define their ambient occlusion.
  137289. */
  137290. useRadianceOcclusion: boolean;
  137291. /**
  137292. * If set to true, no lighting calculations will be applied.
  137293. */
  137294. unlit: boolean;
  137295. /**
  137296. * Gets the image processing configuration used either in this material.
  137297. */
  137298. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  137299. /**
  137300. * Sets the Default image processing configuration used either in the this material.
  137301. *
  137302. * If sets to null, the scene one is in use.
  137303. */
  137304. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  137305. /**
  137306. * Gets wether the color curves effect is enabled.
  137307. */
  137308. get cameraColorCurvesEnabled(): boolean;
  137309. /**
  137310. * Sets wether the color curves effect is enabled.
  137311. */
  137312. set cameraColorCurvesEnabled(value: boolean);
  137313. /**
  137314. * Gets wether the color grading effect is enabled.
  137315. */
  137316. get cameraColorGradingEnabled(): boolean;
  137317. /**
  137318. * Gets wether the color grading effect is enabled.
  137319. */
  137320. set cameraColorGradingEnabled(value: boolean);
  137321. /**
  137322. * Gets wether tonemapping is enabled or not.
  137323. */
  137324. get cameraToneMappingEnabled(): boolean;
  137325. /**
  137326. * Sets wether tonemapping is enabled or not
  137327. */
  137328. set cameraToneMappingEnabled(value: boolean);
  137329. /**
  137330. * The camera exposure used on this material.
  137331. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137332. * This corresponds to a photographic exposure.
  137333. */
  137334. get cameraExposure(): number;
  137335. /**
  137336. * The camera exposure used on this material.
  137337. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137338. * This corresponds to a photographic exposure.
  137339. */
  137340. set cameraExposure(value: number);
  137341. /**
  137342. * Gets The camera contrast used on this material.
  137343. */
  137344. get cameraContrast(): number;
  137345. /**
  137346. * Sets The camera contrast used on this material.
  137347. */
  137348. set cameraContrast(value: number);
  137349. /**
  137350. * Gets the Color Grading 2D Lookup Texture.
  137351. */
  137352. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  137353. /**
  137354. * Sets the Color Grading 2D Lookup Texture.
  137355. */
  137356. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  137357. /**
  137358. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137359. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137360. * 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;
  137361. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137362. */
  137363. get cameraColorCurves(): Nullable<ColorCurves>;
  137364. /**
  137365. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137366. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137367. * 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;
  137368. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137369. */
  137370. set cameraColorCurves(value: Nullable<ColorCurves>);
  137371. /**
  137372. * Instantiates a new PBRMaterial instance.
  137373. *
  137374. * @param name The material name
  137375. * @param scene The scene the material will be use in.
  137376. */
  137377. constructor(name: string, scene: Scene);
  137378. /**
  137379. * Returns the name of this material class.
  137380. */
  137381. getClassName(): string;
  137382. /**
  137383. * Makes a duplicate of the current material.
  137384. * @param name - name to use for the new material.
  137385. */
  137386. clone(name: string): PBRMaterial;
  137387. /**
  137388. * Serializes this PBR Material.
  137389. * @returns - An object with the serialized material.
  137390. */
  137391. serialize(): any;
  137392. /**
  137393. * Parses a PBR Material from a serialized object.
  137394. * @param source - Serialized object.
  137395. * @param scene - BJS scene instance.
  137396. * @param rootUrl - url for the scene object
  137397. * @returns - PBRMaterial
  137398. */
  137399. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  137400. }
  137401. }
  137402. declare module BABYLON {
  137403. /**
  137404. * Direct draw surface info
  137405. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  137406. */
  137407. export interface DDSInfo {
  137408. /**
  137409. * Width of the texture
  137410. */
  137411. width: number;
  137412. /**
  137413. * Width of the texture
  137414. */
  137415. height: number;
  137416. /**
  137417. * Number of Mipmaps for the texture
  137418. * @see https://en.wikipedia.org/wiki/Mipmap
  137419. */
  137420. mipmapCount: number;
  137421. /**
  137422. * If the textures format is a known fourCC format
  137423. * @see https://www.fourcc.org/
  137424. */
  137425. isFourCC: boolean;
  137426. /**
  137427. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  137428. */
  137429. isRGB: boolean;
  137430. /**
  137431. * If the texture is a lumincance format
  137432. */
  137433. isLuminance: boolean;
  137434. /**
  137435. * If this is a cube texture
  137436. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  137437. */
  137438. isCube: boolean;
  137439. /**
  137440. * If the texture is a compressed format eg. FOURCC_DXT1
  137441. */
  137442. isCompressed: boolean;
  137443. /**
  137444. * The dxgiFormat of the texture
  137445. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  137446. */
  137447. dxgiFormat: number;
  137448. /**
  137449. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  137450. */
  137451. textureType: number;
  137452. /**
  137453. * Sphericle polynomial created for the dds texture
  137454. */
  137455. sphericalPolynomial?: SphericalPolynomial;
  137456. }
  137457. /**
  137458. * Class used to provide DDS decompression tools
  137459. */
  137460. export class DDSTools {
  137461. /**
  137462. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  137463. */
  137464. static StoreLODInAlphaChannel: boolean;
  137465. /**
  137466. * Gets DDS information from an array buffer
  137467. * @param data defines the array buffer view to read data from
  137468. * @returns the DDS information
  137469. */
  137470. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  137471. private static _FloatView;
  137472. private static _Int32View;
  137473. private static _ToHalfFloat;
  137474. private static _FromHalfFloat;
  137475. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  137476. private static _GetHalfFloatRGBAArrayBuffer;
  137477. private static _GetFloatRGBAArrayBuffer;
  137478. private static _GetFloatAsUIntRGBAArrayBuffer;
  137479. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  137480. private static _GetRGBAArrayBuffer;
  137481. private static _ExtractLongWordOrder;
  137482. private static _GetRGBArrayBuffer;
  137483. private static _GetLuminanceArrayBuffer;
  137484. /**
  137485. * Uploads DDS Levels to a Babylon Texture
  137486. * @hidden
  137487. */
  137488. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  137489. }
  137490. interface ThinEngine {
  137491. /**
  137492. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  137493. * @param rootUrl defines the url where the file to load is located
  137494. * @param scene defines the current scene
  137495. * @param lodScale defines scale to apply to the mip map selection
  137496. * @param lodOffset defines offset to apply to the mip map selection
  137497. * @param onLoad defines an optional callback raised when the texture is loaded
  137498. * @param onError defines an optional callback raised if there is an issue to load the texture
  137499. * @param format defines the format of the data
  137500. * @param forcedExtension defines the extension to use to pick the right loader
  137501. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  137502. * @returns the cube texture as an InternalTexture
  137503. */
  137504. 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;
  137505. }
  137506. }
  137507. declare module BABYLON {
  137508. /**
  137509. * Implementation of the DDS Texture Loader.
  137510. * @hidden
  137511. */
  137512. export class _DDSTextureLoader implements IInternalTextureLoader {
  137513. /**
  137514. * Defines wether the loader supports cascade loading the different faces.
  137515. */
  137516. readonly supportCascades: boolean;
  137517. /**
  137518. * This returns if the loader support the current file information.
  137519. * @param extension defines the file extension of the file being loaded
  137520. * @returns true if the loader can load the specified file
  137521. */
  137522. canLoad(extension: string): boolean;
  137523. /**
  137524. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137525. * @param data contains the texture data
  137526. * @param texture defines the BabylonJS internal texture
  137527. * @param createPolynomials will be true if polynomials have been requested
  137528. * @param onLoad defines the callback to trigger once the texture is ready
  137529. * @param onError defines the callback to trigger in case of error
  137530. */
  137531. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137532. /**
  137533. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137534. * @param data contains the texture data
  137535. * @param texture defines the BabylonJS internal texture
  137536. * @param callback defines the method to call once ready to upload
  137537. */
  137538. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137539. }
  137540. }
  137541. declare module BABYLON {
  137542. /**
  137543. * Implementation of the ENV Texture Loader.
  137544. * @hidden
  137545. */
  137546. export class _ENVTextureLoader implements IInternalTextureLoader {
  137547. /**
  137548. * Defines wether the loader supports cascade loading the different faces.
  137549. */
  137550. readonly supportCascades: boolean;
  137551. /**
  137552. * This returns if the loader support the current file information.
  137553. * @param extension defines the file extension of the file being loaded
  137554. * @returns true if the loader can load the specified file
  137555. */
  137556. canLoad(extension: string): boolean;
  137557. /**
  137558. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137559. * @param data contains the texture data
  137560. * @param texture defines the BabylonJS internal texture
  137561. * @param createPolynomials will be true if polynomials have been requested
  137562. * @param onLoad defines the callback to trigger once the texture is ready
  137563. * @param onError defines the callback to trigger in case of error
  137564. */
  137565. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137566. /**
  137567. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137568. * @param data contains the texture data
  137569. * @param texture defines the BabylonJS internal texture
  137570. * @param callback defines the method to call once ready to upload
  137571. */
  137572. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137573. }
  137574. }
  137575. declare module BABYLON {
  137576. /**
  137577. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  137578. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  137579. */
  137580. export class KhronosTextureContainer {
  137581. /** contents of the KTX container file */
  137582. data: ArrayBufferView;
  137583. private static HEADER_LEN;
  137584. private static COMPRESSED_2D;
  137585. private static COMPRESSED_3D;
  137586. private static TEX_2D;
  137587. private static TEX_3D;
  137588. /**
  137589. * Gets the openGL type
  137590. */
  137591. glType: number;
  137592. /**
  137593. * Gets the openGL type size
  137594. */
  137595. glTypeSize: number;
  137596. /**
  137597. * Gets the openGL format
  137598. */
  137599. glFormat: number;
  137600. /**
  137601. * Gets the openGL internal format
  137602. */
  137603. glInternalFormat: number;
  137604. /**
  137605. * Gets the base internal format
  137606. */
  137607. glBaseInternalFormat: number;
  137608. /**
  137609. * Gets image width in pixel
  137610. */
  137611. pixelWidth: number;
  137612. /**
  137613. * Gets image height in pixel
  137614. */
  137615. pixelHeight: number;
  137616. /**
  137617. * Gets image depth in pixels
  137618. */
  137619. pixelDepth: number;
  137620. /**
  137621. * Gets the number of array elements
  137622. */
  137623. numberOfArrayElements: number;
  137624. /**
  137625. * Gets the number of faces
  137626. */
  137627. numberOfFaces: number;
  137628. /**
  137629. * Gets the number of mipmap levels
  137630. */
  137631. numberOfMipmapLevels: number;
  137632. /**
  137633. * Gets the bytes of key value data
  137634. */
  137635. bytesOfKeyValueData: number;
  137636. /**
  137637. * Gets the load type
  137638. */
  137639. loadType: number;
  137640. /**
  137641. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  137642. */
  137643. isInvalid: boolean;
  137644. /**
  137645. * Creates a new KhronosTextureContainer
  137646. * @param data contents of the KTX container file
  137647. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  137648. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  137649. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  137650. */
  137651. constructor(
  137652. /** contents of the KTX container file */
  137653. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  137654. /**
  137655. * Uploads KTX content to a Babylon Texture.
  137656. * It is assumed that the texture has already been created & is currently bound
  137657. * @hidden
  137658. */
  137659. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  137660. private _upload2DCompressedLevels;
  137661. /**
  137662. * Checks if the given data starts with a KTX file identifier.
  137663. * @param data the data to check
  137664. * @returns true if the data is a KTX file or false otherwise
  137665. */
  137666. static IsValid(data: ArrayBufferView): boolean;
  137667. }
  137668. }
  137669. declare module BABYLON {
  137670. /**
  137671. * Helper class to push actions to a pool of workers.
  137672. */
  137673. export class WorkerPool implements IDisposable {
  137674. private _workerInfos;
  137675. private _pendingActions;
  137676. /**
  137677. * Constructor
  137678. * @param workers Array of workers to use for actions
  137679. */
  137680. constructor(workers: Array<Worker>);
  137681. /**
  137682. * Terminates all workers and clears any pending actions.
  137683. */
  137684. dispose(): void;
  137685. /**
  137686. * Pushes an action to the worker pool. If all the workers are active, the action will be
  137687. * pended until a worker has completed its action.
  137688. * @param action The action to perform. Call onComplete when the action is complete.
  137689. */
  137690. push(action: (worker: Worker, onComplete: () => void) => void): void;
  137691. private _execute;
  137692. }
  137693. }
  137694. declare module BABYLON {
  137695. /**
  137696. * Class for loading KTX2 files
  137697. * @hidden
  137698. */
  137699. export class KhronosTextureContainer2 {
  137700. private static _WorkerPoolPromise?;
  137701. private static _Initialized;
  137702. private static _Ktx2Decoder;
  137703. /**
  137704. * URL to use when loading the KTX2 decoder module
  137705. */
  137706. static JSModuleURL: string;
  137707. /**
  137708. * Default number of workers used to handle data decoding
  137709. */
  137710. static DefaultNumWorkers: number;
  137711. private static GetDefaultNumWorkers;
  137712. private _engine;
  137713. private static _CreateWorkerPool;
  137714. /**
  137715. * Constructor
  137716. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  137717. */
  137718. constructor(engine: ThinEngine, numWorkers?: number);
  137719. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  137720. /**
  137721. * Stop all async operations and release resources.
  137722. */
  137723. dispose(): void;
  137724. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  137725. /**
  137726. * Checks if the given data starts with a KTX2 file identifier.
  137727. * @param data the data to check
  137728. * @returns true if the data is a KTX2 file or false otherwise
  137729. */
  137730. static IsValid(data: ArrayBufferView): boolean;
  137731. }
  137732. export function workerFunc(): void;
  137733. }
  137734. declare module BABYLON {
  137735. /**
  137736. * Implementation of the KTX Texture Loader.
  137737. * @hidden
  137738. */
  137739. export class _KTXTextureLoader implements IInternalTextureLoader {
  137740. /**
  137741. * Defines wether the loader supports cascade loading the different faces.
  137742. */
  137743. readonly supportCascades: boolean;
  137744. /**
  137745. * This returns if the loader support the current file information.
  137746. * @param extension defines the file extension of the file being loaded
  137747. * @param mimeType defines the optional mime type of the file being loaded
  137748. * @returns true if the loader can load the specified file
  137749. */
  137750. canLoad(extension: string, mimeType?: string): boolean;
  137751. /**
  137752. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137753. * @param data contains the texture data
  137754. * @param texture defines the BabylonJS internal texture
  137755. * @param createPolynomials will be true if polynomials have been requested
  137756. * @param onLoad defines the callback to trigger once the texture is ready
  137757. * @param onError defines the callback to trigger in case of error
  137758. */
  137759. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137760. /**
  137761. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137762. * @param data contains the texture data
  137763. * @param texture defines the BabylonJS internal texture
  137764. * @param callback defines the method to call once ready to upload
  137765. */
  137766. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  137767. }
  137768. }
  137769. declare module BABYLON {
  137770. /** @hidden */
  137771. export var _forceSceneHelpersToBundle: boolean;
  137772. interface Scene {
  137773. /**
  137774. * Creates a default light for the scene.
  137775. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  137776. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  137777. */
  137778. createDefaultLight(replace?: boolean): void;
  137779. /**
  137780. * Creates a default camera for the scene.
  137781. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  137782. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  137783. * @param replace has default false, when true replaces the active camera in the scene
  137784. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  137785. */
  137786. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  137787. /**
  137788. * Creates a default camera and a default light.
  137789. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  137790. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  137791. * @param replace has the default false, when true replaces the active camera/light in the scene
  137792. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  137793. */
  137794. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  137795. /**
  137796. * Creates a new sky box
  137797. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  137798. * @param environmentTexture defines the texture to use as environment texture
  137799. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  137800. * @param scale defines the overall scale of the skybox
  137801. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  137802. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  137803. * @returns a new mesh holding the sky box
  137804. */
  137805. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  137806. /**
  137807. * Creates a new environment
  137808. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  137809. * @param options defines the options you can use to configure the environment
  137810. * @returns the new EnvironmentHelper
  137811. */
  137812. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  137813. /**
  137814. * Creates a new VREXperienceHelper
  137815. * @see https://doc.babylonjs.com/how_to/webvr_helper
  137816. * @param webVROptions defines the options used to create the new VREXperienceHelper
  137817. * @returns a new VREXperienceHelper
  137818. */
  137819. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  137820. /**
  137821. * Creates a new WebXRDefaultExperience
  137822. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  137823. * @param options experience options
  137824. * @returns a promise for a new WebXRDefaultExperience
  137825. */
  137826. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  137827. }
  137828. }
  137829. declare module BABYLON {
  137830. /**
  137831. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  137832. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  137833. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  137834. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  137835. */
  137836. export class VideoDome extends TextureDome<VideoTexture> {
  137837. /**
  137838. * Define the video source as a Monoscopic panoramic 360 video.
  137839. */
  137840. static readonly MODE_MONOSCOPIC: number;
  137841. /**
  137842. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  137843. */
  137844. static readonly MODE_TOPBOTTOM: number;
  137845. /**
  137846. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  137847. */
  137848. static readonly MODE_SIDEBYSIDE: number;
  137849. /**
  137850. * Get the video texture associated with this video dome
  137851. */
  137852. get videoTexture(): VideoTexture;
  137853. /**
  137854. * Get the video mode of this dome
  137855. */
  137856. get videoMode(): number;
  137857. /**
  137858. * Set the video mode of this dome.
  137859. * @see textureMode
  137860. */
  137861. set videoMode(value: number);
  137862. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  137863. }
  137864. }
  137865. declare module BABYLON {
  137866. /**
  137867. * This class can be used to get instrumentation data from a Babylon engine
  137868. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  137869. */
  137870. export class EngineInstrumentation implements IDisposable {
  137871. /**
  137872. * Define the instrumented engine.
  137873. */
  137874. engine: Engine;
  137875. private _captureGPUFrameTime;
  137876. private _gpuFrameTimeToken;
  137877. private _gpuFrameTime;
  137878. private _captureShaderCompilationTime;
  137879. private _shaderCompilationTime;
  137880. private _onBeginFrameObserver;
  137881. private _onEndFrameObserver;
  137882. private _onBeforeShaderCompilationObserver;
  137883. private _onAfterShaderCompilationObserver;
  137884. /**
  137885. * Gets the perf counter used for GPU frame time
  137886. */
  137887. get gpuFrameTimeCounter(): PerfCounter;
  137888. /**
  137889. * Gets the GPU frame time capture status
  137890. */
  137891. get captureGPUFrameTime(): boolean;
  137892. /**
  137893. * Enable or disable the GPU frame time capture
  137894. */
  137895. set captureGPUFrameTime(value: boolean);
  137896. /**
  137897. * Gets the perf counter used for shader compilation time
  137898. */
  137899. get shaderCompilationTimeCounter(): PerfCounter;
  137900. /**
  137901. * Gets the shader compilation time capture status
  137902. */
  137903. get captureShaderCompilationTime(): boolean;
  137904. /**
  137905. * Enable or disable the shader compilation time capture
  137906. */
  137907. set captureShaderCompilationTime(value: boolean);
  137908. /**
  137909. * Instantiates a new engine instrumentation.
  137910. * This class can be used to get instrumentation data from a Babylon engine
  137911. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  137912. * @param engine Defines the engine to instrument
  137913. */
  137914. constructor(
  137915. /**
  137916. * Define the instrumented engine.
  137917. */
  137918. engine: Engine);
  137919. /**
  137920. * Dispose and release associated resources.
  137921. */
  137922. dispose(): void;
  137923. }
  137924. }
  137925. declare module BABYLON {
  137926. /**
  137927. * This class can be used to get instrumentation data from a Babylon engine
  137928. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  137929. */
  137930. export class SceneInstrumentation implements IDisposable {
  137931. /**
  137932. * Defines the scene to instrument
  137933. */
  137934. scene: Scene;
  137935. private _captureActiveMeshesEvaluationTime;
  137936. private _activeMeshesEvaluationTime;
  137937. private _captureRenderTargetsRenderTime;
  137938. private _renderTargetsRenderTime;
  137939. private _captureFrameTime;
  137940. private _frameTime;
  137941. private _captureRenderTime;
  137942. private _renderTime;
  137943. private _captureInterFrameTime;
  137944. private _interFrameTime;
  137945. private _captureParticlesRenderTime;
  137946. private _particlesRenderTime;
  137947. private _captureSpritesRenderTime;
  137948. private _spritesRenderTime;
  137949. private _capturePhysicsTime;
  137950. private _physicsTime;
  137951. private _captureAnimationsTime;
  137952. private _animationsTime;
  137953. private _captureCameraRenderTime;
  137954. private _cameraRenderTime;
  137955. private _onBeforeActiveMeshesEvaluationObserver;
  137956. private _onAfterActiveMeshesEvaluationObserver;
  137957. private _onBeforeRenderTargetsRenderObserver;
  137958. private _onAfterRenderTargetsRenderObserver;
  137959. private _onAfterRenderObserver;
  137960. private _onBeforeDrawPhaseObserver;
  137961. private _onAfterDrawPhaseObserver;
  137962. private _onBeforeAnimationsObserver;
  137963. private _onBeforeParticlesRenderingObserver;
  137964. private _onAfterParticlesRenderingObserver;
  137965. private _onBeforeSpritesRenderingObserver;
  137966. private _onAfterSpritesRenderingObserver;
  137967. private _onBeforePhysicsObserver;
  137968. private _onAfterPhysicsObserver;
  137969. private _onAfterAnimationsObserver;
  137970. private _onBeforeCameraRenderObserver;
  137971. private _onAfterCameraRenderObserver;
  137972. /**
  137973. * Gets the perf counter used for active meshes evaluation time
  137974. */
  137975. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  137976. /**
  137977. * Gets the active meshes evaluation time capture status
  137978. */
  137979. get captureActiveMeshesEvaluationTime(): boolean;
  137980. /**
  137981. * Enable or disable the active meshes evaluation time capture
  137982. */
  137983. set captureActiveMeshesEvaluationTime(value: boolean);
  137984. /**
  137985. * Gets the perf counter used for render targets render time
  137986. */
  137987. get renderTargetsRenderTimeCounter(): PerfCounter;
  137988. /**
  137989. * Gets the render targets render time capture status
  137990. */
  137991. get captureRenderTargetsRenderTime(): boolean;
  137992. /**
  137993. * Enable or disable the render targets render time capture
  137994. */
  137995. set captureRenderTargetsRenderTime(value: boolean);
  137996. /**
  137997. * Gets the perf counter used for particles render time
  137998. */
  137999. get particlesRenderTimeCounter(): PerfCounter;
  138000. /**
  138001. * Gets the particles render time capture status
  138002. */
  138003. get captureParticlesRenderTime(): boolean;
  138004. /**
  138005. * Enable or disable the particles render time capture
  138006. */
  138007. set captureParticlesRenderTime(value: boolean);
  138008. /**
  138009. * Gets the perf counter used for sprites render time
  138010. */
  138011. get spritesRenderTimeCounter(): PerfCounter;
  138012. /**
  138013. * Gets the sprites render time capture status
  138014. */
  138015. get captureSpritesRenderTime(): boolean;
  138016. /**
  138017. * Enable or disable the sprites render time capture
  138018. */
  138019. set captureSpritesRenderTime(value: boolean);
  138020. /**
  138021. * Gets the perf counter used for physics time
  138022. */
  138023. get physicsTimeCounter(): PerfCounter;
  138024. /**
  138025. * Gets the physics time capture status
  138026. */
  138027. get capturePhysicsTime(): boolean;
  138028. /**
  138029. * Enable or disable the physics time capture
  138030. */
  138031. set capturePhysicsTime(value: boolean);
  138032. /**
  138033. * Gets the perf counter used for animations time
  138034. */
  138035. get animationsTimeCounter(): PerfCounter;
  138036. /**
  138037. * Gets the animations time capture status
  138038. */
  138039. get captureAnimationsTime(): boolean;
  138040. /**
  138041. * Enable or disable the animations time capture
  138042. */
  138043. set captureAnimationsTime(value: boolean);
  138044. /**
  138045. * Gets the perf counter used for frame time capture
  138046. */
  138047. get frameTimeCounter(): PerfCounter;
  138048. /**
  138049. * Gets the frame time capture status
  138050. */
  138051. get captureFrameTime(): boolean;
  138052. /**
  138053. * Enable or disable the frame time capture
  138054. */
  138055. set captureFrameTime(value: boolean);
  138056. /**
  138057. * Gets the perf counter used for inter-frames time capture
  138058. */
  138059. get interFrameTimeCounter(): PerfCounter;
  138060. /**
  138061. * Gets the inter-frames time capture status
  138062. */
  138063. get captureInterFrameTime(): boolean;
  138064. /**
  138065. * Enable or disable the inter-frames time capture
  138066. */
  138067. set captureInterFrameTime(value: boolean);
  138068. /**
  138069. * Gets the perf counter used for render time capture
  138070. */
  138071. get renderTimeCounter(): PerfCounter;
  138072. /**
  138073. * Gets the render time capture status
  138074. */
  138075. get captureRenderTime(): boolean;
  138076. /**
  138077. * Enable or disable the render time capture
  138078. */
  138079. set captureRenderTime(value: boolean);
  138080. /**
  138081. * Gets the perf counter used for camera render time capture
  138082. */
  138083. get cameraRenderTimeCounter(): PerfCounter;
  138084. /**
  138085. * Gets the camera render time capture status
  138086. */
  138087. get captureCameraRenderTime(): boolean;
  138088. /**
  138089. * Enable or disable the camera render time capture
  138090. */
  138091. set captureCameraRenderTime(value: boolean);
  138092. /**
  138093. * Gets the perf counter used for draw calls
  138094. */
  138095. get drawCallsCounter(): PerfCounter;
  138096. /**
  138097. * Instantiates a new scene instrumentation.
  138098. * This class can be used to get instrumentation data from a Babylon engine
  138099. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138100. * @param scene Defines the scene to instrument
  138101. */
  138102. constructor(
  138103. /**
  138104. * Defines the scene to instrument
  138105. */
  138106. scene: Scene);
  138107. /**
  138108. * Dispose and release associated resources.
  138109. */
  138110. dispose(): void;
  138111. }
  138112. }
  138113. declare module BABYLON {
  138114. /** @hidden */
  138115. export var glowMapGenerationPixelShader: {
  138116. name: string;
  138117. shader: string;
  138118. };
  138119. }
  138120. declare module BABYLON {
  138121. /** @hidden */
  138122. export var glowMapGenerationVertexShader: {
  138123. name: string;
  138124. shader: string;
  138125. };
  138126. }
  138127. declare module BABYLON {
  138128. /**
  138129. * Effect layer options. This helps customizing the behaviour
  138130. * of the effect layer.
  138131. */
  138132. export interface IEffectLayerOptions {
  138133. /**
  138134. * Multiplication factor apply to the canvas size to compute the render target size
  138135. * used to generated the objects (the smaller the faster).
  138136. */
  138137. mainTextureRatio: number;
  138138. /**
  138139. * Enforces a fixed size texture to ensure effect stability across devices.
  138140. */
  138141. mainTextureFixedSize?: number;
  138142. /**
  138143. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  138144. */
  138145. alphaBlendingMode: number;
  138146. /**
  138147. * The camera attached to the layer.
  138148. */
  138149. camera: Nullable<Camera>;
  138150. /**
  138151. * The rendering group to draw the layer in.
  138152. */
  138153. renderingGroupId: number;
  138154. }
  138155. /**
  138156. * The effect layer Helps adding post process effect blended with the main pass.
  138157. *
  138158. * This can be for instance use to generate glow or higlight effects on the scene.
  138159. *
  138160. * The effect layer class can not be used directly and is intented to inherited from to be
  138161. * customized per effects.
  138162. */
  138163. export abstract class EffectLayer {
  138164. private _vertexBuffers;
  138165. private _indexBuffer;
  138166. private _cachedDefines;
  138167. private _effectLayerMapGenerationEffect;
  138168. private _effectLayerOptions;
  138169. private _mergeEffect;
  138170. protected _scene: Scene;
  138171. protected _engine: Engine;
  138172. protected _maxSize: number;
  138173. protected _mainTextureDesiredSize: ISize;
  138174. protected _mainTexture: RenderTargetTexture;
  138175. protected _shouldRender: boolean;
  138176. protected _postProcesses: PostProcess[];
  138177. protected _textures: BaseTexture[];
  138178. protected _emissiveTextureAndColor: {
  138179. texture: Nullable<BaseTexture>;
  138180. color: Color4;
  138181. };
  138182. /**
  138183. * The name of the layer
  138184. */
  138185. name: string;
  138186. /**
  138187. * The clear color of the texture used to generate the glow map.
  138188. */
  138189. neutralColor: Color4;
  138190. /**
  138191. * Specifies whether the highlight layer is enabled or not.
  138192. */
  138193. isEnabled: boolean;
  138194. /**
  138195. * Gets the camera attached to the layer.
  138196. */
  138197. get camera(): Nullable<Camera>;
  138198. /**
  138199. * Gets the rendering group id the layer should render in.
  138200. */
  138201. get renderingGroupId(): number;
  138202. set renderingGroupId(renderingGroupId: number);
  138203. /**
  138204. * An event triggered when the effect layer has been disposed.
  138205. */
  138206. onDisposeObservable: Observable<EffectLayer>;
  138207. /**
  138208. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  138209. */
  138210. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  138211. /**
  138212. * An event triggered when the generated texture is being merged in the scene.
  138213. */
  138214. onBeforeComposeObservable: Observable<EffectLayer>;
  138215. /**
  138216. * An event triggered when the mesh is rendered into the effect render target.
  138217. */
  138218. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  138219. /**
  138220. * An event triggered after the mesh has been rendered into the effect render target.
  138221. */
  138222. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  138223. /**
  138224. * An event triggered when the generated texture has been merged in the scene.
  138225. */
  138226. onAfterComposeObservable: Observable<EffectLayer>;
  138227. /**
  138228. * An event triggered when the efffect layer changes its size.
  138229. */
  138230. onSizeChangedObservable: Observable<EffectLayer>;
  138231. /** @hidden */
  138232. static _SceneComponentInitialization: (scene: Scene) => void;
  138233. /**
  138234. * Instantiates a new effect Layer and references it in the scene.
  138235. * @param name The name of the layer
  138236. * @param scene The scene to use the layer in
  138237. */
  138238. constructor(
  138239. /** The Friendly of the effect in the scene */
  138240. name: string, scene: Scene);
  138241. /**
  138242. * Get the effect name of the layer.
  138243. * @return The effect name
  138244. */
  138245. abstract getEffectName(): string;
  138246. /**
  138247. * Checks for the readiness of the element composing the layer.
  138248. * @param subMesh the mesh to check for
  138249. * @param useInstances specify whether or not to use instances to render the mesh
  138250. * @return true if ready otherwise, false
  138251. */
  138252. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138253. /**
  138254. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138255. * @returns true if the effect requires stencil during the main canvas render pass.
  138256. */
  138257. abstract needStencil(): boolean;
  138258. /**
  138259. * Create the merge effect. This is the shader use to blit the information back
  138260. * to the main canvas at the end of the scene rendering.
  138261. * @returns The effect containing the shader used to merge the effect on the main canvas
  138262. */
  138263. protected abstract _createMergeEffect(): Effect;
  138264. /**
  138265. * Creates the render target textures and post processes used in the effect layer.
  138266. */
  138267. protected abstract _createTextureAndPostProcesses(): void;
  138268. /**
  138269. * Implementation specific of rendering the generating effect on the main canvas.
  138270. * @param effect The effect used to render through
  138271. */
  138272. protected abstract _internalRender(effect: Effect): void;
  138273. /**
  138274. * Sets the required values for both the emissive texture and and the main color.
  138275. */
  138276. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138277. /**
  138278. * Free any resources and references associated to a mesh.
  138279. * Internal use
  138280. * @param mesh The mesh to free.
  138281. */
  138282. abstract _disposeMesh(mesh: Mesh): void;
  138283. /**
  138284. * Serializes this layer (Glow or Highlight for example)
  138285. * @returns a serialized layer object
  138286. */
  138287. abstract serialize?(): any;
  138288. /**
  138289. * Initializes the effect layer with the required options.
  138290. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  138291. */
  138292. protected _init(options: Partial<IEffectLayerOptions>): void;
  138293. /**
  138294. * Generates the index buffer of the full screen quad blending to the main canvas.
  138295. */
  138296. private _generateIndexBuffer;
  138297. /**
  138298. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  138299. */
  138300. private _generateVertexBuffer;
  138301. /**
  138302. * Sets the main texture desired size which is the closest power of two
  138303. * of the engine canvas size.
  138304. */
  138305. private _setMainTextureSize;
  138306. /**
  138307. * Creates the main texture for the effect layer.
  138308. */
  138309. protected _createMainTexture(): void;
  138310. /**
  138311. * Adds specific effects defines.
  138312. * @param defines The defines to add specifics to.
  138313. */
  138314. protected _addCustomEffectDefines(defines: string[]): void;
  138315. /**
  138316. * Checks for the readiness of the element composing the layer.
  138317. * @param subMesh the mesh to check for
  138318. * @param useInstances specify whether or not to use instances to render the mesh
  138319. * @param emissiveTexture the associated emissive texture used to generate the glow
  138320. * @return true if ready otherwise, false
  138321. */
  138322. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  138323. /**
  138324. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  138325. */
  138326. render(): void;
  138327. /**
  138328. * Determine if a given mesh will be used in the current effect.
  138329. * @param mesh mesh to test
  138330. * @returns true if the mesh will be used
  138331. */
  138332. hasMesh(mesh: AbstractMesh): boolean;
  138333. /**
  138334. * Returns true if the layer contains information to display, otherwise false.
  138335. * @returns true if the glow layer should be rendered
  138336. */
  138337. shouldRender(): boolean;
  138338. /**
  138339. * Returns true if the mesh should render, otherwise false.
  138340. * @param mesh The mesh to render
  138341. * @returns true if it should render otherwise false
  138342. */
  138343. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  138344. /**
  138345. * Returns true if the mesh can be rendered, otherwise false.
  138346. * @param mesh The mesh to render
  138347. * @param material The material used on the mesh
  138348. * @returns true if it can be rendered otherwise false
  138349. */
  138350. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138351. /**
  138352. * Returns true if the mesh should render, otherwise false.
  138353. * @param mesh The mesh to render
  138354. * @returns true if it should render otherwise false
  138355. */
  138356. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  138357. /**
  138358. * Renders the submesh passed in parameter to the generation map.
  138359. */
  138360. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  138361. /**
  138362. * Defines whether the current material of the mesh should be use to render the effect.
  138363. * @param mesh defines the current mesh to render
  138364. */
  138365. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138366. /**
  138367. * Rebuild the required buffers.
  138368. * @hidden Internal use only.
  138369. */
  138370. _rebuild(): void;
  138371. /**
  138372. * Dispose only the render target textures and post process.
  138373. */
  138374. private _disposeTextureAndPostProcesses;
  138375. /**
  138376. * Dispose the highlight layer and free resources.
  138377. */
  138378. dispose(): void;
  138379. /**
  138380. * Gets the class name of the effect layer
  138381. * @returns the string with the class name of the effect layer
  138382. */
  138383. getClassName(): string;
  138384. /**
  138385. * Creates an effect layer from parsed effect layer data
  138386. * @param parsedEffectLayer defines effect layer data
  138387. * @param scene defines the current scene
  138388. * @param rootUrl defines the root URL containing the effect layer information
  138389. * @returns a parsed effect Layer
  138390. */
  138391. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  138392. }
  138393. }
  138394. declare module BABYLON {
  138395. interface AbstractScene {
  138396. /**
  138397. * The list of effect layers (highlights/glow) added to the scene
  138398. * @see https://doc.babylonjs.com/how_to/highlight_layer
  138399. * @see https://doc.babylonjs.com/how_to/glow_layer
  138400. */
  138401. effectLayers: Array<EffectLayer>;
  138402. /**
  138403. * Removes the given effect layer from this scene.
  138404. * @param toRemove defines the effect layer to remove
  138405. * @returns the index of the removed effect layer
  138406. */
  138407. removeEffectLayer(toRemove: EffectLayer): number;
  138408. /**
  138409. * Adds the given effect layer to this scene
  138410. * @param newEffectLayer defines the effect layer to add
  138411. */
  138412. addEffectLayer(newEffectLayer: EffectLayer): void;
  138413. }
  138414. /**
  138415. * Defines the layer scene component responsible to manage any effect layers
  138416. * in a given scene.
  138417. */
  138418. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  138419. /**
  138420. * The component name helpfull to identify the component in the list of scene components.
  138421. */
  138422. readonly name: string;
  138423. /**
  138424. * The scene the component belongs to.
  138425. */
  138426. scene: Scene;
  138427. private _engine;
  138428. private _renderEffects;
  138429. private _needStencil;
  138430. private _previousStencilState;
  138431. /**
  138432. * Creates a new instance of the component for the given scene
  138433. * @param scene Defines the scene to register the component in
  138434. */
  138435. constructor(scene: Scene);
  138436. /**
  138437. * Registers the component in a given scene
  138438. */
  138439. register(): void;
  138440. /**
  138441. * Rebuilds the elements related to this component in case of
  138442. * context lost for instance.
  138443. */
  138444. rebuild(): void;
  138445. /**
  138446. * Serializes the component data to the specified json object
  138447. * @param serializationObject The object to serialize to
  138448. */
  138449. serialize(serializationObject: any): void;
  138450. /**
  138451. * Adds all the elements from the container to the scene
  138452. * @param container the container holding the elements
  138453. */
  138454. addFromContainer(container: AbstractScene): void;
  138455. /**
  138456. * Removes all the elements in the container from the scene
  138457. * @param container contains the elements to remove
  138458. * @param dispose if the removed element should be disposed (default: false)
  138459. */
  138460. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138461. /**
  138462. * Disposes the component and the associated ressources.
  138463. */
  138464. dispose(): void;
  138465. private _isReadyForMesh;
  138466. private _renderMainTexture;
  138467. private _setStencil;
  138468. private _setStencilBack;
  138469. private _draw;
  138470. private _drawCamera;
  138471. private _drawRenderingGroup;
  138472. }
  138473. }
  138474. declare module BABYLON {
  138475. /** @hidden */
  138476. export var glowMapMergePixelShader: {
  138477. name: string;
  138478. shader: string;
  138479. };
  138480. }
  138481. declare module BABYLON {
  138482. /** @hidden */
  138483. export var glowMapMergeVertexShader: {
  138484. name: string;
  138485. shader: string;
  138486. };
  138487. }
  138488. declare module BABYLON {
  138489. interface AbstractScene {
  138490. /**
  138491. * Return a the first highlight layer of the scene with a given name.
  138492. * @param name The name of the highlight layer to look for.
  138493. * @return The highlight layer if found otherwise null.
  138494. */
  138495. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  138496. }
  138497. /**
  138498. * Glow layer options. This helps customizing the behaviour
  138499. * of the glow layer.
  138500. */
  138501. export interface IGlowLayerOptions {
  138502. /**
  138503. * Multiplication factor apply to the canvas size to compute the render target size
  138504. * used to generated the glowing objects (the smaller the faster).
  138505. */
  138506. mainTextureRatio: number;
  138507. /**
  138508. * Enforces a fixed size texture to ensure resize independant blur.
  138509. */
  138510. mainTextureFixedSize?: number;
  138511. /**
  138512. * How big is the kernel of the blur texture.
  138513. */
  138514. blurKernelSize: number;
  138515. /**
  138516. * The camera attached to the layer.
  138517. */
  138518. camera: Nullable<Camera>;
  138519. /**
  138520. * Enable MSAA by chosing the number of samples.
  138521. */
  138522. mainTextureSamples?: number;
  138523. /**
  138524. * The rendering group to draw the layer in.
  138525. */
  138526. renderingGroupId: number;
  138527. }
  138528. /**
  138529. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  138530. *
  138531. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  138532. *
  138533. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  138534. */
  138535. export class GlowLayer extends EffectLayer {
  138536. /**
  138537. * Effect Name of the layer.
  138538. */
  138539. static readonly EffectName: string;
  138540. /**
  138541. * The default blur kernel size used for the glow.
  138542. */
  138543. static DefaultBlurKernelSize: number;
  138544. /**
  138545. * The default texture size ratio used for the glow.
  138546. */
  138547. static DefaultTextureRatio: number;
  138548. /**
  138549. * Sets the kernel size of the blur.
  138550. */
  138551. set blurKernelSize(value: number);
  138552. /**
  138553. * Gets the kernel size of the blur.
  138554. */
  138555. get blurKernelSize(): number;
  138556. /**
  138557. * Sets the glow intensity.
  138558. */
  138559. set intensity(value: number);
  138560. /**
  138561. * Gets the glow intensity.
  138562. */
  138563. get intensity(): number;
  138564. private _options;
  138565. private _intensity;
  138566. private _horizontalBlurPostprocess1;
  138567. private _verticalBlurPostprocess1;
  138568. private _horizontalBlurPostprocess2;
  138569. private _verticalBlurPostprocess2;
  138570. private _blurTexture1;
  138571. private _blurTexture2;
  138572. private _postProcesses1;
  138573. private _postProcesses2;
  138574. private _includedOnlyMeshes;
  138575. private _excludedMeshes;
  138576. private _meshesUsingTheirOwnMaterials;
  138577. /**
  138578. * Callback used to let the user override the color selection on a per mesh basis
  138579. */
  138580. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  138581. /**
  138582. * Callback used to let the user override the texture selection on a per mesh basis
  138583. */
  138584. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  138585. /**
  138586. * Instantiates a new glow Layer and references it to the scene.
  138587. * @param name The name of the layer
  138588. * @param scene The scene to use the layer in
  138589. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  138590. */
  138591. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  138592. /**
  138593. * Get the effect name of the layer.
  138594. * @return The effect name
  138595. */
  138596. getEffectName(): string;
  138597. /**
  138598. * Create the merge effect. This is the shader use to blit the information back
  138599. * to the main canvas at the end of the scene rendering.
  138600. */
  138601. protected _createMergeEffect(): Effect;
  138602. /**
  138603. * Creates the render target textures and post processes used in the glow layer.
  138604. */
  138605. protected _createTextureAndPostProcesses(): void;
  138606. /**
  138607. * Checks for the readiness of the element composing the layer.
  138608. * @param subMesh the mesh to check for
  138609. * @param useInstances specify wether or not to use instances to render the mesh
  138610. * @param emissiveTexture the associated emissive texture used to generate the glow
  138611. * @return true if ready otherwise, false
  138612. */
  138613. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138614. /**
  138615. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138616. */
  138617. needStencil(): boolean;
  138618. /**
  138619. * Returns true if the mesh can be rendered, otherwise false.
  138620. * @param mesh The mesh to render
  138621. * @param material The material used on the mesh
  138622. * @returns true if it can be rendered otherwise false
  138623. */
  138624. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138625. /**
  138626. * Implementation specific of rendering the generating effect on the main canvas.
  138627. * @param effect The effect used to render through
  138628. */
  138629. protected _internalRender(effect: Effect): void;
  138630. /**
  138631. * Sets the required values for both the emissive texture and and the main color.
  138632. */
  138633. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138634. /**
  138635. * Returns true if the mesh should render, otherwise false.
  138636. * @param mesh The mesh to render
  138637. * @returns true if it should render otherwise false
  138638. */
  138639. protected _shouldRenderMesh(mesh: Mesh): boolean;
  138640. /**
  138641. * Adds specific effects defines.
  138642. * @param defines The defines to add specifics to.
  138643. */
  138644. protected _addCustomEffectDefines(defines: string[]): void;
  138645. /**
  138646. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  138647. * @param mesh The mesh to exclude from the glow layer
  138648. */
  138649. addExcludedMesh(mesh: Mesh): void;
  138650. /**
  138651. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  138652. * @param mesh The mesh to remove
  138653. */
  138654. removeExcludedMesh(mesh: Mesh): void;
  138655. /**
  138656. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  138657. * @param mesh The mesh to include in the glow layer
  138658. */
  138659. addIncludedOnlyMesh(mesh: Mesh): void;
  138660. /**
  138661. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  138662. * @param mesh The mesh to remove
  138663. */
  138664. removeIncludedOnlyMesh(mesh: Mesh): void;
  138665. /**
  138666. * Determine if a given mesh will be used in the glow layer
  138667. * @param mesh The mesh to test
  138668. * @returns true if the mesh will be highlighted by the current glow layer
  138669. */
  138670. hasMesh(mesh: AbstractMesh): boolean;
  138671. /**
  138672. * Defines whether the current material of the mesh should be use to render the effect.
  138673. * @param mesh defines the current mesh to render
  138674. */
  138675. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138676. /**
  138677. * Add a mesh to be rendered through its own material and not with emissive only.
  138678. * @param mesh The mesh for which we need to use its material
  138679. */
  138680. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  138681. /**
  138682. * Remove a mesh from being rendered through its own material and not with emissive only.
  138683. * @param mesh The mesh for which we need to not use its material
  138684. */
  138685. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  138686. /**
  138687. * Free any resources and references associated to a mesh.
  138688. * Internal use
  138689. * @param mesh The mesh to free.
  138690. * @hidden
  138691. */
  138692. _disposeMesh(mesh: Mesh): void;
  138693. /**
  138694. * Gets the class name of the effect layer
  138695. * @returns the string with the class name of the effect layer
  138696. */
  138697. getClassName(): string;
  138698. /**
  138699. * Serializes this glow layer
  138700. * @returns a serialized glow layer object
  138701. */
  138702. serialize(): any;
  138703. /**
  138704. * Creates a Glow Layer from parsed glow layer data
  138705. * @param parsedGlowLayer defines glow layer data
  138706. * @param scene defines the current scene
  138707. * @param rootUrl defines the root URL containing the glow layer information
  138708. * @returns a parsed Glow Layer
  138709. */
  138710. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  138711. }
  138712. }
  138713. declare module BABYLON {
  138714. /** @hidden */
  138715. export var glowBlurPostProcessPixelShader: {
  138716. name: string;
  138717. shader: string;
  138718. };
  138719. }
  138720. declare module BABYLON {
  138721. interface AbstractScene {
  138722. /**
  138723. * Return a the first highlight layer of the scene with a given name.
  138724. * @param name The name of the highlight layer to look for.
  138725. * @return The highlight layer if found otherwise null.
  138726. */
  138727. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  138728. }
  138729. /**
  138730. * Highlight layer options. This helps customizing the behaviour
  138731. * of the highlight layer.
  138732. */
  138733. export interface IHighlightLayerOptions {
  138734. /**
  138735. * Multiplication factor apply to the canvas size to compute the render target size
  138736. * used to generated the glowing objects (the smaller the faster).
  138737. */
  138738. mainTextureRatio: number;
  138739. /**
  138740. * Enforces a fixed size texture to ensure resize independant blur.
  138741. */
  138742. mainTextureFixedSize?: number;
  138743. /**
  138744. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  138745. * of the picture to blur (the smaller the faster).
  138746. */
  138747. blurTextureSizeRatio: number;
  138748. /**
  138749. * How big in texel of the blur texture is the vertical blur.
  138750. */
  138751. blurVerticalSize: number;
  138752. /**
  138753. * How big in texel of the blur texture is the horizontal blur.
  138754. */
  138755. blurHorizontalSize: number;
  138756. /**
  138757. * Alpha blending mode used to apply the blur. Default is combine.
  138758. */
  138759. alphaBlendingMode: number;
  138760. /**
  138761. * The camera attached to the layer.
  138762. */
  138763. camera: Nullable<Camera>;
  138764. /**
  138765. * Should we display highlight as a solid stroke?
  138766. */
  138767. isStroke?: boolean;
  138768. /**
  138769. * The rendering group to draw the layer in.
  138770. */
  138771. renderingGroupId: number;
  138772. }
  138773. /**
  138774. * The highlight layer Helps adding a glow effect around a mesh.
  138775. *
  138776. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  138777. * glowy meshes to your scene.
  138778. *
  138779. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  138780. */
  138781. export class HighlightLayer extends EffectLayer {
  138782. name: string;
  138783. /**
  138784. * Effect Name of the highlight layer.
  138785. */
  138786. static readonly EffectName: string;
  138787. /**
  138788. * The neutral color used during the preparation of the glow effect.
  138789. * This is black by default as the blend operation is a blend operation.
  138790. */
  138791. static NeutralColor: Color4;
  138792. /**
  138793. * Stencil value used for glowing meshes.
  138794. */
  138795. static GlowingMeshStencilReference: number;
  138796. /**
  138797. * Stencil value used for the other meshes in the scene.
  138798. */
  138799. static NormalMeshStencilReference: number;
  138800. /**
  138801. * Specifies whether or not the inner glow is ACTIVE in the layer.
  138802. */
  138803. innerGlow: boolean;
  138804. /**
  138805. * Specifies whether or not the outer glow is ACTIVE in the layer.
  138806. */
  138807. outerGlow: boolean;
  138808. /**
  138809. * Specifies the horizontal size of the blur.
  138810. */
  138811. set blurHorizontalSize(value: number);
  138812. /**
  138813. * Specifies the vertical size of the blur.
  138814. */
  138815. set blurVerticalSize(value: number);
  138816. /**
  138817. * Gets the horizontal size of the blur.
  138818. */
  138819. get blurHorizontalSize(): number;
  138820. /**
  138821. * Gets the vertical size of the blur.
  138822. */
  138823. get blurVerticalSize(): number;
  138824. /**
  138825. * An event triggered when the highlight layer is being blurred.
  138826. */
  138827. onBeforeBlurObservable: Observable<HighlightLayer>;
  138828. /**
  138829. * An event triggered when the highlight layer has been blurred.
  138830. */
  138831. onAfterBlurObservable: Observable<HighlightLayer>;
  138832. private _instanceGlowingMeshStencilReference;
  138833. private _options;
  138834. private _downSamplePostprocess;
  138835. private _horizontalBlurPostprocess;
  138836. private _verticalBlurPostprocess;
  138837. private _blurTexture;
  138838. private _meshes;
  138839. private _excludedMeshes;
  138840. /**
  138841. * Instantiates a new highlight Layer and references it to the scene..
  138842. * @param name The name of the layer
  138843. * @param scene The scene to use the layer in
  138844. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  138845. */
  138846. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  138847. /**
  138848. * Get the effect name of the layer.
  138849. * @return The effect name
  138850. */
  138851. getEffectName(): string;
  138852. /**
  138853. * Create the merge effect. This is the shader use to blit the information back
  138854. * to the main canvas at the end of the scene rendering.
  138855. */
  138856. protected _createMergeEffect(): Effect;
  138857. /**
  138858. * Creates the render target textures and post processes used in the highlight layer.
  138859. */
  138860. protected _createTextureAndPostProcesses(): void;
  138861. /**
  138862. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  138863. */
  138864. needStencil(): boolean;
  138865. /**
  138866. * Checks for the readiness of the element composing the layer.
  138867. * @param subMesh the mesh to check for
  138868. * @param useInstances specify wether or not to use instances to render the mesh
  138869. * @param emissiveTexture the associated emissive texture used to generate the glow
  138870. * @return true if ready otherwise, false
  138871. */
  138872. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138873. /**
  138874. * Implementation specific of rendering the generating effect on the main canvas.
  138875. * @param effect The effect used to render through
  138876. */
  138877. protected _internalRender(effect: Effect): void;
  138878. /**
  138879. * Returns true if the layer contains information to display, otherwise false.
  138880. */
  138881. shouldRender(): boolean;
  138882. /**
  138883. * Returns true if the mesh should render, otherwise false.
  138884. * @param mesh The mesh to render
  138885. * @returns true if it should render otherwise false
  138886. */
  138887. protected _shouldRenderMesh(mesh: Mesh): boolean;
  138888. /**
  138889. * Returns true if the mesh can be rendered, otherwise false.
  138890. * @param mesh The mesh to render
  138891. * @param material The material used on the mesh
  138892. * @returns true if it can be rendered otherwise false
  138893. */
  138894. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138895. /**
  138896. * Adds specific effects defines.
  138897. * @param defines The defines to add specifics to.
  138898. */
  138899. protected _addCustomEffectDefines(defines: string[]): void;
  138900. /**
  138901. * Sets the required values for both the emissive texture and and the main color.
  138902. */
  138903. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138904. /**
  138905. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  138906. * @param mesh The mesh to exclude from the highlight layer
  138907. */
  138908. addExcludedMesh(mesh: Mesh): void;
  138909. /**
  138910. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  138911. * @param mesh The mesh to highlight
  138912. */
  138913. removeExcludedMesh(mesh: Mesh): void;
  138914. /**
  138915. * Determine if a given mesh will be highlighted by the current HighlightLayer
  138916. * @param mesh mesh to test
  138917. * @returns true if the mesh will be highlighted by the current HighlightLayer
  138918. */
  138919. hasMesh(mesh: AbstractMesh): boolean;
  138920. /**
  138921. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  138922. * @param mesh The mesh to highlight
  138923. * @param color The color of the highlight
  138924. * @param glowEmissiveOnly Extract the glow from the emissive texture
  138925. */
  138926. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  138927. /**
  138928. * Remove a mesh from the highlight layer in order to make it stop glowing.
  138929. * @param mesh The mesh to highlight
  138930. */
  138931. removeMesh(mesh: Mesh): void;
  138932. /**
  138933. * Remove all the meshes currently referenced in the highlight layer
  138934. */
  138935. removeAllMeshes(): void;
  138936. /**
  138937. * Force the stencil to the normal expected value for none glowing parts
  138938. */
  138939. private _defaultStencilReference;
  138940. /**
  138941. * Free any resources and references associated to a mesh.
  138942. * Internal use
  138943. * @param mesh The mesh to free.
  138944. * @hidden
  138945. */
  138946. _disposeMesh(mesh: Mesh): void;
  138947. /**
  138948. * Dispose the highlight layer and free resources.
  138949. */
  138950. dispose(): void;
  138951. /**
  138952. * Gets the class name of the effect layer
  138953. * @returns the string with the class name of the effect layer
  138954. */
  138955. getClassName(): string;
  138956. /**
  138957. * Serializes this Highlight layer
  138958. * @returns a serialized Highlight layer object
  138959. */
  138960. serialize(): any;
  138961. /**
  138962. * Creates a Highlight layer from parsed Highlight layer data
  138963. * @param parsedHightlightLayer defines the Highlight layer data
  138964. * @param scene defines the current scene
  138965. * @param rootUrl defines the root URL containing the Highlight layer information
  138966. * @returns a parsed Highlight layer
  138967. */
  138968. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  138969. }
  138970. }
  138971. declare module BABYLON {
  138972. interface AbstractScene {
  138973. /**
  138974. * The list of layers (background and foreground) of the scene
  138975. */
  138976. layers: Array<Layer>;
  138977. }
  138978. /**
  138979. * Defines the layer scene component responsible to manage any layers
  138980. * in a given scene.
  138981. */
  138982. export class LayerSceneComponent implements ISceneComponent {
  138983. /**
  138984. * The component name helpfull to identify the component in the list of scene components.
  138985. */
  138986. readonly name: string;
  138987. /**
  138988. * The scene the component belongs to.
  138989. */
  138990. scene: Scene;
  138991. private _engine;
  138992. /**
  138993. * Creates a new instance of the component for the given scene
  138994. * @param scene Defines the scene to register the component in
  138995. */
  138996. constructor(scene: Scene);
  138997. /**
  138998. * Registers the component in a given scene
  138999. */
  139000. register(): void;
  139001. /**
  139002. * Rebuilds the elements related to this component in case of
  139003. * context lost for instance.
  139004. */
  139005. rebuild(): void;
  139006. /**
  139007. * Disposes the component and the associated ressources.
  139008. */
  139009. dispose(): void;
  139010. private _draw;
  139011. private _drawCameraPredicate;
  139012. private _drawCameraBackground;
  139013. private _drawCameraForeground;
  139014. private _drawRenderTargetPredicate;
  139015. private _drawRenderTargetBackground;
  139016. private _drawRenderTargetForeground;
  139017. /**
  139018. * Adds all the elements from the container to the scene
  139019. * @param container the container holding the elements
  139020. */
  139021. addFromContainer(container: AbstractScene): void;
  139022. /**
  139023. * Removes all the elements in the container from the scene
  139024. * @param container contains the elements to remove
  139025. * @param dispose if the removed element should be disposed (default: false)
  139026. */
  139027. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139028. }
  139029. }
  139030. declare module BABYLON {
  139031. /** @hidden */
  139032. export var layerPixelShader: {
  139033. name: string;
  139034. shader: string;
  139035. };
  139036. }
  139037. declare module BABYLON {
  139038. /** @hidden */
  139039. export var layerVertexShader: {
  139040. name: string;
  139041. shader: string;
  139042. };
  139043. }
  139044. declare module BABYLON {
  139045. /**
  139046. * This represents a full screen 2d layer.
  139047. * This can be useful to display a picture in the background of your scene for instance.
  139048. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139049. */
  139050. export class Layer {
  139051. /**
  139052. * Define the name of the layer.
  139053. */
  139054. name: string;
  139055. /**
  139056. * Define the texture the layer should display.
  139057. */
  139058. texture: Nullable<Texture>;
  139059. /**
  139060. * Is the layer in background or foreground.
  139061. */
  139062. isBackground: boolean;
  139063. /**
  139064. * Define the color of the layer (instead of texture).
  139065. */
  139066. color: Color4;
  139067. /**
  139068. * Define the scale of the layer in order to zoom in out of the texture.
  139069. */
  139070. scale: Vector2;
  139071. /**
  139072. * Define an offset for the layer in order to shift the texture.
  139073. */
  139074. offset: Vector2;
  139075. /**
  139076. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  139077. */
  139078. alphaBlendingMode: number;
  139079. /**
  139080. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  139081. * Alpha test will not mix with the background color in case of transparency.
  139082. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  139083. */
  139084. alphaTest: boolean;
  139085. /**
  139086. * Define a mask to restrict the layer to only some of the scene cameras.
  139087. */
  139088. layerMask: number;
  139089. /**
  139090. * Define the list of render target the layer is visible into.
  139091. */
  139092. renderTargetTextures: RenderTargetTexture[];
  139093. /**
  139094. * Define if the layer is only used in renderTarget or if it also
  139095. * renders in the main frame buffer of the canvas.
  139096. */
  139097. renderOnlyInRenderTargetTextures: boolean;
  139098. private _scene;
  139099. private _vertexBuffers;
  139100. private _indexBuffer;
  139101. private _effect;
  139102. private _previousDefines;
  139103. /**
  139104. * An event triggered when the layer is disposed.
  139105. */
  139106. onDisposeObservable: Observable<Layer>;
  139107. private _onDisposeObserver;
  139108. /**
  139109. * Back compatibility with callback before the onDisposeObservable existed.
  139110. * The set callback will be triggered when the layer has been disposed.
  139111. */
  139112. set onDispose(callback: () => void);
  139113. /**
  139114. * An event triggered before rendering the scene
  139115. */
  139116. onBeforeRenderObservable: Observable<Layer>;
  139117. private _onBeforeRenderObserver;
  139118. /**
  139119. * Back compatibility with callback before the onBeforeRenderObservable existed.
  139120. * The set callback will be triggered just before rendering the layer.
  139121. */
  139122. set onBeforeRender(callback: () => void);
  139123. /**
  139124. * An event triggered after rendering the scene
  139125. */
  139126. onAfterRenderObservable: Observable<Layer>;
  139127. private _onAfterRenderObserver;
  139128. /**
  139129. * Back compatibility with callback before the onAfterRenderObservable existed.
  139130. * The set callback will be triggered just after rendering the layer.
  139131. */
  139132. set onAfterRender(callback: () => void);
  139133. /**
  139134. * Instantiates a new layer.
  139135. * This represents a full screen 2d layer.
  139136. * This can be useful to display a picture in the background of your scene for instance.
  139137. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139138. * @param name Define the name of the layer in the scene
  139139. * @param imgUrl Define the url of the texture to display in the layer
  139140. * @param scene Define the scene the layer belongs to
  139141. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  139142. * @param color Defines a color for the layer
  139143. */
  139144. constructor(
  139145. /**
  139146. * Define the name of the layer.
  139147. */
  139148. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  139149. private _createIndexBuffer;
  139150. /** @hidden */
  139151. _rebuild(): void;
  139152. /**
  139153. * Renders the layer in the scene.
  139154. */
  139155. render(): void;
  139156. /**
  139157. * Disposes and releases the associated ressources.
  139158. */
  139159. dispose(): void;
  139160. }
  139161. }
  139162. declare module BABYLON {
  139163. /** @hidden */
  139164. export var lensFlarePixelShader: {
  139165. name: string;
  139166. shader: string;
  139167. };
  139168. }
  139169. declare module BABYLON {
  139170. /** @hidden */
  139171. export var lensFlareVertexShader: {
  139172. name: string;
  139173. shader: string;
  139174. };
  139175. }
  139176. declare module BABYLON {
  139177. /**
  139178. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139179. * It is usually composed of several `lensFlare`.
  139180. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139181. */
  139182. export class LensFlareSystem {
  139183. /**
  139184. * Define the name of the lens flare system
  139185. */
  139186. name: string;
  139187. /**
  139188. * List of lens flares used in this system.
  139189. */
  139190. lensFlares: LensFlare[];
  139191. /**
  139192. * Define a limit from the border the lens flare can be visible.
  139193. */
  139194. borderLimit: number;
  139195. /**
  139196. * Define a viewport border we do not want to see the lens flare in.
  139197. */
  139198. viewportBorder: number;
  139199. /**
  139200. * Define a predicate which could limit the list of meshes able to occlude the effect.
  139201. */
  139202. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  139203. /**
  139204. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  139205. */
  139206. layerMask: number;
  139207. /**
  139208. * Define the id of the lens flare system in the scene.
  139209. * (equal to name by default)
  139210. */
  139211. id: string;
  139212. private _scene;
  139213. private _emitter;
  139214. private _vertexBuffers;
  139215. private _indexBuffer;
  139216. private _effect;
  139217. private _positionX;
  139218. private _positionY;
  139219. private _isEnabled;
  139220. /** @hidden */
  139221. static _SceneComponentInitialization: (scene: Scene) => void;
  139222. /**
  139223. * Instantiates a lens flare system.
  139224. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139225. * It is usually composed of several `lensFlare`.
  139226. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139227. * @param name Define the name of the lens flare system in the scene
  139228. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  139229. * @param scene Define the scene the lens flare system belongs to
  139230. */
  139231. constructor(
  139232. /**
  139233. * Define the name of the lens flare system
  139234. */
  139235. name: string, emitter: any, scene: Scene);
  139236. /**
  139237. * Define if the lens flare system is enabled.
  139238. */
  139239. get isEnabled(): boolean;
  139240. set isEnabled(value: boolean);
  139241. /**
  139242. * Get the scene the effects belongs to.
  139243. * @returns the scene holding the lens flare system
  139244. */
  139245. getScene(): Scene;
  139246. /**
  139247. * Get the emitter of the lens flare system.
  139248. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139249. * @returns the emitter of the lens flare system
  139250. */
  139251. getEmitter(): any;
  139252. /**
  139253. * Set the emitter of the lens flare system.
  139254. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139255. * @param newEmitter Define the new emitter of the system
  139256. */
  139257. setEmitter(newEmitter: any): void;
  139258. /**
  139259. * Get the lens flare system emitter position.
  139260. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  139261. * @returns the position
  139262. */
  139263. getEmitterPosition(): Vector3;
  139264. /**
  139265. * @hidden
  139266. */
  139267. computeEffectivePosition(globalViewport: Viewport): boolean;
  139268. /** @hidden */
  139269. _isVisible(): boolean;
  139270. /**
  139271. * @hidden
  139272. */
  139273. render(): boolean;
  139274. /**
  139275. * Dispose and release the lens flare with its associated resources.
  139276. */
  139277. dispose(): void;
  139278. /**
  139279. * Parse a lens flare system from a JSON repressentation
  139280. * @param parsedLensFlareSystem Define the JSON to parse
  139281. * @param scene Define the scene the parsed system should be instantiated in
  139282. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  139283. * @returns the parsed system
  139284. */
  139285. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  139286. /**
  139287. * Serialize the current Lens Flare System into a JSON representation.
  139288. * @returns the serialized JSON
  139289. */
  139290. serialize(): any;
  139291. }
  139292. }
  139293. declare module BABYLON {
  139294. /**
  139295. * This represents one of the lens effect in a `lensFlareSystem`.
  139296. * It controls one of the indiviual texture used in the effect.
  139297. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139298. */
  139299. export class LensFlare {
  139300. /**
  139301. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139302. */
  139303. size: number;
  139304. /**
  139305. * 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.
  139306. */
  139307. position: number;
  139308. /**
  139309. * Define the lens color.
  139310. */
  139311. color: Color3;
  139312. /**
  139313. * Define the lens texture.
  139314. */
  139315. texture: Nullable<Texture>;
  139316. /**
  139317. * Define the alpha mode to render this particular lens.
  139318. */
  139319. alphaMode: number;
  139320. private _system;
  139321. /**
  139322. * Creates a new Lens Flare.
  139323. * This represents one of the lens effect in a `lensFlareSystem`.
  139324. * It controls one of the indiviual texture used in the effect.
  139325. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139326. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  139327. * @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.
  139328. * @param color Define the lens color
  139329. * @param imgUrl Define the lens texture url
  139330. * @param system Define the `lensFlareSystem` this flare is part of
  139331. * @returns The newly created Lens Flare
  139332. */
  139333. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  139334. /**
  139335. * Instantiates a new Lens Flare.
  139336. * This represents one of the lens effect in a `lensFlareSystem`.
  139337. * It controls one of the indiviual texture used in the effect.
  139338. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139339. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  139340. * @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.
  139341. * @param color Define the lens color
  139342. * @param imgUrl Define the lens texture url
  139343. * @param system Define the `lensFlareSystem` this flare is part of
  139344. */
  139345. constructor(
  139346. /**
  139347. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139348. */
  139349. size: number,
  139350. /**
  139351. * 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.
  139352. */
  139353. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  139354. /**
  139355. * Dispose and release the lens flare with its associated resources.
  139356. */
  139357. dispose(): void;
  139358. }
  139359. }
  139360. declare module BABYLON {
  139361. interface AbstractScene {
  139362. /**
  139363. * The list of lens flare system added to the scene
  139364. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139365. */
  139366. lensFlareSystems: Array<LensFlareSystem>;
  139367. /**
  139368. * Removes the given lens flare system from this scene.
  139369. * @param toRemove The lens flare system to remove
  139370. * @returns The index of the removed lens flare system
  139371. */
  139372. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  139373. /**
  139374. * Adds the given lens flare system to this scene
  139375. * @param newLensFlareSystem The lens flare system to add
  139376. */
  139377. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  139378. /**
  139379. * Gets a lens flare system using its name
  139380. * @param name defines the name to look for
  139381. * @returns the lens flare system or null if not found
  139382. */
  139383. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  139384. /**
  139385. * Gets a lens flare system using its id
  139386. * @param id defines the id to look for
  139387. * @returns the lens flare system or null if not found
  139388. */
  139389. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  139390. }
  139391. /**
  139392. * Defines the lens flare scene component responsible to manage any lens flares
  139393. * in a given scene.
  139394. */
  139395. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  139396. /**
  139397. * The component name helpfull to identify the component in the list of scene components.
  139398. */
  139399. readonly name: string;
  139400. /**
  139401. * The scene the component belongs to.
  139402. */
  139403. scene: Scene;
  139404. /**
  139405. * Creates a new instance of the component for the given scene
  139406. * @param scene Defines the scene to register the component in
  139407. */
  139408. constructor(scene: Scene);
  139409. /**
  139410. * Registers the component in a given scene
  139411. */
  139412. register(): void;
  139413. /**
  139414. * Rebuilds the elements related to this component in case of
  139415. * context lost for instance.
  139416. */
  139417. rebuild(): void;
  139418. /**
  139419. * Adds all the elements from the container to the scene
  139420. * @param container the container holding the elements
  139421. */
  139422. addFromContainer(container: AbstractScene): void;
  139423. /**
  139424. * Removes all the elements in the container from the scene
  139425. * @param container contains the elements to remove
  139426. * @param dispose if the removed element should be disposed (default: false)
  139427. */
  139428. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139429. /**
  139430. * Serializes the component data to the specified json object
  139431. * @param serializationObject The object to serialize to
  139432. */
  139433. serialize(serializationObject: any): void;
  139434. /**
  139435. * Disposes the component and the associated ressources.
  139436. */
  139437. dispose(): void;
  139438. private _draw;
  139439. }
  139440. }
  139441. declare module BABYLON {
  139442. /** @hidden */
  139443. export var depthPixelShader: {
  139444. name: string;
  139445. shader: string;
  139446. };
  139447. }
  139448. declare module BABYLON {
  139449. /** @hidden */
  139450. export var depthVertexShader: {
  139451. name: string;
  139452. shader: string;
  139453. };
  139454. }
  139455. declare module BABYLON {
  139456. /**
  139457. * This represents a depth renderer in Babylon.
  139458. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  139459. */
  139460. export class DepthRenderer {
  139461. private _scene;
  139462. private _depthMap;
  139463. private _effect;
  139464. private readonly _storeNonLinearDepth;
  139465. private readonly _clearColor;
  139466. /** Get if the depth renderer is using packed depth or not */
  139467. readonly isPacked: boolean;
  139468. private _cachedDefines;
  139469. private _camera;
  139470. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  139471. enabled: boolean;
  139472. /**
  139473. * Specifiess that the depth renderer will only be used within
  139474. * the camera it is created for.
  139475. * This can help forcing its rendering during the camera processing.
  139476. */
  139477. useOnlyInActiveCamera: boolean;
  139478. /** @hidden */
  139479. static _SceneComponentInitialization: (scene: Scene) => void;
  139480. /**
  139481. * Instantiates a depth renderer
  139482. * @param scene The scene the renderer belongs to
  139483. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  139484. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  139485. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139486. */
  139487. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  139488. /**
  139489. * Creates the depth rendering effect and checks if the effect is ready.
  139490. * @param subMesh The submesh to be used to render the depth map of
  139491. * @param useInstances If multiple world instances should be used
  139492. * @returns if the depth renderer is ready to render the depth map
  139493. */
  139494. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139495. /**
  139496. * Gets the texture which the depth map will be written to.
  139497. * @returns The depth map texture
  139498. */
  139499. getDepthMap(): RenderTargetTexture;
  139500. /**
  139501. * Disposes of the depth renderer.
  139502. */
  139503. dispose(): void;
  139504. }
  139505. }
  139506. declare module BABYLON {
  139507. /** @hidden */
  139508. export var minmaxReduxPixelShader: {
  139509. name: string;
  139510. shader: string;
  139511. };
  139512. }
  139513. declare module BABYLON {
  139514. /**
  139515. * This class computes a min/max reduction from a texture: it means it computes the minimum
  139516. * and maximum values from all values of the texture.
  139517. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  139518. * The source values are read from the red channel of the texture.
  139519. */
  139520. export class MinMaxReducer {
  139521. /**
  139522. * Observable triggered when the computation has been performed
  139523. */
  139524. onAfterReductionPerformed: Observable<{
  139525. min: number;
  139526. max: number;
  139527. }>;
  139528. protected _camera: Camera;
  139529. protected _sourceTexture: Nullable<RenderTargetTexture>;
  139530. protected _reductionSteps: Nullable<Array<PostProcess>>;
  139531. protected _postProcessManager: PostProcessManager;
  139532. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  139533. protected _forceFullscreenViewport: boolean;
  139534. /**
  139535. * Creates a min/max reducer
  139536. * @param camera The camera to use for the post processes
  139537. */
  139538. constructor(camera: Camera);
  139539. /**
  139540. * Gets the texture used to read the values from.
  139541. */
  139542. get sourceTexture(): Nullable<RenderTargetTexture>;
  139543. /**
  139544. * Sets the source texture to read the values from.
  139545. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  139546. * because in such textures '1' value must not be taken into account to compute the maximum
  139547. * as this value is used to clear the texture.
  139548. * Note that the computation is not activated by calling this function, you must call activate() for that!
  139549. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  139550. * @param depthRedux Indicates if the texture is a depth texture or not
  139551. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  139552. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  139553. */
  139554. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  139555. /**
  139556. * Defines the refresh rate of the computation.
  139557. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  139558. */
  139559. get refreshRate(): number;
  139560. set refreshRate(value: number);
  139561. protected _activated: boolean;
  139562. /**
  139563. * Gets the activation status of the reducer
  139564. */
  139565. get activated(): boolean;
  139566. /**
  139567. * Activates the reduction computation.
  139568. * When activated, the observers registered in onAfterReductionPerformed are
  139569. * called after the compuation is performed
  139570. */
  139571. activate(): void;
  139572. /**
  139573. * Deactivates the reduction computation.
  139574. */
  139575. deactivate(): void;
  139576. /**
  139577. * Disposes the min/max reducer
  139578. * @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.
  139579. */
  139580. dispose(disposeAll?: boolean): void;
  139581. }
  139582. }
  139583. declare module BABYLON {
  139584. /**
  139585. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  139586. */
  139587. export class DepthReducer extends MinMaxReducer {
  139588. private _depthRenderer;
  139589. private _depthRendererId;
  139590. /**
  139591. * Gets the depth renderer used for the computation.
  139592. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  139593. */
  139594. get depthRenderer(): Nullable<DepthRenderer>;
  139595. /**
  139596. * Creates a depth reducer
  139597. * @param camera The camera used to render the depth texture
  139598. */
  139599. constructor(camera: Camera);
  139600. /**
  139601. * Sets the depth renderer to use to generate the depth map
  139602. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  139603. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  139604. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  139605. */
  139606. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  139607. /** @hidden */
  139608. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  139609. /**
  139610. * Activates the reduction computation.
  139611. * When activated, the observers registered in onAfterReductionPerformed are
  139612. * called after the compuation is performed
  139613. */
  139614. activate(): void;
  139615. /**
  139616. * Deactivates the reduction computation.
  139617. */
  139618. deactivate(): void;
  139619. /**
  139620. * Disposes the depth reducer
  139621. * @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.
  139622. */
  139623. dispose(disposeAll?: boolean): void;
  139624. }
  139625. }
  139626. declare module BABYLON {
  139627. /**
  139628. * A CSM implementation allowing casting shadows on large scenes.
  139629. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  139630. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  139631. */
  139632. export class CascadedShadowGenerator extends ShadowGenerator {
  139633. private static readonly frustumCornersNDCSpace;
  139634. /**
  139635. * Name of the CSM class
  139636. */
  139637. static CLASSNAME: string;
  139638. /**
  139639. * Defines the default number of cascades used by the CSM.
  139640. */
  139641. static readonly DEFAULT_CASCADES_COUNT: number;
  139642. /**
  139643. * Defines the minimum number of cascades used by the CSM.
  139644. */
  139645. static readonly MIN_CASCADES_COUNT: number;
  139646. /**
  139647. * Defines the maximum number of cascades used by the CSM.
  139648. */
  139649. static readonly MAX_CASCADES_COUNT: number;
  139650. protected _validateFilter(filter: number): number;
  139651. /**
  139652. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  139653. */
  139654. penumbraDarkness: number;
  139655. private _numCascades;
  139656. /**
  139657. * Gets or set the number of cascades used by the CSM.
  139658. */
  139659. get numCascades(): number;
  139660. set numCascades(value: number);
  139661. /**
  139662. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  139663. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  139664. */
  139665. stabilizeCascades: boolean;
  139666. private _freezeShadowCastersBoundingInfo;
  139667. private _freezeShadowCastersBoundingInfoObservable;
  139668. /**
  139669. * Enables or disables the shadow casters bounding info computation.
  139670. * If your shadow casters don't move, you can disable this feature.
  139671. * If it is enabled, the bounding box computation is done every frame.
  139672. */
  139673. get freezeShadowCastersBoundingInfo(): boolean;
  139674. set freezeShadowCastersBoundingInfo(freeze: boolean);
  139675. private _scbiMin;
  139676. private _scbiMax;
  139677. protected _computeShadowCastersBoundingInfo(): void;
  139678. protected _shadowCastersBoundingInfo: BoundingInfo;
  139679. /**
  139680. * Gets or sets the shadow casters bounding info.
  139681. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  139682. * so that the system won't overwrite the bounds you provide
  139683. */
  139684. get shadowCastersBoundingInfo(): BoundingInfo;
  139685. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  139686. protected _breaksAreDirty: boolean;
  139687. protected _minDistance: number;
  139688. protected _maxDistance: number;
  139689. /**
  139690. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  139691. *
  139692. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  139693. * If you don't know these values, simply leave them to their defaults and don't call this function.
  139694. * @param min minimal distance for the breaks (default to 0.)
  139695. * @param max maximal distance for the breaks (default to 1.)
  139696. */
  139697. setMinMaxDistance(min: number, max: number): void;
  139698. /** Gets the minimal distance used in the cascade break computation */
  139699. get minDistance(): number;
  139700. /** Gets the maximal distance used in the cascade break computation */
  139701. get maxDistance(): number;
  139702. /**
  139703. * Gets the class name of that object
  139704. * @returns "CascadedShadowGenerator"
  139705. */
  139706. getClassName(): string;
  139707. private _cascadeMinExtents;
  139708. private _cascadeMaxExtents;
  139709. /**
  139710. * Gets a cascade minimum extents
  139711. * @param cascadeIndex index of the cascade
  139712. * @returns the minimum cascade extents
  139713. */
  139714. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  139715. /**
  139716. * Gets a cascade maximum extents
  139717. * @param cascadeIndex index of the cascade
  139718. * @returns the maximum cascade extents
  139719. */
  139720. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  139721. private _cascades;
  139722. private _currentLayer;
  139723. private _viewSpaceFrustumsZ;
  139724. private _viewMatrices;
  139725. private _projectionMatrices;
  139726. private _transformMatrices;
  139727. private _transformMatricesAsArray;
  139728. private _frustumLengths;
  139729. private _lightSizeUVCorrection;
  139730. private _depthCorrection;
  139731. private _frustumCornersWorldSpace;
  139732. private _frustumCenter;
  139733. private _shadowCameraPos;
  139734. private _shadowMaxZ;
  139735. /**
  139736. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  139737. * It defaults to camera.maxZ
  139738. */
  139739. get shadowMaxZ(): number;
  139740. /**
  139741. * Sets the shadow max z distance.
  139742. */
  139743. set shadowMaxZ(value: number);
  139744. protected _debug: boolean;
  139745. /**
  139746. * Gets or sets the debug flag.
  139747. * When enabled, the cascades are materialized by different colors on the screen.
  139748. */
  139749. get debug(): boolean;
  139750. set debug(dbg: boolean);
  139751. private _depthClamp;
  139752. /**
  139753. * Gets or sets the depth clamping value.
  139754. *
  139755. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  139756. * to account for the shadow casters far away.
  139757. *
  139758. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  139759. */
  139760. get depthClamp(): boolean;
  139761. set depthClamp(value: boolean);
  139762. private _cascadeBlendPercentage;
  139763. /**
  139764. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  139765. * It defaults to 0.1 (10% blending).
  139766. */
  139767. get cascadeBlendPercentage(): number;
  139768. set cascadeBlendPercentage(value: number);
  139769. private _lambda;
  139770. /**
  139771. * Gets or set the lambda parameter.
  139772. * This parameter is used to split the camera frustum and create the cascades.
  139773. * 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.
  139774. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  139775. */
  139776. get lambda(): number;
  139777. set lambda(value: number);
  139778. /**
  139779. * Gets the view matrix corresponding to a given cascade
  139780. * @param cascadeNum cascade to retrieve the view matrix from
  139781. * @returns the cascade view matrix
  139782. */
  139783. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  139784. /**
  139785. * Gets the projection matrix corresponding to a given cascade
  139786. * @param cascadeNum cascade to retrieve the projection matrix from
  139787. * @returns the cascade projection matrix
  139788. */
  139789. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  139790. /**
  139791. * Gets the transformation matrix corresponding to a given cascade
  139792. * @param cascadeNum cascade to retrieve the transformation matrix from
  139793. * @returns the cascade transformation matrix
  139794. */
  139795. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  139796. private _depthRenderer;
  139797. /**
  139798. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  139799. *
  139800. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  139801. *
  139802. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  139803. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  139804. * @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
  139805. */
  139806. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  139807. private _depthReducer;
  139808. private _autoCalcDepthBounds;
  139809. /**
  139810. * Gets or sets the autoCalcDepthBounds property.
  139811. *
  139812. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  139813. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  139814. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  139815. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  139816. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  139817. */
  139818. get autoCalcDepthBounds(): boolean;
  139819. set autoCalcDepthBounds(value: boolean);
  139820. /**
  139821. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  139822. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  139823. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  139824. * for setting the refresh rate on the renderer yourself!
  139825. */
  139826. get autoCalcDepthBoundsRefreshRate(): number;
  139827. set autoCalcDepthBoundsRefreshRate(value: number);
  139828. /**
  139829. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  139830. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  139831. * you change the camera near/far planes!
  139832. */
  139833. splitFrustum(): void;
  139834. private _splitFrustum;
  139835. private _computeMatrices;
  139836. private _computeFrustumInWorldSpace;
  139837. private _computeCascadeFrustum;
  139838. /**
  139839. * Support test.
  139840. */
  139841. static get IsSupported(): boolean;
  139842. /** @hidden */
  139843. static _SceneComponentInitialization: (scene: Scene) => void;
  139844. /**
  139845. * Creates a Cascaded Shadow Generator object.
  139846. * A ShadowGenerator is the required tool to use the shadows.
  139847. * Each directional light casting shadows needs to use its own ShadowGenerator.
  139848. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  139849. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  139850. * @param light The directional light object generating the shadows.
  139851. * @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.
  139852. */
  139853. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  139854. protected _initializeGenerator(): void;
  139855. protected _createTargetRenderTexture(): void;
  139856. protected _initializeShadowMap(): void;
  139857. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  139858. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  139859. /**
  139860. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  139861. * @param defines Defines of the material we want to update
  139862. * @param lightIndex Index of the light in the enabled light list of the material
  139863. */
  139864. prepareDefines(defines: any, lightIndex: number): void;
  139865. /**
  139866. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  139867. * defined in the generator but impacting the effect).
  139868. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  139869. * @param effect The effect we are binfing the information for
  139870. */
  139871. bindShadowLight(lightIndex: string, effect: Effect): void;
  139872. /**
  139873. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  139874. * (eq to view projection * shadow projection matrices)
  139875. * @returns The transform matrix used to create the shadow map
  139876. */
  139877. getTransformMatrix(): Matrix;
  139878. /**
  139879. * Disposes the ShadowGenerator.
  139880. * Returns nothing.
  139881. */
  139882. dispose(): void;
  139883. /**
  139884. * Serializes the shadow generator setup to a json object.
  139885. * @returns The serialized JSON object
  139886. */
  139887. serialize(): any;
  139888. /**
  139889. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  139890. * @param parsedShadowGenerator The JSON object to parse
  139891. * @param scene The scene to create the shadow map for
  139892. * @returns The parsed shadow generator
  139893. */
  139894. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  139895. }
  139896. }
  139897. declare module BABYLON {
  139898. /**
  139899. * Defines the shadow generator component responsible to manage any shadow generators
  139900. * in a given scene.
  139901. */
  139902. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  139903. /**
  139904. * The component name helpfull to identify the component in the list of scene components.
  139905. */
  139906. readonly name: string;
  139907. /**
  139908. * The scene the component belongs to.
  139909. */
  139910. scene: Scene;
  139911. /**
  139912. * Creates a new instance of the component for the given scene
  139913. * @param scene Defines the scene to register the component in
  139914. */
  139915. constructor(scene: Scene);
  139916. /**
  139917. * Registers the component in a given scene
  139918. */
  139919. register(): void;
  139920. /**
  139921. * Rebuilds the elements related to this component in case of
  139922. * context lost for instance.
  139923. */
  139924. rebuild(): void;
  139925. /**
  139926. * Serializes the component data to the specified json object
  139927. * @param serializationObject The object to serialize to
  139928. */
  139929. serialize(serializationObject: any): void;
  139930. /**
  139931. * Adds all the elements from the container to the scene
  139932. * @param container the container holding the elements
  139933. */
  139934. addFromContainer(container: AbstractScene): void;
  139935. /**
  139936. * Removes all the elements in the container from the scene
  139937. * @param container contains the elements to remove
  139938. * @param dispose if the removed element should be disposed (default: false)
  139939. */
  139940. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139941. /**
  139942. * Rebuilds the elements related to this component in case of
  139943. * context lost for instance.
  139944. */
  139945. dispose(): void;
  139946. private _gatherRenderTargets;
  139947. }
  139948. }
  139949. declare module BABYLON {
  139950. /**
  139951. * A point light is a light defined by an unique point in world space.
  139952. * The light is emitted in every direction from this point.
  139953. * A good example of a point light is a standard light bulb.
  139954. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139955. */
  139956. export class PointLight extends ShadowLight {
  139957. private _shadowAngle;
  139958. /**
  139959. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139960. * This specifies what angle the shadow will use to be created.
  139961. *
  139962. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  139963. */
  139964. get shadowAngle(): number;
  139965. /**
  139966. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139967. * This specifies what angle the shadow will use to be created.
  139968. *
  139969. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  139970. */
  139971. set shadowAngle(value: number);
  139972. /**
  139973. * Gets the direction if it has been set.
  139974. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139975. */
  139976. get direction(): Vector3;
  139977. /**
  139978. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139979. */
  139980. set direction(value: Vector3);
  139981. /**
  139982. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  139983. * A PointLight emits the light in every direction.
  139984. * It can cast shadows.
  139985. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  139986. * ```javascript
  139987. * var pointLight = new PointLight("pl", camera.position, scene);
  139988. * ```
  139989. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139990. * @param name The light friendly name
  139991. * @param position The position of the point light in the scene
  139992. * @param scene The scene the lights belongs to
  139993. */
  139994. constructor(name: string, position: Vector3, scene: Scene);
  139995. /**
  139996. * Returns the string "PointLight"
  139997. * @returns the class name
  139998. */
  139999. getClassName(): string;
  140000. /**
  140001. * Returns the integer 0.
  140002. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  140003. */
  140004. getTypeID(): number;
  140005. /**
  140006. * Specifies wether or not the shadowmap should be a cube texture.
  140007. * @returns true if the shadowmap needs to be a cube texture.
  140008. */
  140009. needCube(): boolean;
  140010. /**
  140011. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  140012. * @param faceIndex The index of the face we are computed the direction to generate shadow
  140013. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  140014. */
  140015. getShadowDirection(faceIndex?: number): Vector3;
  140016. /**
  140017. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  140018. * - fov = PI / 2
  140019. * - aspect ratio : 1.0
  140020. * - z-near and far equal to the active camera minZ and maxZ.
  140021. * Returns the PointLight.
  140022. */
  140023. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  140024. protected _buildUniformLayout(): void;
  140025. /**
  140026. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  140027. * @param effect The effect to update
  140028. * @param lightIndex The index of the light in the effect to update
  140029. * @returns The point light
  140030. */
  140031. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  140032. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  140033. /**
  140034. * Prepares the list of defines specific to the light type.
  140035. * @param defines the list of defines
  140036. * @param lightIndex defines the index of the light for the effect
  140037. */
  140038. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  140039. }
  140040. }
  140041. declare module BABYLON {
  140042. /**
  140043. * Header information of HDR texture files.
  140044. */
  140045. export interface HDRInfo {
  140046. /**
  140047. * The height of the texture in pixels.
  140048. */
  140049. height: number;
  140050. /**
  140051. * The width of the texture in pixels.
  140052. */
  140053. width: number;
  140054. /**
  140055. * The index of the beginning of the data in the binary file.
  140056. */
  140057. dataPosition: number;
  140058. }
  140059. /**
  140060. * This groups tools to convert HDR texture to native colors array.
  140061. */
  140062. export class HDRTools {
  140063. private static Ldexp;
  140064. private static Rgbe2float;
  140065. private static readStringLine;
  140066. /**
  140067. * Reads header information from an RGBE texture stored in a native array.
  140068. * More information on this format are available here:
  140069. * https://en.wikipedia.org/wiki/RGBE_image_format
  140070. *
  140071. * @param uint8array The binary file stored in native array.
  140072. * @return The header information.
  140073. */
  140074. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  140075. /**
  140076. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  140077. * This RGBE texture needs to store the information as a panorama.
  140078. *
  140079. * More information on this format are available here:
  140080. * https://en.wikipedia.org/wiki/RGBE_image_format
  140081. *
  140082. * @param buffer The binary file stored in an array buffer.
  140083. * @param size The expected size of the extracted cubemap.
  140084. * @return The Cube Map information.
  140085. */
  140086. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  140087. /**
  140088. * Returns the pixels data extracted from an RGBE texture.
  140089. * This pixels will be stored left to right up to down in the R G B order in one array.
  140090. *
  140091. * More information on this format are available here:
  140092. * https://en.wikipedia.org/wiki/RGBE_image_format
  140093. *
  140094. * @param uint8array The binary file stored in an array buffer.
  140095. * @param hdrInfo The header information of the file.
  140096. * @return The pixels data in RGB right to left up to down order.
  140097. */
  140098. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  140099. private static RGBE_ReadPixels_RLE;
  140100. private static RGBE_ReadPixels_NOT_RLE;
  140101. }
  140102. }
  140103. declare module BABYLON {
  140104. /**
  140105. * Effect Render Options
  140106. */
  140107. export interface IEffectRendererOptions {
  140108. /**
  140109. * Defines the vertices positions.
  140110. */
  140111. positions?: number[];
  140112. /**
  140113. * Defines the indices.
  140114. */
  140115. indices?: number[];
  140116. }
  140117. /**
  140118. * Helper class to render one or more effects.
  140119. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  140120. */
  140121. export class EffectRenderer {
  140122. private engine;
  140123. private static _DefaultOptions;
  140124. private _vertexBuffers;
  140125. private _indexBuffer;
  140126. private _fullscreenViewport;
  140127. /**
  140128. * Creates an effect renderer
  140129. * @param engine the engine to use for rendering
  140130. * @param options defines the options of the effect renderer
  140131. */
  140132. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  140133. /**
  140134. * Sets the current viewport in normalized coordinates 0-1
  140135. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  140136. */
  140137. setViewport(viewport?: Viewport): void;
  140138. /**
  140139. * Binds the embedded attributes buffer to the effect.
  140140. * @param effect Defines the effect to bind the attributes for
  140141. */
  140142. bindBuffers(effect: Effect): void;
  140143. /**
  140144. * Sets the current effect wrapper to use during draw.
  140145. * The effect needs to be ready before calling this api.
  140146. * This also sets the default full screen position attribute.
  140147. * @param effectWrapper Defines the effect to draw with
  140148. */
  140149. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  140150. /**
  140151. * Restores engine states
  140152. */
  140153. restoreStates(): void;
  140154. /**
  140155. * Draws a full screen quad.
  140156. */
  140157. draw(): void;
  140158. private isRenderTargetTexture;
  140159. /**
  140160. * renders one or more effects to a specified texture
  140161. * @param effectWrapper the effect to renderer
  140162. * @param outputTexture texture to draw to, if null it will render to the screen.
  140163. */
  140164. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  140165. /**
  140166. * Disposes of the effect renderer
  140167. */
  140168. dispose(): void;
  140169. }
  140170. /**
  140171. * Options to create an EffectWrapper
  140172. */
  140173. interface EffectWrapperCreationOptions {
  140174. /**
  140175. * Engine to use to create the effect
  140176. */
  140177. engine: ThinEngine;
  140178. /**
  140179. * Fragment shader for the effect
  140180. */
  140181. fragmentShader: string;
  140182. /**
  140183. * Use the shader store instead of direct source code
  140184. */
  140185. useShaderStore?: boolean;
  140186. /**
  140187. * Vertex shader for the effect
  140188. */
  140189. vertexShader?: string;
  140190. /**
  140191. * Attributes to use in the shader
  140192. */
  140193. attributeNames?: Array<string>;
  140194. /**
  140195. * Uniforms to use in the shader
  140196. */
  140197. uniformNames?: Array<string>;
  140198. /**
  140199. * Texture sampler names to use in the shader
  140200. */
  140201. samplerNames?: Array<string>;
  140202. /**
  140203. * Defines to use in the shader
  140204. */
  140205. defines?: Array<string>;
  140206. /**
  140207. * Callback when effect is compiled
  140208. */
  140209. onCompiled?: Nullable<(effect: Effect) => void>;
  140210. /**
  140211. * The friendly name of the effect displayed in Spector.
  140212. */
  140213. name?: string;
  140214. }
  140215. /**
  140216. * Wraps an effect to be used for rendering
  140217. */
  140218. export class EffectWrapper {
  140219. /**
  140220. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  140221. */
  140222. onApplyObservable: Observable<{}>;
  140223. /**
  140224. * The underlying effect
  140225. */
  140226. effect: Effect;
  140227. /**
  140228. * Creates an effect to be renderer
  140229. * @param creationOptions options to create the effect
  140230. */
  140231. constructor(creationOptions: EffectWrapperCreationOptions);
  140232. /**
  140233. * Disposes of the effect wrapper
  140234. */
  140235. dispose(): void;
  140236. }
  140237. }
  140238. declare module BABYLON {
  140239. /** @hidden */
  140240. export var hdrFilteringVertexShader: {
  140241. name: string;
  140242. shader: string;
  140243. };
  140244. }
  140245. declare module BABYLON {
  140246. /** @hidden */
  140247. export var hdrFilteringPixelShader: {
  140248. name: string;
  140249. shader: string;
  140250. };
  140251. }
  140252. declare module BABYLON {
  140253. /**
  140254. * Options for texture filtering
  140255. */
  140256. interface IHDRFilteringOptions {
  140257. /**
  140258. * Scales pixel intensity for the input HDR map.
  140259. */
  140260. hdrScale?: number;
  140261. /**
  140262. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  140263. */
  140264. quality?: number;
  140265. }
  140266. /**
  140267. * Filters HDR maps to get correct renderings of PBR reflections
  140268. */
  140269. export class HDRFiltering {
  140270. private _engine;
  140271. private _effectRenderer;
  140272. private _effectWrapper;
  140273. private _lodGenerationOffset;
  140274. private _lodGenerationScale;
  140275. /**
  140276. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  140277. * you care about baking speed.
  140278. */
  140279. quality: number;
  140280. /**
  140281. * Scales pixel intensity for the input HDR map.
  140282. */
  140283. hdrScale: number;
  140284. /**
  140285. * Instantiates HDR filter for reflection maps
  140286. *
  140287. * @param engine Thin engine
  140288. * @param options Options
  140289. */
  140290. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  140291. private _createRenderTarget;
  140292. private _prefilterInternal;
  140293. private _createEffect;
  140294. /**
  140295. * Get a value indicating if the filter is ready to be used
  140296. * @param texture Texture to filter
  140297. * @returns true if the filter is ready
  140298. */
  140299. isReady(texture: BaseTexture): boolean;
  140300. /**
  140301. * Prefilters a cube texture to have mipmap levels representing roughness values.
  140302. * Prefiltering will be invoked at the end of next rendering pass.
  140303. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  140304. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  140305. * @param texture Texture to filter
  140306. * @param onFinished Callback when filtering is done
  140307. * @return Promise called when prefiltering is done
  140308. */
  140309. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  140310. }
  140311. }
  140312. declare module BABYLON {
  140313. /**
  140314. * This represents a texture coming from an HDR input.
  140315. *
  140316. * The only supported format is currently panorama picture stored in RGBE format.
  140317. * Example of such files can be found on HDRLib: http://hdrlib.com/
  140318. */
  140319. export class HDRCubeTexture extends BaseTexture {
  140320. private static _facesMapping;
  140321. private _generateHarmonics;
  140322. private _noMipmap;
  140323. private _prefilterOnLoad;
  140324. private _textureMatrix;
  140325. private _size;
  140326. private _onLoad;
  140327. private _onError;
  140328. /**
  140329. * The texture URL.
  140330. */
  140331. url: string;
  140332. protected _isBlocking: boolean;
  140333. /**
  140334. * Sets wether or not the texture is blocking during loading.
  140335. */
  140336. set isBlocking(value: boolean);
  140337. /**
  140338. * Gets wether or not the texture is blocking during loading.
  140339. */
  140340. get isBlocking(): boolean;
  140341. protected _rotationY: number;
  140342. /**
  140343. * Sets texture matrix rotation angle around Y axis in radians.
  140344. */
  140345. set rotationY(value: number);
  140346. /**
  140347. * Gets texture matrix rotation angle around Y axis radians.
  140348. */
  140349. get rotationY(): number;
  140350. /**
  140351. * Gets or sets the center of the bounding box associated with the cube texture
  140352. * It must define where the camera used to render the texture was set
  140353. */
  140354. boundingBoxPosition: Vector3;
  140355. private _boundingBoxSize;
  140356. /**
  140357. * Gets or sets the size of the bounding box associated with the cube texture
  140358. * When defined, the cubemap will switch to local mode
  140359. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  140360. * @example https://www.babylonjs-playground.com/#RNASML
  140361. */
  140362. set boundingBoxSize(value: Vector3);
  140363. get boundingBoxSize(): Vector3;
  140364. /**
  140365. * Instantiates an HDRTexture from the following parameters.
  140366. *
  140367. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  140368. * @param sceneOrEngine The scene or engine the texture will be used in
  140369. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  140370. * @param noMipmap Forces to not generate the mipmap if true
  140371. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  140372. * @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)
  140373. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  140374. */
  140375. 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>);
  140376. /**
  140377. * Get the current class name of the texture useful for serialization or dynamic coding.
  140378. * @returns "HDRCubeTexture"
  140379. */
  140380. getClassName(): string;
  140381. /**
  140382. * Occurs when the file is raw .hdr file.
  140383. */
  140384. private loadTexture;
  140385. clone(): HDRCubeTexture;
  140386. delayLoad(): void;
  140387. /**
  140388. * Get the texture reflection matrix used to rotate/transform the reflection.
  140389. * @returns the reflection matrix
  140390. */
  140391. getReflectionTextureMatrix(): Matrix;
  140392. /**
  140393. * Set the texture reflection matrix used to rotate/transform the reflection.
  140394. * @param value Define the reflection matrix to set
  140395. */
  140396. setReflectionTextureMatrix(value: Matrix): void;
  140397. /**
  140398. * Parses a JSON representation of an HDR Texture in order to create the texture
  140399. * @param parsedTexture Define the JSON representation
  140400. * @param scene Define the scene the texture should be created in
  140401. * @param rootUrl Define the root url in case we need to load relative dependencies
  140402. * @returns the newly created texture after parsing
  140403. */
  140404. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  140405. serialize(): any;
  140406. }
  140407. }
  140408. declare module BABYLON {
  140409. /**
  140410. * Class used to control physics engine
  140411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140412. */
  140413. export class PhysicsEngine implements IPhysicsEngine {
  140414. private _physicsPlugin;
  140415. /**
  140416. * Global value used to control the smallest number supported by the simulation
  140417. */
  140418. static Epsilon: number;
  140419. private _impostors;
  140420. private _joints;
  140421. private _subTimeStep;
  140422. /**
  140423. * Gets the gravity vector used by the simulation
  140424. */
  140425. gravity: Vector3;
  140426. /**
  140427. * Factory used to create the default physics plugin.
  140428. * @returns The default physics plugin
  140429. */
  140430. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  140431. /**
  140432. * Creates a new Physics Engine
  140433. * @param gravity defines the gravity vector used by the simulation
  140434. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  140435. */
  140436. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  140437. /**
  140438. * Sets the gravity vector used by the simulation
  140439. * @param gravity defines the gravity vector to use
  140440. */
  140441. setGravity(gravity: Vector3): void;
  140442. /**
  140443. * Set the time step of the physics engine.
  140444. * Default is 1/60.
  140445. * To slow it down, enter 1/600 for example.
  140446. * To speed it up, 1/30
  140447. * @param newTimeStep defines the new timestep to apply to this world.
  140448. */
  140449. setTimeStep(newTimeStep?: number): void;
  140450. /**
  140451. * Get the time step of the physics engine.
  140452. * @returns the current time step
  140453. */
  140454. getTimeStep(): number;
  140455. /**
  140456. * Set the sub time step of the physics engine.
  140457. * Default is 0 meaning there is no sub steps
  140458. * To increase physics resolution precision, set a small value (like 1 ms)
  140459. * @param subTimeStep defines the new sub timestep used for physics resolution.
  140460. */
  140461. setSubTimeStep(subTimeStep?: number): void;
  140462. /**
  140463. * Get the sub time step of the physics engine.
  140464. * @returns the current sub time step
  140465. */
  140466. getSubTimeStep(): number;
  140467. /**
  140468. * Release all resources
  140469. */
  140470. dispose(): void;
  140471. /**
  140472. * Gets the name of the current physics plugin
  140473. * @returns the name of the plugin
  140474. */
  140475. getPhysicsPluginName(): string;
  140476. /**
  140477. * Adding a new impostor for the impostor tracking.
  140478. * This will be done by the impostor itself.
  140479. * @param impostor the impostor to add
  140480. */
  140481. addImpostor(impostor: PhysicsImpostor): void;
  140482. /**
  140483. * Remove an impostor from the engine.
  140484. * This impostor and its mesh will not longer be updated by the physics engine.
  140485. * @param impostor the impostor to remove
  140486. */
  140487. removeImpostor(impostor: PhysicsImpostor): void;
  140488. /**
  140489. * Add a joint to the physics engine
  140490. * @param mainImpostor defines the main impostor to which the joint is added.
  140491. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  140492. * @param joint defines the joint that will connect both impostors.
  140493. */
  140494. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  140495. /**
  140496. * Removes a joint from the simulation
  140497. * @param mainImpostor defines the impostor used with the joint
  140498. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  140499. * @param joint defines the joint to remove
  140500. */
  140501. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  140502. /**
  140503. * Called by the scene. No need to call it.
  140504. * @param delta defines the timespam between frames
  140505. */
  140506. _step(delta: number): void;
  140507. /**
  140508. * Gets the current plugin used to run the simulation
  140509. * @returns current plugin
  140510. */
  140511. getPhysicsPlugin(): IPhysicsEnginePlugin;
  140512. /**
  140513. * Gets the list of physic impostors
  140514. * @returns an array of PhysicsImpostor
  140515. */
  140516. getImpostors(): Array<PhysicsImpostor>;
  140517. /**
  140518. * Gets the impostor for a physics enabled object
  140519. * @param object defines the object impersonated by the impostor
  140520. * @returns the PhysicsImpostor or null if not found
  140521. */
  140522. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  140523. /**
  140524. * Gets the impostor for a physics body object
  140525. * @param body defines physics body used by the impostor
  140526. * @returns the PhysicsImpostor or null if not found
  140527. */
  140528. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  140529. /**
  140530. * Does a raycast in the physics world
  140531. * @param from when should the ray start?
  140532. * @param to when should the ray end?
  140533. * @returns PhysicsRaycastResult
  140534. */
  140535. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140536. }
  140537. }
  140538. declare module BABYLON {
  140539. /** @hidden */
  140540. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  140541. private _useDeltaForWorldStep;
  140542. world: any;
  140543. name: string;
  140544. private _physicsMaterials;
  140545. private _fixedTimeStep;
  140546. private _cannonRaycastResult;
  140547. private _raycastResult;
  140548. private _physicsBodysToRemoveAfterStep;
  140549. private _firstFrame;
  140550. BJSCANNON: any;
  140551. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  140552. setGravity(gravity: Vector3): void;
  140553. setTimeStep(timeStep: number): void;
  140554. getTimeStep(): number;
  140555. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140556. private _removeMarkedPhysicsBodiesFromWorld;
  140557. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140558. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140559. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140560. private _processChildMeshes;
  140561. removePhysicsBody(impostor: PhysicsImpostor): void;
  140562. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140563. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140564. private _addMaterial;
  140565. private _checkWithEpsilon;
  140566. private _createShape;
  140567. private _createHeightmap;
  140568. private _minus90X;
  140569. private _plus90X;
  140570. private _tmpPosition;
  140571. private _tmpDeltaPosition;
  140572. private _tmpUnityRotation;
  140573. private _updatePhysicsBodyTransformation;
  140574. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140575. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140576. isSupported(): boolean;
  140577. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140578. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140579. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140580. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140581. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140582. getBodyMass(impostor: PhysicsImpostor): number;
  140583. getBodyFriction(impostor: PhysicsImpostor): number;
  140584. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140585. getBodyRestitution(impostor: PhysicsImpostor): number;
  140586. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140587. sleepBody(impostor: PhysicsImpostor): void;
  140588. wakeUpBody(impostor: PhysicsImpostor): void;
  140589. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  140590. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  140591. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  140592. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140593. getRadius(impostor: PhysicsImpostor): number;
  140594. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140595. dispose(): void;
  140596. private _extendNamespace;
  140597. /**
  140598. * Does a raycast in the physics world
  140599. * @param from when should the ray start?
  140600. * @param to when should the ray end?
  140601. * @returns PhysicsRaycastResult
  140602. */
  140603. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140604. }
  140605. }
  140606. declare module BABYLON {
  140607. /** @hidden */
  140608. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  140609. private _useDeltaForWorldStep;
  140610. world: any;
  140611. name: string;
  140612. BJSOIMO: any;
  140613. private _raycastResult;
  140614. private _fixedTimeStep;
  140615. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  140616. setGravity(gravity: Vector3): void;
  140617. setTimeStep(timeStep: number): void;
  140618. getTimeStep(): number;
  140619. private _tmpImpostorsArray;
  140620. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140621. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140622. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140623. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140624. private _tmpPositionVector;
  140625. removePhysicsBody(impostor: PhysicsImpostor): void;
  140626. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140627. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140628. isSupported(): boolean;
  140629. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140630. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140631. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140632. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140633. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140634. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140635. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140636. getBodyMass(impostor: PhysicsImpostor): number;
  140637. getBodyFriction(impostor: PhysicsImpostor): number;
  140638. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140639. getBodyRestitution(impostor: PhysicsImpostor): number;
  140640. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140641. sleepBody(impostor: PhysicsImpostor): void;
  140642. wakeUpBody(impostor: PhysicsImpostor): void;
  140643. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  140644. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  140645. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  140646. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140647. getRadius(impostor: PhysicsImpostor): number;
  140648. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140649. dispose(): void;
  140650. /**
  140651. * Does a raycast in the physics world
  140652. * @param from when should the ray start?
  140653. * @param to when should the ray end?
  140654. * @returns PhysicsRaycastResult
  140655. */
  140656. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140657. }
  140658. }
  140659. declare module BABYLON {
  140660. /**
  140661. * AmmoJS Physics plugin
  140662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140663. * @see https://github.com/kripken/ammo.js/
  140664. */
  140665. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  140666. private _useDeltaForWorldStep;
  140667. /**
  140668. * Reference to the Ammo library
  140669. */
  140670. bjsAMMO: any;
  140671. /**
  140672. * Created ammoJS world which physics bodies are added to
  140673. */
  140674. world: any;
  140675. /**
  140676. * Name of the plugin
  140677. */
  140678. name: string;
  140679. private _timeStep;
  140680. private _fixedTimeStep;
  140681. private _maxSteps;
  140682. private _tmpQuaternion;
  140683. private _tmpAmmoTransform;
  140684. private _tmpAmmoQuaternion;
  140685. private _tmpAmmoConcreteContactResultCallback;
  140686. private _collisionConfiguration;
  140687. private _dispatcher;
  140688. private _overlappingPairCache;
  140689. private _solver;
  140690. private _softBodySolver;
  140691. private _tmpAmmoVectorA;
  140692. private _tmpAmmoVectorB;
  140693. private _tmpAmmoVectorC;
  140694. private _tmpAmmoVectorD;
  140695. private _tmpContactCallbackResult;
  140696. private _tmpAmmoVectorRCA;
  140697. private _tmpAmmoVectorRCB;
  140698. private _raycastResult;
  140699. private static readonly DISABLE_COLLISION_FLAG;
  140700. private static readonly KINEMATIC_FLAG;
  140701. private static readonly DISABLE_DEACTIVATION_FLAG;
  140702. /**
  140703. * Initializes the ammoJS plugin
  140704. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  140705. * @param ammoInjection can be used to inject your own ammo reference
  140706. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  140707. */
  140708. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  140709. /**
  140710. * Sets the gravity of the physics world (m/(s^2))
  140711. * @param gravity Gravity to set
  140712. */
  140713. setGravity(gravity: Vector3): void;
  140714. /**
  140715. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  140716. * @param timeStep timestep to use in seconds
  140717. */
  140718. setTimeStep(timeStep: number): void;
  140719. /**
  140720. * 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)
  140721. * @param fixedTimeStep fixedTimeStep to use in seconds
  140722. */
  140723. setFixedTimeStep(fixedTimeStep: number): void;
  140724. /**
  140725. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  140726. * @param maxSteps the maximum number of steps by the physics engine per frame
  140727. */
  140728. setMaxSteps(maxSteps: number): void;
  140729. /**
  140730. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  140731. * @returns the current timestep in seconds
  140732. */
  140733. getTimeStep(): number;
  140734. /**
  140735. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  140736. */
  140737. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  140738. private _isImpostorInContact;
  140739. private _isImpostorPairInContact;
  140740. private _stepSimulation;
  140741. /**
  140742. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  140743. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  140744. * After the step the babylon meshes are set to the position of the physics imposters
  140745. * @param delta amount of time to step forward
  140746. * @param impostors array of imposters to update before/after the step
  140747. */
  140748. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140749. /**
  140750. * Update babylon mesh to match physics world object
  140751. * @param impostor imposter to match
  140752. */
  140753. private _afterSoftStep;
  140754. /**
  140755. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  140756. * @param impostor imposter to match
  140757. */
  140758. private _ropeStep;
  140759. /**
  140760. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  140761. * @param impostor imposter to match
  140762. */
  140763. private _softbodyOrClothStep;
  140764. private _tmpMatrix;
  140765. /**
  140766. * Applies an impulse on the imposter
  140767. * @param impostor imposter to apply impulse to
  140768. * @param force amount of force to be applied to the imposter
  140769. * @param contactPoint the location to apply the impulse on the imposter
  140770. */
  140771. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140772. /**
  140773. * Applies a force on the imposter
  140774. * @param impostor imposter to apply force
  140775. * @param force amount of force to be applied to the imposter
  140776. * @param contactPoint the location to apply the force on the imposter
  140777. */
  140778. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140779. /**
  140780. * Creates a physics body using the plugin
  140781. * @param impostor the imposter to create the physics body on
  140782. */
  140783. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140784. /**
  140785. * Removes the physics body from the imposter and disposes of the body's memory
  140786. * @param impostor imposter to remove the physics body from
  140787. */
  140788. removePhysicsBody(impostor: PhysicsImpostor): void;
  140789. /**
  140790. * Generates a joint
  140791. * @param impostorJoint the imposter joint to create the joint with
  140792. */
  140793. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140794. /**
  140795. * Removes a joint
  140796. * @param impostorJoint the imposter joint to remove the joint from
  140797. */
  140798. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140799. private _addMeshVerts;
  140800. /**
  140801. * Initialise the soft body vertices to match its object's (mesh) vertices
  140802. * Softbody vertices (nodes) are in world space and to match this
  140803. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  140804. * @param impostor to create the softbody for
  140805. */
  140806. private _softVertexData;
  140807. /**
  140808. * Create an impostor's soft body
  140809. * @param impostor to create the softbody for
  140810. */
  140811. private _createSoftbody;
  140812. /**
  140813. * Create cloth for an impostor
  140814. * @param impostor to create the softbody for
  140815. */
  140816. private _createCloth;
  140817. /**
  140818. * Create rope for an impostor
  140819. * @param impostor to create the softbody for
  140820. */
  140821. private _createRope;
  140822. /**
  140823. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  140824. * @param impostor to create the custom physics shape for
  140825. */
  140826. private _createCustom;
  140827. private _addHullVerts;
  140828. private _createShape;
  140829. /**
  140830. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  140831. * @param impostor imposter containing the physics body and babylon object
  140832. */
  140833. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140834. /**
  140835. * Sets the babylon object's position/rotation from the physics body's position/rotation
  140836. * @param impostor imposter containing the physics body and babylon object
  140837. * @param newPosition new position
  140838. * @param newRotation new rotation
  140839. */
  140840. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140841. /**
  140842. * If this plugin is supported
  140843. * @returns true if its supported
  140844. */
  140845. isSupported(): boolean;
  140846. /**
  140847. * Sets the linear velocity of the physics body
  140848. * @param impostor imposter to set the velocity on
  140849. * @param velocity velocity to set
  140850. */
  140851. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140852. /**
  140853. * Sets the angular velocity of the physics body
  140854. * @param impostor imposter to set the velocity on
  140855. * @param velocity velocity to set
  140856. */
  140857. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140858. /**
  140859. * gets the linear velocity
  140860. * @param impostor imposter to get linear velocity from
  140861. * @returns linear velocity
  140862. */
  140863. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140864. /**
  140865. * gets the angular velocity
  140866. * @param impostor imposter to get angular velocity from
  140867. * @returns angular velocity
  140868. */
  140869. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140870. /**
  140871. * Sets the mass of physics body
  140872. * @param impostor imposter to set the mass on
  140873. * @param mass mass to set
  140874. */
  140875. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140876. /**
  140877. * Gets the mass of the physics body
  140878. * @param impostor imposter to get the mass from
  140879. * @returns mass
  140880. */
  140881. getBodyMass(impostor: PhysicsImpostor): number;
  140882. /**
  140883. * Gets friction of the impostor
  140884. * @param impostor impostor to get friction from
  140885. * @returns friction value
  140886. */
  140887. getBodyFriction(impostor: PhysicsImpostor): number;
  140888. /**
  140889. * Sets friction of the impostor
  140890. * @param impostor impostor to set friction on
  140891. * @param friction friction value
  140892. */
  140893. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140894. /**
  140895. * Gets restitution of the impostor
  140896. * @param impostor impostor to get restitution from
  140897. * @returns restitution value
  140898. */
  140899. getBodyRestitution(impostor: PhysicsImpostor): number;
  140900. /**
  140901. * Sets resitution of the impostor
  140902. * @param impostor impostor to set resitution on
  140903. * @param restitution resitution value
  140904. */
  140905. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140906. /**
  140907. * Gets pressure inside the impostor
  140908. * @param impostor impostor to get pressure from
  140909. * @returns pressure value
  140910. */
  140911. getBodyPressure(impostor: PhysicsImpostor): number;
  140912. /**
  140913. * Sets pressure inside a soft body impostor
  140914. * Cloth and rope must remain 0 pressure
  140915. * @param impostor impostor to set pressure on
  140916. * @param pressure pressure value
  140917. */
  140918. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  140919. /**
  140920. * Gets stiffness of the impostor
  140921. * @param impostor impostor to get stiffness from
  140922. * @returns pressure value
  140923. */
  140924. getBodyStiffness(impostor: PhysicsImpostor): number;
  140925. /**
  140926. * Sets stiffness of the impostor
  140927. * @param impostor impostor to set stiffness on
  140928. * @param stiffness stiffness value from 0 to 1
  140929. */
  140930. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  140931. /**
  140932. * Gets velocityIterations of the impostor
  140933. * @param impostor impostor to get velocity iterations from
  140934. * @returns velocityIterations value
  140935. */
  140936. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  140937. /**
  140938. * Sets velocityIterations of the impostor
  140939. * @param impostor impostor to set velocity iterations on
  140940. * @param velocityIterations velocityIterations value
  140941. */
  140942. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  140943. /**
  140944. * Gets positionIterations of the impostor
  140945. * @param impostor impostor to get position iterations from
  140946. * @returns positionIterations value
  140947. */
  140948. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  140949. /**
  140950. * Sets positionIterations of the impostor
  140951. * @param impostor impostor to set position on
  140952. * @param positionIterations positionIterations value
  140953. */
  140954. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  140955. /**
  140956. * Append an anchor to a cloth object
  140957. * @param impostor is the cloth impostor to add anchor to
  140958. * @param otherImpostor is the rigid impostor to anchor to
  140959. * @param width ratio across width from 0 to 1
  140960. * @param height ratio up height from 0 to 1
  140961. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  140962. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  140963. */
  140964. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  140965. /**
  140966. * Append an hook to a rope object
  140967. * @param impostor is the rope impostor to add hook to
  140968. * @param otherImpostor is the rigid impostor to hook to
  140969. * @param length ratio along the rope from 0 to 1
  140970. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  140971. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  140972. */
  140973. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  140974. /**
  140975. * Sleeps the physics body and stops it from being active
  140976. * @param impostor impostor to sleep
  140977. */
  140978. sleepBody(impostor: PhysicsImpostor): void;
  140979. /**
  140980. * Activates the physics body
  140981. * @param impostor impostor to activate
  140982. */
  140983. wakeUpBody(impostor: PhysicsImpostor): void;
  140984. /**
  140985. * Updates the distance parameters of the joint
  140986. * @param joint joint to update
  140987. * @param maxDistance maximum distance of the joint
  140988. * @param minDistance minimum distance of the joint
  140989. */
  140990. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  140991. /**
  140992. * Sets a motor on the joint
  140993. * @param joint joint to set motor on
  140994. * @param speed speed of the motor
  140995. * @param maxForce maximum force of the motor
  140996. * @param motorIndex index of the motor
  140997. */
  140998. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  140999. /**
  141000. * Sets the motors limit
  141001. * @param joint joint to set limit on
  141002. * @param upperLimit upper limit
  141003. * @param lowerLimit lower limit
  141004. */
  141005. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141006. /**
  141007. * Syncs the position and rotation of a mesh with the impostor
  141008. * @param mesh mesh to sync
  141009. * @param impostor impostor to update the mesh with
  141010. */
  141011. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141012. /**
  141013. * Gets the radius of the impostor
  141014. * @param impostor impostor to get radius from
  141015. * @returns the radius
  141016. */
  141017. getRadius(impostor: PhysicsImpostor): number;
  141018. /**
  141019. * Gets the box size of the impostor
  141020. * @param impostor impostor to get box size from
  141021. * @param result the resulting box size
  141022. */
  141023. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141024. /**
  141025. * Disposes of the impostor
  141026. */
  141027. dispose(): void;
  141028. /**
  141029. * Does a raycast in the physics world
  141030. * @param from when should the ray start?
  141031. * @param to when should the ray end?
  141032. * @returns PhysicsRaycastResult
  141033. */
  141034. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141035. }
  141036. }
  141037. declare module BABYLON {
  141038. interface AbstractScene {
  141039. /**
  141040. * The list of reflection probes added to the scene
  141041. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141042. */
  141043. reflectionProbes: Array<ReflectionProbe>;
  141044. /**
  141045. * Removes the given reflection probe from this scene.
  141046. * @param toRemove The reflection probe to remove
  141047. * @returns The index of the removed reflection probe
  141048. */
  141049. removeReflectionProbe(toRemove: ReflectionProbe): number;
  141050. /**
  141051. * Adds the given reflection probe to this scene.
  141052. * @param newReflectionProbe The reflection probe to add
  141053. */
  141054. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  141055. }
  141056. /**
  141057. * Class used to generate realtime reflection / refraction cube textures
  141058. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141059. */
  141060. export class ReflectionProbe {
  141061. /** defines the name of the probe */
  141062. name: string;
  141063. private _scene;
  141064. private _renderTargetTexture;
  141065. private _projectionMatrix;
  141066. private _viewMatrix;
  141067. private _target;
  141068. private _add;
  141069. private _attachedMesh;
  141070. private _invertYAxis;
  141071. /** Gets or sets probe position (center of the cube map) */
  141072. position: Vector3;
  141073. /**
  141074. * Creates a new reflection probe
  141075. * @param name defines the name of the probe
  141076. * @param size defines the texture resolution (for each face)
  141077. * @param scene defines the hosting scene
  141078. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  141079. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  141080. */
  141081. constructor(
  141082. /** defines the name of the probe */
  141083. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  141084. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  141085. get samples(): number;
  141086. set samples(value: number);
  141087. /** Gets or sets the refresh rate to use (on every frame by default) */
  141088. get refreshRate(): number;
  141089. set refreshRate(value: number);
  141090. /**
  141091. * Gets the hosting scene
  141092. * @returns a Scene
  141093. */
  141094. getScene(): Scene;
  141095. /** Gets the internal CubeTexture used to render to */
  141096. get cubeTexture(): RenderTargetTexture;
  141097. /** Gets the list of meshes to render */
  141098. get renderList(): Nullable<AbstractMesh[]>;
  141099. /**
  141100. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  141101. * @param mesh defines the mesh to attach to
  141102. */
  141103. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  141104. /**
  141105. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  141106. * @param renderingGroupId The rendering group id corresponding to its index
  141107. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  141108. */
  141109. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  141110. /**
  141111. * Clean all associated resources
  141112. */
  141113. dispose(): void;
  141114. /**
  141115. * Converts the reflection probe information to a readable string for debug purpose.
  141116. * @param fullDetails Supports for multiple levels of logging within scene loading
  141117. * @returns the human readable reflection probe info
  141118. */
  141119. toString(fullDetails?: boolean): string;
  141120. /**
  141121. * Get the class name of the relfection probe.
  141122. * @returns "ReflectionProbe"
  141123. */
  141124. getClassName(): string;
  141125. /**
  141126. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  141127. * @returns The JSON representation of the texture
  141128. */
  141129. serialize(): any;
  141130. /**
  141131. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  141132. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  141133. * @param scene Define the scene the parsed reflection probe should be instantiated in
  141134. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  141135. * @returns The parsed reflection probe if successful
  141136. */
  141137. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  141138. }
  141139. }
  141140. declare module BABYLON {
  141141. /** @hidden */
  141142. export var _BabylonLoaderRegistered: boolean;
  141143. /**
  141144. * Helps setting up some configuration for the babylon file loader.
  141145. */
  141146. export class BabylonFileLoaderConfiguration {
  141147. /**
  141148. * The loader does not allow injecting custom physix engine into the plugins.
  141149. * Unfortunately in ES6, we need to manually inject them into the plugin.
  141150. * So you could set this variable to your engine import to make it work.
  141151. */
  141152. static LoaderInjectedPhysicsEngine: any;
  141153. }
  141154. }
  141155. declare module BABYLON {
  141156. /**
  141157. * The Physically based simple base material of BJS.
  141158. *
  141159. * This enables better naming and convention enforcements on top of the pbrMaterial.
  141160. * It is used as the base class for both the specGloss and metalRough conventions.
  141161. */
  141162. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  141163. /**
  141164. * Number of Simultaneous lights allowed on the material.
  141165. */
  141166. maxSimultaneousLights: number;
  141167. /**
  141168. * If sets to true, disables all the lights affecting the material.
  141169. */
  141170. disableLighting: boolean;
  141171. /**
  141172. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  141173. */
  141174. environmentTexture: BaseTexture;
  141175. /**
  141176. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  141177. */
  141178. invertNormalMapX: boolean;
  141179. /**
  141180. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  141181. */
  141182. invertNormalMapY: boolean;
  141183. /**
  141184. * Normal map used in the model.
  141185. */
  141186. normalTexture: BaseTexture;
  141187. /**
  141188. * Emissivie color used to self-illuminate the model.
  141189. */
  141190. emissiveColor: Color3;
  141191. /**
  141192. * Emissivie texture used to self-illuminate the model.
  141193. */
  141194. emissiveTexture: BaseTexture;
  141195. /**
  141196. * Occlusion Channel Strenght.
  141197. */
  141198. occlusionStrength: number;
  141199. /**
  141200. * Occlusion Texture of the material (adding extra occlusion effects).
  141201. */
  141202. occlusionTexture: BaseTexture;
  141203. /**
  141204. * Defines the alpha limits in alpha test mode.
  141205. */
  141206. alphaCutOff: number;
  141207. /**
  141208. * Gets the current double sided mode.
  141209. */
  141210. get doubleSided(): boolean;
  141211. /**
  141212. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  141213. */
  141214. set doubleSided(value: boolean);
  141215. /**
  141216. * Stores the pre-calculated light information of a mesh in a texture.
  141217. */
  141218. lightmapTexture: BaseTexture;
  141219. /**
  141220. * If true, the light map contains occlusion information instead of lighting info.
  141221. */
  141222. useLightmapAsShadowmap: boolean;
  141223. /**
  141224. * Instantiates a new PBRMaterial instance.
  141225. *
  141226. * @param name The material name
  141227. * @param scene The scene the material will be use in.
  141228. */
  141229. constructor(name: string, scene: Scene);
  141230. getClassName(): string;
  141231. }
  141232. }
  141233. declare module BABYLON {
  141234. /**
  141235. * The PBR material of BJS following the metal roughness convention.
  141236. *
  141237. * This fits to the PBR convention in the GLTF definition:
  141238. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  141239. */
  141240. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  141241. /**
  141242. * The base color has two different interpretations depending on the value of metalness.
  141243. * When the material is a metal, the base color is the specific measured reflectance value
  141244. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  141245. * of the material.
  141246. */
  141247. baseColor: Color3;
  141248. /**
  141249. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  141250. * well as opacity information in the alpha channel.
  141251. */
  141252. baseTexture: BaseTexture;
  141253. /**
  141254. * Specifies the metallic scalar value of the material.
  141255. * Can also be used to scale the metalness values of the metallic texture.
  141256. */
  141257. metallic: number;
  141258. /**
  141259. * Specifies the roughness scalar value of the material.
  141260. * Can also be used to scale the roughness values of the metallic texture.
  141261. */
  141262. roughness: number;
  141263. /**
  141264. * Texture containing both the metallic value in the B channel and the
  141265. * roughness value in the G channel to keep better precision.
  141266. */
  141267. metallicRoughnessTexture: BaseTexture;
  141268. /**
  141269. * Instantiates a new PBRMetalRoughnessMaterial instance.
  141270. *
  141271. * @param name The material name
  141272. * @param scene The scene the material will be use in.
  141273. */
  141274. constructor(name: string, scene: Scene);
  141275. /**
  141276. * Return the currrent class name of the material.
  141277. */
  141278. getClassName(): string;
  141279. /**
  141280. * Makes a duplicate of the current material.
  141281. * @param name - name to use for the new material.
  141282. */
  141283. clone(name: string): PBRMetallicRoughnessMaterial;
  141284. /**
  141285. * Serialize the material to a parsable JSON object.
  141286. */
  141287. serialize(): any;
  141288. /**
  141289. * Parses a JSON object correponding to the serialize function.
  141290. */
  141291. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  141292. }
  141293. }
  141294. declare module BABYLON {
  141295. /**
  141296. * The PBR material of BJS following the specular glossiness convention.
  141297. *
  141298. * This fits to the PBR convention in the GLTF definition:
  141299. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  141300. */
  141301. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  141302. /**
  141303. * Specifies the diffuse color of the material.
  141304. */
  141305. diffuseColor: Color3;
  141306. /**
  141307. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  141308. * channel.
  141309. */
  141310. diffuseTexture: BaseTexture;
  141311. /**
  141312. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  141313. */
  141314. specularColor: Color3;
  141315. /**
  141316. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  141317. */
  141318. glossiness: number;
  141319. /**
  141320. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  141321. */
  141322. specularGlossinessTexture: BaseTexture;
  141323. /**
  141324. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  141325. *
  141326. * @param name The material name
  141327. * @param scene The scene the material will be use in.
  141328. */
  141329. constructor(name: string, scene: Scene);
  141330. /**
  141331. * Return the currrent class name of the material.
  141332. */
  141333. getClassName(): string;
  141334. /**
  141335. * Makes a duplicate of the current material.
  141336. * @param name - name to use for the new material.
  141337. */
  141338. clone(name: string): PBRSpecularGlossinessMaterial;
  141339. /**
  141340. * Serialize the material to a parsable JSON object.
  141341. */
  141342. serialize(): any;
  141343. /**
  141344. * Parses a JSON object correponding to the serialize function.
  141345. */
  141346. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  141347. }
  141348. }
  141349. declare module BABYLON {
  141350. /**
  141351. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  141352. * It can help converting any input color in a desired output one. This can then be used to create effects
  141353. * from sepia, black and white to sixties or futuristic rendering...
  141354. *
  141355. * The only supported format is currently 3dl.
  141356. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  141357. */
  141358. export class ColorGradingTexture extends BaseTexture {
  141359. /**
  141360. * The texture URL.
  141361. */
  141362. url: string;
  141363. /**
  141364. * Empty line regex stored for GC.
  141365. */
  141366. private static _noneEmptyLineRegex;
  141367. private _textureMatrix;
  141368. private _onLoad;
  141369. /**
  141370. * Instantiates a ColorGradingTexture from the following parameters.
  141371. *
  141372. * @param url The location of the color gradind data (currently only supporting 3dl)
  141373. * @param sceneOrEngine The scene or engine the texture will be used in
  141374. * @param onLoad defines a callback triggered when the texture has been loaded
  141375. */
  141376. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  141377. /**
  141378. * Fires the onload event from the constructor if requested.
  141379. */
  141380. private _triggerOnLoad;
  141381. /**
  141382. * Returns the texture matrix used in most of the material.
  141383. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  141384. */
  141385. getTextureMatrix(): Matrix;
  141386. /**
  141387. * Occurs when the file being loaded is a .3dl LUT file.
  141388. */
  141389. private load3dlTexture;
  141390. /**
  141391. * Starts the loading process of the texture.
  141392. */
  141393. private loadTexture;
  141394. /**
  141395. * Clones the color gradind texture.
  141396. */
  141397. clone(): ColorGradingTexture;
  141398. /**
  141399. * Called during delayed load for textures.
  141400. */
  141401. delayLoad(): void;
  141402. /**
  141403. * Parses a color grading texture serialized by Babylon.
  141404. * @param parsedTexture The texture information being parsedTexture
  141405. * @param scene The scene to load the texture in
  141406. * @param rootUrl The root url of the data assets to load
  141407. * @return A color gradind texture
  141408. */
  141409. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  141410. /**
  141411. * Serializes the LUT texture to json format.
  141412. */
  141413. serialize(): any;
  141414. }
  141415. }
  141416. declare module BABYLON {
  141417. /**
  141418. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  141419. */
  141420. export class EquiRectangularCubeTexture extends BaseTexture {
  141421. /** The six faces of the cube. */
  141422. private static _FacesMapping;
  141423. private _noMipmap;
  141424. private _onLoad;
  141425. private _onError;
  141426. /** The size of the cubemap. */
  141427. private _size;
  141428. /** The buffer of the image. */
  141429. private _buffer;
  141430. /** The width of the input image. */
  141431. private _width;
  141432. /** The height of the input image. */
  141433. private _height;
  141434. /** The URL to the image. */
  141435. url: string;
  141436. /**
  141437. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  141438. * @param url The location of the image
  141439. * @param scene The scene the texture will be used in
  141440. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141441. * @param noMipmap Forces to not generate the mipmap if true
  141442. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141443. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141444. * @param onLoad — defines a callback called when texture is loaded
  141445. * @param onError — defines a callback called if there is an error
  141446. */
  141447. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  141448. /**
  141449. * Load the image data, by putting the image on a canvas and extracting its buffer.
  141450. */
  141451. private loadImage;
  141452. /**
  141453. * Convert the image buffer into a cubemap and create a CubeTexture.
  141454. */
  141455. private loadTexture;
  141456. /**
  141457. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  141458. * @param buffer The ArrayBuffer that should be converted.
  141459. * @returns The buffer as Float32Array.
  141460. */
  141461. private getFloat32ArrayFromArrayBuffer;
  141462. /**
  141463. * Get the current class name of the texture useful for serialization or dynamic coding.
  141464. * @returns "EquiRectangularCubeTexture"
  141465. */
  141466. getClassName(): string;
  141467. /**
  141468. * Create a clone of the current EquiRectangularCubeTexture and return it.
  141469. * @returns A clone of the current EquiRectangularCubeTexture.
  141470. */
  141471. clone(): EquiRectangularCubeTexture;
  141472. }
  141473. }
  141474. declare module BABYLON {
  141475. /**
  141476. * Defines the options related to the creation of an HtmlElementTexture
  141477. */
  141478. export interface IHtmlElementTextureOptions {
  141479. /**
  141480. * Defines wether mip maps should be created or not.
  141481. */
  141482. generateMipMaps?: boolean;
  141483. /**
  141484. * Defines the sampling mode of the texture.
  141485. */
  141486. samplingMode?: number;
  141487. /**
  141488. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  141489. */
  141490. engine: Nullable<ThinEngine>;
  141491. /**
  141492. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  141493. */
  141494. scene: Nullable<Scene>;
  141495. }
  141496. /**
  141497. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  141498. * To be as efficient as possible depending on your constraints nothing aside the first upload
  141499. * is automatically managed.
  141500. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  141501. * in your application.
  141502. *
  141503. * As the update is not automatic, you need to call them manually.
  141504. */
  141505. export class HtmlElementTexture extends BaseTexture {
  141506. /**
  141507. * The texture URL.
  141508. */
  141509. element: HTMLVideoElement | HTMLCanvasElement;
  141510. private static readonly DefaultOptions;
  141511. private _textureMatrix;
  141512. private _isVideo;
  141513. private _generateMipMaps;
  141514. private _samplingMode;
  141515. /**
  141516. * Instantiates a HtmlElementTexture from the following parameters.
  141517. *
  141518. * @param name Defines the name of the texture
  141519. * @param element Defines the video or canvas the texture is filled with
  141520. * @param options Defines the other none mandatory texture creation options
  141521. */
  141522. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  141523. private _createInternalTexture;
  141524. /**
  141525. * Returns the texture matrix used in most of the material.
  141526. */
  141527. getTextureMatrix(): Matrix;
  141528. /**
  141529. * Updates the content of the texture.
  141530. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  141531. */
  141532. update(invertY?: Nullable<boolean>): void;
  141533. }
  141534. }
  141535. declare module BABYLON {
  141536. /**
  141537. * Based on jsTGALoader - Javascript loader for TGA file
  141538. * By Vincent Thibault
  141539. * @see http://blog.robrowser.com/javascript-tga-loader.html
  141540. */
  141541. export class TGATools {
  141542. private static _TYPE_INDEXED;
  141543. private static _TYPE_RGB;
  141544. private static _TYPE_GREY;
  141545. private static _TYPE_RLE_INDEXED;
  141546. private static _TYPE_RLE_RGB;
  141547. private static _TYPE_RLE_GREY;
  141548. private static _ORIGIN_MASK;
  141549. private static _ORIGIN_SHIFT;
  141550. private static _ORIGIN_BL;
  141551. private static _ORIGIN_BR;
  141552. private static _ORIGIN_UL;
  141553. private static _ORIGIN_UR;
  141554. /**
  141555. * Gets the header of a TGA file
  141556. * @param data defines the TGA data
  141557. * @returns the header
  141558. */
  141559. static GetTGAHeader(data: Uint8Array): any;
  141560. /**
  141561. * Uploads TGA content to a Babylon Texture
  141562. * @hidden
  141563. */
  141564. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  141565. /** @hidden */
  141566. 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;
  141567. /** @hidden */
  141568. 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;
  141569. /** @hidden */
  141570. 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;
  141571. /** @hidden */
  141572. 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;
  141573. /** @hidden */
  141574. 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;
  141575. /** @hidden */
  141576. 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;
  141577. }
  141578. }
  141579. declare module BABYLON {
  141580. /**
  141581. * Implementation of the TGA Texture Loader.
  141582. * @hidden
  141583. */
  141584. export class _TGATextureLoader implements IInternalTextureLoader {
  141585. /**
  141586. * Defines wether the loader supports cascade loading the different faces.
  141587. */
  141588. readonly supportCascades: boolean;
  141589. /**
  141590. * This returns if the loader support the current file information.
  141591. * @param extension defines the file extension of the file being loaded
  141592. * @returns true if the loader can load the specified file
  141593. */
  141594. canLoad(extension: string): boolean;
  141595. /**
  141596. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  141597. * @param data contains the texture data
  141598. * @param texture defines the BabylonJS internal texture
  141599. * @param createPolynomials will be true if polynomials have been requested
  141600. * @param onLoad defines the callback to trigger once the texture is ready
  141601. * @param onError defines the callback to trigger in case of error
  141602. */
  141603. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  141604. /**
  141605. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  141606. * @param data contains the texture data
  141607. * @param texture defines the BabylonJS internal texture
  141608. * @param callback defines the method to call once ready to upload
  141609. */
  141610. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  141611. }
  141612. }
  141613. declare module BABYLON {
  141614. /**
  141615. * Info about the .basis files
  141616. */
  141617. class BasisFileInfo {
  141618. /**
  141619. * If the file has alpha
  141620. */
  141621. hasAlpha: boolean;
  141622. /**
  141623. * Info about each image of the basis file
  141624. */
  141625. images: Array<{
  141626. levels: Array<{
  141627. width: number;
  141628. height: number;
  141629. transcodedPixels: ArrayBufferView;
  141630. }>;
  141631. }>;
  141632. }
  141633. /**
  141634. * Result of transcoding a basis file
  141635. */
  141636. class TranscodeResult {
  141637. /**
  141638. * Info about the .basis file
  141639. */
  141640. fileInfo: BasisFileInfo;
  141641. /**
  141642. * Format to use when loading the file
  141643. */
  141644. format: number;
  141645. }
  141646. /**
  141647. * Configuration options for the Basis transcoder
  141648. */
  141649. export class BasisTranscodeConfiguration {
  141650. /**
  141651. * Supported compression formats used to determine the supported output format of the transcoder
  141652. */
  141653. supportedCompressionFormats?: {
  141654. /**
  141655. * etc1 compression format
  141656. */
  141657. etc1?: boolean;
  141658. /**
  141659. * s3tc compression format
  141660. */
  141661. s3tc?: boolean;
  141662. /**
  141663. * pvrtc compression format
  141664. */
  141665. pvrtc?: boolean;
  141666. /**
  141667. * etc2 compression format
  141668. */
  141669. etc2?: boolean;
  141670. };
  141671. /**
  141672. * If mipmap levels should be loaded for transcoded images (Default: true)
  141673. */
  141674. loadMipmapLevels?: boolean;
  141675. /**
  141676. * Index of a single image to load (Default: all images)
  141677. */
  141678. loadSingleImage?: number;
  141679. }
  141680. /**
  141681. * Used to load .Basis files
  141682. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  141683. */
  141684. export class BasisTools {
  141685. private static _IgnoreSupportedFormats;
  141686. /**
  141687. * URL to use when loading the basis transcoder
  141688. */
  141689. static JSModuleURL: string;
  141690. /**
  141691. * URL to use when loading the wasm module for the transcoder
  141692. */
  141693. static WasmModuleURL: string;
  141694. /**
  141695. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  141696. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  141697. * @returns internal format corresponding to the Basis format
  141698. */
  141699. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  141700. private static _WorkerPromise;
  141701. private static _Worker;
  141702. private static _actionId;
  141703. private static _CreateWorkerAsync;
  141704. /**
  141705. * Transcodes a loaded image file to compressed pixel data
  141706. * @param data image data to transcode
  141707. * @param config configuration options for the transcoding
  141708. * @returns a promise resulting in the transcoded image
  141709. */
  141710. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  141711. /**
  141712. * Loads a texture from the transcode result
  141713. * @param texture texture load to
  141714. * @param transcodeResult the result of transcoding the basis file to load from
  141715. */
  141716. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  141717. }
  141718. }
  141719. declare module BABYLON {
  141720. /**
  141721. * Loader for .basis file format
  141722. */
  141723. export class _BasisTextureLoader implements IInternalTextureLoader {
  141724. /**
  141725. * Defines whether the loader supports cascade loading the different faces.
  141726. */
  141727. readonly supportCascades: boolean;
  141728. /**
  141729. * This returns if the loader support the current file information.
  141730. * @param extension defines the file extension of the file being loaded
  141731. * @returns true if the loader can load the specified file
  141732. */
  141733. canLoad(extension: string): boolean;
  141734. /**
  141735. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  141736. * @param data contains the texture data
  141737. * @param texture defines the BabylonJS internal texture
  141738. * @param createPolynomials will be true if polynomials have been requested
  141739. * @param onLoad defines the callback to trigger once the texture is ready
  141740. * @param onError defines the callback to trigger in case of error
  141741. */
  141742. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  141743. /**
  141744. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  141745. * @param data contains the texture data
  141746. * @param texture defines the BabylonJS internal texture
  141747. * @param callback defines the method to call once ready to upload
  141748. */
  141749. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  141750. }
  141751. }
  141752. declare module BABYLON {
  141753. /**
  141754. * Defines the basic options interface of a TexturePacker Frame
  141755. */
  141756. export interface ITexturePackerFrame {
  141757. /**
  141758. * The frame ID
  141759. */
  141760. id: number;
  141761. /**
  141762. * The frames Scale
  141763. */
  141764. scale: Vector2;
  141765. /**
  141766. * The Frames offset
  141767. */
  141768. offset: Vector2;
  141769. }
  141770. /**
  141771. * This is a support class for frame Data on texture packer sets.
  141772. */
  141773. export class TexturePackerFrame implements ITexturePackerFrame {
  141774. /**
  141775. * The frame ID
  141776. */
  141777. id: number;
  141778. /**
  141779. * The frames Scale
  141780. */
  141781. scale: Vector2;
  141782. /**
  141783. * The Frames offset
  141784. */
  141785. offset: Vector2;
  141786. /**
  141787. * Initializes a texture package frame.
  141788. * @param id The numerical frame identifier
  141789. * @param scale Scalar Vector2 for UV frame
  141790. * @param offset Vector2 for the frame position in UV units.
  141791. * @returns TexturePackerFrame
  141792. */
  141793. constructor(id: number, scale: Vector2, offset: Vector2);
  141794. }
  141795. }
  141796. declare module BABYLON {
  141797. /**
  141798. * Defines the basic options interface of a TexturePacker
  141799. */
  141800. export interface ITexturePackerOptions {
  141801. /**
  141802. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  141803. */
  141804. map?: string[];
  141805. /**
  141806. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  141807. */
  141808. uvsIn?: string;
  141809. /**
  141810. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  141811. */
  141812. uvsOut?: string;
  141813. /**
  141814. * number representing the layout style. Defaults to LAYOUT_STRIP
  141815. */
  141816. layout?: number;
  141817. /**
  141818. * number of columns if using custom column count layout(2). This defaults to 4.
  141819. */
  141820. colnum?: number;
  141821. /**
  141822. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  141823. */
  141824. updateInputMeshes?: boolean;
  141825. /**
  141826. * boolean flag to dispose all the source textures. Defaults to true.
  141827. */
  141828. disposeSources?: boolean;
  141829. /**
  141830. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  141831. */
  141832. fillBlanks?: boolean;
  141833. /**
  141834. * string value representing the context fill style color. Defaults to 'black'.
  141835. */
  141836. customFillColor?: string;
  141837. /**
  141838. * Width and Height Value of each Frame in the TexturePacker Sets
  141839. */
  141840. frameSize?: number;
  141841. /**
  141842. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  141843. */
  141844. paddingRatio?: number;
  141845. /**
  141846. * Number that declares the fill method for the padding gutter.
  141847. */
  141848. paddingMode?: number;
  141849. /**
  141850. * If in SUBUV_COLOR padding mode what color to use.
  141851. */
  141852. paddingColor?: Color3 | Color4;
  141853. }
  141854. /**
  141855. * Defines the basic interface of a TexturePacker JSON File
  141856. */
  141857. export interface ITexturePackerJSON {
  141858. /**
  141859. * The frame ID
  141860. */
  141861. name: string;
  141862. /**
  141863. * The base64 channel data
  141864. */
  141865. sets: any;
  141866. /**
  141867. * The options of the Packer
  141868. */
  141869. options: ITexturePackerOptions;
  141870. /**
  141871. * The frame data of the Packer
  141872. */
  141873. frames: Array<number>;
  141874. }
  141875. /**
  141876. * This is a support class that generates a series of packed texture sets.
  141877. * @see https://doc.babylonjs.com/babylon101/materials
  141878. */
  141879. export class TexturePacker {
  141880. /** Packer Layout Constant 0 */
  141881. static readonly LAYOUT_STRIP: number;
  141882. /** Packer Layout Constant 1 */
  141883. static readonly LAYOUT_POWER2: number;
  141884. /** Packer Layout Constant 2 */
  141885. static readonly LAYOUT_COLNUM: number;
  141886. /** Packer Layout Constant 0 */
  141887. static readonly SUBUV_WRAP: number;
  141888. /** Packer Layout Constant 1 */
  141889. static readonly SUBUV_EXTEND: number;
  141890. /** Packer Layout Constant 2 */
  141891. static readonly SUBUV_COLOR: number;
  141892. /** The Name of the Texture Package */
  141893. name: string;
  141894. /** The scene scope of the TexturePacker */
  141895. scene: Scene;
  141896. /** The Meshes to target */
  141897. meshes: AbstractMesh[];
  141898. /** Arguments passed with the Constructor */
  141899. options: ITexturePackerOptions;
  141900. /** The promise that is started upon initialization */
  141901. promise: Nullable<Promise<TexturePacker | string>>;
  141902. /** The Container object for the channel sets that are generated */
  141903. sets: object;
  141904. /** The Container array for the frames that are generated */
  141905. frames: TexturePackerFrame[];
  141906. /** The expected number of textures the system is parsing. */
  141907. private _expecting;
  141908. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  141909. private _paddingValue;
  141910. /**
  141911. * Initializes a texture package series from an array of meshes or a single mesh.
  141912. * @param name The name of the package
  141913. * @param meshes The target meshes to compose the package from
  141914. * @param options The arguments that texture packer should follow while building.
  141915. * @param scene The scene which the textures are scoped to.
  141916. * @returns TexturePacker
  141917. */
  141918. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  141919. /**
  141920. * Starts the package process
  141921. * @param resolve The promises resolution function
  141922. * @returns TexturePacker
  141923. */
  141924. private _createFrames;
  141925. /**
  141926. * Calculates the Size of the Channel Sets
  141927. * @returns Vector2
  141928. */
  141929. private _calculateSize;
  141930. /**
  141931. * Calculates the UV data for the frames.
  141932. * @param baseSize the base frameSize
  141933. * @param padding the base frame padding
  141934. * @param dtSize size of the Dynamic Texture for that channel
  141935. * @param dtUnits is 1/dtSize
  141936. * @param update flag to update the input meshes
  141937. */
  141938. private _calculateMeshUVFrames;
  141939. /**
  141940. * Calculates the frames Offset.
  141941. * @param index of the frame
  141942. * @returns Vector2
  141943. */
  141944. private _getFrameOffset;
  141945. /**
  141946. * Updates a Mesh to the frame data
  141947. * @param mesh that is the target
  141948. * @param frameID or the frame index
  141949. */
  141950. private _updateMeshUV;
  141951. /**
  141952. * Updates a Meshes materials to use the texture packer channels
  141953. * @param m is the mesh to target
  141954. * @param force all channels on the packer to be set.
  141955. */
  141956. private _updateTextureReferences;
  141957. /**
  141958. * Public method to set a Mesh to a frame
  141959. * @param m that is the target
  141960. * @param frameID or the frame index
  141961. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  141962. */
  141963. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  141964. /**
  141965. * Starts the async promise to compile the texture packer.
  141966. * @returns Promise<void>
  141967. */
  141968. processAsync(): Promise<void>;
  141969. /**
  141970. * Disposes all textures associated with this packer
  141971. */
  141972. dispose(): void;
  141973. /**
  141974. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  141975. * @param imageType is the image type to use.
  141976. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  141977. */
  141978. download(imageType?: string, quality?: number): void;
  141979. /**
  141980. * Public method to load a texturePacker JSON file.
  141981. * @param data of the JSON file in string format.
  141982. */
  141983. updateFromJSON(data: string): void;
  141984. }
  141985. }
  141986. declare module BABYLON {
  141987. /**
  141988. * 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.
  141989. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  141990. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  141991. */
  141992. export class CustomProceduralTexture extends ProceduralTexture {
  141993. private _animate;
  141994. private _time;
  141995. private _config;
  141996. private _texturePath;
  141997. /**
  141998. * Instantiates a new Custom Procedural Texture.
  141999. * 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.
  142000. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142001. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142002. * @param name Define the name of the texture
  142003. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  142004. * @param size Define the size of the texture to create
  142005. * @param scene Define the scene the texture belongs to
  142006. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  142007. * @param generateMipMaps Define if the texture should creates mip maps or not
  142008. */
  142009. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142010. private _loadJson;
  142011. /**
  142012. * Is the texture ready to be used ? (rendered at least once)
  142013. * @returns true if ready, otherwise, false.
  142014. */
  142015. isReady(): boolean;
  142016. /**
  142017. * Render the texture to its associated render target.
  142018. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  142019. */
  142020. render(useCameraPostProcess?: boolean): void;
  142021. /**
  142022. * Update the list of dependant textures samplers in the shader.
  142023. */
  142024. updateTextures(): void;
  142025. /**
  142026. * Update the uniform values of the procedural texture in the shader.
  142027. */
  142028. updateShaderUniforms(): void;
  142029. /**
  142030. * Define if the texture animates or not.
  142031. */
  142032. get animate(): boolean;
  142033. set animate(value: boolean);
  142034. }
  142035. }
  142036. declare module BABYLON {
  142037. /** @hidden */
  142038. export var noisePixelShader: {
  142039. name: string;
  142040. shader: string;
  142041. };
  142042. }
  142043. declare module BABYLON {
  142044. /**
  142045. * Class used to generate noise procedural textures
  142046. */
  142047. export class NoiseProceduralTexture extends ProceduralTexture {
  142048. /** Gets or sets the start time (default is 0) */
  142049. time: number;
  142050. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  142051. brightness: number;
  142052. /** Defines the number of octaves to process */
  142053. octaves: number;
  142054. /** Defines the level of persistence (0.8 by default) */
  142055. persistence: number;
  142056. /** Gets or sets animation speed factor (default is 1) */
  142057. animationSpeedFactor: number;
  142058. /**
  142059. * Creates a new NoiseProceduralTexture
  142060. * @param name defines the name fo the texture
  142061. * @param size defines the size of the texture (default is 256)
  142062. * @param scene defines the hosting scene
  142063. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  142064. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  142065. */
  142066. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142067. private _updateShaderUniforms;
  142068. protected _getDefines(): string;
  142069. /** Generate the current state of the procedural texture */
  142070. render(useCameraPostProcess?: boolean): void;
  142071. /**
  142072. * Serializes this noise procedural texture
  142073. * @returns a serialized noise procedural texture object
  142074. */
  142075. serialize(): any;
  142076. /**
  142077. * Clone the texture.
  142078. * @returns the cloned texture
  142079. */
  142080. clone(): NoiseProceduralTexture;
  142081. /**
  142082. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  142083. * @param parsedTexture defines parsed texture data
  142084. * @param scene defines the current scene
  142085. * @param rootUrl defines the root URL containing noise procedural texture information
  142086. * @returns a parsed NoiseProceduralTexture
  142087. */
  142088. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  142089. }
  142090. }
  142091. declare module BABYLON {
  142092. /**
  142093. * Raw cube texture where the raw buffers are passed in
  142094. */
  142095. export class RawCubeTexture extends CubeTexture {
  142096. /**
  142097. * Creates a cube texture where the raw buffers are passed in.
  142098. * @param scene defines the scene the texture is attached to
  142099. * @param data defines the array of data to use to create each face
  142100. * @param size defines the size of the textures
  142101. * @param format defines the format of the data
  142102. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  142103. * @param generateMipMaps defines if the engine should generate the mip levels
  142104. * @param invertY defines if data must be stored with Y axis inverted
  142105. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  142106. * @param compression defines the compression used (null by default)
  142107. */
  142108. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  142109. /**
  142110. * Updates the raw cube texture.
  142111. * @param data defines the data to store
  142112. * @param format defines the data format
  142113. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  142114. * @param invertY defines if data must be stored with Y axis inverted
  142115. * @param compression defines the compression used (null by default)
  142116. * @param level defines which level of the texture to update
  142117. */
  142118. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  142119. /**
  142120. * Updates a raw cube texture with RGBD encoded data.
  142121. * @param data defines the array of data [mipmap][face] to use to create each face
  142122. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  142123. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  142124. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  142125. * @returns a promsie that resolves when the operation is complete
  142126. */
  142127. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  142128. /**
  142129. * Clones the raw cube texture.
  142130. * @return a new cube texture
  142131. */
  142132. clone(): CubeTexture;
  142133. /** @hidden */
  142134. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  142135. }
  142136. }
  142137. declare module BABYLON {
  142138. /**
  142139. * Class used to store 2D array textures containing user data
  142140. */
  142141. export class RawTexture2DArray extends Texture {
  142142. /** Gets or sets the texture format to use */
  142143. format: number;
  142144. /**
  142145. * Create a new RawTexture2DArray
  142146. * @param data defines the data of the texture
  142147. * @param width defines the width of the texture
  142148. * @param height defines the height of the texture
  142149. * @param depth defines the number of layers of the texture
  142150. * @param format defines the texture format to use
  142151. * @param scene defines the hosting scene
  142152. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142153. * @param invertY defines if texture must be stored with Y axis inverted
  142154. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142155. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142156. */
  142157. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142158. /** Gets or sets the texture format to use */
  142159. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142160. /**
  142161. * Update the texture with new data
  142162. * @param data defines the data to store in the texture
  142163. */
  142164. update(data: ArrayBufferView): void;
  142165. }
  142166. }
  142167. declare module BABYLON {
  142168. /**
  142169. * Class used to store 3D textures containing user data
  142170. */
  142171. export class RawTexture3D extends Texture {
  142172. /** Gets or sets the texture format to use */
  142173. format: number;
  142174. /**
  142175. * Create a new RawTexture3D
  142176. * @param data defines the data of the texture
  142177. * @param width defines the width of the texture
  142178. * @param height defines the height of the texture
  142179. * @param depth defines the depth of the texture
  142180. * @param format defines the texture format to use
  142181. * @param scene defines the hosting scene
  142182. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142183. * @param invertY defines if texture must be stored with Y axis inverted
  142184. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142185. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142186. */
  142187. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142188. /** Gets or sets the texture format to use */
  142189. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142190. /**
  142191. * Update the texture with new data
  142192. * @param data defines the data to store in the texture
  142193. */
  142194. update(data: ArrayBufferView): void;
  142195. }
  142196. }
  142197. declare module BABYLON {
  142198. /**
  142199. * Creates a refraction texture used by refraction channel of the standard material.
  142200. * It is like a mirror but to see through a material.
  142201. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142202. */
  142203. export class RefractionTexture extends RenderTargetTexture {
  142204. /**
  142205. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  142206. * 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.
  142207. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142208. */
  142209. refractionPlane: Plane;
  142210. /**
  142211. * Define how deep under the surface we should see.
  142212. */
  142213. depth: number;
  142214. /**
  142215. * Creates a refraction texture used by refraction channel of the standard material.
  142216. * It is like a mirror but to see through a material.
  142217. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142218. * @param name Define the texture name
  142219. * @param size Define the size of the underlying texture
  142220. * @param scene Define the scene the refraction belongs to
  142221. * @param generateMipMaps Define if we need to generate mips level for the refraction
  142222. */
  142223. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  142224. /**
  142225. * Clone the refraction texture.
  142226. * @returns the cloned texture
  142227. */
  142228. clone(): RefractionTexture;
  142229. /**
  142230. * Serialize the texture to a JSON representation you could use in Parse later on
  142231. * @returns the serialized JSON representation
  142232. */
  142233. serialize(): any;
  142234. }
  142235. }
  142236. declare module BABYLON {
  142237. /**
  142238. * Block used to add support for vertex skinning (bones)
  142239. */
  142240. export class BonesBlock extends NodeMaterialBlock {
  142241. /**
  142242. * Creates a new BonesBlock
  142243. * @param name defines the block name
  142244. */
  142245. constructor(name: string);
  142246. /**
  142247. * Initialize the block and prepare the context for build
  142248. * @param state defines the state that will be used for the build
  142249. */
  142250. initialize(state: NodeMaterialBuildState): void;
  142251. /**
  142252. * Gets the current class name
  142253. * @returns the class name
  142254. */
  142255. getClassName(): string;
  142256. /**
  142257. * Gets the matrix indices input component
  142258. */
  142259. get matricesIndices(): NodeMaterialConnectionPoint;
  142260. /**
  142261. * Gets the matrix weights input component
  142262. */
  142263. get matricesWeights(): NodeMaterialConnectionPoint;
  142264. /**
  142265. * Gets the extra matrix indices input component
  142266. */
  142267. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  142268. /**
  142269. * Gets the extra matrix weights input component
  142270. */
  142271. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  142272. /**
  142273. * Gets the world input component
  142274. */
  142275. get world(): NodeMaterialConnectionPoint;
  142276. /**
  142277. * Gets the output component
  142278. */
  142279. get output(): NodeMaterialConnectionPoint;
  142280. autoConfigure(material: NodeMaterial): void;
  142281. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  142282. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142283. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142284. protected _buildBlock(state: NodeMaterialBuildState): this;
  142285. }
  142286. }
  142287. declare module BABYLON {
  142288. /**
  142289. * Block used to add support for instances
  142290. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  142291. */
  142292. export class InstancesBlock extends NodeMaterialBlock {
  142293. /**
  142294. * Creates a new InstancesBlock
  142295. * @param name defines the block name
  142296. */
  142297. constructor(name: string);
  142298. /**
  142299. * Gets the current class name
  142300. * @returns the class name
  142301. */
  142302. getClassName(): string;
  142303. /**
  142304. * Gets the first world row input component
  142305. */
  142306. get world0(): NodeMaterialConnectionPoint;
  142307. /**
  142308. * Gets the second world row input component
  142309. */
  142310. get world1(): NodeMaterialConnectionPoint;
  142311. /**
  142312. * Gets the third world row input component
  142313. */
  142314. get world2(): NodeMaterialConnectionPoint;
  142315. /**
  142316. * Gets the forth world row input component
  142317. */
  142318. get world3(): NodeMaterialConnectionPoint;
  142319. /**
  142320. * Gets the world input component
  142321. */
  142322. get world(): NodeMaterialConnectionPoint;
  142323. /**
  142324. * Gets the output component
  142325. */
  142326. get output(): NodeMaterialConnectionPoint;
  142327. /**
  142328. * Gets the isntanceID component
  142329. */
  142330. get instanceID(): NodeMaterialConnectionPoint;
  142331. autoConfigure(material: NodeMaterial): void;
  142332. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  142333. protected _buildBlock(state: NodeMaterialBuildState): this;
  142334. }
  142335. }
  142336. declare module BABYLON {
  142337. /**
  142338. * Block used to add morph targets support to vertex shader
  142339. */
  142340. export class MorphTargetsBlock extends NodeMaterialBlock {
  142341. private _repeatableContentAnchor;
  142342. /**
  142343. * Create a new MorphTargetsBlock
  142344. * @param name defines the block name
  142345. */
  142346. constructor(name: string);
  142347. /**
  142348. * Gets the current class name
  142349. * @returns the class name
  142350. */
  142351. getClassName(): string;
  142352. /**
  142353. * Gets the position input component
  142354. */
  142355. get position(): NodeMaterialConnectionPoint;
  142356. /**
  142357. * Gets the normal input component
  142358. */
  142359. get normal(): NodeMaterialConnectionPoint;
  142360. /**
  142361. * Gets the tangent input component
  142362. */
  142363. get tangent(): NodeMaterialConnectionPoint;
  142364. /**
  142365. * Gets the tangent input component
  142366. */
  142367. get uv(): NodeMaterialConnectionPoint;
  142368. /**
  142369. * Gets the position output component
  142370. */
  142371. get positionOutput(): NodeMaterialConnectionPoint;
  142372. /**
  142373. * Gets the normal output component
  142374. */
  142375. get normalOutput(): NodeMaterialConnectionPoint;
  142376. /**
  142377. * Gets the tangent output component
  142378. */
  142379. get tangentOutput(): NodeMaterialConnectionPoint;
  142380. /**
  142381. * Gets the tangent output component
  142382. */
  142383. get uvOutput(): NodeMaterialConnectionPoint;
  142384. initialize(state: NodeMaterialBuildState): void;
  142385. autoConfigure(material: NodeMaterial): void;
  142386. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142387. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142388. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  142389. protected _buildBlock(state: NodeMaterialBuildState): this;
  142390. }
  142391. }
  142392. declare module BABYLON {
  142393. /**
  142394. * Block used to get data information from a light
  142395. */
  142396. export class LightInformationBlock extends NodeMaterialBlock {
  142397. private _lightDataUniformName;
  142398. private _lightColorUniformName;
  142399. private _lightTypeDefineName;
  142400. /**
  142401. * Gets or sets the light associated with this block
  142402. */
  142403. light: Nullable<Light>;
  142404. /**
  142405. * Creates a new LightInformationBlock
  142406. * @param name defines the block name
  142407. */
  142408. constructor(name: string);
  142409. /**
  142410. * Gets the current class name
  142411. * @returns the class name
  142412. */
  142413. getClassName(): string;
  142414. /**
  142415. * Gets the world position input component
  142416. */
  142417. get worldPosition(): NodeMaterialConnectionPoint;
  142418. /**
  142419. * Gets the direction output component
  142420. */
  142421. get direction(): NodeMaterialConnectionPoint;
  142422. /**
  142423. * Gets the direction output component
  142424. */
  142425. get color(): NodeMaterialConnectionPoint;
  142426. /**
  142427. * Gets the direction output component
  142428. */
  142429. get intensity(): NodeMaterialConnectionPoint;
  142430. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142431. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142432. protected _buildBlock(state: NodeMaterialBuildState): this;
  142433. serialize(): any;
  142434. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142435. }
  142436. }
  142437. declare module BABYLON {
  142438. /**
  142439. * Block used to add image processing support to fragment shader
  142440. */
  142441. export class ImageProcessingBlock extends NodeMaterialBlock {
  142442. /**
  142443. * Create a new ImageProcessingBlock
  142444. * @param name defines the block name
  142445. */
  142446. constructor(name: string);
  142447. /**
  142448. * Gets the current class name
  142449. * @returns the class name
  142450. */
  142451. getClassName(): string;
  142452. /**
  142453. * Gets the color input component
  142454. */
  142455. get color(): NodeMaterialConnectionPoint;
  142456. /**
  142457. * Gets the output component
  142458. */
  142459. get output(): NodeMaterialConnectionPoint;
  142460. /**
  142461. * Initialize the block and prepare the context for build
  142462. * @param state defines the state that will be used for the build
  142463. */
  142464. initialize(state: NodeMaterialBuildState): void;
  142465. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  142466. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142467. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142468. protected _buildBlock(state: NodeMaterialBuildState): this;
  142469. }
  142470. }
  142471. declare module BABYLON {
  142472. /**
  142473. * Block used to pertub normals based on a normal map
  142474. */
  142475. export class PerturbNormalBlock extends NodeMaterialBlock {
  142476. private _tangentSpaceParameterName;
  142477. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  142478. invertX: boolean;
  142479. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  142480. invertY: boolean;
  142481. /**
  142482. * Create a new PerturbNormalBlock
  142483. * @param name defines the block name
  142484. */
  142485. constructor(name: string);
  142486. /**
  142487. * Gets the current class name
  142488. * @returns the class name
  142489. */
  142490. getClassName(): string;
  142491. /**
  142492. * Gets the world position input component
  142493. */
  142494. get worldPosition(): NodeMaterialConnectionPoint;
  142495. /**
  142496. * Gets the world normal input component
  142497. */
  142498. get worldNormal(): NodeMaterialConnectionPoint;
  142499. /**
  142500. * Gets the world tangent input component
  142501. */
  142502. get worldTangent(): NodeMaterialConnectionPoint;
  142503. /**
  142504. * Gets the uv input component
  142505. */
  142506. get uv(): NodeMaterialConnectionPoint;
  142507. /**
  142508. * Gets the normal map color input component
  142509. */
  142510. get normalMapColor(): NodeMaterialConnectionPoint;
  142511. /**
  142512. * Gets the strength input component
  142513. */
  142514. get strength(): NodeMaterialConnectionPoint;
  142515. /**
  142516. * Gets the output component
  142517. */
  142518. get output(): NodeMaterialConnectionPoint;
  142519. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142520. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142521. autoConfigure(material: NodeMaterial): void;
  142522. protected _buildBlock(state: NodeMaterialBuildState): this;
  142523. protected _dumpPropertiesCode(): string;
  142524. serialize(): any;
  142525. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142526. }
  142527. }
  142528. declare module BABYLON {
  142529. /**
  142530. * Block used to discard a pixel if a value is smaller than a cutoff
  142531. */
  142532. export class DiscardBlock extends NodeMaterialBlock {
  142533. /**
  142534. * Create a new DiscardBlock
  142535. * @param name defines the block name
  142536. */
  142537. constructor(name: string);
  142538. /**
  142539. * Gets the current class name
  142540. * @returns the class name
  142541. */
  142542. getClassName(): string;
  142543. /**
  142544. * Gets the color input component
  142545. */
  142546. get value(): NodeMaterialConnectionPoint;
  142547. /**
  142548. * Gets the cutoff input component
  142549. */
  142550. get cutoff(): NodeMaterialConnectionPoint;
  142551. protected _buildBlock(state: NodeMaterialBuildState): this;
  142552. }
  142553. }
  142554. declare module BABYLON {
  142555. /**
  142556. * Block used to test if the fragment shader is front facing
  142557. */
  142558. export class FrontFacingBlock extends NodeMaterialBlock {
  142559. /**
  142560. * Creates a new FrontFacingBlock
  142561. * @param name defines the block name
  142562. */
  142563. constructor(name: string);
  142564. /**
  142565. * Gets the current class name
  142566. * @returns the class name
  142567. */
  142568. getClassName(): string;
  142569. /**
  142570. * Gets the output component
  142571. */
  142572. get output(): NodeMaterialConnectionPoint;
  142573. protected _buildBlock(state: NodeMaterialBuildState): this;
  142574. }
  142575. }
  142576. declare module BABYLON {
  142577. /**
  142578. * Block used to get the derivative value on x and y of a given input
  142579. */
  142580. export class DerivativeBlock extends NodeMaterialBlock {
  142581. /**
  142582. * Create a new DerivativeBlock
  142583. * @param name defines the block name
  142584. */
  142585. constructor(name: string);
  142586. /**
  142587. * Gets the current class name
  142588. * @returns the class name
  142589. */
  142590. getClassName(): string;
  142591. /**
  142592. * Gets the input component
  142593. */
  142594. get input(): NodeMaterialConnectionPoint;
  142595. /**
  142596. * Gets the derivative output on x
  142597. */
  142598. get dx(): NodeMaterialConnectionPoint;
  142599. /**
  142600. * Gets the derivative output on y
  142601. */
  142602. get dy(): NodeMaterialConnectionPoint;
  142603. protected _buildBlock(state: NodeMaterialBuildState): this;
  142604. }
  142605. }
  142606. declare module BABYLON {
  142607. /**
  142608. * Block used to make gl_FragCoord available
  142609. */
  142610. export class FragCoordBlock extends NodeMaterialBlock {
  142611. /**
  142612. * Creates a new FragCoordBlock
  142613. * @param name defines the block name
  142614. */
  142615. constructor(name: string);
  142616. /**
  142617. * Gets the current class name
  142618. * @returns the class name
  142619. */
  142620. getClassName(): string;
  142621. /**
  142622. * Gets the xy component
  142623. */
  142624. get xy(): NodeMaterialConnectionPoint;
  142625. /**
  142626. * Gets the xyz component
  142627. */
  142628. get xyz(): NodeMaterialConnectionPoint;
  142629. /**
  142630. * Gets the xyzw component
  142631. */
  142632. get xyzw(): NodeMaterialConnectionPoint;
  142633. /**
  142634. * Gets the x component
  142635. */
  142636. get x(): NodeMaterialConnectionPoint;
  142637. /**
  142638. * Gets the y component
  142639. */
  142640. get y(): NodeMaterialConnectionPoint;
  142641. /**
  142642. * Gets the z component
  142643. */
  142644. get z(): NodeMaterialConnectionPoint;
  142645. /**
  142646. * Gets the w component
  142647. */
  142648. get output(): NodeMaterialConnectionPoint;
  142649. protected writeOutputs(state: NodeMaterialBuildState): string;
  142650. protected _buildBlock(state: NodeMaterialBuildState): this;
  142651. }
  142652. }
  142653. declare module BABYLON {
  142654. /**
  142655. * Block used to get the screen sizes
  142656. */
  142657. export class ScreenSizeBlock extends NodeMaterialBlock {
  142658. private _varName;
  142659. private _scene;
  142660. /**
  142661. * Creates a new ScreenSizeBlock
  142662. * @param name defines the block name
  142663. */
  142664. constructor(name: string);
  142665. /**
  142666. * Gets the current class name
  142667. * @returns the class name
  142668. */
  142669. getClassName(): string;
  142670. /**
  142671. * Gets the xy component
  142672. */
  142673. get xy(): NodeMaterialConnectionPoint;
  142674. /**
  142675. * Gets the x component
  142676. */
  142677. get x(): NodeMaterialConnectionPoint;
  142678. /**
  142679. * Gets the y component
  142680. */
  142681. get y(): NodeMaterialConnectionPoint;
  142682. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142683. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  142684. protected _buildBlock(state: NodeMaterialBuildState): this;
  142685. }
  142686. }
  142687. declare module BABYLON {
  142688. /**
  142689. * Block used to add support for scene fog
  142690. */
  142691. export class FogBlock extends NodeMaterialBlock {
  142692. private _fogDistanceName;
  142693. private _fogParameters;
  142694. /**
  142695. * Create a new FogBlock
  142696. * @param name defines the block name
  142697. */
  142698. constructor(name: string);
  142699. /**
  142700. * Gets the current class name
  142701. * @returns the class name
  142702. */
  142703. getClassName(): string;
  142704. /**
  142705. * Gets the world position input component
  142706. */
  142707. get worldPosition(): NodeMaterialConnectionPoint;
  142708. /**
  142709. * Gets the view input component
  142710. */
  142711. get view(): NodeMaterialConnectionPoint;
  142712. /**
  142713. * Gets the color input component
  142714. */
  142715. get input(): NodeMaterialConnectionPoint;
  142716. /**
  142717. * Gets the fog color input component
  142718. */
  142719. get fogColor(): NodeMaterialConnectionPoint;
  142720. /**
  142721. * Gets the output component
  142722. */
  142723. get output(): NodeMaterialConnectionPoint;
  142724. autoConfigure(material: NodeMaterial): void;
  142725. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142726. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142727. protected _buildBlock(state: NodeMaterialBuildState): this;
  142728. }
  142729. }
  142730. declare module BABYLON {
  142731. /**
  142732. * Block used to add light in the fragment shader
  142733. */
  142734. export class LightBlock extends NodeMaterialBlock {
  142735. private _lightId;
  142736. /**
  142737. * Gets or sets the light associated with this block
  142738. */
  142739. light: Nullable<Light>;
  142740. /**
  142741. * Create a new LightBlock
  142742. * @param name defines the block name
  142743. */
  142744. constructor(name: string);
  142745. /**
  142746. * Gets the current class name
  142747. * @returns the class name
  142748. */
  142749. getClassName(): string;
  142750. /**
  142751. * Gets the world position input component
  142752. */
  142753. get worldPosition(): NodeMaterialConnectionPoint;
  142754. /**
  142755. * Gets the world normal input component
  142756. */
  142757. get worldNormal(): NodeMaterialConnectionPoint;
  142758. /**
  142759. * Gets the camera (or eye) position component
  142760. */
  142761. get cameraPosition(): NodeMaterialConnectionPoint;
  142762. /**
  142763. * Gets the glossiness component
  142764. */
  142765. get glossiness(): NodeMaterialConnectionPoint;
  142766. /**
  142767. * Gets the glossinness power component
  142768. */
  142769. get glossPower(): NodeMaterialConnectionPoint;
  142770. /**
  142771. * Gets the diffuse color component
  142772. */
  142773. get diffuseColor(): NodeMaterialConnectionPoint;
  142774. /**
  142775. * Gets the specular color component
  142776. */
  142777. get specularColor(): NodeMaterialConnectionPoint;
  142778. /**
  142779. * Gets the diffuse output component
  142780. */
  142781. get diffuseOutput(): NodeMaterialConnectionPoint;
  142782. /**
  142783. * Gets the specular output component
  142784. */
  142785. get specularOutput(): NodeMaterialConnectionPoint;
  142786. /**
  142787. * Gets the shadow output component
  142788. */
  142789. get shadow(): NodeMaterialConnectionPoint;
  142790. autoConfigure(material: NodeMaterial): void;
  142791. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142792. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  142793. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142794. private _injectVertexCode;
  142795. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142796. serialize(): any;
  142797. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142798. }
  142799. }
  142800. declare module BABYLON {
  142801. /**
  142802. * Block used to read a reflection texture from a sampler
  142803. */
  142804. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  142805. /**
  142806. * Create a new ReflectionTextureBlock
  142807. * @param name defines the block name
  142808. */
  142809. constructor(name: string);
  142810. /**
  142811. * Gets the current class name
  142812. * @returns the class name
  142813. */
  142814. getClassName(): string;
  142815. /**
  142816. * Gets the world position input component
  142817. */
  142818. get position(): NodeMaterialConnectionPoint;
  142819. /**
  142820. * Gets the world position input component
  142821. */
  142822. get worldPosition(): NodeMaterialConnectionPoint;
  142823. /**
  142824. * Gets the world normal input component
  142825. */
  142826. get worldNormal(): NodeMaterialConnectionPoint;
  142827. /**
  142828. * Gets the world input component
  142829. */
  142830. get world(): NodeMaterialConnectionPoint;
  142831. /**
  142832. * Gets the camera (or eye) position component
  142833. */
  142834. get cameraPosition(): NodeMaterialConnectionPoint;
  142835. /**
  142836. * Gets the view input component
  142837. */
  142838. get view(): NodeMaterialConnectionPoint;
  142839. /**
  142840. * Gets the rgb output component
  142841. */
  142842. get rgb(): NodeMaterialConnectionPoint;
  142843. /**
  142844. * Gets the rgba output component
  142845. */
  142846. get rgba(): NodeMaterialConnectionPoint;
  142847. /**
  142848. * Gets the r output component
  142849. */
  142850. get r(): NodeMaterialConnectionPoint;
  142851. /**
  142852. * Gets the g output component
  142853. */
  142854. get g(): NodeMaterialConnectionPoint;
  142855. /**
  142856. * Gets the b output component
  142857. */
  142858. get b(): NodeMaterialConnectionPoint;
  142859. /**
  142860. * Gets the a output component
  142861. */
  142862. get a(): NodeMaterialConnectionPoint;
  142863. autoConfigure(material: NodeMaterial): void;
  142864. protected _buildBlock(state: NodeMaterialBuildState): this;
  142865. }
  142866. }
  142867. declare module BABYLON {
  142868. /**
  142869. * Block used to add 2 vectors
  142870. */
  142871. export class AddBlock extends NodeMaterialBlock {
  142872. /**
  142873. * Creates a new AddBlock
  142874. * @param name defines the block name
  142875. */
  142876. constructor(name: string);
  142877. /**
  142878. * Gets the current class name
  142879. * @returns the class name
  142880. */
  142881. getClassName(): string;
  142882. /**
  142883. * Gets the left operand input component
  142884. */
  142885. get left(): NodeMaterialConnectionPoint;
  142886. /**
  142887. * Gets the right operand input component
  142888. */
  142889. get right(): NodeMaterialConnectionPoint;
  142890. /**
  142891. * Gets the output component
  142892. */
  142893. get output(): NodeMaterialConnectionPoint;
  142894. protected _buildBlock(state: NodeMaterialBuildState): this;
  142895. }
  142896. }
  142897. declare module BABYLON {
  142898. /**
  142899. * Block used to scale a vector by a float
  142900. */
  142901. export class ScaleBlock extends NodeMaterialBlock {
  142902. /**
  142903. * Creates a new ScaleBlock
  142904. * @param name defines the block name
  142905. */
  142906. constructor(name: string);
  142907. /**
  142908. * Gets the current class name
  142909. * @returns the class name
  142910. */
  142911. getClassName(): string;
  142912. /**
  142913. * Gets the input component
  142914. */
  142915. get input(): NodeMaterialConnectionPoint;
  142916. /**
  142917. * Gets the factor input component
  142918. */
  142919. get factor(): NodeMaterialConnectionPoint;
  142920. /**
  142921. * Gets the output component
  142922. */
  142923. get output(): NodeMaterialConnectionPoint;
  142924. protected _buildBlock(state: NodeMaterialBuildState): this;
  142925. }
  142926. }
  142927. declare module BABYLON {
  142928. /**
  142929. * Block used to clamp a float
  142930. */
  142931. export class ClampBlock extends NodeMaterialBlock {
  142932. /** Gets or sets the minimum range */
  142933. minimum: number;
  142934. /** Gets or sets the maximum range */
  142935. maximum: number;
  142936. /**
  142937. * Creates a new ClampBlock
  142938. * @param name defines the block name
  142939. */
  142940. constructor(name: string);
  142941. /**
  142942. * Gets the current class name
  142943. * @returns the class name
  142944. */
  142945. getClassName(): string;
  142946. /**
  142947. * Gets the value input component
  142948. */
  142949. get value(): NodeMaterialConnectionPoint;
  142950. /**
  142951. * Gets the output component
  142952. */
  142953. get output(): NodeMaterialConnectionPoint;
  142954. protected _buildBlock(state: NodeMaterialBuildState): this;
  142955. protected _dumpPropertiesCode(): string;
  142956. serialize(): any;
  142957. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142958. }
  142959. }
  142960. declare module BABYLON {
  142961. /**
  142962. * Block used to apply a cross product between 2 vectors
  142963. */
  142964. export class CrossBlock extends NodeMaterialBlock {
  142965. /**
  142966. * Creates a new CrossBlock
  142967. * @param name defines the block name
  142968. */
  142969. constructor(name: string);
  142970. /**
  142971. * Gets the current class name
  142972. * @returns the class name
  142973. */
  142974. getClassName(): string;
  142975. /**
  142976. * Gets the left operand input component
  142977. */
  142978. get left(): NodeMaterialConnectionPoint;
  142979. /**
  142980. * Gets the right operand input component
  142981. */
  142982. get right(): NodeMaterialConnectionPoint;
  142983. /**
  142984. * Gets the output component
  142985. */
  142986. get output(): NodeMaterialConnectionPoint;
  142987. protected _buildBlock(state: NodeMaterialBuildState): this;
  142988. }
  142989. }
  142990. declare module BABYLON {
  142991. /**
  142992. * Block used to apply a dot product between 2 vectors
  142993. */
  142994. export class DotBlock extends NodeMaterialBlock {
  142995. /**
  142996. * Creates a new DotBlock
  142997. * @param name defines the block name
  142998. */
  142999. constructor(name: string);
  143000. /**
  143001. * Gets the current class name
  143002. * @returns the class name
  143003. */
  143004. getClassName(): string;
  143005. /**
  143006. * Gets the left operand input component
  143007. */
  143008. get left(): NodeMaterialConnectionPoint;
  143009. /**
  143010. * Gets the right operand input component
  143011. */
  143012. get right(): NodeMaterialConnectionPoint;
  143013. /**
  143014. * Gets the output component
  143015. */
  143016. get output(): NodeMaterialConnectionPoint;
  143017. protected _buildBlock(state: NodeMaterialBuildState): this;
  143018. }
  143019. }
  143020. declare module BABYLON {
  143021. /**
  143022. * Block used to normalize a vector
  143023. */
  143024. export class NormalizeBlock extends NodeMaterialBlock {
  143025. /**
  143026. * Creates a new NormalizeBlock
  143027. * @param name defines the block name
  143028. */
  143029. constructor(name: string);
  143030. /**
  143031. * Gets the current class name
  143032. * @returns the class name
  143033. */
  143034. getClassName(): string;
  143035. /**
  143036. * Gets the input component
  143037. */
  143038. get input(): NodeMaterialConnectionPoint;
  143039. /**
  143040. * Gets the output component
  143041. */
  143042. get output(): NodeMaterialConnectionPoint;
  143043. protected _buildBlock(state: NodeMaterialBuildState): this;
  143044. }
  143045. }
  143046. declare module BABYLON {
  143047. /**
  143048. * Operations supported by the Trigonometry block
  143049. */
  143050. export enum TrigonometryBlockOperations {
  143051. /** Cos */
  143052. Cos = 0,
  143053. /** Sin */
  143054. Sin = 1,
  143055. /** Abs */
  143056. Abs = 2,
  143057. /** Exp */
  143058. Exp = 3,
  143059. /** Exp2 */
  143060. Exp2 = 4,
  143061. /** Round */
  143062. Round = 5,
  143063. /** Floor */
  143064. Floor = 6,
  143065. /** Ceiling */
  143066. Ceiling = 7,
  143067. /** Square root */
  143068. Sqrt = 8,
  143069. /** Log */
  143070. Log = 9,
  143071. /** Tangent */
  143072. Tan = 10,
  143073. /** Arc tangent */
  143074. ArcTan = 11,
  143075. /** Arc cosinus */
  143076. ArcCos = 12,
  143077. /** Arc sinus */
  143078. ArcSin = 13,
  143079. /** Fraction */
  143080. Fract = 14,
  143081. /** Sign */
  143082. Sign = 15,
  143083. /** To radians (from degrees) */
  143084. Radians = 16,
  143085. /** To degrees (from radians) */
  143086. Degrees = 17
  143087. }
  143088. /**
  143089. * Block used to apply trigonometry operation to floats
  143090. */
  143091. export class TrigonometryBlock extends NodeMaterialBlock {
  143092. /**
  143093. * Gets or sets the operation applied by the block
  143094. */
  143095. operation: TrigonometryBlockOperations;
  143096. /**
  143097. * Creates a new TrigonometryBlock
  143098. * @param name defines the block name
  143099. */
  143100. constructor(name: string);
  143101. /**
  143102. * Gets the current class name
  143103. * @returns the class name
  143104. */
  143105. getClassName(): string;
  143106. /**
  143107. * Gets the input component
  143108. */
  143109. get input(): NodeMaterialConnectionPoint;
  143110. /**
  143111. * Gets the output component
  143112. */
  143113. get output(): NodeMaterialConnectionPoint;
  143114. protected _buildBlock(state: NodeMaterialBuildState): this;
  143115. serialize(): any;
  143116. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143117. protected _dumpPropertiesCode(): string;
  143118. }
  143119. }
  143120. declare module BABYLON {
  143121. /**
  143122. * Block used to create a Color3/4 out of individual inputs (one for each component)
  143123. */
  143124. export class ColorMergerBlock extends NodeMaterialBlock {
  143125. /**
  143126. * Create a new ColorMergerBlock
  143127. * @param name defines the block name
  143128. */
  143129. constructor(name: string);
  143130. /**
  143131. * Gets the current class name
  143132. * @returns the class name
  143133. */
  143134. getClassName(): string;
  143135. /**
  143136. * Gets the rgb component (input)
  143137. */
  143138. get rgbIn(): NodeMaterialConnectionPoint;
  143139. /**
  143140. * Gets the r component (input)
  143141. */
  143142. get r(): NodeMaterialConnectionPoint;
  143143. /**
  143144. * Gets the g component (input)
  143145. */
  143146. get g(): NodeMaterialConnectionPoint;
  143147. /**
  143148. * Gets the b component (input)
  143149. */
  143150. get b(): NodeMaterialConnectionPoint;
  143151. /**
  143152. * Gets the a component (input)
  143153. */
  143154. get a(): NodeMaterialConnectionPoint;
  143155. /**
  143156. * Gets the rgba component (output)
  143157. */
  143158. get rgba(): NodeMaterialConnectionPoint;
  143159. /**
  143160. * Gets the rgb component (output)
  143161. */
  143162. get rgbOut(): NodeMaterialConnectionPoint;
  143163. /**
  143164. * Gets the rgb component (output)
  143165. * @deprecated Please use rgbOut instead.
  143166. */
  143167. get rgb(): NodeMaterialConnectionPoint;
  143168. protected _buildBlock(state: NodeMaterialBuildState): this;
  143169. }
  143170. }
  143171. declare module BABYLON {
  143172. /**
  143173. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  143174. */
  143175. export class VectorSplitterBlock extends NodeMaterialBlock {
  143176. /**
  143177. * Create a new VectorSplitterBlock
  143178. * @param name defines the block name
  143179. */
  143180. constructor(name: string);
  143181. /**
  143182. * Gets the current class name
  143183. * @returns the class name
  143184. */
  143185. getClassName(): string;
  143186. /**
  143187. * Gets the xyzw component (input)
  143188. */
  143189. get xyzw(): NodeMaterialConnectionPoint;
  143190. /**
  143191. * Gets the xyz component (input)
  143192. */
  143193. get xyzIn(): NodeMaterialConnectionPoint;
  143194. /**
  143195. * Gets the xy component (input)
  143196. */
  143197. get xyIn(): NodeMaterialConnectionPoint;
  143198. /**
  143199. * Gets the xyz component (output)
  143200. */
  143201. get xyzOut(): NodeMaterialConnectionPoint;
  143202. /**
  143203. * Gets the xy component (output)
  143204. */
  143205. get xyOut(): NodeMaterialConnectionPoint;
  143206. /**
  143207. * Gets the x component (output)
  143208. */
  143209. get x(): NodeMaterialConnectionPoint;
  143210. /**
  143211. * Gets the y component (output)
  143212. */
  143213. get y(): NodeMaterialConnectionPoint;
  143214. /**
  143215. * Gets the z component (output)
  143216. */
  143217. get z(): NodeMaterialConnectionPoint;
  143218. /**
  143219. * Gets the w component (output)
  143220. */
  143221. get w(): NodeMaterialConnectionPoint;
  143222. protected _inputRename(name: string): string;
  143223. protected _outputRename(name: string): string;
  143224. protected _buildBlock(state: NodeMaterialBuildState): this;
  143225. }
  143226. }
  143227. declare module BABYLON {
  143228. /**
  143229. * Block used to lerp between 2 values
  143230. */
  143231. export class LerpBlock extends NodeMaterialBlock {
  143232. /**
  143233. * Creates a new LerpBlock
  143234. * @param name defines the block name
  143235. */
  143236. constructor(name: string);
  143237. /**
  143238. * Gets the current class name
  143239. * @returns the class name
  143240. */
  143241. getClassName(): string;
  143242. /**
  143243. * Gets the left operand input component
  143244. */
  143245. get left(): NodeMaterialConnectionPoint;
  143246. /**
  143247. * Gets the right operand input component
  143248. */
  143249. get right(): NodeMaterialConnectionPoint;
  143250. /**
  143251. * Gets the gradient operand input component
  143252. */
  143253. get gradient(): NodeMaterialConnectionPoint;
  143254. /**
  143255. * Gets the output component
  143256. */
  143257. get output(): NodeMaterialConnectionPoint;
  143258. protected _buildBlock(state: NodeMaterialBuildState): this;
  143259. }
  143260. }
  143261. declare module BABYLON {
  143262. /**
  143263. * Block used to divide 2 vectors
  143264. */
  143265. export class DivideBlock extends NodeMaterialBlock {
  143266. /**
  143267. * Creates a new DivideBlock
  143268. * @param name defines the block name
  143269. */
  143270. constructor(name: string);
  143271. /**
  143272. * Gets the current class name
  143273. * @returns the class name
  143274. */
  143275. getClassName(): string;
  143276. /**
  143277. * Gets the left operand input component
  143278. */
  143279. get left(): NodeMaterialConnectionPoint;
  143280. /**
  143281. * Gets the right operand input component
  143282. */
  143283. get right(): NodeMaterialConnectionPoint;
  143284. /**
  143285. * Gets the output component
  143286. */
  143287. get output(): NodeMaterialConnectionPoint;
  143288. protected _buildBlock(state: NodeMaterialBuildState): this;
  143289. }
  143290. }
  143291. declare module BABYLON {
  143292. /**
  143293. * Block used to subtract 2 vectors
  143294. */
  143295. export class SubtractBlock extends NodeMaterialBlock {
  143296. /**
  143297. * Creates a new SubtractBlock
  143298. * @param name defines the block name
  143299. */
  143300. constructor(name: string);
  143301. /**
  143302. * Gets the current class name
  143303. * @returns the class name
  143304. */
  143305. getClassName(): string;
  143306. /**
  143307. * Gets the left operand input component
  143308. */
  143309. get left(): NodeMaterialConnectionPoint;
  143310. /**
  143311. * Gets the right operand input component
  143312. */
  143313. get right(): NodeMaterialConnectionPoint;
  143314. /**
  143315. * Gets the output component
  143316. */
  143317. get output(): NodeMaterialConnectionPoint;
  143318. protected _buildBlock(state: NodeMaterialBuildState): this;
  143319. }
  143320. }
  143321. declare module BABYLON {
  143322. /**
  143323. * Block used to step a value
  143324. */
  143325. export class StepBlock extends NodeMaterialBlock {
  143326. /**
  143327. * Creates a new StepBlock
  143328. * @param name defines the block name
  143329. */
  143330. constructor(name: string);
  143331. /**
  143332. * Gets the current class name
  143333. * @returns the class name
  143334. */
  143335. getClassName(): string;
  143336. /**
  143337. * Gets the value operand input component
  143338. */
  143339. get value(): NodeMaterialConnectionPoint;
  143340. /**
  143341. * Gets the edge operand input component
  143342. */
  143343. get edge(): NodeMaterialConnectionPoint;
  143344. /**
  143345. * Gets the output component
  143346. */
  143347. get output(): NodeMaterialConnectionPoint;
  143348. protected _buildBlock(state: NodeMaterialBuildState): this;
  143349. }
  143350. }
  143351. declare module BABYLON {
  143352. /**
  143353. * Block used to get the opposite (1 - x) of a value
  143354. */
  143355. export class OneMinusBlock extends NodeMaterialBlock {
  143356. /**
  143357. * Creates a new OneMinusBlock
  143358. * @param name defines the block name
  143359. */
  143360. constructor(name: string);
  143361. /**
  143362. * Gets the current class name
  143363. * @returns the class name
  143364. */
  143365. getClassName(): string;
  143366. /**
  143367. * Gets the input component
  143368. */
  143369. get input(): NodeMaterialConnectionPoint;
  143370. /**
  143371. * Gets the output component
  143372. */
  143373. get output(): NodeMaterialConnectionPoint;
  143374. protected _buildBlock(state: NodeMaterialBuildState): this;
  143375. }
  143376. }
  143377. declare module BABYLON {
  143378. /**
  143379. * Block used to get the view direction
  143380. */
  143381. export class ViewDirectionBlock extends NodeMaterialBlock {
  143382. /**
  143383. * Creates a new ViewDirectionBlock
  143384. * @param name defines the block name
  143385. */
  143386. constructor(name: string);
  143387. /**
  143388. * Gets the current class name
  143389. * @returns the class name
  143390. */
  143391. getClassName(): string;
  143392. /**
  143393. * Gets the world position component
  143394. */
  143395. get worldPosition(): NodeMaterialConnectionPoint;
  143396. /**
  143397. * Gets the camera position component
  143398. */
  143399. get cameraPosition(): NodeMaterialConnectionPoint;
  143400. /**
  143401. * Gets the output component
  143402. */
  143403. get output(): NodeMaterialConnectionPoint;
  143404. autoConfigure(material: NodeMaterial): void;
  143405. protected _buildBlock(state: NodeMaterialBuildState): this;
  143406. }
  143407. }
  143408. declare module BABYLON {
  143409. /**
  143410. * Block used to compute fresnel value
  143411. */
  143412. export class FresnelBlock extends NodeMaterialBlock {
  143413. /**
  143414. * Create a new FresnelBlock
  143415. * @param name defines the block name
  143416. */
  143417. constructor(name: string);
  143418. /**
  143419. * Gets the current class name
  143420. * @returns the class name
  143421. */
  143422. getClassName(): string;
  143423. /**
  143424. * Gets the world normal input component
  143425. */
  143426. get worldNormal(): NodeMaterialConnectionPoint;
  143427. /**
  143428. * Gets the view direction input component
  143429. */
  143430. get viewDirection(): NodeMaterialConnectionPoint;
  143431. /**
  143432. * Gets the bias input component
  143433. */
  143434. get bias(): NodeMaterialConnectionPoint;
  143435. /**
  143436. * Gets the camera (or eye) position component
  143437. */
  143438. get power(): NodeMaterialConnectionPoint;
  143439. /**
  143440. * Gets the fresnel output component
  143441. */
  143442. get fresnel(): NodeMaterialConnectionPoint;
  143443. autoConfigure(material: NodeMaterial): void;
  143444. protected _buildBlock(state: NodeMaterialBuildState): this;
  143445. }
  143446. }
  143447. declare module BABYLON {
  143448. /**
  143449. * Block used to get the max of 2 values
  143450. */
  143451. export class MaxBlock extends NodeMaterialBlock {
  143452. /**
  143453. * Creates a new MaxBlock
  143454. * @param name defines the block name
  143455. */
  143456. constructor(name: string);
  143457. /**
  143458. * Gets the current class name
  143459. * @returns the class name
  143460. */
  143461. getClassName(): string;
  143462. /**
  143463. * Gets the left operand input component
  143464. */
  143465. get left(): NodeMaterialConnectionPoint;
  143466. /**
  143467. * Gets the right operand input component
  143468. */
  143469. get right(): NodeMaterialConnectionPoint;
  143470. /**
  143471. * Gets the output component
  143472. */
  143473. get output(): NodeMaterialConnectionPoint;
  143474. protected _buildBlock(state: NodeMaterialBuildState): this;
  143475. }
  143476. }
  143477. declare module BABYLON {
  143478. /**
  143479. * Block used to get the min of 2 values
  143480. */
  143481. export class MinBlock extends NodeMaterialBlock {
  143482. /**
  143483. * Creates a new MinBlock
  143484. * @param name defines the block name
  143485. */
  143486. constructor(name: string);
  143487. /**
  143488. * Gets the current class name
  143489. * @returns the class name
  143490. */
  143491. getClassName(): string;
  143492. /**
  143493. * Gets the left operand input component
  143494. */
  143495. get left(): NodeMaterialConnectionPoint;
  143496. /**
  143497. * Gets the right operand input component
  143498. */
  143499. get right(): NodeMaterialConnectionPoint;
  143500. /**
  143501. * Gets the output component
  143502. */
  143503. get output(): NodeMaterialConnectionPoint;
  143504. protected _buildBlock(state: NodeMaterialBuildState): this;
  143505. }
  143506. }
  143507. declare module BABYLON {
  143508. /**
  143509. * Block used to get the distance between 2 values
  143510. */
  143511. export class DistanceBlock extends NodeMaterialBlock {
  143512. /**
  143513. * Creates a new DistanceBlock
  143514. * @param name defines the block name
  143515. */
  143516. constructor(name: string);
  143517. /**
  143518. * Gets the current class name
  143519. * @returns the class name
  143520. */
  143521. getClassName(): string;
  143522. /**
  143523. * Gets the left operand input component
  143524. */
  143525. get left(): NodeMaterialConnectionPoint;
  143526. /**
  143527. * Gets the right operand input component
  143528. */
  143529. get right(): NodeMaterialConnectionPoint;
  143530. /**
  143531. * Gets the output component
  143532. */
  143533. get output(): NodeMaterialConnectionPoint;
  143534. protected _buildBlock(state: NodeMaterialBuildState): this;
  143535. }
  143536. }
  143537. declare module BABYLON {
  143538. /**
  143539. * Block used to get the length of a vector
  143540. */
  143541. export class LengthBlock extends NodeMaterialBlock {
  143542. /**
  143543. * Creates a new LengthBlock
  143544. * @param name defines the block name
  143545. */
  143546. constructor(name: string);
  143547. /**
  143548. * Gets the current class name
  143549. * @returns the class name
  143550. */
  143551. getClassName(): string;
  143552. /**
  143553. * Gets the value input component
  143554. */
  143555. get value(): NodeMaterialConnectionPoint;
  143556. /**
  143557. * Gets the output component
  143558. */
  143559. get output(): NodeMaterialConnectionPoint;
  143560. protected _buildBlock(state: NodeMaterialBuildState): this;
  143561. }
  143562. }
  143563. declare module BABYLON {
  143564. /**
  143565. * Block used to get negative version of a value (i.e. x * -1)
  143566. */
  143567. export class NegateBlock extends NodeMaterialBlock {
  143568. /**
  143569. * Creates a new NegateBlock
  143570. * @param name defines the block name
  143571. */
  143572. constructor(name: string);
  143573. /**
  143574. * Gets the current class name
  143575. * @returns the class name
  143576. */
  143577. getClassName(): string;
  143578. /**
  143579. * Gets the value input component
  143580. */
  143581. get value(): NodeMaterialConnectionPoint;
  143582. /**
  143583. * Gets the output component
  143584. */
  143585. get output(): NodeMaterialConnectionPoint;
  143586. protected _buildBlock(state: NodeMaterialBuildState): this;
  143587. }
  143588. }
  143589. declare module BABYLON {
  143590. /**
  143591. * Block used to get the value of the first parameter raised to the power of the second
  143592. */
  143593. export class PowBlock extends NodeMaterialBlock {
  143594. /**
  143595. * Creates a new PowBlock
  143596. * @param name defines the block name
  143597. */
  143598. constructor(name: string);
  143599. /**
  143600. * Gets the current class name
  143601. * @returns the class name
  143602. */
  143603. getClassName(): string;
  143604. /**
  143605. * Gets the value operand input component
  143606. */
  143607. get value(): NodeMaterialConnectionPoint;
  143608. /**
  143609. * Gets the power operand input component
  143610. */
  143611. get power(): NodeMaterialConnectionPoint;
  143612. /**
  143613. * Gets the output component
  143614. */
  143615. get output(): NodeMaterialConnectionPoint;
  143616. protected _buildBlock(state: NodeMaterialBuildState): this;
  143617. }
  143618. }
  143619. declare module BABYLON {
  143620. /**
  143621. * Block used to get a random number
  143622. */
  143623. export class RandomNumberBlock extends NodeMaterialBlock {
  143624. /**
  143625. * Creates a new RandomNumberBlock
  143626. * @param name defines the block name
  143627. */
  143628. constructor(name: string);
  143629. /**
  143630. * Gets the current class name
  143631. * @returns the class name
  143632. */
  143633. getClassName(): string;
  143634. /**
  143635. * Gets the seed input component
  143636. */
  143637. get seed(): NodeMaterialConnectionPoint;
  143638. /**
  143639. * Gets the output component
  143640. */
  143641. get output(): NodeMaterialConnectionPoint;
  143642. protected _buildBlock(state: NodeMaterialBuildState): this;
  143643. }
  143644. }
  143645. declare module BABYLON {
  143646. /**
  143647. * Block used to compute arc tangent of 2 values
  143648. */
  143649. export class ArcTan2Block extends NodeMaterialBlock {
  143650. /**
  143651. * Creates a new ArcTan2Block
  143652. * @param name defines the block name
  143653. */
  143654. constructor(name: string);
  143655. /**
  143656. * Gets the current class name
  143657. * @returns the class name
  143658. */
  143659. getClassName(): string;
  143660. /**
  143661. * Gets the x operand input component
  143662. */
  143663. get x(): NodeMaterialConnectionPoint;
  143664. /**
  143665. * Gets the y operand input component
  143666. */
  143667. get y(): NodeMaterialConnectionPoint;
  143668. /**
  143669. * Gets the output component
  143670. */
  143671. get output(): NodeMaterialConnectionPoint;
  143672. protected _buildBlock(state: NodeMaterialBuildState): this;
  143673. }
  143674. }
  143675. declare module BABYLON {
  143676. /**
  143677. * Block used to smooth step a value
  143678. */
  143679. export class SmoothStepBlock extends NodeMaterialBlock {
  143680. /**
  143681. * Creates a new SmoothStepBlock
  143682. * @param name defines the block name
  143683. */
  143684. constructor(name: string);
  143685. /**
  143686. * Gets the current class name
  143687. * @returns the class name
  143688. */
  143689. getClassName(): string;
  143690. /**
  143691. * Gets the value operand input component
  143692. */
  143693. get value(): NodeMaterialConnectionPoint;
  143694. /**
  143695. * Gets the first edge operand input component
  143696. */
  143697. get edge0(): NodeMaterialConnectionPoint;
  143698. /**
  143699. * Gets the second edge operand input component
  143700. */
  143701. get edge1(): NodeMaterialConnectionPoint;
  143702. /**
  143703. * Gets the output component
  143704. */
  143705. get output(): NodeMaterialConnectionPoint;
  143706. protected _buildBlock(state: NodeMaterialBuildState): this;
  143707. }
  143708. }
  143709. declare module BABYLON {
  143710. /**
  143711. * Block used to get the reciprocal (1 / x) of a value
  143712. */
  143713. export class ReciprocalBlock extends NodeMaterialBlock {
  143714. /**
  143715. * Creates a new ReciprocalBlock
  143716. * @param name defines the block name
  143717. */
  143718. constructor(name: string);
  143719. /**
  143720. * Gets the current class name
  143721. * @returns the class name
  143722. */
  143723. getClassName(): string;
  143724. /**
  143725. * Gets the input component
  143726. */
  143727. get input(): NodeMaterialConnectionPoint;
  143728. /**
  143729. * Gets the output component
  143730. */
  143731. get output(): NodeMaterialConnectionPoint;
  143732. protected _buildBlock(state: NodeMaterialBuildState): this;
  143733. }
  143734. }
  143735. declare module BABYLON {
  143736. /**
  143737. * Block used to replace a color by another one
  143738. */
  143739. export class ReplaceColorBlock extends NodeMaterialBlock {
  143740. /**
  143741. * Creates a new ReplaceColorBlock
  143742. * @param name defines the block name
  143743. */
  143744. constructor(name: string);
  143745. /**
  143746. * Gets the current class name
  143747. * @returns the class name
  143748. */
  143749. getClassName(): string;
  143750. /**
  143751. * Gets the value input component
  143752. */
  143753. get value(): NodeMaterialConnectionPoint;
  143754. /**
  143755. * Gets the reference input component
  143756. */
  143757. get reference(): NodeMaterialConnectionPoint;
  143758. /**
  143759. * Gets the distance input component
  143760. */
  143761. get distance(): NodeMaterialConnectionPoint;
  143762. /**
  143763. * Gets the replacement input component
  143764. */
  143765. get replacement(): NodeMaterialConnectionPoint;
  143766. /**
  143767. * Gets the output component
  143768. */
  143769. get output(): NodeMaterialConnectionPoint;
  143770. protected _buildBlock(state: NodeMaterialBuildState): this;
  143771. }
  143772. }
  143773. declare module BABYLON {
  143774. /**
  143775. * Block used to posterize a value
  143776. * @see https://en.wikipedia.org/wiki/Posterization
  143777. */
  143778. export class PosterizeBlock extends NodeMaterialBlock {
  143779. /**
  143780. * Creates a new PosterizeBlock
  143781. * @param name defines the block name
  143782. */
  143783. constructor(name: string);
  143784. /**
  143785. * Gets the current class name
  143786. * @returns the class name
  143787. */
  143788. getClassName(): string;
  143789. /**
  143790. * Gets the value input component
  143791. */
  143792. get value(): NodeMaterialConnectionPoint;
  143793. /**
  143794. * Gets the steps input component
  143795. */
  143796. get steps(): NodeMaterialConnectionPoint;
  143797. /**
  143798. * Gets the output component
  143799. */
  143800. get output(): NodeMaterialConnectionPoint;
  143801. protected _buildBlock(state: NodeMaterialBuildState): this;
  143802. }
  143803. }
  143804. declare module BABYLON {
  143805. /**
  143806. * Operations supported by the Wave block
  143807. */
  143808. export enum WaveBlockKind {
  143809. /** SawTooth */
  143810. SawTooth = 0,
  143811. /** Square */
  143812. Square = 1,
  143813. /** Triangle */
  143814. Triangle = 2
  143815. }
  143816. /**
  143817. * Block used to apply wave operation to floats
  143818. */
  143819. export class WaveBlock extends NodeMaterialBlock {
  143820. /**
  143821. * Gets or sets the kibnd of wave to be applied by the block
  143822. */
  143823. kind: WaveBlockKind;
  143824. /**
  143825. * Creates a new WaveBlock
  143826. * @param name defines the block name
  143827. */
  143828. constructor(name: string);
  143829. /**
  143830. * Gets the current class name
  143831. * @returns the class name
  143832. */
  143833. getClassName(): string;
  143834. /**
  143835. * Gets the input component
  143836. */
  143837. get input(): NodeMaterialConnectionPoint;
  143838. /**
  143839. * Gets the output component
  143840. */
  143841. get output(): NodeMaterialConnectionPoint;
  143842. protected _buildBlock(state: NodeMaterialBuildState): this;
  143843. serialize(): any;
  143844. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143845. }
  143846. }
  143847. declare module BABYLON {
  143848. /**
  143849. * Class used to store a color step for the GradientBlock
  143850. */
  143851. export class GradientBlockColorStep {
  143852. private _step;
  143853. /**
  143854. * Gets value indicating which step this color is associated with (between 0 and 1)
  143855. */
  143856. get step(): number;
  143857. /**
  143858. * Sets a value indicating which step this color is associated with (between 0 and 1)
  143859. */
  143860. set step(val: number);
  143861. private _color;
  143862. /**
  143863. * Gets the color associated with this step
  143864. */
  143865. get color(): Color3;
  143866. /**
  143867. * Sets the color associated with this step
  143868. */
  143869. set color(val: Color3);
  143870. /**
  143871. * Creates a new GradientBlockColorStep
  143872. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  143873. * @param color defines the color associated with this step
  143874. */
  143875. constructor(step: number, color: Color3);
  143876. }
  143877. /**
  143878. * Block used to return a color from a gradient based on an input value between 0 and 1
  143879. */
  143880. export class GradientBlock extends NodeMaterialBlock {
  143881. /**
  143882. * Gets or sets the list of color steps
  143883. */
  143884. colorSteps: GradientBlockColorStep[];
  143885. /** Gets an observable raised when the value is changed */
  143886. onValueChangedObservable: Observable<GradientBlock>;
  143887. /** calls observable when the value is changed*/
  143888. colorStepsUpdated(): void;
  143889. /**
  143890. * Creates a new GradientBlock
  143891. * @param name defines the block name
  143892. */
  143893. constructor(name: string);
  143894. /**
  143895. * Gets the current class name
  143896. * @returns the class name
  143897. */
  143898. getClassName(): string;
  143899. /**
  143900. * Gets the gradient input component
  143901. */
  143902. get gradient(): NodeMaterialConnectionPoint;
  143903. /**
  143904. * Gets the output component
  143905. */
  143906. get output(): NodeMaterialConnectionPoint;
  143907. private _writeColorConstant;
  143908. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143909. serialize(): any;
  143910. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143911. protected _dumpPropertiesCode(): string;
  143912. }
  143913. }
  143914. declare module BABYLON {
  143915. /**
  143916. * Block used to normalize lerp between 2 values
  143917. */
  143918. export class NLerpBlock extends NodeMaterialBlock {
  143919. /**
  143920. * Creates a new NLerpBlock
  143921. * @param name defines the block name
  143922. */
  143923. constructor(name: string);
  143924. /**
  143925. * Gets the current class name
  143926. * @returns the class name
  143927. */
  143928. getClassName(): string;
  143929. /**
  143930. * Gets the left operand input component
  143931. */
  143932. get left(): NodeMaterialConnectionPoint;
  143933. /**
  143934. * Gets the right operand input component
  143935. */
  143936. get right(): NodeMaterialConnectionPoint;
  143937. /**
  143938. * Gets the gradient operand input component
  143939. */
  143940. get gradient(): NodeMaterialConnectionPoint;
  143941. /**
  143942. * Gets the output component
  143943. */
  143944. get output(): NodeMaterialConnectionPoint;
  143945. protected _buildBlock(state: NodeMaterialBuildState): this;
  143946. }
  143947. }
  143948. declare module BABYLON {
  143949. /**
  143950. * block used to Generate a Worley Noise 3D Noise Pattern
  143951. */
  143952. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  143953. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143954. manhattanDistance: boolean;
  143955. /**
  143956. * Creates a new WorleyNoise3DBlock
  143957. * @param name defines the block name
  143958. */
  143959. constructor(name: string);
  143960. /**
  143961. * Gets the current class name
  143962. * @returns the class name
  143963. */
  143964. getClassName(): string;
  143965. /**
  143966. * Gets the seed input component
  143967. */
  143968. get seed(): NodeMaterialConnectionPoint;
  143969. /**
  143970. * Gets the jitter input component
  143971. */
  143972. get jitter(): NodeMaterialConnectionPoint;
  143973. /**
  143974. * Gets the output component
  143975. */
  143976. get output(): NodeMaterialConnectionPoint;
  143977. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143978. /**
  143979. * Exposes the properties to the UI?
  143980. */
  143981. protected _dumpPropertiesCode(): string;
  143982. /**
  143983. * Exposes the properties to the Seralize?
  143984. */
  143985. serialize(): any;
  143986. /**
  143987. * Exposes the properties to the deseralize?
  143988. */
  143989. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143990. }
  143991. }
  143992. declare module BABYLON {
  143993. /**
  143994. * block used to Generate a Simplex Perlin 3d Noise Pattern
  143995. */
  143996. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  143997. /**
  143998. * Creates a new SimplexPerlin3DBlock
  143999. * @param name defines the block name
  144000. */
  144001. constructor(name: string);
  144002. /**
  144003. * Gets the current class name
  144004. * @returns the class name
  144005. */
  144006. getClassName(): string;
  144007. /**
  144008. * Gets the seed operand input component
  144009. */
  144010. get seed(): NodeMaterialConnectionPoint;
  144011. /**
  144012. * Gets the output component
  144013. */
  144014. get output(): NodeMaterialConnectionPoint;
  144015. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144016. }
  144017. }
  144018. declare module BABYLON {
  144019. /**
  144020. * Block used to blend normals
  144021. */
  144022. export class NormalBlendBlock extends NodeMaterialBlock {
  144023. /**
  144024. * Creates a new NormalBlendBlock
  144025. * @param name defines the block name
  144026. */
  144027. constructor(name: string);
  144028. /**
  144029. * Gets the current class name
  144030. * @returns the class name
  144031. */
  144032. getClassName(): string;
  144033. /**
  144034. * Gets the first input component
  144035. */
  144036. get normalMap0(): NodeMaterialConnectionPoint;
  144037. /**
  144038. * Gets the second input component
  144039. */
  144040. get normalMap1(): NodeMaterialConnectionPoint;
  144041. /**
  144042. * Gets the output component
  144043. */
  144044. get output(): NodeMaterialConnectionPoint;
  144045. protected _buildBlock(state: NodeMaterialBuildState): this;
  144046. }
  144047. }
  144048. declare module BABYLON {
  144049. /**
  144050. * Block used to rotate a 2d vector by a given angle
  144051. */
  144052. export class Rotate2dBlock extends NodeMaterialBlock {
  144053. /**
  144054. * Creates a new Rotate2dBlock
  144055. * @param name defines the block name
  144056. */
  144057. constructor(name: string);
  144058. /**
  144059. * Gets the current class name
  144060. * @returns the class name
  144061. */
  144062. getClassName(): string;
  144063. /**
  144064. * Gets the input vector
  144065. */
  144066. get input(): NodeMaterialConnectionPoint;
  144067. /**
  144068. * Gets the input angle
  144069. */
  144070. get angle(): NodeMaterialConnectionPoint;
  144071. /**
  144072. * Gets the output component
  144073. */
  144074. get output(): NodeMaterialConnectionPoint;
  144075. autoConfigure(material: NodeMaterial): void;
  144076. protected _buildBlock(state: NodeMaterialBuildState): this;
  144077. }
  144078. }
  144079. declare module BABYLON {
  144080. /**
  144081. * Block used to get the reflected vector from a direction and a normal
  144082. */
  144083. export class ReflectBlock extends NodeMaterialBlock {
  144084. /**
  144085. * Creates a new ReflectBlock
  144086. * @param name defines the block name
  144087. */
  144088. constructor(name: string);
  144089. /**
  144090. * Gets the current class name
  144091. * @returns the class name
  144092. */
  144093. getClassName(): string;
  144094. /**
  144095. * Gets the incident component
  144096. */
  144097. get incident(): NodeMaterialConnectionPoint;
  144098. /**
  144099. * Gets the normal component
  144100. */
  144101. get normal(): NodeMaterialConnectionPoint;
  144102. /**
  144103. * Gets the output component
  144104. */
  144105. get output(): NodeMaterialConnectionPoint;
  144106. protected _buildBlock(state: NodeMaterialBuildState): this;
  144107. }
  144108. }
  144109. declare module BABYLON {
  144110. /**
  144111. * Block used to get the refracted vector from a direction and a normal
  144112. */
  144113. export class RefractBlock extends NodeMaterialBlock {
  144114. /**
  144115. * Creates a new RefractBlock
  144116. * @param name defines the block name
  144117. */
  144118. constructor(name: string);
  144119. /**
  144120. * Gets the current class name
  144121. * @returns the class name
  144122. */
  144123. getClassName(): string;
  144124. /**
  144125. * Gets the incident component
  144126. */
  144127. get incident(): NodeMaterialConnectionPoint;
  144128. /**
  144129. * Gets the normal component
  144130. */
  144131. get normal(): NodeMaterialConnectionPoint;
  144132. /**
  144133. * Gets the index of refraction component
  144134. */
  144135. get ior(): NodeMaterialConnectionPoint;
  144136. /**
  144137. * Gets the output component
  144138. */
  144139. get output(): NodeMaterialConnectionPoint;
  144140. protected _buildBlock(state: NodeMaterialBuildState): this;
  144141. }
  144142. }
  144143. declare module BABYLON {
  144144. /**
  144145. * Block used to desaturate a color
  144146. */
  144147. export class DesaturateBlock extends NodeMaterialBlock {
  144148. /**
  144149. * Creates a new DesaturateBlock
  144150. * @param name defines the block name
  144151. */
  144152. constructor(name: string);
  144153. /**
  144154. * Gets the current class name
  144155. * @returns the class name
  144156. */
  144157. getClassName(): string;
  144158. /**
  144159. * Gets the color operand input component
  144160. */
  144161. get color(): NodeMaterialConnectionPoint;
  144162. /**
  144163. * Gets the level operand input component
  144164. */
  144165. get level(): NodeMaterialConnectionPoint;
  144166. /**
  144167. * Gets the output component
  144168. */
  144169. get output(): NodeMaterialConnectionPoint;
  144170. protected _buildBlock(state: NodeMaterialBuildState): this;
  144171. }
  144172. }
  144173. declare module BABYLON {
  144174. /**
  144175. * Block used to implement the ambient occlusion module of the PBR material
  144176. */
  144177. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  144178. /**
  144179. * Create a new AmbientOcclusionBlock
  144180. * @param name defines the block name
  144181. */
  144182. constructor(name: string);
  144183. /**
  144184. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  144185. */
  144186. useAmbientInGrayScale: boolean;
  144187. /**
  144188. * Initialize the block and prepare the context for build
  144189. * @param state defines the state that will be used for the build
  144190. */
  144191. initialize(state: NodeMaterialBuildState): void;
  144192. /**
  144193. * Gets the current class name
  144194. * @returns the class name
  144195. */
  144196. getClassName(): string;
  144197. /**
  144198. * Gets the texture input component
  144199. */
  144200. get texture(): NodeMaterialConnectionPoint;
  144201. /**
  144202. * Gets the texture intensity component
  144203. */
  144204. get intensity(): NodeMaterialConnectionPoint;
  144205. /**
  144206. * Gets the direct light intensity input component
  144207. */
  144208. get directLightIntensity(): NodeMaterialConnectionPoint;
  144209. /**
  144210. * Gets the ambient occlusion object output component
  144211. */
  144212. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144213. /**
  144214. * Gets the main code of the block (fragment side)
  144215. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  144216. * @returns the shader code
  144217. */
  144218. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  144219. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144220. protected _buildBlock(state: NodeMaterialBuildState): this;
  144221. protected _dumpPropertiesCode(): string;
  144222. serialize(): any;
  144223. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144224. }
  144225. }
  144226. declare module BABYLON {
  144227. /**
  144228. * Block used to implement the reflection module of the PBR material
  144229. */
  144230. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  144231. /** @hidden */
  144232. _defineLODReflectionAlpha: string;
  144233. /** @hidden */
  144234. _defineLinearSpecularReflection: string;
  144235. private _vEnvironmentIrradianceName;
  144236. /** @hidden */
  144237. _vReflectionMicrosurfaceInfosName: string;
  144238. /** @hidden */
  144239. _vReflectionInfosName: string;
  144240. /** @hidden */
  144241. _vReflectionFilteringInfoName: string;
  144242. private _scene;
  144243. /**
  144244. * The three properties below are set by the main PBR block prior to calling methods of this class.
  144245. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144246. * It's less burden on the user side in the editor part.
  144247. */
  144248. /** @hidden */
  144249. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144250. /** @hidden */
  144251. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144252. /** @hidden */
  144253. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  144254. /**
  144255. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  144256. * diffuse part of the IBL.
  144257. */
  144258. useSphericalHarmonics: boolean;
  144259. /**
  144260. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  144261. */
  144262. forceIrradianceInFragment: boolean;
  144263. /**
  144264. * Create a new ReflectionBlock
  144265. * @param name defines the block name
  144266. */
  144267. constructor(name: string);
  144268. /**
  144269. * Gets the current class name
  144270. * @returns the class name
  144271. */
  144272. getClassName(): string;
  144273. /**
  144274. * Gets the position input component
  144275. */
  144276. get position(): NodeMaterialConnectionPoint;
  144277. /**
  144278. * Gets the world position input component
  144279. */
  144280. get worldPosition(): NodeMaterialConnectionPoint;
  144281. /**
  144282. * Gets the world normal input component
  144283. */
  144284. get worldNormal(): NodeMaterialConnectionPoint;
  144285. /**
  144286. * Gets the world input component
  144287. */
  144288. get world(): NodeMaterialConnectionPoint;
  144289. /**
  144290. * Gets the camera (or eye) position component
  144291. */
  144292. get cameraPosition(): NodeMaterialConnectionPoint;
  144293. /**
  144294. * Gets the view input component
  144295. */
  144296. get view(): NodeMaterialConnectionPoint;
  144297. /**
  144298. * Gets the color input component
  144299. */
  144300. get color(): NodeMaterialConnectionPoint;
  144301. /**
  144302. * Gets the reflection object output component
  144303. */
  144304. get reflection(): NodeMaterialConnectionPoint;
  144305. /**
  144306. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  144307. */
  144308. get hasTexture(): boolean;
  144309. /**
  144310. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  144311. */
  144312. get reflectionColor(): string;
  144313. protected _getTexture(): Nullable<BaseTexture>;
  144314. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144315. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144316. /**
  144317. * Gets the code to inject in the vertex shader
  144318. * @param state current state of the node material building
  144319. * @returns the shader code
  144320. */
  144321. handleVertexSide(state: NodeMaterialBuildState): string;
  144322. /**
  144323. * Gets the main code of the block (fragment side)
  144324. * @param state current state of the node material building
  144325. * @param normalVarName name of the existing variable corresponding to the normal
  144326. * @returns the shader code
  144327. */
  144328. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  144329. protected _buildBlock(state: NodeMaterialBuildState): this;
  144330. protected _dumpPropertiesCode(): string;
  144331. serialize(): any;
  144332. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144333. }
  144334. }
  144335. declare module BABYLON {
  144336. /**
  144337. * Block used to implement the sheen module of the PBR material
  144338. */
  144339. export class SheenBlock extends NodeMaterialBlock {
  144340. /**
  144341. * Create a new SheenBlock
  144342. * @param name defines the block name
  144343. */
  144344. constructor(name: string);
  144345. /**
  144346. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  144347. * It allows the strength of the sheen effect to not depend on the base color of the material,
  144348. * making it easier to setup and tweak the effect
  144349. */
  144350. albedoScaling: boolean;
  144351. /**
  144352. * Defines if the sheen is linked to the sheen color.
  144353. */
  144354. linkSheenWithAlbedo: boolean;
  144355. /**
  144356. * Initialize the block and prepare the context for build
  144357. * @param state defines the state that will be used for the build
  144358. */
  144359. initialize(state: NodeMaterialBuildState): void;
  144360. /**
  144361. * Gets the current class name
  144362. * @returns the class name
  144363. */
  144364. getClassName(): string;
  144365. /**
  144366. * Gets the intensity input component
  144367. */
  144368. get intensity(): NodeMaterialConnectionPoint;
  144369. /**
  144370. * Gets the color input component
  144371. */
  144372. get color(): NodeMaterialConnectionPoint;
  144373. /**
  144374. * Gets the roughness input component
  144375. */
  144376. get roughness(): NodeMaterialConnectionPoint;
  144377. /**
  144378. * Gets the sheen object output component
  144379. */
  144380. get sheen(): NodeMaterialConnectionPoint;
  144381. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144382. /**
  144383. * Gets the main code of the block (fragment side)
  144384. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144385. * @returns the shader code
  144386. */
  144387. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  144388. protected _buildBlock(state: NodeMaterialBuildState): this;
  144389. protected _dumpPropertiesCode(): string;
  144390. serialize(): any;
  144391. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144392. }
  144393. }
  144394. declare module BABYLON {
  144395. /**
  144396. * Block used to implement the reflectivity module of the PBR material
  144397. */
  144398. export class ReflectivityBlock extends NodeMaterialBlock {
  144399. private _metallicReflectanceColor;
  144400. private _metallicF0Factor;
  144401. /** @hidden */
  144402. _vMetallicReflectanceFactorsName: string;
  144403. /**
  144404. * The property below is set by the main PBR block prior to calling methods of this class.
  144405. */
  144406. /** @hidden */
  144407. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  144408. /**
  144409. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  144410. */
  144411. useAmbientOcclusionFromMetallicTextureRed: boolean;
  144412. /**
  144413. * Specifies if the metallic texture contains the metallness information in its blue channel.
  144414. */
  144415. useMetallnessFromMetallicTextureBlue: boolean;
  144416. /**
  144417. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  144418. */
  144419. useRoughnessFromMetallicTextureAlpha: boolean;
  144420. /**
  144421. * Specifies if the metallic texture contains the roughness information in its green channel.
  144422. */
  144423. useRoughnessFromMetallicTextureGreen: boolean;
  144424. /**
  144425. * Create a new ReflectivityBlock
  144426. * @param name defines the block name
  144427. */
  144428. constructor(name: string);
  144429. /**
  144430. * Initialize the block and prepare the context for build
  144431. * @param state defines the state that will be used for the build
  144432. */
  144433. initialize(state: NodeMaterialBuildState): void;
  144434. /**
  144435. * Gets the current class name
  144436. * @returns the class name
  144437. */
  144438. getClassName(): string;
  144439. /**
  144440. * Gets the metallic input component
  144441. */
  144442. get metallic(): NodeMaterialConnectionPoint;
  144443. /**
  144444. * Gets the roughness input component
  144445. */
  144446. get roughness(): NodeMaterialConnectionPoint;
  144447. /**
  144448. * Gets the texture input component
  144449. */
  144450. get texture(): NodeMaterialConnectionPoint;
  144451. /**
  144452. * Gets the reflectivity object output component
  144453. */
  144454. get reflectivity(): NodeMaterialConnectionPoint;
  144455. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144456. /**
  144457. * Gets the main code of the block (fragment side)
  144458. * @param state current state of the node material building
  144459. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  144460. * @returns the shader code
  144461. */
  144462. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  144463. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144464. protected _buildBlock(state: NodeMaterialBuildState): this;
  144465. protected _dumpPropertiesCode(): string;
  144466. serialize(): any;
  144467. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144468. }
  144469. }
  144470. declare module BABYLON {
  144471. /**
  144472. * Block used to implement the anisotropy module of the PBR material
  144473. */
  144474. export class AnisotropyBlock extends NodeMaterialBlock {
  144475. /**
  144476. * The two properties below are set by the main PBR block prior to calling methods of this class.
  144477. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144478. * It's less burden on the user side in the editor part.
  144479. */
  144480. /** @hidden */
  144481. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144482. /** @hidden */
  144483. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144484. /**
  144485. * Create a new AnisotropyBlock
  144486. * @param name defines the block name
  144487. */
  144488. constructor(name: string);
  144489. /**
  144490. * Initialize the block and prepare the context for build
  144491. * @param state defines the state that will be used for the build
  144492. */
  144493. initialize(state: NodeMaterialBuildState): void;
  144494. /**
  144495. * Gets the current class name
  144496. * @returns the class name
  144497. */
  144498. getClassName(): string;
  144499. /**
  144500. * Gets the intensity input component
  144501. */
  144502. get intensity(): NodeMaterialConnectionPoint;
  144503. /**
  144504. * Gets the direction input component
  144505. */
  144506. get direction(): NodeMaterialConnectionPoint;
  144507. /**
  144508. * Gets the texture input component
  144509. */
  144510. get texture(): NodeMaterialConnectionPoint;
  144511. /**
  144512. * Gets the uv input component
  144513. */
  144514. get uv(): NodeMaterialConnectionPoint;
  144515. /**
  144516. * Gets the worldTangent input component
  144517. */
  144518. get worldTangent(): NodeMaterialConnectionPoint;
  144519. /**
  144520. * Gets the anisotropy object output component
  144521. */
  144522. get anisotropy(): NodeMaterialConnectionPoint;
  144523. private _generateTBNSpace;
  144524. /**
  144525. * Gets the main code of the block (fragment side)
  144526. * @param state current state of the node material building
  144527. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  144528. * @returns the shader code
  144529. */
  144530. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  144531. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144532. protected _buildBlock(state: NodeMaterialBuildState): this;
  144533. }
  144534. }
  144535. declare module BABYLON {
  144536. /**
  144537. * Block used to implement the clear coat module of the PBR material
  144538. */
  144539. export class ClearCoatBlock extends NodeMaterialBlock {
  144540. private _scene;
  144541. /**
  144542. * Create a new ClearCoatBlock
  144543. * @param name defines the block name
  144544. */
  144545. constructor(name: string);
  144546. /**
  144547. * Initialize the block and prepare the context for build
  144548. * @param state defines the state that will be used for the build
  144549. */
  144550. initialize(state: NodeMaterialBuildState): void;
  144551. /**
  144552. * Gets the current class name
  144553. * @returns the class name
  144554. */
  144555. getClassName(): string;
  144556. /**
  144557. * Gets the intensity input component
  144558. */
  144559. get intensity(): NodeMaterialConnectionPoint;
  144560. /**
  144561. * Gets the roughness input component
  144562. */
  144563. get roughness(): NodeMaterialConnectionPoint;
  144564. /**
  144565. * Gets the ior input component
  144566. */
  144567. get ior(): NodeMaterialConnectionPoint;
  144568. /**
  144569. * Gets the texture input component
  144570. */
  144571. get texture(): NodeMaterialConnectionPoint;
  144572. /**
  144573. * Gets the bump texture input component
  144574. */
  144575. get bumpTexture(): NodeMaterialConnectionPoint;
  144576. /**
  144577. * Gets the uv input component
  144578. */
  144579. get uv(): NodeMaterialConnectionPoint;
  144580. /**
  144581. * Gets the tint color input component
  144582. */
  144583. get tintColor(): NodeMaterialConnectionPoint;
  144584. /**
  144585. * Gets the tint "at distance" input component
  144586. */
  144587. get tintAtDistance(): NodeMaterialConnectionPoint;
  144588. /**
  144589. * Gets the tint thickness input component
  144590. */
  144591. get tintThickness(): NodeMaterialConnectionPoint;
  144592. /**
  144593. * Gets the world tangent input component
  144594. */
  144595. get worldTangent(): NodeMaterialConnectionPoint;
  144596. /**
  144597. * Gets the clear coat object output component
  144598. */
  144599. get clearcoat(): NodeMaterialConnectionPoint;
  144600. autoConfigure(material: NodeMaterial): void;
  144601. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144602. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144603. private _generateTBNSpace;
  144604. /**
  144605. * Gets the main code of the block (fragment side)
  144606. * @param state current state of the node material building
  144607. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  144608. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144609. * @param worldPosVarName name of the variable holding the world position
  144610. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  144611. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  144612. * @param worldNormalVarName name of the variable holding the world normal
  144613. * @returns the shader code
  144614. */
  144615. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  144616. protected _buildBlock(state: NodeMaterialBuildState): this;
  144617. }
  144618. }
  144619. declare module BABYLON {
  144620. /**
  144621. * Block used to implement the sub surface module of the PBR material
  144622. */
  144623. export class SubSurfaceBlock extends NodeMaterialBlock {
  144624. /**
  144625. * Create a new SubSurfaceBlock
  144626. * @param name defines the block name
  144627. */
  144628. constructor(name: string);
  144629. /**
  144630. * Stores the intensity of the different subsurface effects in the thickness texture.
  144631. * * the green channel is the translucency intensity.
  144632. * * the blue channel is the scattering intensity.
  144633. * * the alpha channel is the refraction intensity.
  144634. */
  144635. useMaskFromThicknessTexture: boolean;
  144636. /**
  144637. * Initialize the block and prepare the context for build
  144638. * @param state defines the state that will be used for the build
  144639. */
  144640. initialize(state: NodeMaterialBuildState): void;
  144641. /**
  144642. * Gets the current class name
  144643. * @returns the class name
  144644. */
  144645. getClassName(): string;
  144646. /**
  144647. * Gets the min thickness input component
  144648. */
  144649. get minThickness(): NodeMaterialConnectionPoint;
  144650. /**
  144651. * Gets the max thickness input component
  144652. */
  144653. get maxThickness(): NodeMaterialConnectionPoint;
  144654. /**
  144655. * Gets the thickness texture component
  144656. */
  144657. get thicknessTexture(): NodeMaterialConnectionPoint;
  144658. /**
  144659. * Gets the tint color input component
  144660. */
  144661. get tintColor(): NodeMaterialConnectionPoint;
  144662. /**
  144663. * Gets the translucency intensity input component
  144664. */
  144665. get translucencyIntensity(): NodeMaterialConnectionPoint;
  144666. /**
  144667. * Gets the translucency diffusion distance input component
  144668. */
  144669. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  144670. /**
  144671. * Gets the refraction object parameters
  144672. */
  144673. get refraction(): NodeMaterialConnectionPoint;
  144674. /**
  144675. * Gets the sub surface object output component
  144676. */
  144677. get subsurface(): NodeMaterialConnectionPoint;
  144678. autoConfigure(material: NodeMaterial): void;
  144679. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144680. /**
  144681. * Gets the main code of the block (fragment side)
  144682. * @param state current state of the node material building
  144683. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  144684. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144685. * @param worldPosVarName name of the variable holding the world position
  144686. * @returns the shader code
  144687. */
  144688. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  144689. protected _buildBlock(state: NodeMaterialBuildState): this;
  144690. }
  144691. }
  144692. declare module BABYLON {
  144693. /**
  144694. * Block used to implement the PBR metallic/roughness model
  144695. */
  144696. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  144697. /**
  144698. * Gets or sets the light associated with this block
  144699. */
  144700. light: Nullable<Light>;
  144701. private _lightId;
  144702. private _scene;
  144703. private _environmentBRDFTexture;
  144704. private _environmentBrdfSamplerName;
  144705. private _vNormalWName;
  144706. private _invertNormalName;
  144707. /**
  144708. * Create a new ReflectionBlock
  144709. * @param name defines the block name
  144710. */
  144711. constructor(name: string);
  144712. /**
  144713. * Intensity of the direct lights e.g. the four lights available in your scene.
  144714. * This impacts both the direct diffuse and specular highlights.
  144715. */
  144716. directIntensity: number;
  144717. /**
  144718. * Intensity of the environment e.g. how much the environment will light the object
  144719. * either through harmonics for rough material or through the refelction for shiny ones.
  144720. */
  144721. environmentIntensity: number;
  144722. /**
  144723. * This is a special control allowing the reduction of the specular highlights coming from the
  144724. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  144725. */
  144726. specularIntensity: number;
  144727. /**
  144728. * Defines the falloff type used in this material.
  144729. * It by default is Physical.
  144730. */
  144731. lightFalloff: number;
  144732. /**
  144733. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  144734. */
  144735. useAlphaFromAlbedoTexture: boolean;
  144736. /**
  144737. * Specifies that alpha test should be used
  144738. */
  144739. useAlphaTest: boolean;
  144740. /**
  144741. * Defines the alpha limits in alpha test mode.
  144742. */
  144743. alphaTestCutoff: number;
  144744. /**
  144745. * Specifies that alpha blending should be used
  144746. */
  144747. useAlphaBlending: boolean;
  144748. /**
  144749. * Defines if the alpha value should be determined via the rgb values.
  144750. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  144751. */
  144752. opacityRGB: boolean;
  144753. /**
  144754. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  144755. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  144756. */
  144757. useRadianceOverAlpha: boolean;
  144758. /**
  144759. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  144760. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  144761. */
  144762. useSpecularOverAlpha: boolean;
  144763. /**
  144764. * Enables specular anti aliasing in the PBR shader.
  144765. * It will both interacts on the Geometry for analytical and IBL lighting.
  144766. * It also prefilter the roughness map based on the bump values.
  144767. */
  144768. enableSpecularAntiAliasing: boolean;
  144769. /**
  144770. * Enables realtime filtering on the texture.
  144771. */
  144772. realTimeFiltering: boolean;
  144773. /**
  144774. * Quality switch for realtime filtering
  144775. */
  144776. realTimeFilteringQuality: number;
  144777. /**
  144778. * Defines if the material uses energy conservation.
  144779. */
  144780. useEnergyConservation: boolean;
  144781. /**
  144782. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  144783. * too much the area relying on ambient texture to define their ambient occlusion.
  144784. */
  144785. useRadianceOcclusion: boolean;
  144786. /**
  144787. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  144788. * makes the reflect vector face the model (under horizon).
  144789. */
  144790. useHorizonOcclusion: boolean;
  144791. /**
  144792. * If set to true, no lighting calculations will be applied.
  144793. */
  144794. unlit: boolean;
  144795. /**
  144796. * Force normal to face away from face.
  144797. */
  144798. forceNormalForward: boolean;
  144799. /**
  144800. * Defines the material debug mode.
  144801. * It helps seeing only some components of the material while troubleshooting.
  144802. */
  144803. debugMode: number;
  144804. /**
  144805. * Specify from where on screen the debug mode should start.
  144806. * The value goes from -1 (full screen) to 1 (not visible)
  144807. * It helps with side by side comparison against the final render
  144808. * This defaults to 0
  144809. */
  144810. debugLimit: number;
  144811. /**
  144812. * As the default viewing range might not be enough (if the ambient is really small for instance)
  144813. * You can use the factor to better multiply the final value.
  144814. */
  144815. debugFactor: number;
  144816. /**
  144817. * Initialize the block and prepare the context for build
  144818. * @param state defines the state that will be used for the build
  144819. */
  144820. initialize(state: NodeMaterialBuildState): void;
  144821. /**
  144822. * Gets the current class name
  144823. * @returns the class name
  144824. */
  144825. getClassName(): string;
  144826. /**
  144827. * Gets the world position input component
  144828. */
  144829. get worldPosition(): NodeMaterialConnectionPoint;
  144830. /**
  144831. * Gets the world normal input component
  144832. */
  144833. get worldNormal(): NodeMaterialConnectionPoint;
  144834. /**
  144835. * Gets the perturbed normal input component
  144836. */
  144837. get perturbedNormal(): NodeMaterialConnectionPoint;
  144838. /**
  144839. * Gets the camera position input component
  144840. */
  144841. get cameraPosition(): NodeMaterialConnectionPoint;
  144842. /**
  144843. * Gets the base color input component
  144844. */
  144845. get baseColor(): NodeMaterialConnectionPoint;
  144846. /**
  144847. * Gets the opacity texture input component
  144848. */
  144849. get opacityTexture(): NodeMaterialConnectionPoint;
  144850. /**
  144851. * Gets the ambient color input component
  144852. */
  144853. get ambientColor(): NodeMaterialConnectionPoint;
  144854. /**
  144855. * Gets the reflectivity object parameters
  144856. */
  144857. get reflectivity(): NodeMaterialConnectionPoint;
  144858. /**
  144859. * Gets the ambient occlusion object parameters
  144860. */
  144861. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144862. /**
  144863. * Gets the reflection object parameters
  144864. */
  144865. get reflection(): NodeMaterialConnectionPoint;
  144866. /**
  144867. * Gets the sheen object parameters
  144868. */
  144869. get sheen(): NodeMaterialConnectionPoint;
  144870. /**
  144871. * Gets the clear coat object parameters
  144872. */
  144873. get clearcoat(): NodeMaterialConnectionPoint;
  144874. /**
  144875. * Gets the sub surface object parameters
  144876. */
  144877. get subsurface(): NodeMaterialConnectionPoint;
  144878. /**
  144879. * Gets the anisotropy object parameters
  144880. */
  144881. get anisotropy(): NodeMaterialConnectionPoint;
  144882. /**
  144883. * Gets the ambient output component
  144884. */
  144885. get ambient(): NodeMaterialConnectionPoint;
  144886. /**
  144887. * Gets the diffuse output component
  144888. */
  144889. get diffuse(): NodeMaterialConnectionPoint;
  144890. /**
  144891. * Gets the specular output component
  144892. */
  144893. get specular(): NodeMaterialConnectionPoint;
  144894. /**
  144895. * Gets the sheen output component
  144896. */
  144897. get sheenDir(): NodeMaterialConnectionPoint;
  144898. /**
  144899. * Gets the clear coat output component
  144900. */
  144901. get clearcoatDir(): NodeMaterialConnectionPoint;
  144902. /**
  144903. * Gets the indirect diffuse output component
  144904. */
  144905. get diffuseIndirect(): NodeMaterialConnectionPoint;
  144906. /**
  144907. * Gets the indirect specular output component
  144908. */
  144909. get specularIndirect(): NodeMaterialConnectionPoint;
  144910. /**
  144911. * Gets the indirect sheen output component
  144912. */
  144913. get sheenIndirect(): NodeMaterialConnectionPoint;
  144914. /**
  144915. * Gets the indirect clear coat output component
  144916. */
  144917. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  144918. /**
  144919. * Gets the refraction output component
  144920. */
  144921. get refraction(): NodeMaterialConnectionPoint;
  144922. /**
  144923. * Gets the global lighting output component
  144924. */
  144925. get lighting(): NodeMaterialConnectionPoint;
  144926. /**
  144927. * Gets the shadow output component
  144928. */
  144929. get shadow(): NodeMaterialConnectionPoint;
  144930. /**
  144931. * Gets the alpha output component
  144932. */
  144933. get alpha(): NodeMaterialConnectionPoint;
  144934. autoConfigure(material: NodeMaterial): void;
  144935. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144936. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  144937. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144938. private _injectVertexCode;
  144939. /**
  144940. * Gets the code corresponding to the albedo/opacity module
  144941. * @returns the shader code
  144942. */
  144943. getAlbedoOpacityCode(): string;
  144944. protected _buildBlock(state: NodeMaterialBuildState): this;
  144945. protected _dumpPropertiesCode(): string;
  144946. serialize(): any;
  144947. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144948. }
  144949. }
  144950. declare module BABYLON {
  144951. /**
  144952. * Block used to compute value of one parameter modulo another
  144953. */
  144954. export class ModBlock extends NodeMaterialBlock {
  144955. /**
  144956. * Creates a new ModBlock
  144957. * @param name defines the block name
  144958. */
  144959. constructor(name: string);
  144960. /**
  144961. * Gets the current class name
  144962. * @returns the class name
  144963. */
  144964. getClassName(): string;
  144965. /**
  144966. * Gets the left operand input component
  144967. */
  144968. get left(): NodeMaterialConnectionPoint;
  144969. /**
  144970. * Gets the right operand input component
  144971. */
  144972. get right(): NodeMaterialConnectionPoint;
  144973. /**
  144974. * Gets the output component
  144975. */
  144976. get output(): NodeMaterialConnectionPoint;
  144977. protected _buildBlock(state: NodeMaterialBuildState): this;
  144978. }
  144979. }
  144980. declare module BABYLON {
  144981. /**
  144982. * Configuration for Draco compression
  144983. */
  144984. export interface IDracoCompressionConfiguration {
  144985. /**
  144986. * Configuration for the decoder.
  144987. */
  144988. decoder: {
  144989. /**
  144990. * The url to the WebAssembly module.
  144991. */
  144992. wasmUrl?: string;
  144993. /**
  144994. * The url to the WebAssembly binary.
  144995. */
  144996. wasmBinaryUrl?: string;
  144997. /**
  144998. * The url to the fallback JavaScript module.
  144999. */
  145000. fallbackUrl?: string;
  145001. };
  145002. }
  145003. /**
  145004. * Draco compression (https://google.github.io/draco/)
  145005. *
  145006. * This class wraps the Draco module.
  145007. *
  145008. * **Encoder**
  145009. *
  145010. * The encoder is not currently implemented.
  145011. *
  145012. * **Decoder**
  145013. *
  145014. * 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.
  145015. *
  145016. * To update the configuration, use the following code:
  145017. * ```javascript
  145018. * DracoCompression.Configuration = {
  145019. * decoder: {
  145020. * wasmUrl: "<url to the WebAssembly library>",
  145021. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  145022. * fallbackUrl: "<url to the fallback JavaScript library>",
  145023. * }
  145024. * };
  145025. * ```
  145026. *
  145027. * 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.
  145028. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  145029. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  145030. *
  145031. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  145032. * ```javascript
  145033. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  145034. * ```
  145035. *
  145036. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  145037. */
  145038. export class DracoCompression implements IDisposable {
  145039. private _workerPoolPromise?;
  145040. private _decoderModulePromise?;
  145041. /**
  145042. * The configuration. Defaults to the following urls:
  145043. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  145044. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  145045. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  145046. */
  145047. static Configuration: IDracoCompressionConfiguration;
  145048. /**
  145049. * Returns true if the decoder configuration is available.
  145050. */
  145051. static get DecoderAvailable(): boolean;
  145052. /**
  145053. * Default number of workers to create when creating the draco compression object.
  145054. */
  145055. static DefaultNumWorkers: number;
  145056. private static GetDefaultNumWorkers;
  145057. private static _Default;
  145058. /**
  145059. * Default instance for the draco compression object.
  145060. */
  145061. static get Default(): DracoCompression;
  145062. /**
  145063. * Constructor
  145064. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  145065. */
  145066. constructor(numWorkers?: number);
  145067. /**
  145068. * Stop all async operations and release resources.
  145069. */
  145070. dispose(): void;
  145071. /**
  145072. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  145073. * @returns a promise that resolves when ready
  145074. */
  145075. whenReadyAsync(): Promise<void>;
  145076. /**
  145077. * Decode Draco compressed mesh data to vertex data.
  145078. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  145079. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  145080. * @returns A promise that resolves with the decoded vertex data
  145081. */
  145082. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  145083. [kind: string]: number;
  145084. }): Promise<VertexData>;
  145085. }
  145086. }
  145087. declare module BABYLON {
  145088. /**
  145089. * Class for building Constructive Solid Geometry
  145090. */
  145091. export class CSG {
  145092. private polygons;
  145093. /**
  145094. * The world matrix
  145095. */
  145096. matrix: Matrix;
  145097. /**
  145098. * Stores the position
  145099. */
  145100. position: Vector3;
  145101. /**
  145102. * Stores the rotation
  145103. */
  145104. rotation: Vector3;
  145105. /**
  145106. * Stores the rotation quaternion
  145107. */
  145108. rotationQuaternion: Nullable<Quaternion>;
  145109. /**
  145110. * Stores the scaling vector
  145111. */
  145112. scaling: Vector3;
  145113. /**
  145114. * Convert the Mesh to CSG
  145115. * @param mesh The Mesh to convert to CSG
  145116. * @returns A new CSG from the Mesh
  145117. */
  145118. static FromMesh(mesh: Mesh): CSG;
  145119. /**
  145120. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  145121. * @param polygons Polygons used to construct a CSG solid
  145122. */
  145123. private static FromPolygons;
  145124. /**
  145125. * Clones, or makes a deep copy, of the CSG
  145126. * @returns A new CSG
  145127. */
  145128. clone(): CSG;
  145129. /**
  145130. * Unions this CSG with another CSG
  145131. * @param csg The CSG to union against this CSG
  145132. * @returns The unioned CSG
  145133. */
  145134. union(csg: CSG): CSG;
  145135. /**
  145136. * Unions this CSG with another CSG in place
  145137. * @param csg The CSG to union against this CSG
  145138. */
  145139. unionInPlace(csg: CSG): void;
  145140. /**
  145141. * Subtracts this CSG with another CSG
  145142. * @param csg The CSG to subtract against this CSG
  145143. * @returns A new CSG
  145144. */
  145145. subtract(csg: CSG): CSG;
  145146. /**
  145147. * Subtracts this CSG with another CSG in place
  145148. * @param csg The CSG to subtact against this CSG
  145149. */
  145150. subtractInPlace(csg: CSG): void;
  145151. /**
  145152. * Intersect this CSG with another CSG
  145153. * @param csg The CSG to intersect against this CSG
  145154. * @returns A new CSG
  145155. */
  145156. intersect(csg: CSG): CSG;
  145157. /**
  145158. * Intersects this CSG with another CSG in place
  145159. * @param csg The CSG to intersect against this CSG
  145160. */
  145161. intersectInPlace(csg: CSG): void;
  145162. /**
  145163. * Return a new CSG solid with solid and empty space switched. This solid is
  145164. * not modified.
  145165. * @returns A new CSG solid with solid and empty space switched
  145166. */
  145167. inverse(): CSG;
  145168. /**
  145169. * Inverses the CSG in place
  145170. */
  145171. inverseInPlace(): void;
  145172. /**
  145173. * This is used to keep meshes transformations so they can be restored
  145174. * when we build back a Babylon Mesh
  145175. * NB : All CSG operations are performed in world coordinates
  145176. * @param csg The CSG to copy the transform attributes from
  145177. * @returns This CSG
  145178. */
  145179. copyTransformAttributes(csg: CSG): CSG;
  145180. /**
  145181. * Build Raw mesh from CSG
  145182. * Coordinates here are in world space
  145183. * @param name The name of the mesh geometry
  145184. * @param scene The Scene
  145185. * @param keepSubMeshes Specifies if the submeshes should be kept
  145186. * @returns A new Mesh
  145187. */
  145188. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145189. /**
  145190. * Build Mesh from CSG taking material and transforms into account
  145191. * @param name The name of the Mesh
  145192. * @param material The material of the Mesh
  145193. * @param scene The Scene
  145194. * @param keepSubMeshes Specifies if submeshes should be kept
  145195. * @returns The new Mesh
  145196. */
  145197. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145198. }
  145199. }
  145200. declare module BABYLON {
  145201. /**
  145202. * Class used to create a trail following a mesh
  145203. */
  145204. export class TrailMesh extends Mesh {
  145205. private _generator;
  145206. private _autoStart;
  145207. private _running;
  145208. private _diameter;
  145209. private _length;
  145210. private _sectionPolygonPointsCount;
  145211. private _sectionVectors;
  145212. private _sectionNormalVectors;
  145213. private _beforeRenderObserver;
  145214. /**
  145215. * @constructor
  145216. * @param name The value used by scene.getMeshByName() to do a lookup.
  145217. * @param generator The mesh or transform node to generate a trail.
  145218. * @param scene The scene to add this mesh to.
  145219. * @param diameter Diameter of trailing mesh. Default is 1.
  145220. * @param length Length of trailing mesh. Default is 60.
  145221. * @param autoStart Automatically start trailing mesh. Default true.
  145222. */
  145223. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  145224. /**
  145225. * "TrailMesh"
  145226. * @returns "TrailMesh"
  145227. */
  145228. getClassName(): string;
  145229. private _createMesh;
  145230. /**
  145231. * Start trailing mesh.
  145232. */
  145233. start(): void;
  145234. /**
  145235. * Stop trailing mesh.
  145236. */
  145237. stop(): void;
  145238. /**
  145239. * Update trailing mesh geometry.
  145240. */
  145241. update(): void;
  145242. /**
  145243. * Returns a new TrailMesh object.
  145244. * @param name is a string, the name given to the new mesh
  145245. * @param newGenerator use new generator object for cloned trail mesh
  145246. * @returns a new mesh
  145247. */
  145248. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  145249. /**
  145250. * Serializes this trail mesh
  145251. * @param serializationObject object to write serialization to
  145252. */
  145253. serialize(serializationObject: any): void;
  145254. /**
  145255. * Parses a serialized trail mesh
  145256. * @param parsedMesh the serialized mesh
  145257. * @param scene the scene to create the trail mesh in
  145258. * @returns the created trail mesh
  145259. */
  145260. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  145261. }
  145262. }
  145263. declare module BABYLON {
  145264. /**
  145265. * Class containing static functions to help procedurally build meshes
  145266. */
  145267. export class TiledBoxBuilder {
  145268. /**
  145269. * Creates a box mesh
  145270. * 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)
  145271. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145273. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145275. * @param name defines the name of the mesh
  145276. * @param options defines the options used to create the mesh
  145277. * @param scene defines the hosting scene
  145278. * @returns the box mesh
  145279. */
  145280. static CreateTiledBox(name: string, options: {
  145281. pattern?: number;
  145282. width?: number;
  145283. height?: number;
  145284. depth?: number;
  145285. tileSize?: number;
  145286. tileWidth?: number;
  145287. tileHeight?: number;
  145288. alignHorizontal?: number;
  145289. alignVertical?: number;
  145290. faceUV?: Vector4[];
  145291. faceColors?: Color4[];
  145292. sideOrientation?: number;
  145293. updatable?: boolean;
  145294. }, scene?: Nullable<Scene>): Mesh;
  145295. }
  145296. }
  145297. declare module BABYLON {
  145298. /**
  145299. * Class containing static functions to help procedurally build meshes
  145300. */
  145301. export class TorusKnotBuilder {
  145302. /**
  145303. * Creates a torus knot mesh
  145304. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145305. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145306. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145307. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145309. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145311. * @param name defines the name of the mesh
  145312. * @param options defines the options used to create the mesh
  145313. * @param scene defines the hosting scene
  145314. * @returns the torus knot mesh
  145315. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145316. */
  145317. static CreateTorusKnot(name: string, options: {
  145318. radius?: number;
  145319. tube?: number;
  145320. radialSegments?: number;
  145321. tubularSegments?: number;
  145322. p?: number;
  145323. q?: number;
  145324. updatable?: boolean;
  145325. sideOrientation?: number;
  145326. frontUVs?: Vector4;
  145327. backUVs?: Vector4;
  145328. }, scene: any): Mesh;
  145329. }
  145330. }
  145331. declare module BABYLON {
  145332. /**
  145333. * Polygon
  145334. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  145335. */
  145336. export class Polygon {
  145337. /**
  145338. * Creates a rectangle
  145339. * @param xmin bottom X coord
  145340. * @param ymin bottom Y coord
  145341. * @param xmax top X coord
  145342. * @param ymax top Y coord
  145343. * @returns points that make the resulting rectation
  145344. */
  145345. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  145346. /**
  145347. * Creates a circle
  145348. * @param radius radius of circle
  145349. * @param cx scale in x
  145350. * @param cy scale in y
  145351. * @param numberOfSides number of sides that make up the circle
  145352. * @returns points that make the resulting circle
  145353. */
  145354. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  145355. /**
  145356. * Creates a polygon from input string
  145357. * @param input Input polygon data
  145358. * @returns the parsed points
  145359. */
  145360. static Parse(input: string): Vector2[];
  145361. /**
  145362. * Starts building a polygon from x and y coordinates
  145363. * @param x x coordinate
  145364. * @param y y coordinate
  145365. * @returns the started path2
  145366. */
  145367. static StartingAt(x: number, y: number): Path2;
  145368. }
  145369. /**
  145370. * Builds a polygon
  145371. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  145372. */
  145373. export class PolygonMeshBuilder {
  145374. private _points;
  145375. private _outlinepoints;
  145376. private _holes;
  145377. private _name;
  145378. private _scene;
  145379. private _epoints;
  145380. private _eholes;
  145381. private _addToepoint;
  145382. /**
  145383. * Babylon reference to the earcut plugin.
  145384. */
  145385. bjsEarcut: any;
  145386. /**
  145387. * Creates a PolygonMeshBuilder
  145388. * @param name name of the builder
  145389. * @param contours Path of the polygon
  145390. * @param scene scene to add to when creating the mesh
  145391. * @param earcutInjection can be used to inject your own earcut reference
  145392. */
  145393. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  145394. /**
  145395. * Adds a whole within the polygon
  145396. * @param hole Array of points defining the hole
  145397. * @returns this
  145398. */
  145399. addHole(hole: Vector2[]): PolygonMeshBuilder;
  145400. /**
  145401. * Creates the polygon
  145402. * @param updatable If the mesh should be updatable
  145403. * @param depth The depth of the mesh created
  145404. * @returns the created mesh
  145405. */
  145406. build(updatable?: boolean, depth?: number): Mesh;
  145407. /**
  145408. * Creates the polygon
  145409. * @param depth The depth of the mesh created
  145410. * @returns the created VertexData
  145411. */
  145412. buildVertexData(depth?: number): VertexData;
  145413. /**
  145414. * Adds a side to the polygon
  145415. * @param positions points that make the polygon
  145416. * @param normals normals of the polygon
  145417. * @param uvs uvs of the polygon
  145418. * @param indices indices of the polygon
  145419. * @param bounds bounds of the polygon
  145420. * @param points points of the polygon
  145421. * @param depth depth of the polygon
  145422. * @param flip flip of the polygon
  145423. */
  145424. private addSide;
  145425. }
  145426. }
  145427. declare module BABYLON {
  145428. /**
  145429. * Class containing static functions to help procedurally build meshes
  145430. */
  145431. export class PolygonBuilder {
  145432. /**
  145433. * Creates a polygon mesh
  145434. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  145435. * * 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
  145436. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145438. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  145439. * * Remember you can only change the shape positions, not their number when updating a polygon
  145440. * @param name defines the name of the mesh
  145441. * @param options defines the options used to create the mesh
  145442. * @param scene defines the hosting scene
  145443. * @param earcutInjection can be used to inject your own earcut reference
  145444. * @returns the polygon mesh
  145445. */
  145446. static CreatePolygon(name: string, options: {
  145447. shape: Vector3[];
  145448. holes?: Vector3[][];
  145449. depth?: number;
  145450. faceUV?: Vector4[];
  145451. faceColors?: Color4[];
  145452. updatable?: boolean;
  145453. sideOrientation?: number;
  145454. frontUVs?: Vector4;
  145455. backUVs?: Vector4;
  145456. wrap?: boolean;
  145457. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145458. /**
  145459. * Creates an extruded polygon mesh, with depth in the Y direction.
  145460. * * 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)
  145461. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145462. * @param name defines the name of the mesh
  145463. * @param options defines the options used to create the mesh
  145464. * @param scene defines the hosting scene
  145465. * @param earcutInjection can be used to inject your own earcut reference
  145466. * @returns the polygon mesh
  145467. */
  145468. static ExtrudePolygon(name: string, options: {
  145469. shape: Vector3[];
  145470. holes?: Vector3[][];
  145471. depth?: number;
  145472. faceUV?: Vector4[];
  145473. faceColors?: Color4[];
  145474. updatable?: boolean;
  145475. sideOrientation?: number;
  145476. frontUVs?: Vector4;
  145477. backUVs?: Vector4;
  145478. wrap?: boolean;
  145479. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145480. }
  145481. }
  145482. declare module BABYLON {
  145483. /**
  145484. * Class containing static functions to help procedurally build meshes
  145485. */
  145486. export class LatheBuilder {
  145487. /**
  145488. * Creates lathe mesh.
  145489. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145490. * * 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
  145491. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145492. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145493. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145494. * * 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
  145495. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145496. * * 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
  145497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145499. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145501. * @param name defines the name of the mesh
  145502. * @param options defines the options used to create the mesh
  145503. * @param scene defines the hosting scene
  145504. * @returns the lathe mesh
  145505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145506. */
  145507. static CreateLathe(name: string, options: {
  145508. shape: Vector3[];
  145509. radius?: number;
  145510. tessellation?: number;
  145511. clip?: number;
  145512. arc?: number;
  145513. closed?: boolean;
  145514. updatable?: boolean;
  145515. sideOrientation?: number;
  145516. frontUVs?: Vector4;
  145517. backUVs?: Vector4;
  145518. cap?: number;
  145519. invertUV?: boolean;
  145520. }, scene?: Nullable<Scene>): Mesh;
  145521. }
  145522. }
  145523. declare module BABYLON {
  145524. /**
  145525. * Class containing static functions to help procedurally build meshes
  145526. */
  145527. export class TiledPlaneBuilder {
  145528. /**
  145529. * Creates a tiled plane mesh
  145530. * * The parameter `pattern` will, depending on value, do nothing or
  145531. * * * flip (reflect about central vertical) alternate tiles across and up
  145532. * * * flip every tile on alternate rows
  145533. * * * rotate (180 degs) alternate tiles across and up
  145534. * * * rotate every tile on alternate rows
  145535. * * * flip and rotate alternate tiles across and up
  145536. * * * flip and rotate every tile on alternate rows
  145537. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  145538. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  145539. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145540. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145541. * * 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)
  145542. * * 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)
  145543. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  145544. * @param name defines the name of the mesh
  145545. * @param options defines the options used to create the mesh
  145546. * @param scene defines the hosting scene
  145547. * @returns the box mesh
  145548. */
  145549. static CreateTiledPlane(name: string, options: {
  145550. pattern?: number;
  145551. tileSize?: number;
  145552. tileWidth?: number;
  145553. tileHeight?: number;
  145554. size?: number;
  145555. width?: number;
  145556. height?: number;
  145557. alignHorizontal?: number;
  145558. alignVertical?: number;
  145559. sideOrientation?: number;
  145560. frontUVs?: Vector4;
  145561. backUVs?: Vector4;
  145562. updatable?: boolean;
  145563. }, scene?: Nullable<Scene>): Mesh;
  145564. }
  145565. }
  145566. declare module BABYLON {
  145567. /**
  145568. * Class containing static functions to help procedurally build meshes
  145569. */
  145570. export class TubeBuilder {
  145571. /**
  145572. * Creates a tube mesh.
  145573. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145574. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  145575. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  145576. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  145577. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  145578. * * 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)
  145579. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  145580. * * 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
  145581. * * 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
  145582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145584. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145586. * @param name defines the name of the mesh
  145587. * @param options defines the options used to create the mesh
  145588. * @param scene defines the hosting scene
  145589. * @returns the tube mesh
  145590. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145591. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  145592. */
  145593. static CreateTube(name: string, options: {
  145594. path: Vector3[];
  145595. radius?: number;
  145596. tessellation?: number;
  145597. radiusFunction?: {
  145598. (i: number, distance: number): number;
  145599. };
  145600. cap?: number;
  145601. arc?: number;
  145602. updatable?: boolean;
  145603. sideOrientation?: number;
  145604. frontUVs?: Vector4;
  145605. backUVs?: Vector4;
  145606. instance?: Mesh;
  145607. invertUV?: boolean;
  145608. }, scene?: Nullable<Scene>): Mesh;
  145609. }
  145610. }
  145611. declare module BABYLON {
  145612. /**
  145613. * Class containing static functions to help procedurally build meshes
  145614. */
  145615. export class IcoSphereBuilder {
  145616. /**
  145617. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  145618. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  145619. * * 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`)
  145620. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  145621. * * 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
  145622. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145623. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145625. * @param name defines the name of the mesh
  145626. * @param options defines the options used to create the mesh
  145627. * @param scene defines the hosting scene
  145628. * @returns the icosahedron mesh
  145629. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  145630. */
  145631. static CreateIcoSphere(name: string, options: {
  145632. radius?: number;
  145633. radiusX?: number;
  145634. radiusY?: number;
  145635. radiusZ?: number;
  145636. flat?: boolean;
  145637. subdivisions?: number;
  145638. sideOrientation?: number;
  145639. frontUVs?: Vector4;
  145640. backUVs?: Vector4;
  145641. updatable?: boolean;
  145642. }, scene?: Nullable<Scene>): Mesh;
  145643. }
  145644. }
  145645. declare module BABYLON {
  145646. /**
  145647. * Class containing static functions to help procedurally build meshes
  145648. */
  145649. export class DecalBuilder {
  145650. /**
  145651. * Creates a decal mesh.
  145652. * 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
  145653. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  145654. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  145655. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  145656. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  145657. * @param name defines the name of the mesh
  145658. * @param sourceMesh defines the mesh where the decal must be applied
  145659. * @param options defines the options used to create the mesh
  145660. * @param scene defines the hosting scene
  145661. * @returns the decal mesh
  145662. * @see https://doc.babylonjs.com/how_to/decals
  145663. */
  145664. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  145665. position?: Vector3;
  145666. normal?: Vector3;
  145667. size?: Vector3;
  145668. angle?: number;
  145669. }): Mesh;
  145670. }
  145671. }
  145672. declare module BABYLON {
  145673. /**
  145674. * Class containing static functions to help procedurally build meshes
  145675. */
  145676. export class MeshBuilder {
  145677. /**
  145678. * Creates a box mesh
  145679. * * The parameter `size` sets the size (float) of each box side (default 1)
  145680. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  145681. * * 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)
  145682. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145686. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  145687. * @param name defines the name of the mesh
  145688. * @param options defines the options used to create the mesh
  145689. * @param scene defines the hosting scene
  145690. * @returns the box mesh
  145691. */
  145692. static CreateBox(name: string, options: {
  145693. size?: number;
  145694. width?: number;
  145695. height?: number;
  145696. depth?: number;
  145697. faceUV?: Vector4[];
  145698. faceColors?: Color4[];
  145699. sideOrientation?: number;
  145700. frontUVs?: Vector4;
  145701. backUVs?: Vector4;
  145702. wrap?: boolean;
  145703. topBaseAt?: number;
  145704. bottomBaseAt?: number;
  145705. updatable?: boolean;
  145706. }, scene?: Nullable<Scene>): Mesh;
  145707. /**
  145708. * Creates a tiled box mesh
  145709. * * faceTiles sets the pattern, tile size and number of tiles for a face
  145710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145711. * @param name defines the name of the mesh
  145712. * @param options defines the options used to create the mesh
  145713. * @param scene defines the hosting scene
  145714. * @returns the tiled box mesh
  145715. */
  145716. static CreateTiledBox(name: string, options: {
  145717. pattern?: number;
  145718. size?: number;
  145719. width?: number;
  145720. height?: number;
  145721. depth: number;
  145722. tileSize?: number;
  145723. tileWidth?: number;
  145724. tileHeight?: number;
  145725. faceUV?: Vector4[];
  145726. faceColors?: Color4[];
  145727. alignHorizontal?: number;
  145728. alignVertical?: number;
  145729. sideOrientation?: number;
  145730. updatable?: boolean;
  145731. }, scene?: Nullable<Scene>): Mesh;
  145732. /**
  145733. * Creates a sphere mesh
  145734. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  145735. * * 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`)
  145736. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  145737. * * 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
  145738. * * 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)
  145739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145740. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145742. * @param name defines the name of the mesh
  145743. * @param options defines the options used to create the mesh
  145744. * @param scene defines the hosting scene
  145745. * @returns the sphere mesh
  145746. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  145747. */
  145748. static CreateSphere(name: string, options: {
  145749. segments?: number;
  145750. diameter?: number;
  145751. diameterX?: number;
  145752. diameterY?: number;
  145753. diameterZ?: number;
  145754. arc?: number;
  145755. slice?: number;
  145756. sideOrientation?: number;
  145757. frontUVs?: Vector4;
  145758. backUVs?: Vector4;
  145759. updatable?: boolean;
  145760. }, scene?: Nullable<Scene>): Mesh;
  145761. /**
  145762. * Creates a plane polygonal mesh. By default, this is a disc
  145763. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  145764. * * 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
  145765. * * 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
  145766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145769. * @param name defines the name of the mesh
  145770. * @param options defines the options used to create the mesh
  145771. * @param scene defines the hosting scene
  145772. * @returns the plane polygonal mesh
  145773. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  145774. */
  145775. static CreateDisc(name: string, options: {
  145776. radius?: number;
  145777. tessellation?: number;
  145778. arc?: number;
  145779. updatable?: boolean;
  145780. sideOrientation?: number;
  145781. frontUVs?: Vector4;
  145782. backUVs?: Vector4;
  145783. }, scene?: Nullable<Scene>): Mesh;
  145784. /**
  145785. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  145786. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  145787. * * 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`)
  145788. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  145789. * * 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
  145790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145793. * @param name defines the name of the mesh
  145794. * @param options defines the options used to create the mesh
  145795. * @param scene defines the hosting scene
  145796. * @returns the icosahedron mesh
  145797. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  145798. */
  145799. static CreateIcoSphere(name: string, options: {
  145800. radius?: number;
  145801. radiusX?: number;
  145802. radiusY?: number;
  145803. radiusZ?: number;
  145804. flat?: boolean;
  145805. subdivisions?: number;
  145806. sideOrientation?: number;
  145807. frontUVs?: Vector4;
  145808. backUVs?: Vector4;
  145809. updatable?: boolean;
  145810. }, scene?: Nullable<Scene>): Mesh;
  145811. /**
  145812. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145813. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  145814. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  145815. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  145816. * * 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
  145817. * * 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
  145818. * * 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
  145819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145820. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145821. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145822. * * 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
  145823. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  145824. * * 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
  145825. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  145826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145827. * @param name defines the name of the mesh
  145828. * @param options defines the options used to create the mesh
  145829. * @param scene defines the hosting scene
  145830. * @returns the ribbon mesh
  145831. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  145832. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145833. */
  145834. static CreateRibbon(name: string, options: {
  145835. pathArray: Vector3[][];
  145836. closeArray?: boolean;
  145837. closePath?: boolean;
  145838. offset?: number;
  145839. updatable?: boolean;
  145840. sideOrientation?: number;
  145841. frontUVs?: Vector4;
  145842. backUVs?: Vector4;
  145843. instance?: Mesh;
  145844. invertUV?: boolean;
  145845. uvs?: Vector2[];
  145846. colors?: Color4[];
  145847. }, scene?: Nullable<Scene>): Mesh;
  145848. /**
  145849. * Creates a cylinder or a cone mesh
  145850. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  145851. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  145852. * * 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.
  145853. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  145854. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  145855. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  145856. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  145857. * * 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).
  145858. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  145859. * * 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).
  145860. * * 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
  145861. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  145862. * * 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
  145863. * * 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.
  145864. * * If `enclose` is false, a ring surface is one element.
  145865. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  145866. * * 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
  145867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145868. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145870. * @param name defines the name of the mesh
  145871. * @param options defines the options used to create the mesh
  145872. * @param scene defines the hosting scene
  145873. * @returns the cylinder mesh
  145874. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  145875. */
  145876. static CreateCylinder(name: string, options: {
  145877. height?: number;
  145878. diameterTop?: number;
  145879. diameterBottom?: number;
  145880. diameter?: number;
  145881. tessellation?: number;
  145882. subdivisions?: number;
  145883. arc?: number;
  145884. faceColors?: Color4[];
  145885. faceUV?: Vector4[];
  145886. updatable?: boolean;
  145887. hasRings?: boolean;
  145888. enclose?: boolean;
  145889. cap?: number;
  145890. sideOrientation?: number;
  145891. frontUVs?: Vector4;
  145892. backUVs?: Vector4;
  145893. }, scene?: Nullable<Scene>): Mesh;
  145894. /**
  145895. * Creates a torus mesh
  145896. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  145897. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  145898. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  145899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145900. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145902. * @param name defines the name of the mesh
  145903. * @param options defines the options used to create the mesh
  145904. * @param scene defines the hosting scene
  145905. * @returns the torus mesh
  145906. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  145907. */
  145908. static CreateTorus(name: string, options: {
  145909. diameter?: number;
  145910. thickness?: number;
  145911. tessellation?: number;
  145912. updatable?: boolean;
  145913. sideOrientation?: number;
  145914. frontUVs?: Vector4;
  145915. backUVs?: Vector4;
  145916. }, scene?: Nullable<Scene>): Mesh;
  145917. /**
  145918. * Creates a torus knot mesh
  145919. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145920. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145921. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145922. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145924. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145926. * @param name defines the name of the mesh
  145927. * @param options defines the options used to create the mesh
  145928. * @param scene defines the hosting scene
  145929. * @returns the torus knot mesh
  145930. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145931. */
  145932. static CreateTorusKnot(name: string, options: {
  145933. radius?: number;
  145934. tube?: number;
  145935. radialSegments?: number;
  145936. tubularSegments?: number;
  145937. p?: number;
  145938. q?: number;
  145939. updatable?: boolean;
  145940. sideOrientation?: number;
  145941. frontUVs?: Vector4;
  145942. backUVs?: Vector4;
  145943. }, scene?: Nullable<Scene>): Mesh;
  145944. /**
  145945. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  145946. * * 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
  145947. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  145948. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  145949. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  145950. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  145951. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  145952. * * 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
  145953. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  145954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145955. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  145956. * @param name defines the name of the new line system
  145957. * @param options defines the options used to create the line system
  145958. * @param scene defines the hosting scene
  145959. * @returns a new line system mesh
  145960. */
  145961. static CreateLineSystem(name: string, options: {
  145962. lines: Vector3[][];
  145963. updatable?: boolean;
  145964. instance?: Nullable<LinesMesh>;
  145965. colors?: Nullable<Color4[][]>;
  145966. useVertexAlpha?: boolean;
  145967. }, scene: Nullable<Scene>): LinesMesh;
  145968. /**
  145969. * Creates a line mesh
  145970. * 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
  145971. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  145972. * * The parameter `points` is an array successive Vector3
  145973. * * 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
  145974. * * The optional parameter `colors` is an array of successive Color4, one per line point
  145975. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  145976. * * When updating an instance, remember that only point positions can change, not the number of points
  145977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145978. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  145979. * @param name defines the name of the new line system
  145980. * @param options defines the options used to create the line system
  145981. * @param scene defines the hosting scene
  145982. * @returns a new line mesh
  145983. */
  145984. static CreateLines(name: string, options: {
  145985. points: Vector3[];
  145986. updatable?: boolean;
  145987. instance?: Nullable<LinesMesh>;
  145988. colors?: Color4[];
  145989. useVertexAlpha?: boolean;
  145990. }, scene?: Nullable<Scene>): LinesMesh;
  145991. /**
  145992. * Creates a dashed line mesh
  145993. * * 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
  145994. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  145995. * * The parameter `points` is an array successive Vector3
  145996. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  145997. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  145998. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  145999. * * 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
  146000. * * When updating an instance, remember that only point positions can change, not the number of points
  146001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146002. * @param name defines the name of the mesh
  146003. * @param options defines the options used to create the mesh
  146004. * @param scene defines the hosting scene
  146005. * @returns the dashed line mesh
  146006. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  146007. */
  146008. static CreateDashedLines(name: string, options: {
  146009. points: Vector3[];
  146010. dashSize?: number;
  146011. gapSize?: number;
  146012. dashNb?: number;
  146013. updatable?: boolean;
  146014. instance?: LinesMesh;
  146015. }, scene?: Nullable<Scene>): LinesMesh;
  146016. /**
  146017. * 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.
  146018. * * 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.
  146019. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146020. * * 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.
  146021. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  146022. * * 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
  146023. * * 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
  146024. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  146025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146026. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146027. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  146028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146029. * @param name defines the name of the mesh
  146030. * @param options defines the options used to create the mesh
  146031. * @param scene defines the hosting scene
  146032. * @returns the extruded shape mesh
  146033. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146034. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146035. */
  146036. static ExtrudeShape(name: string, options: {
  146037. shape: Vector3[];
  146038. path: Vector3[];
  146039. scale?: number;
  146040. rotation?: number;
  146041. cap?: number;
  146042. updatable?: boolean;
  146043. sideOrientation?: number;
  146044. frontUVs?: Vector4;
  146045. backUVs?: Vector4;
  146046. instance?: Mesh;
  146047. invertUV?: boolean;
  146048. }, scene?: Nullable<Scene>): Mesh;
  146049. /**
  146050. * Creates an custom extruded shape mesh.
  146051. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  146052. * * 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.
  146053. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146054. * * 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
  146055. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  146056. * * 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
  146057. * * It must returns a float value that will be the scale value applied to the shape on each path point
  146058. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  146059. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  146060. * * 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
  146061. * * 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
  146062. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  146063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146065. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146067. * @param name defines the name of the mesh
  146068. * @param options defines the options used to create the mesh
  146069. * @param scene defines the hosting scene
  146070. * @returns the custom extruded shape mesh
  146071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  146072. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146073. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146074. */
  146075. static ExtrudeShapeCustom(name: string, options: {
  146076. shape: Vector3[];
  146077. path: Vector3[];
  146078. scaleFunction?: any;
  146079. rotationFunction?: any;
  146080. ribbonCloseArray?: boolean;
  146081. ribbonClosePath?: boolean;
  146082. cap?: number;
  146083. updatable?: boolean;
  146084. sideOrientation?: number;
  146085. frontUVs?: Vector4;
  146086. backUVs?: Vector4;
  146087. instance?: Mesh;
  146088. invertUV?: boolean;
  146089. }, scene?: Nullable<Scene>): Mesh;
  146090. /**
  146091. * Creates lathe mesh.
  146092. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146093. * * 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
  146094. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146095. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146096. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146097. * * 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
  146098. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146099. * * 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
  146100. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146101. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146102. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146104. * @param name defines the name of the mesh
  146105. * @param options defines the options used to create the mesh
  146106. * @param scene defines the hosting scene
  146107. * @returns the lathe mesh
  146108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146109. */
  146110. static CreateLathe(name: string, options: {
  146111. shape: Vector3[];
  146112. radius?: number;
  146113. tessellation?: number;
  146114. clip?: number;
  146115. arc?: number;
  146116. closed?: boolean;
  146117. updatable?: boolean;
  146118. sideOrientation?: number;
  146119. frontUVs?: Vector4;
  146120. backUVs?: Vector4;
  146121. cap?: number;
  146122. invertUV?: boolean;
  146123. }, scene?: Nullable<Scene>): Mesh;
  146124. /**
  146125. * Creates a tiled plane mesh
  146126. * * You can set a limited pattern arrangement with the tiles
  146127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146130. * @param name defines the name of the mesh
  146131. * @param options defines the options used to create the mesh
  146132. * @param scene defines the hosting scene
  146133. * @returns the plane mesh
  146134. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146135. */
  146136. static CreateTiledPlane(name: string, options: {
  146137. pattern?: number;
  146138. tileSize?: number;
  146139. tileWidth?: number;
  146140. tileHeight?: number;
  146141. size?: number;
  146142. width?: number;
  146143. height?: number;
  146144. alignHorizontal?: number;
  146145. alignVertical?: number;
  146146. sideOrientation?: number;
  146147. frontUVs?: Vector4;
  146148. backUVs?: Vector4;
  146149. updatable?: boolean;
  146150. }, scene?: Nullable<Scene>): Mesh;
  146151. /**
  146152. * Creates a plane mesh
  146153. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  146154. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  146155. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  146156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146157. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146159. * @param name defines the name of the mesh
  146160. * @param options defines the options used to create the mesh
  146161. * @param scene defines the hosting scene
  146162. * @returns the plane mesh
  146163. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146164. */
  146165. static CreatePlane(name: string, options: {
  146166. size?: number;
  146167. width?: number;
  146168. height?: number;
  146169. sideOrientation?: number;
  146170. frontUVs?: Vector4;
  146171. backUVs?: Vector4;
  146172. updatable?: boolean;
  146173. sourcePlane?: Plane;
  146174. }, scene?: Nullable<Scene>): Mesh;
  146175. /**
  146176. * Creates a ground mesh
  146177. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  146178. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  146179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146180. * @param name defines the name of the mesh
  146181. * @param options defines the options used to create the mesh
  146182. * @param scene defines the hosting scene
  146183. * @returns the ground mesh
  146184. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  146185. */
  146186. static CreateGround(name: string, options: {
  146187. width?: number;
  146188. height?: number;
  146189. subdivisions?: number;
  146190. subdivisionsX?: number;
  146191. subdivisionsY?: number;
  146192. updatable?: boolean;
  146193. }, scene?: Nullable<Scene>): Mesh;
  146194. /**
  146195. * Creates a tiled ground mesh
  146196. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  146197. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  146198. * * 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
  146199. * * 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
  146200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146201. * @param name defines the name of the mesh
  146202. * @param options defines the options used to create the mesh
  146203. * @param scene defines the hosting scene
  146204. * @returns the tiled ground mesh
  146205. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  146206. */
  146207. static CreateTiledGround(name: string, options: {
  146208. xmin: number;
  146209. zmin: number;
  146210. xmax: number;
  146211. zmax: number;
  146212. subdivisions?: {
  146213. w: number;
  146214. h: number;
  146215. };
  146216. precision?: {
  146217. w: number;
  146218. h: number;
  146219. };
  146220. updatable?: boolean;
  146221. }, scene?: Nullable<Scene>): Mesh;
  146222. /**
  146223. * Creates a ground mesh from a height map
  146224. * * The parameter `url` sets the URL of the height map image resource.
  146225. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  146226. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  146227. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  146228. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  146229. * * 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.
  146230. * * 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).
  146231. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  146232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146233. * @param name defines the name of the mesh
  146234. * @param url defines the url to the height map
  146235. * @param options defines the options used to create the mesh
  146236. * @param scene defines the hosting scene
  146237. * @returns the ground mesh
  146238. * @see https://doc.babylonjs.com/babylon101/height_map
  146239. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  146240. */
  146241. static CreateGroundFromHeightMap(name: string, url: string, options: {
  146242. width?: number;
  146243. height?: number;
  146244. subdivisions?: number;
  146245. minHeight?: number;
  146246. maxHeight?: number;
  146247. colorFilter?: Color3;
  146248. alphaFilter?: number;
  146249. updatable?: boolean;
  146250. onReady?: (mesh: GroundMesh) => void;
  146251. }, scene?: Nullable<Scene>): GroundMesh;
  146252. /**
  146253. * Creates a polygon mesh
  146254. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146255. * * 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
  146256. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146259. * * Remember you can only change the shape positions, not their number when updating a polygon
  146260. * @param name defines the name of the mesh
  146261. * @param options defines the options used to create the mesh
  146262. * @param scene defines the hosting scene
  146263. * @param earcutInjection can be used to inject your own earcut reference
  146264. * @returns the polygon mesh
  146265. */
  146266. static CreatePolygon(name: string, options: {
  146267. shape: Vector3[];
  146268. holes?: Vector3[][];
  146269. depth?: number;
  146270. faceUV?: Vector4[];
  146271. faceColors?: Color4[];
  146272. updatable?: boolean;
  146273. sideOrientation?: number;
  146274. frontUVs?: Vector4;
  146275. backUVs?: Vector4;
  146276. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146277. /**
  146278. * Creates an extruded polygon mesh, with depth in the Y direction.
  146279. * * 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)
  146280. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146281. * @param name defines the name of the mesh
  146282. * @param options defines the options used to create the mesh
  146283. * @param scene defines the hosting scene
  146284. * @param earcutInjection can be used to inject your own earcut reference
  146285. * @returns the polygon mesh
  146286. */
  146287. static ExtrudePolygon(name: string, options: {
  146288. shape: Vector3[];
  146289. holes?: Vector3[][];
  146290. depth?: number;
  146291. faceUV?: Vector4[];
  146292. faceColors?: Color4[];
  146293. updatable?: boolean;
  146294. sideOrientation?: number;
  146295. frontUVs?: Vector4;
  146296. backUVs?: Vector4;
  146297. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146298. /**
  146299. * Creates a tube mesh.
  146300. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146301. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146302. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146303. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146304. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146305. * * 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)
  146306. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146307. * * 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
  146308. * * 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
  146309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146310. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146311. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146313. * @param name defines the name of the mesh
  146314. * @param options defines the options used to create the mesh
  146315. * @param scene defines the hosting scene
  146316. * @returns the tube mesh
  146317. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146318. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146319. */
  146320. static CreateTube(name: string, options: {
  146321. path: Vector3[];
  146322. radius?: number;
  146323. tessellation?: number;
  146324. radiusFunction?: {
  146325. (i: number, distance: number): number;
  146326. };
  146327. cap?: number;
  146328. arc?: number;
  146329. updatable?: boolean;
  146330. sideOrientation?: number;
  146331. frontUVs?: Vector4;
  146332. backUVs?: Vector4;
  146333. instance?: Mesh;
  146334. invertUV?: boolean;
  146335. }, scene?: Nullable<Scene>): Mesh;
  146336. /**
  146337. * Creates a polyhedron mesh
  146338. * * 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
  146339. * * The parameter `size` (positive float, default 1) sets the polygon size
  146340. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  146341. * * 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`
  146342. * * 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
  146343. * * 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)`)
  146344. * * 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
  146345. * * 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
  146346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146349. * @param name defines the name of the mesh
  146350. * @param options defines the options used to create the mesh
  146351. * @param scene defines the hosting scene
  146352. * @returns the polyhedron mesh
  146353. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  146354. */
  146355. static CreatePolyhedron(name: string, options: {
  146356. type?: number;
  146357. size?: number;
  146358. sizeX?: number;
  146359. sizeY?: number;
  146360. sizeZ?: number;
  146361. custom?: any;
  146362. faceUV?: Vector4[];
  146363. faceColors?: Color4[];
  146364. flat?: boolean;
  146365. updatable?: boolean;
  146366. sideOrientation?: number;
  146367. frontUVs?: Vector4;
  146368. backUVs?: Vector4;
  146369. }, scene?: Nullable<Scene>): Mesh;
  146370. /**
  146371. * Creates a decal mesh.
  146372. * 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
  146373. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146374. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146375. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146376. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146377. * @param name defines the name of the mesh
  146378. * @param sourceMesh defines the mesh where the decal must be applied
  146379. * @param options defines the options used to create the mesh
  146380. * @param scene defines the hosting scene
  146381. * @returns the decal mesh
  146382. * @see https://doc.babylonjs.com/how_to/decals
  146383. */
  146384. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146385. position?: Vector3;
  146386. normal?: Vector3;
  146387. size?: Vector3;
  146388. angle?: number;
  146389. }): Mesh;
  146390. /**
  146391. * Creates a Capsule Mesh
  146392. * @param name defines the name of the mesh.
  146393. * @param options the constructors options used to shape the mesh.
  146394. * @param scene defines the scene the mesh is scoped to.
  146395. * @returns the capsule mesh
  146396. * @see https://doc.babylonjs.com/how_to/capsule_shape
  146397. */
  146398. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  146399. }
  146400. }
  146401. declare module BABYLON {
  146402. /**
  146403. * A simplifier interface for future simplification implementations
  146404. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146405. */
  146406. export interface ISimplifier {
  146407. /**
  146408. * Simplification of a given mesh according to the given settings.
  146409. * Since this requires computation, it is assumed that the function runs async.
  146410. * @param settings The settings of the simplification, including quality and distance
  146411. * @param successCallback A callback that will be called after the mesh was simplified.
  146412. * @param errorCallback in case of an error, this callback will be called. optional.
  146413. */
  146414. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  146415. }
  146416. /**
  146417. * Expected simplification settings.
  146418. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  146419. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146420. */
  146421. export interface ISimplificationSettings {
  146422. /**
  146423. * Gets or sets the expected quality
  146424. */
  146425. quality: number;
  146426. /**
  146427. * Gets or sets the distance when this optimized version should be used
  146428. */
  146429. distance: number;
  146430. /**
  146431. * Gets an already optimized mesh
  146432. */
  146433. optimizeMesh?: boolean;
  146434. }
  146435. /**
  146436. * Class used to specify simplification options
  146437. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146438. */
  146439. export class SimplificationSettings implements ISimplificationSettings {
  146440. /** expected quality */
  146441. quality: number;
  146442. /** distance when this optimized version should be used */
  146443. distance: number;
  146444. /** already optimized mesh */
  146445. optimizeMesh?: boolean | undefined;
  146446. /**
  146447. * Creates a SimplificationSettings
  146448. * @param quality expected quality
  146449. * @param distance distance when this optimized version should be used
  146450. * @param optimizeMesh already optimized mesh
  146451. */
  146452. constructor(
  146453. /** expected quality */
  146454. quality: number,
  146455. /** distance when this optimized version should be used */
  146456. distance: number,
  146457. /** already optimized mesh */
  146458. optimizeMesh?: boolean | undefined);
  146459. }
  146460. /**
  146461. * Interface used to define a simplification task
  146462. */
  146463. export interface ISimplificationTask {
  146464. /**
  146465. * Array of settings
  146466. */
  146467. settings: Array<ISimplificationSettings>;
  146468. /**
  146469. * Simplification type
  146470. */
  146471. simplificationType: SimplificationType;
  146472. /**
  146473. * Mesh to simplify
  146474. */
  146475. mesh: Mesh;
  146476. /**
  146477. * Callback called on success
  146478. */
  146479. successCallback?: () => void;
  146480. /**
  146481. * Defines if parallel processing can be used
  146482. */
  146483. parallelProcessing: boolean;
  146484. }
  146485. /**
  146486. * Queue used to order the simplification tasks
  146487. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146488. */
  146489. export class SimplificationQueue {
  146490. private _simplificationArray;
  146491. /**
  146492. * Gets a boolean indicating that the process is still running
  146493. */
  146494. running: boolean;
  146495. /**
  146496. * Creates a new queue
  146497. */
  146498. constructor();
  146499. /**
  146500. * Adds a new simplification task
  146501. * @param task defines a task to add
  146502. */
  146503. addTask(task: ISimplificationTask): void;
  146504. /**
  146505. * Execute next task
  146506. */
  146507. executeNext(): void;
  146508. /**
  146509. * Execute a simplification task
  146510. * @param task defines the task to run
  146511. */
  146512. runSimplification(task: ISimplificationTask): void;
  146513. private getSimplifier;
  146514. }
  146515. /**
  146516. * The implemented types of simplification
  146517. * At the moment only Quadratic Error Decimation is implemented
  146518. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146519. */
  146520. export enum SimplificationType {
  146521. /** Quadratic error decimation */
  146522. QUADRATIC = 0
  146523. }
  146524. /**
  146525. * An implementation of the Quadratic Error simplification algorithm.
  146526. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  146527. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  146528. * @author RaananW
  146529. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146530. */
  146531. export class QuadraticErrorSimplification implements ISimplifier {
  146532. private _mesh;
  146533. private triangles;
  146534. private vertices;
  146535. private references;
  146536. private _reconstructedMesh;
  146537. /** Gets or sets the number pf sync interations */
  146538. syncIterations: number;
  146539. /** Gets or sets the aggressiveness of the simplifier */
  146540. aggressiveness: number;
  146541. /** Gets or sets the number of allowed iterations for decimation */
  146542. decimationIterations: number;
  146543. /** Gets or sets the espilon to use for bounding box computation */
  146544. boundingBoxEpsilon: number;
  146545. /**
  146546. * Creates a new QuadraticErrorSimplification
  146547. * @param _mesh defines the target mesh
  146548. */
  146549. constructor(_mesh: Mesh);
  146550. /**
  146551. * Simplification of a given mesh according to the given settings.
  146552. * Since this requires computation, it is assumed that the function runs async.
  146553. * @param settings The settings of the simplification, including quality and distance
  146554. * @param successCallback A callback that will be called after the mesh was simplified.
  146555. */
  146556. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  146557. private runDecimation;
  146558. private initWithMesh;
  146559. private init;
  146560. private reconstructMesh;
  146561. private initDecimatedMesh;
  146562. private isFlipped;
  146563. private updateTriangles;
  146564. private identifyBorder;
  146565. private updateMesh;
  146566. private vertexError;
  146567. private calculateError;
  146568. }
  146569. }
  146570. declare module BABYLON {
  146571. interface Scene {
  146572. /** @hidden (Backing field) */
  146573. _simplificationQueue: SimplificationQueue;
  146574. /**
  146575. * Gets or sets the simplification queue attached to the scene
  146576. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146577. */
  146578. simplificationQueue: SimplificationQueue;
  146579. }
  146580. interface Mesh {
  146581. /**
  146582. * Simplify the mesh according to the given array of settings.
  146583. * Function will return immediately and will simplify async
  146584. * @param settings a collection of simplification settings
  146585. * @param parallelProcessing should all levels calculate parallel or one after the other
  146586. * @param simplificationType the type of simplification to run
  146587. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  146588. * @returns the current mesh
  146589. */
  146590. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  146591. }
  146592. /**
  146593. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  146594. * created in a scene
  146595. */
  146596. export class SimplicationQueueSceneComponent implements ISceneComponent {
  146597. /**
  146598. * The component name helpfull to identify the component in the list of scene components.
  146599. */
  146600. readonly name: string;
  146601. /**
  146602. * The scene the component belongs to.
  146603. */
  146604. scene: Scene;
  146605. /**
  146606. * Creates a new instance of the component for the given scene
  146607. * @param scene Defines the scene to register the component in
  146608. */
  146609. constructor(scene: Scene);
  146610. /**
  146611. * Registers the component in a given scene
  146612. */
  146613. register(): void;
  146614. /**
  146615. * Rebuilds the elements related to this component in case of
  146616. * context lost for instance.
  146617. */
  146618. rebuild(): void;
  146619. /**
  146620. * Disposes the component and the associated ressources
  146621. */
  146622. dispose(): void;
  146623. private _beforeCameraUpdate;
  146624. }
  146625. }
  146626. declare module BABYLON {
  146627. interface Mesh {
  146628. /**
  146629. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  146630. */
  146631. thinInstanceEnablePicking: boolean;
  146632. /**
  146633. * Creates a new thin instance
  146634. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  146635. * @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
  146636. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  146637. */
  146638. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  146639. /**
  146640. * Adds the transformation (matrix) of the current mesh as a thin instance
  146641. * @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
  146642. * @returns the thin instance index number
  146643. */
  146644. thinInstanceAddSelf(refresh: boolean): number;
  146645. /**
  146646. * Registers a custom attribute to be used with thin instances
  146647. * @param kind name of the attribute
  146648. * @param stride size in floats of the attribute
  146649. */
  146650. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  146651. /**
  146652. * Sets the matrix of a thin instance
  146653. * @param index index of the thin instance
  146654. * @param matrix matrix to set
  146655. * @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
  146656. */
  146657. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  146658. /**
  146659. * Sets the value of a custom attribute for a thin instance
  146660. * @param kind name of the attribute
  146661. * @param index index of the thin instance
  146662. * @param value value to set
  146663. * @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
  146664. */
  146665. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  146666. /**
  146667. * 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.
  146668. */
  146669. thinInstanceCount: number;
  146670. /**
  146671. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  146672. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  146673. * @param buffer buffer to set
  146674. * @param stride size in floats of each value of the buffer
  146675. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  146676. */
  146677. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  146678. /**
  146679. * Gets the list of world matrices
  146680. * @return an array containing all the world matrices from the thin instances
  146681. */
  146682. thinInstanceGetWorldMatrices(): Matrix[];
  146683. /**
  146684. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  146685. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  146686. */
  146687. thinInstanceBufferUpdated(kind: string): void;
  146688. /**
  146689. * Applies a partial update to a buffer directly on the GPU
  146690. * 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
  146691. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  146692. * @param data the data to set in the GPU buffer
  146693. * @param offset the offset in the GPU buffer where to update the data
  146694. */
  146695. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  146696. /**
  146697. * Refreshes the bounding info, taking into account all the thin instances defined
  146698. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  146699. */
  146700. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  146701. /** @hidden */
  146702. _thinInstanceInitializeUserStorage(): void;
  146703. /** @hidden */
  146704. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  146705. /** @hidden */
  146706. _userThinInstanceBuffersStorage: {
  146707. data: {
  146708. [key: string]: Float32Array;
  146709. };
  146710. sizes: {
  146711. [key: string]: number;
  146712. };
  146713. vertexBuffers: {
  146714. [key: string]: Nullable<VertexBuffer>;
  146715. };
  146716. strides: {
  146717. [key: string]: number;
  146718. };
  146719. };
  146720. }
  146721. }
  146722. declare module BABYLON {
  146723. /**
  146724. * Navigation plugin interface to add navigation constrained by a navigation mesh
  146725. */
  146726. export interface INavigationEnginePlugin {
  146727. /**
  146728. * plugin name
  146729. */
  146730. name: string;
  146731. /**
  146732. * Creates a navigation mesh
  146733. * @param meshes array of all the geometry used to compute the navigatio mesh
  146734. * @param parameters bunch of parameters used to filter geometry
  146735. */
  146736. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  146737. /**
  146738. * Create a navigation mesh debug mesh
  146739. * @param scene is where the mesh will be added
  146740. * @returns debug display mesh
  146741. */
  146742. createDebugNavMesh(scene: Scene): Mesh;
  146743. /**
  146744. * Get a navigation mesh constrained position, closest to the parameter position
  146745. * @param position world position
  146746. * @returns the closest point to position constrained by the navigation mesh
  146747. */
  146748. getClosestPoint(position: Vector3): Vector3;
  146749. /**
  146750. * Get a navigation mesh constrained position, closest to the parameter position
  146751. * @param position world position
  146752. * @param result output the closest point to position constrained by the navigation mesh
  146753. */
  146754. getClosestPointToRef(position: Vector3, result: Vector3): void;
  146755. /**
  146756. * Get a navigation mesh constrained position, within a particular radius
  146757. * @param position world position
  146758. * @param maxRadius the maximum distance to the constrained world position
  146759. * @returns the closest point to position constrained by the navigation mesh
  146760. */
  146761. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  146762. /**
  146763. * Get a navigation mesh constrained position, within a particular radius
  146764. * @param position world position
  146765. * @param maxRadius the maximum distance to the constrained world position
  146766. * @param result output the closest point to position constrained by the navigation mesh
  146767. */
  146768. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  146769. /**
  146770. * Compute the final position from a segment made of destination-position
  146771. * @param position world position
  146772. * @param destination world position
  146773. * @returns the resulting point along the navmesh
  146774. */
  146775. moveAlong(position: Vector3, destination: Vector3): Vector3;
  146776. /**
  146777. * Compute the final position from a segment made of destination-position
  146778. * @param position world position
  146779. * @param destination world position
  146780. * @param result output the resulting point along the navmesh
  146781. */
  146782. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  146783. /**
  146784. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  146785. * @param start world position
  146786. * @param end world position
  146787. * @returns array containing world position composing the path
  146788. */
  146789. computePath(start: Vector3, end: Vector3): Vector3[];
  146790. /**
  146791. * If this plugin is supported
  146792. * @returns true if plugin is supported
  146793. */
  146794. isSupported(): boolean;
  146795. /**
  146796. * Create a new Crowd so you can add agents
  146797. * @param maxAgents the maximum agent count in the crowd
  146798. * @param maxAgentRadius the maximum radius an agent can have
  146799. * @param scene to attach the crowd to
  146800. * @returns the crowd you can add agents to
  146801. */
  146802. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  146803. /**
  146804. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146805. * The queries will try to find a solution within those bounds
  146806. * default is (1,1,1)
  146807. * @param extent x,y,z value that define the extent around the queries point of reference
  146808. */
  146809. setDefaultQueryExtent(extent: Vector3): void;
  146810. /**
  146811. * Get the Bounding box extent specified by setDefaultQueryExtent
  146812. * @returns the box extent values
  146813. */
  146814. getDefaultQueryExtent(): Vector3;
  146815. /**
  146816. * build the navmesh from a previously saved state using getNavmeshData
  146817. * @param data the Uint8Array returned by getNavmeshData
  146818. */
  146819. buildFromNavmeshData(data: Uint8Array): void;
  146820. /**
  146821. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  146822. * @returns data the Uint8Array that can be saved and reused
  146823. */
  146824. getNavmeshData(): Uint8Array;
  146825. /**
  146826. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146827. * @param result output the box extent values
  146828. */
  146829. getDefaultQueryExtentToRef(result: Vector3): void;
  146830. /**
  146831. * Release all resources
  146832. */
  146833. dispose(): void;
  146834. }
  146835. /**
  146836. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  146837. */
  146838. export interface ICrowd {
  146839. /**
  146840. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  146841. * You can attach anything to that node. The node position is updated in the scene update tick.
  146842. * @param pos world position that will be constrained by the navigation mesh
  146843. * @param parameters agent parameters
  146844. * @param transform hooked to the agent that will be update by the scene
  146845. * @returns agent index
  146846. */
  146847. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  146848. /**
  146849. * Returns the agent position in world space
  146850. * @param index agent index returned by addAgent
  146851. * @returns world space position
  146852. */
  146853. getAgentPosition(index: number): Vector3;
  146854. /**
  146855. * Gets the agent position result in world space
  146856. * @param index agent index returned by addAgent
  146857. * @param result output world space position
  146858. */
  146859. getAgentPositionToRef(index: number, result: Vector3): void;
  146860. /**
  146861. * Gets the agent velocity in world space
  146862. * @param index agent index returned by addAgent
  146863. * @returns world space velocity
  146864. */
  146865. getAgentVelocity(index: number): Vector3;
  146866. /**
  146867. * Gets the agent velocity result in world space
  146868. * @param index agent index returned by addAgent
  146869. * @param result output world space velocity
  146870. */
  146871. getAgentVelocityToRef(index: number, result: Vector3): void;
  146872. /**
  146873. * remove a particular agent previously created
  146874. * @param index agent index returned by addAgent
  146875. */
  146876. removeAgent(index: number): void;
  146877. /**
  146878. * get the list of all agents attached to this crowd
  146879. * @returns list of agent indices
  146880. */
  146881. getAgents(): number[];
  146882. /**
  146883. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  146884. * @param deltaTime in seconds
  146885. */
  146886. update(deltaTime: number): void;
  146887. /**
  146888. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  146889. * @param index agent index returned by addAgent
  146890. * @param destination targeted world position
  146891. */
  146892. agentGoto(index: number, destination: Vector3): void;
  146893. /**
  146894. * Teleport the agent to a new position
  146895. * @param index agent index returned by addAgent
  146896. * @param destination targeted world position
  146897. */
  146898. agentTeleport(index: number, destination: Vector3): void;
  146899. /**
  146900. * Update agent parameters
  146901. * @param index agent index returned by addAgent
  146902. * @param parameters agent parameters
  146903. */
  146904. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  146905. /**
  146906. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146907. * The queries will try to find a solution within those bounds
  146908. * default is (1,1,1)
  146909. * @param extent x,y,z value that define the extent around the queries point of reference
  146910. */
  146911. setDefaultQueryExtent(extent: Vector3): void;
  146912. /**
  146913. * Get the Bounding box extent specified by setDefaultQueryExtent
  146914. * @returns the box extent values
  146915. */
  146916. getDefaultQueryExtent(): Vector3;
  146917. /**
  146918. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146919. * @param result output the box extent values
  146920. */
  146921. getDefaultQueryExtentToRef(result: Vector3): void;
  146922. /**
  146923. * Release all resources
  146924. */
  146925. dispose(): void;
  146926. }
  146927. /**
  146928. * Configures an agent
  146929. */
  146930. export interface IAgentParameters {
  146931. /**
  146932. * Agent radius. [Limit: >= 0]
  146933. */
  146934. radius: number;
  146935. /**
  146936. * Agent height. [Limit: > 0]
  146937. */
  146938. height: number;
  146939. /**
  146940. * Maximum allowed acceleration. [Limit: >= 0]
  146941. */
  146942. maxAcceleration: number;
  146943. /**
  146944. * Maximum allowed speed. [Limit: >= 0]
  146945. */
  146946. maxSpeed: number;
  146947. /**
  146948. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  146949. */
  146950. collisionQueryRange: number;
  146951. /**
  146952. * The path visibility optimization range. [Limit: > 0]
  146953. */
  146954. pathOptimizationRange: number;
  146955. /**
  146956. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  146957. */
  146958. separationWeight: number;
  146959. }
  146960. /**
  146961. * Configures the navigation mesh creation
  146962. */
  146963. export interface INavMeshParameters {
  146964. /**
  146965. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  146966. */
  146967. cs: number;
  146968. /**
  146969. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  146970. */
  146971. ch: number;
  146972. /**
  146973. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  146974. */
  146975. walkableSlopeAngle: number;
  146976. /**
  146977. * Minimum floor to 'ceiling' height that will still allow the floor area to
  146978. * be considered walkable. [Limit: >= 3] [Units: vx]
  146979. */
  146980. walkableHeight: number;
  146981. /**
  146982. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  146983. */
  146984. walkableClimb: number;
  146985. /**
  146986. * The distance to erode/shrink the walkable area of the heightfield away from
  146987. * obstructions. [Limit: >=0] [Units: vx]
  146988. */
  146989. walkableRadius: number;
  146990. /**
  146991. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  146992. */
  146993. maxEdgeLen: number;
  146994. /**
  146995. * The maximum distance a simplfied contour's border edges should deviate
  146996. * the original raw contour. [Limit: >=0] [Units: vx]
  146997. */
  146998. maxSimplificationError: number;
  146999. /**
  147000. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  147001. */
  147002. minRegionArea: number;
  147003. /**
  147004. * Any regions with a span count smaller than this value will, if possible,
  147005. * be merged with larger regions. [Limit: >=0] [Units: vx]
  147006. */
  147007. mergeRegionArea: number;
  147008. /**
  147009. * The maximum number of vertices allowed for polygons generated during the
  147010. * contour to polygon conversion process. [Limit: >= 3]
  147011. */
  147012. maxVertsPerPoly: number;
  147013. /**
  147014. * Sets the sampling distance to use when generating the detail mesh.
  147015. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  147016. */
  147017. detailSampleDist: number;
  147018. /**
  147019. * The maximum distance the detail mesh surface should deviate from heightfield
  147020. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  147021. */
  147022. detailSampleMaxError: number;
  147023. }
  147024. }
  147025. declare module BABYLON {
  147026. /**
  147027. * RecastJS navigation plugin
  147028. */
  147029. export class RecastJSPlugin implements INavigationEnginePlugin {
  147030. /**
  147031. * Reference to the Recast library
  147032. */
  147033. bjsRECAST: any;
  147034. /**
  147035. * plugin name
  147036. */
  147037. name: string;
  147038. /**
  147039. * the first navmesh created. We might extend this to support multiple navmeshes
  147040. */
  147041. navMesh: any;
  147042. /**
  147043. * Initializes the recastJS plugin
  147044. * @param recastInjection can be used to inject your own recast reference
  147045. */
  147046. constructor(recastInjection?: any);
  147047. /**
  147048. * Creates a navigation mesh
  147049. * @param meshes array of all the geometry used to compute the navigatio mesh
  147050. * @param parameters bunch of parameters used to filter geometry
  147051. */
  147052. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147053. /**
  147054. * Create a navigation mesh debug mesh
  147055. * @param scene is where the mesh will be added
  147056. * @returns debug display mesh
  147057. */
  147058. createDebugNavMesh(scene: Scene): Mesh;
  147059. /**
  147060. * Get a navigation mesh constrained position, closest to the parameter position
  147061. * @param position world position
  147062. * @returns the closest point to position constrained by the navigation mesh
  147063. */
  147064. getClosestPoint(position: Vector3): Vector3;
  147065. /**
  147066. * Get a navigation mesh constrained position, closest to the parameter position
  147067. * @param position world position
  147068. * @param result output the closest point to position constrained by the navigation mesh
  147069. */
  147070. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147071. /**
  147072. * Get a navigation mesh constrained position, within a particular radius
  147073. * @param position world position
  147074. * @param maxRadius the maximum distance to the constrained world position
  147075. * @returns the closest point to position constrained by the navigation mesh
  147076. */
  147077. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147078. /**
  147079. * Get a navigation mesh constrained position, within a particular radius
  147080. * @param position world position
  147081. * @param maxRadius the maximum distance to the constrained world position
  147082. * @param result output the closest point to position constrained by the navigation mesh
  147083. */
  147084. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147085. /**
  147086. * Compute the final position from a segment made of destination-position
  147087. * @param position world position
  147088. * @param destination world position
  147089. * @returns the resulting point along the navmesh
  147090. */
  147091. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147092. /**
  147093. * Compute the final position from a segment made of destination-position
  147094. * @param position world position
  147095. * @param destination world position
  147096. * @param result output the resulting point along the navmesh
  147097. */
  147098. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147099. /**
  147100. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147101. * @param start world position
  147102. * @param end world position
  147103. * @returns array containing world position composing the path
  147104. */
  147105. computePath(start: Vector3, end: Vector3): Vector3[];
  147106. /**
  147107. * Create a new Crowd so you can add agents
  147108. * @param maxAgents the maximum agent count in the crowd
  147109. * @param maxAgentRadius the maximum radius an agent can have
  147110. * @param scene to attach the crowd to
  147111. * @returns the crowd you can add agents to
  147112. */
  147113. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147114. /**
  147115. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147116. * The queries will try to find a solution within those bounds
  147117. * default is (1,1,1)
  147118. * @param extent x,y,z value that define the extent around the queries point of reference
  147119. */
  147120. setDefaultQueryExtent(extent: Vector3): void;
  147121. /**
  147122. * Get the Bounding box extent specified by setDefaultQueryExtent
  147123. * @returns the box extent values
  147124. */
  147125. getDefaultQueryExtent(): Vector3;
  147126. /**
  147127. * build the navmesh from a previously saved state using getNavmeshData
  147128. * @param data the Uint8Array returned by getNavmeshData
  147129. */
  147130. buildFromNavmeshData(data: Uint8Array): void;
  147131. /**
  147132. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147133. * @returns data the Uint8Array that can be saved and reused
  147134. */
  147135. getNavmeshData(): Uint8Array;
  147136. /**
  147137. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147138. * @param result output the box extent values
  147139. */
  147140. getDefaultQueryExtentToRef(result: Vector3): void;
  147141. /**
  147142. * Disposes
  147143. */
  147144. dispose(): void;
  147145. /**
  147146. * If this plugin is supported
  147147. * @returns true if plugin is supported
  147148. */
  147149. isSupported(): boolean;
  147150. }
  147151. /**
  147152. * Recast detour crowd implementation
  147153. */
  147154. export class RecastJSCrowd implements ICrowd {
  147155. /**
  147156. * Recast/detour plugin
  147157. */
  147158. bjsRECASTPlugin: RecastJSPlugin;
  147159. /**
  147160. * Link to the detour crowd
  147161. */
  147162. recastCrowd: any;
  147163. /**
  147164. * One transform per agent
  147165. */
  147166. transforms: TransformNode[];
  147167. /**
  147168. * All agents created
  147169. */
  147170. agents: number[];
  147171. /**
  147172. * Link to the scene is kept to unregister the crowd from the scene
  147173. */
  147174. private _scene;
  147175. /**
  147176. * Observer for crowd updates
  147177. */
  147178. private _onBeforeAnimationsObserver;
  147179. /**
  147180. * Constructor
  147181. * @param plugin recastJS plugin
  147182. * @param maxAgents the maximum agent count in the crowd
  147183. * @param maxAgentRadius the maximum radius an agent can have
  147184. * @param scene to attach the crowd to
  147185. * @returns the crowd you can add agents to
  147186. */
  147187. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  147188. /**
  147189. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147190. * You can attach anything to that node. The node position is updated in the scene update tick.
  147191. * @param pos world position that will be constrained by the navigation mesh
  147192. * @param parameters agent parameters
  147193. * @param transform hooked to the agent that will be update by the scene
  147194. * @returns agent index
  147195. */
  147196. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147197. /**
  147198. * Returns the agent position in world space
  147199. * @param index agent index returned by addAgent
  147200. * @returns world space position
  147201. */
  147202. getAgentPosition(index: number): Vector3;
  147203. /**
  147204. * Returns the agent position result in world space
  147205. * @param index agent index returned by addAgent
  147206. * @param result output world space position
  147207. */
  147208. getAgentPositionToRef(index: number, result: Vector3): void;
  147209. /**
  147210. * Returns the agent velocity in world space
  147211. * @param index agent index returned by addAgent
  147212. * @returns world space velocity
  147213. */
  147214. getAgentVelocity(index: number): Vector3;
  147215. /**
  147216. * Returns the agent velocity result in world space
  147217. * @param index agent index returned by addAgent
  147218. * @param result output world space velocity
  147219. */
  147220. getAgentVelocityToRef(index: number, result: Vector3): void;
  147221. /**
  147222. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147223. * @param index agent index returned by addAgent
  147224. * @param destination targeted world position
  147225. */
  147226. agentGoto(index: number, destination: Vector3): void;
  147227. /**
  147228. * Teleport the agent to a new position
  147229. * @param index agent index returned by addAgent
  147230. * @param destination targeted world position
  147231. */
  147232. agentTeleport(index: number, destination: Vector3): void;
  147233. /**
  147234. * Update agent parameters
  147235. * @param index agent index returned by addAgent
  147236. * @param parameters agent parameters
  147237. */
  147238. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147239. /**
  147240. * remove a particular agent previously created
  147241. * @param index agent index returned by addAgent
  147242. */
  147243. removeAgent(index: number): void;
  147244. /**
  147245. * get the list of all agents attached to this crowd
  147246. * @returns list of agent indices
  147247. */
  147248. getAgents(): number[];
  147249. /**
  147250. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147251. * @param deltaTime in seconds
  147252. */
  147253. update(deltaTime: number): void;
  147254. /**
  147255. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147256. * The queries will try to find a solution within those bounds
  147257. * default is (1,1,1)
  147258. * @param extent x,y,z value that define the extent around the queries point of reference
  147259. */
  147260. setDefaultQueryExtent(extent: Vector3): void;
  147261. /**
  147262. * Get the Bounding box extent specified by setDefaultQueryExtent
  147263. * @returns the box extent values
  147264. */
  147265. getDefaultQueryExtent(): Vector3;
  147266. /**
  147267. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147268. * @param result output the box extent values
  147269. */
  147270. getDefaultQueryExtentToRef(result: Vector3): void;
  147271. /**
  147272. * Release all resources
  147273. */
  147274. dispose(): void;
  147275. }
  147276. }
  147277. declare module BABYLON {
  147278. /**
  147279. * Class used to enable access to IndexedDB
  147280. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  147281. */
  147282. export class Database implements IOfflineProvider {
  147283. private _callbackManifestChecked;
  147284. private _currentSceneUrl;
  147285. private _db;
  147286. private _enableSceneOffline;
  147287. private _enableTexturesOffline;
  147288. private _manifestVersionFound;
  147289. private _mustUpdateRessources;
  147290. private _hasReachedQuota;
  147291. private _isSupported;
  147292. private _idbFactory;
  147293. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  147294. private static IsUASupportingBlobStorage;
  147295. /**
  147296. * Gets a boolean indicating if Database storate is enabled (off by default)
  147297. */
  147298. static IDBStorageEnabled: boolean;
  147299. /**
  147300. * Gets a boolean indicating if scene must be saved in the database
  147301. */
  147302. get enableSceneOffline(): boolean;
  147303. /**
  147304. * Gets a boolean indicating if textures must be saved in the database
  147305. */
  147306. get enableTexturesOffline(): boolean;
  147307. /**
  147308. * Creates a new Database
  147309. * @param urlToScene defines the url to load the scene
  147310. * @param callbackManifestChecked defines the callback to use when manifest is checked
  147311. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  147312. */
  147313. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  147314. private static _ParseURL;
  147315. private static _ReturnFullUrlLocation;
  147316. private _checkManifestFile;
  147317. /**
  147318. * Open the database and make it available
  147319. * @param successCallback defines the callback to call on success
  147320. * @param errorCallback defines the callback to call on error
  147321. */
  147322. open(successCallback: () => void, errorCallback: () => void): void;
  147323. /**
  147324. * Loads an image from the database
  147325. * @param url defines the url to load from
  147326. * @param image defines the target DOM image
  147327. */
  147328. loadImage(url: string, image: HTMLImageElement): void;
  147329. private _loadImageFromDBAsync;
  147330. private _saveImageIntoDBAsync;
  147331. private _checkVersionFromDB;
  147332. private _loadVersionFromDBAsync;
  147333. private _saveVersionIntoDBAsync;
  147334. /**
  147335. * Loads a file from database
  147336. * @param url defines the URL to load from
  147337. * @param sceneLoaded defines a callback to call on success
  147338. * @param progressCallBack defines a callback to call when progress changed
  147339. * @param errorCallback defines a callback to call on error
  147340. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  147341. */
  147342. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  147343. private _loadFileAsync;
  147344. private _saveFileAsync;
  147345. /**
  147346. * Validates if xhr data is correct
  147347. * @param xhr defines the request to validate
  147348. * @param dataType defines the expected data type
  147349. * @returns true if data is correct
  147350. */
  147351. private static _ValidateXHRData;
  147352. }
  147353. }
  147354. declare module BABYLON {
  147355. /** @hidden */
  147356. export var gpuUpdateParticlesPixelShader: {
  147357. name: string;
  147358. shader: string;
  147359. };
  147360. }
  147361. declare module BABYLON {
  147362. /** @hidden */
  147363. export var gpuUpdateParticlesVertexShader: {
  147364. name: string;
  147365. shader: string;
  147366. };
  147367. }
  147368. declare module BABYLON {
  147369. /** @hidden */
  147370. export var clipPlaneFragmentDeclaration2: {
  147371. name: string;
  147372. shader: string;
  147373. };
  147374. }
  147375. declare module BABYLON {
  147376. /** @hidden */
  147377. export var gpuRenderParticlesPixelShader: {
  147378. name: string;
  147379. shader: string;
  147380. };
  147381. }
  147382. declare module BABYLON {
  147383. /** @hidden */
  147384. export var clipPlaneVertexDeclaration2: {
  147385. name: string;
  147386. shader: string;
  147387. };
  147388. }
  147389. declare module BABYLON {
  147390. /** @hidden */
  147391. export var gpuRenderParticlesVertexShader: {
  147392. name: string;
  147393. shader: string;
  147394. };
  147395. }
  147396. declare module BABYLON {
  147397. /**
  147398. * This represents a GPU particle system in Babylon
  147399. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  147400. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  147401. */
  147402. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  147403. /**
  147404. * The layer mask we are rendering the particles through.
  147405. */
  147406. layerMask: number;
  147407. private _capacity;
  147408. private _activeCount;
  147409. private _currentActiveCount;
  147410. private _accumulatedCount;
  147411. private _renderEffect;
  147412. private _updateEffect;
  147413. private _buffer0;
  147414. private _buffer1;
  147415. private _spriteBuffer;
  147416. private _updateVAO;
  147417. private _renderVAO;
  147418. private _targetIndex;
  147419. private _sourceBuffer;
  147420. private _targetBuffer;
  147421. private _currentRenderId;
  147422. private _started;
  147423. private _stopped;
  147424. private _timeDelta;
  147425. private _randomTexture;
  147426. private _randomTexture2;
  147427. private _attributesStrideSize;
  147428. private _updateEffectOptions;
  147429. private _randomTextureSize;
  147430. private _actualFrame;
  147431. private _customEffect;
  147432. private readonly _rawTextureWidth;
  147433. /**
  147434. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  147435. */
  147436. static get IsSupported(): boolean;
  147437. /**
  147438. * An event triggered when the system is disposed.
  147439. */
  147440. onDisposeObservable: Observable<IParticleSystem>;
  147441. /**
  147442. * Gets the maximum number of particles active at the same time.
  147443. * @returns The max number of active particles.
  147444. */
  147445. getCapacity(): number;
  147446. /**
  147447. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  147448. * to override the particles.
  147449. */
  147450. forceDepthWrite: boolean;
  147451. /**
  147452. * Gets or set the number of active particles
  147453. */
  147454. get activeParticleCount(): number;
  147455. set activeParticleCount(value: number);
  147456. private _preWarmDone;
  147457. /**
  147458. * Specifies if the particles are updated in emitter local space or world space.
  147459. */
  147460. isLocal: boolean;
  147461. /** Gets or sets a matrix to use to compute projection */
  147462. defaultProjectionMatrix: Matrix;
  147463. /**
  147464. * Is this system ready to be used/rendered
  147465. * @return true if the system is ready
  147466. */
  147467. isReady(): boolean;
  147468. /**
  147469. * Gets if the system has been started. (Note: this will still be true after stop is called)
  147470. * @returns True if it has been started, otherwise false.
  147471. */
  147472. isStarted(): boolean;
  147473. /**
  147474. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  147475. * @returns True if it has been stopped, otherwise false.
  147476. */
  147477. isStopped(): boolean;
  147478. /**
  147479. * Gets a boolean indicating that the system is stopping
  147480. * @returns true if the system is currently stopping
  147481. */
  147482. isStopping(): boolean;
  147483. /**
  147484. * Gets the number of particles active at the same time.
  147485. * @returns The number of active particles.
  147486. */
  147487. getActiveCount(): number;
  147488. /**
  147489. * Starts the particle system and begins to emit
  147490. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  147491. */
  147492. start(delay?: number): void;
  147493. /**
  147494. * Stops the particle system.
  147495. */
  147496. stop(): void;
  147497. /**
  147498. * Remove all active particles
  147499. */
  147500. reset(): void;
  147501. /**
  147502. * Returns the string "GPUParticleSystem"
  147503. * @returns a string containing the class name
  147504. */
  147505. getClassName(): string;
  147506. /**
  147507. * Gets the custom effect used to render the particles
  147508. * @param blendMode Blend mode for which the effect should be retrieved
  147509. * @returns The effect
  147510. */
  147511. getCustomEffect(blendMode?: number): Nullable<Effect>;
  147512. /**
  147513. * Sets the custom effect used to render the particles
  147514. * @param effect The effect to set
  147515. * @param blendMode Blend mode for which the effect should be set
  147516. */
  147517. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  147518. /** @hidden */
  147519. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  147520. /**
  147521. * Observable that will be called just before the particles are drawn
  147522. */
  147523. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  147524. /**
  147525. * Gets the name of the particle vertex shader
  147526. */
  147527. get vertexShaderName(): string;
  147528. private _colorGradientsTexture;
  147529. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  147530. /**
  147531. * Adds a new color gradient
  147532. * @param gradient defines the gradient to use (between 0 and 1)
  147533. * @param color1 defines the color to affect to the specified gradient
  147534. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  147535. * @returns the current particle system
  147536. */
  147537. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  147538. private _refreshColorGradient;
  147539. /** Force the system to rebuild all gradients that need to be resync */
  147540. forceRefreshGradients(): void;
  147541. /**
  147542. * Remove a specific color gradient
  147543. * @param gradient defines the gradient to remove
  147544. * @returns the current particle system
  147545. */
  147546. removeColorGradient(gradient: number): GPUParticleSystem;
  147547. private _angularSpeedGradientsTexture;
  147548. private _sizeGradientsTexture;
  147549. private _velocityGradientsTexture;
  147550. private _limitVelocityGradientsTexture;
  147551. private _dragGradientsTexture;
  147552. private _addFactorGradient;
  147553. /**
  147554. * Adds a new size gradient
  147555. * @param gradient defines the gradient to use (between 0 and 1)
  147556. * @param factor defines the size factor to affect to the specified gradient
  147557. * @returns the current particle system
  147558. */
  147559. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  147560. /**
  147561. * Remove a specific size gradient
  147562. * @param gradient defines the gradient to remove
  147563. * @returns the current particle system
  147564. */
  147565. removeSizeGradient(gradient: number): GPUParticleSystem;
  147566. private _refreshFactorGradient;
  147567. /**
  147568. * Adds a new angular speed gradient
  147569. * @param gradient defines the gradient to use (between 0 and 1)
  147570. * @param factor defines the angular speed to affect to the specified gradient
  147571. * @returns the current particle system
  147572. */
  147573. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  147574. /**
  147575. * Remove a specific angular speed gradient
  147576. * @param gradient defines the gradient to remove
  147577. * @returns the current particle system
  147578. */
  147579. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  147580. /**
  147581. * Adds a new velocity gradient
  147582. * @param gradient defines the gradient to use (between 0 and 1)
  147583. * @param factor defines the velocity to affect to the specified gradient
  147584. * @returns the current particle system
  147585. */
  147586. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  147587. /**
  147588. * Remove a specific velocity gradient
  147589. * @param gradient defines the gradient to remove
  147590. * @returns the current particle system
  147591. */
  147592. removeVelocityGradient(gradient: number): GPUParticleSystem;
  147593. /**
  147594. * Adds a new limit velocity gradient
  147595. * @param gradient defines the gradient to use (between 0 and 1)
  147596. * @param factor defines the limit velocity value to affect to the specified gradient
  147597. * @returns the current particle system
  147598. */
  147599. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  147600. /**
  147601. * Remove a specific limit velocity gradient
  147602. * @param gradient defines the gradient to remove
  147603. * @returns the current particle system
  147604. */
  147605. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  147606. /**
  147607. * Adds a new drag gradient
  147608. * @param gradient defines the gradient to use (between 0 and 1)
  147609. * @param factor defines the drag value to affect to the specified gradient
  147610. * @returns the current particle system
  147611. */
  147612. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  147613. /**
  147614. * Remove a specific drag gradient
  147615. * @param gradient defines the gradient to remove
  147616. * @returns the current particle system
  147617. */
  147618. removeDragGradient(gradient: number): GPUParticleSystem;
  147619. /**
  147620. * Not supported by GPUParticleSystem
  147621. * @param gradient defines the gradient to use (between 0 and 1)
  147622. * @param factor defines the emit rate value to affect to the specified gradient
  147623. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147624. * @returns the current particle system
  147625. */
  147626. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147627. /**
  147628. * Not supported by GPUParticleSystem
  147629. * @param gradient defines the gradient to remove
  147630. * @returns the current particle system
  147631. */
  147632. removeEmitRateGradient(gradient: number): IParticleSystem;
  147633. /**
  147634. * Not supported by GPUParticleSystem
  147635. * @param gradient defines the gradient to use (between 0 and 1)
  147636. * @param factor defines the start size value to affect to the specified gradient
  147637. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147638. * @returns the current particle system
  147639. */
  147640. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147641. /**
  147642. * Not supported by GPUParticleSystem
  147643. * @param gradient defines the gradient to remove
  147644. * @returns the current particle system
  147645. */
  147646. removeStartSizeGradient(gradient: number): IParticleSystem;
  147647. /**
  147648. * Not supported by GPUParticleSystem
  147649. * @param gradient defines the gradient to use (between 0 and 1)
  147650. * @param min defines the color remap minimal range
  147651. * @param max defines the color remap maximal range
  147652. * @returns the current particle system
  147653. */
  147654. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  147655. /**
  147656. * Not supported by GPUParticleSystem
  147657. * @param gradient defines the gradient to remove
  147658. * @returns the current particle system
  147659. */
  147660. removeColorRemapGradient(): IParticleSystem;
  147661. /**
  147662. * Not supported by GPUParticleSystem
  147663. * @param gradient defines the gradient to use (between 0 and 1)
  147664. * @param min defines the alpha remap minimal range
  147665. * @param max defines the alpha remap maximal range
  147666. * @returns the current particle system
  147667. */
  147668. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  147669. /**
  147670. * Not supported by GPUParticleSystem
  147671. * @param gradient defines the gradient to remove
  147672. * @returns the current particle system
  147673. */
  147674. removeAlphaRemapGradient(): IParticleSystem;
  147675. /**
  147676. * Not supported by GPUParticleSystem
  147677. * @param gradient defines the gradient to use (between 0 and 1)
  147678. * @param color defines the color to affect to the specified gradient
  147679. * @returns the current particle system
  147680. */
  147681. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  147682. /**
  147683. * Not supported by GPUParticleSystem
  147684. * @param gradient defines the gradient to remove
  147685. * @returns the current particle system
  147686. */
  147687. removeRampGradient(): IParticleSystem;
  147688. /**
  147689. * Not supported by GPUParticleSystem
  147690. * @returns the list of ramp gradients
  147691. */
  147692. getRampGradients(): Nullable<Array<Color3Gradient>>;
  147693. /**
  147694. * Not supported by GPUParticleSystem
  147695. * Gets or sets a boolean indicating that ramp gradients must be used
  147696. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  147697. */
  147698. get useRampGradients(): boolean;
  147699. set useRampGradients(value: boolean);
  147700. /**
  147701. * Not supported by GPUParticleSystem
  147702. * @param gradient defines the gradient to use (between 0 and 1)
  147703. * @param factor defines the life time factor to affect to the specified gradient
  147704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147705. * @returns the current particle system
  147706. */
  147707. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147708. /**
  147709. * Not supported by GPUParticleSystem
  147710. * @param gradient defines the gradient to remove
  147711. * @returns the current particle system
  147712. */
  147713. removeLifeTimeGradient(gradient: number): IParticleSystem;
  147714. /**
  147715. * Instantiates a GPU particle system.
  147716. * 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.
  147717. * @param name The name of the particle system
  147718. * @param options The options used to create the system
  147719. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  147720. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  147721. * @param customEffect a custom effect used to change the way particles are rendered by default
  147722. */
  147723. constructor(name: string, options: Partial<{
  147724. capacity: number;
  147725. randomTextureSize: number;
  147726. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  147727. protected _reset(): void;
  147728. private _createUpdateVAO;
  147729. private _createRenderVAO;
  147730. private _initialize;
  147731. /** @hidden */
  147732. _recreateUpdateEffect(): void;
  147733. private _getEffect;
  147734. /**
  147735. * Fill the defines array according to the current settings of the particle system
  147736. * @param defines Array to be updated
  147737. * @param blendMode blend mode to take into account when updating the array
  147738. */
  147739. fillDefines(defines: Array<string>, blendMode?: number): void;
  147740. /**
  147741. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  147742. * @param uniforms Uniforms array to fill
  147743. * @param attributes Attributes array to fill
  147744. * @param samplers Samplers array to fill
  147745. */
  147746. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  147747. /** @hidden */
  147748. _recreateRenderEffect(): Effect;
  147749. /**
  147750. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  147751. * @param preWarm defines if we are in the pre-warmimg phase
  147752. */
  147753. animate(preWarm?: boolean): void;
  147754. private _createFactorGradientTexture;
  147755. private _createSizeGradientTexture;
  147756. private _createAngularSpeedGradientTexture;
  147757. private _createVelocityGradientTexture;
  147758. private _createLimitVelocityGradientTexture;
  147759. private _createDragGradientTexture;
  147760. private _createColorGradientTexture;
  147761. /**
  147762. * Renders the particle system in its current state
  147763. * @param preWarm defines if the system should only update the particles but not render them
  147764. * @returns the current number of particles
  147765. */
  147766. render(preWarm?: boolean): number;
  147767. /**
  147768. * Rebuilds the particle system
  147769. */
  147770. rebuild(): void;
  147771. private _releaseBuffers;
  147772. private _releaseVAOs;
  147773. /**
  147774. * Disposes the particle system and free the associated resources
  147775. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  147776. */
  147777. dispose(disposeTexture?: boolean): void;
  147778. /**
  147779. * Clones the particle system.
  147780. * @param name The name of the cloned object
  147781. * @param newEmitter The new emitter to use
  147782. * @returns the cloned particle system
  147783. */
  147784. clone(name: string, newEmitter: any): GPUParticleSystem;
  147785. /**
  147786. * Serializes the particle system to a JSON object
  147787. * @param serializeTexture defines if the texture must be serialized as well
  147788. * @returns the JSON object
  147789. */
  147790. serialize(serializeTexture?: boolean): any;
  147791. /**
  147792. * Parses a JSON object to create a GPU particle system.
  147793. * @param parsedParticleSystem The JSON object to parse
  147794. * @param sceneOrEngine The scene or the engine to create the particle system in
  147795. * @param rootUrl The root url to use to load external dependencies like texture
  147796. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  147797. * @returns the parsed GPU particle system
  147798. */
  147799. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  147800. }
  147801. }
  147802. declare module BABYLON {
  147803. /**
  147804. * Represents a set of particle systems working together to create a specific effect
  147805. */
  147806. export class ParticleSystemSet implements IDisposable {
  147807. /**
  147808. * Gets or sets base Assets URL
  147809. */
  147810. static BaseAssetsUrl: string;
  147811. private _emitterCreationOptions;
  147812. private _emitterNode;
  147813. /**
  147814. * Gets the particle system list
  147815. */
  147816. systems: IParticleSystem[];
  147817. /**
  147818. * Gets the emitter node used with this set
  147819. */
  147820. get emitterNode(): Nullable<TransformNode>;
  147821. /**
  147822. * Creates a new emitter mesh as a sphere
  147823. * @param options defines the options used to create the sphere
  147824. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  147825. * @param scene defines the hosting scene
  147826. */
  147827. setEmitterAsSphere(options: {
  147828. diameter: number;
  147829. segments: number;
  147830. color: Color3;
  147831. }, renderingGroupId: number, scene: Scene): void;
  147832. /**
  147833. * Starts all particle systems of the set
  147834. * @param emitter defines an optional mesh to use as emitter for the particle systems
  147835. */
  147836. start(emitter?: AbstractMesh): void;
  147837. /**
  147838. * Release all associated resources
  147839. */
  147840. dispose(): void;
  147841. /**
  147842. * Serialize the set into a JSON compatible object
  147843. * @param serializeTexture defines if the texture must be serialized as well
  147844. * @returns a JSON compatible representation of the set
  147845. */
  147846. serialize(serializeTexture?: boolean): any;
  147847. /**
  147848. * Parse a new ParticleSystemSet from a serialized source
  147849. * @param data defines a JSON compatible representation of the set
  147850. * @param scene defines the hosting scene
  147851. * @param gpu defines if we want GPU particles or CPU particles
  147852. * @returns a new ParticleSystemSet
  147853. */
  147854. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  147855. }
  147856. }
  147857. declare module BABYLON {
  147858. /**
  147859. * This class is made for on one-liner static method to help creating particle system set.
  147860. */
  147861. export class ParticleHelper {
  147862. /**
  147863. * Gets or sets base Assets URL
  147864. */
  147865. static BaseAssetsUrl: string;
  147866. /** Define the Url to load snippets */
  147867. static SnippetUrl: string;
  147868. /**
  147869. * Create a default particle system that you can tweak
  147870. * @param emitter defines the emitter to use
  147871. * @param capacity defines the system capacity (default is 500 particles)
  147872. * @param scene defines the hosting scene
  147873. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  147874. * @returns the new Particle system
  147875. */
  147876. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  147877. /**
  147878. * This is the main static method (one-liner) of this helper to create different particle systems
  147879. * @param type This string represents the type to the particle system to create
  147880. * @param scene The scene where the particle system should live
  147881. * @param gpu If the system will use gpu
  147882. * @returns the ParticleSystemSet created
  147883. */
  147884. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  147885. /**
  147886. * Static function used to export a particle system to a ParticleSystemSet variable.
  147887. * Please note that the emitter shape is not exported
  147888. * @param systems defines the particle systems to export
  147889. * @returns the created particle system set
  147890. */
  147891. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  147892. /**
  147893. * Creates a particle system from a snippet saved in a remote file
  147894. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  147895. * @param url defines the url to load from
  147896. * @param scene defines the hosting scene
  147897. * @param gpu If the system will use gpu
  147898. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  147899. * @returns a promise that will resolve to the new particle system
  147900. */
  147901. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  147902. /**
  147903. * Creates a particle system from a snippet saved by the particle system editor
  147904. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  147905. * @param scene defines the hosting scene
  147906. * @param gpu If the system will use gpu
  147907. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  147908. * @returns a promise that will resolve to the new particle system
  147909. */
  147910. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  147911. }
  147912. }
  147913. declare module BABYLON {
  147914. interface Engine {
  147915. /**
  147916. * Create an effect to use with particle systems.
  147917. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  147918. * the particle system for which you want to create a custom effect in the last parameter
  147919. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  147920. * @param uniformsNames defines a list of attribute names
  147921. * @param samplers defines an array of string used to represent textures
  147922. * @param defines defines the string containing the defines to use to compile the shaders
  147923. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  147924. * @param onCompiled defines a function to call when the effect creation is successful
  147925. * @param onError defines a function to call when the effect creation has failed
  147926. * @param particleSystem the particle system you want to create the effect for
  147927. * @returns the new Effect
  147928. */
  147929. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  147930. }
  147931. interface Mesh {
  147932. /**
  147933. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  147934. * @returns an array of IParticleSystem
  147935. */
  147936. getEmittedParticleSystems(): IParticleSystem[];
  147937. /**
  147938. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  147939. * @returns an array of IParticleSystem
  147940. */
  147941. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  147942. }
  147943. }
  147944. declare module BABYLON {
  147945. /** Defines the 4 color options */
  147946. export enum PointColor {
  147947. /** color value */
  147948. Color = 2,
  147949. /** uv value */
  147950. UV = 1,
  147951. /** random value */
  147952. Random = 0,
  147953. /** stated value */
  147954. Stated = 3
  147955. }
  147956. /**
  147957. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  147958. * 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.
  147959. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  147960. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  147961. *
  147962. * Full documentation here : TO BE ENTERED
  147963. */
  147964. export class PointsCloudSystem implements IDisposable {
  147965. /**
  147966. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  147967. * Example : var p = SPS.particles[i];
  147968. */
  147969. particles: CloudPoint[];
  147970. /**
  147971. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  147972. */
  147973. nbParticles: number;
  147974. /**
  147975. * This a counter for your own usage. It's not set by any SPS functions.
  147976. */
  147977. counter: number;
  147978. /**
  147979. * The PCS name. This name is also given to the underlying mesh.
  147980. */
  147981. name: string;
  147982. /**
  147983. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  147984. */
  147985. mesh: Mesh;
  147986. /**
  147987. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  147988. * Please read :
  147989. */
  147990. vars: any;
  147991. /**
  147992. * @hidden
  147993. */
  147994. _size: number;
  147995. private _scene;
  147996. private _promises;
  147997. private _positions;
  147998. private _indices;
  147999. private _normals;
  148000. private _colors;
  148001. private _uvs;
  148002. private _indices32;
  148003. private _positions32;
  148004. private _colors32;
  148005. private _uvs32;
  148006. private _updatable;
  148007. private _isVisibilityBoxLocked;
  148008. private _alwaysVisible;
  148009. private _groups;
  148010. private _groupCounter;
  148011. private _computeParticleColor;
  148012. private _computeParticleTexture;
  148013. private _computeParticleRotation;
  148014. private _computeBoundingBox;
  148015. private _isReady;
  148016. /**
  148017. * Creates a PCS (Points Cloud System) object
  148018. * @param name (String) is the PCS name, this will be the underlying mesh name
  148019. * @param pointSize (number) is the size for each point
  148020. * @param scene (Scene) is the scene in which the PCS is added
  148021. * @param options defines the options of the PCS e.g.
  148022. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  148023. */
  148024. constructor(name: string, pointSize: number, scene: Scene, options?: {
  148025. updatable?: boolean;
  148026. });
  148027. /**
  148028. * Builds the PCS underlying mesh. Returns a standard Mesh.
  148029. * If no points were added to the PCS, the returned mesh is just a single point.
  148030. * @returns a promise for the created mesh
  148031. */
  148032. buildMeshAsync(): Promise<Mesh>;
  148033. /**
  148034. * @hidden
  148035. */
  148036. private _buildMesh;
  148037. private _addParticle;
  148038. private _randomUnitVector;
  148039. private _getColorIndicesForCoord;
  148040. private _setPointsColorOrUV;
  148041. private _colorFromTexture;
  148042. private _calculateDensity;
  148043. /**
  148044. * Adds points to the PCS in random positions within a unit sphere
  148045. * @param nb (positive integer) the number of particles to be created from this model
  148046. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  148047. * @returns the number of groups in the system
  148048. */
  148049. addPoints(nb: number, pointFunction?: any): number;
  148050. /**
  148051. * Adds points to the PCS from the surface of the model shape
  148052. * @param mesh is any Mesh object that will be used as a surface model for the points
  148053. * @param nb (positive integer) the number of particles to be created from this model
  148054. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148055. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148056. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148057. * @returns the number of groups in the system
  148058. */
  148059. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148060. /**
  148061. * Adds points to the PCS inside the model shape
  148062. * @param mesh is any Mesh object that will be used as a surface model for the points
  148063. * @param nb (positive integer) the number of particles to be created from this model
  148064. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148065. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148066. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148067. * @returns the number of groups in the system
  148068. */
  148069. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148070. /**
  148071. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  148072. * This method calls `updateParticle()` for each particle of the SPS.
  148073. * For an animated SPS, it is usually called within the render loop.
  148074. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  148075. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  148076. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  148077. * @returns the PCS.
  148078. */
  148079. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  148080. /**
  148081. * Disposes the PCS.
  148082. */
  148083. dispose(): void;
  148084. /**
  148085. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  148086. * doc :
  148087. * @returns the PCS.
  148088. */
  148089. refreshVisibleSize(): PointsCloudSystem;
  148090. /**
  148091. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  148092. * @param size the size (float) of the visibility box
  148093. * note : this doesn't lock the PCS mesh bounding box.
  148094. * doc :
  148095. */
  148096. setVisibilityBox(size: number): void;
  148097. /**
  148098. * Gets whether the PCS is always visible or not
  148099. * doc :
  148100. */
  148101. get isAlwaysVisible(): boolean;
  148102. /**
  148103. * Sets the PCS as always visible or not
  148104. * doc :
  148105. */
  148106. set isAlwaysVisible(val: boolean);
  148107. /**
  148108. * Tells to `setParticles()` to compute the particle rotations or not
  148109. * Default value : false. The PCS is faster when it's set to false
  148110. * Note : particle rotations are only applied to parent particles
  148111. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  148112. */
  148113. set computeParticleRotation(val: boolean);
  148114. /**
  148115. * Tells to `setParticles()` to compute the particle colors or not.
  148116. * Default value : true. The PCS is faster when it's set to false.
  148117. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148118. */
  148119. set computeParticleColor(val: boolean);
  148120. set computeParticleTexture(val: boolean);
  148121. /**
  148122. * Gets if `setParticles()` computes the particle colors or not.
  148123. * Default value : false. The PCS is faster when it's set to false.
  148124. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148125. */
  148126. get computeParticleColor(): boolean;
  148127. /**
  148128. * Gets if `setParticles()` computes the particle textures or not.
  148129. * Default value : false. The PCS is faster when it's set to false.
  148130. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  148131. */
  148132. get computeParticleTexture(): boolean;
  148133. /**
  148134. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  148135. */
  148136. set computeBoundingBox(val: boolean);
  148137. /**
  148138. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  148139. */
  148140. get computeBoundingBox(): boolean;
  148141. /**
  148142. * This function does nothing. It may be overwritten to set all the particle first values.
  148143. * The PCS doesn't call this function, you may have to call it by your own.
  148144. * doc :
  148145. */
  148146. initParticles(): void;
  148147. /**
  148148. * This function does nothing. It may be overwritten to recycle a particle
  148149. * The PCS doesn't call this function, you can to call it
  148150. * doc :
  148151. * @param particle The particle to recycle
  148152. * @returns the recycled particle
  148153. */
  148154. recycleParticle(particle: CloudPoint): CloudPoint;
  148155. /**
  148156. * Updates a particle : this function should be overwritten by the user.
  148157. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  148158. * doc :
  148159. * @example : just set a particle position or velocity and recycle conditions
  148160. * @param particle The particle to update
  148161. * @returns the updated particle
  148162. */
  148163. updateParticle(particle: CloudPoint): CloudPoint;
  148164. /**
  148165. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  148166. * This does nothing and may be overwritten by the user.
  148167. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148168. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148169. * @param update the boolean update value actually passed to setParticles()
  148170. */
  148171. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148172. /**
  148173. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  148174. * This will be passed three parameters.
  148175. * This does nothing and may be overwritten by the user.
  148176. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148177. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148178. * @param update the boolean update value actually passed to setParticles()
  148179. */
  148180. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148181. }
  148182. }
  148183. declare module BABYLON {
  148184. /**
  148185. * Represents one particle of a points cloud system.
  148186. */
  148187. export class CloudPoint {
  148188. /**
  148189. * particle global index
  148190. */
  148191. idx: number;
  148192. /**
  148193. * The color of the particle
  148194. */
  148195. color: Nullable<Color4>;
  148196. /**
  148197. * The world space position of the particle.
  148198. */
  148199. position: Vector3;
  148200. /**
  148201. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  148202. */
  148203. rotation: Vector3;
  148204. /**
  148205. * The world space rotation quaternion of the particle.
  148206. */
  148207. rotationQuaternion: Nullable<Quaternion>;
  148208. /**
  148209. * The uv of the particle.
  148210. */
  148211. uv: Nullable<Vector2>;
  148212. /**
  148213. * The current speed of the particle.
  148214. */
  148215. velocity: Vector3;
  148216. /**
  148217. * The pivot point in the particle local space.
  148218. */
  148219. pivot: Vector3;
  148220. /**
  148221. * Must the particle be translated from its pivot point in its local space ?
  148222. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  148223. * Default : false
  148224. */
  148225. translateFromPivot: boolean;
  148226. /**
  148227. * Index of this particle in the global "positions" array (Internal use)
  148228. * @hidden
  148229. */
  148230. _pos: number;
  148231. /**
  148232. * @hidden Index of this particle in the global "indices" array (Internal use)
  148233. */
  148234. _ind: number;
  148235. /**
  148236. * Group this particle belongs to
  148237. */
  148238. _group: PointsGroup;
  148239. /**
  148240. * Group id of this particle
  148241. */
  148242. groupId: number;
  148243. /**
  148244. * Index of the particle in its group id (Internal use)
  148245. */
  148246. idxInGroup: number;
  148247. /**
  148248. * @hidden Particle BoundingInfo object (Internal use)
  148249. */
  148250. _boundingInfo: BoundingInfo;
  148251. /**
  148252. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  148253. */
  148254. _pcs: PointsCloudSystem;
  148255. /**
  148256. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  148257. */
  148258. _stillInvisible: boolean;
  148259. /**
  148260. * @hidden Last computed particle rotation matrix
  148261. */
  148262. _rotationMatrix: number[];
  148263. /**
  148264. * Parent particle Id, if any.
  148265. * Default null.
  148266. */
  148267. parentId: Nullable<number>;
  148268. /**
  148269. * @hidden Internal global position in the PCS.
  148270. */
  148271. _globalPosition: Vector3;
  148272. /**
  148273. * Creates a Point Cloud object.
  148274. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  148275. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  148276. * @param group (PointsGroup) is the group the particle belongs to
  148277. * @param groupId (integer) is the group identifier in the PCS.
  148278. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  148279. * @param pcs defines the PCS it is associated to
  148280. */
  148281. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  148282. /**
  148283. * get point size
  148284. */
  148285. get size(): Vector3;
  148286. /**
  148287. * Set point size
  148288. */
  148289. set size(scale: Vector3);
  148290. /**
  148291. * Legacy support, changed quaternion to rotationQuaternion
  148292. */
  148293. get quaternion(): Nullable<Quaternion>;
  148294. /**
  148295. * Legacy support, changed quaternion to rotationQuaternion
  148296. */
  148297. set quaternion(q: Nullable<Quaternion>);
  148298. /**
  148299. * Returns a boolean. True if the particle intersects a mesh, else false
  148300. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  148301. * @param target is the object (point or mesh) what the intersection is computed against
  148302. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  148303. * @returns true if it intersects
  148304. */
  148305. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  148306. /**
  148307. * get the rotation matrix of the particle
  148308. * @hidden
  148309. */
  148310. getRotationMatrix(m: Matrix): void;
  148311. }
  148312. /**
  148313. * Represents a group of points in a points cloud system
  148314. * * PCS internal tool, don't use it manually.
  148315. */
  148316. export class PointsGroup {
  148317. /**
  148318. * The group id
  148319. * @hidden
  148320. */
  148321. groupID: number;
  148322. /**
  148323. * image data for group (internal use)
  148324. * @hidden
  148325. */
  148326. _groupImageData: Nullable<ArrayBufferView>;
  148327. /**
  148328. * Image Width (internal use)
  148329. * @hidden
  148330. */
  148331. _groupImgWidth: number;
  148332. /**
  148333. * Image Height (internal use)
  148334. * @hidden
  148335. */
  148336. _groupImgHeight: number;
  148337. /**
  148338. * Custom position function (internal use)
  148339. * @hidden
  148340. */
  148341. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  148342. /**
  148343. * density per facet for surface points
  148344. * @hidden
  148345. */
  148346. _groupDensity: number[];
  148347. /**
  148348. * Only when points are colored by texture carries pointer to texture list array
  148349. * @hidden
  148350. */
  148351. _textureNb: number;
  148352. /**
  148353. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  148354. * PCS internal tool, don't use it manually.
  148355. * @hidden
  148356. */
  148357. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  148358. }
  148359. }
  148360. declare module BABYLON {
  148361. interface Scene {
  148362. /** @hidden (Backing field) */
  148363. _physicsEngine: Nullable<IPhysicsEngine>;
  148364. /** @hidden */
  148365. _physicsTimeAccumulator: number;
  148366. /**
  148367. * Gets the current physics engine
  148368. * @returns a IPhysicsEngine or null if none attached
  148369. */
  148370. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  148371. /**
  148372. * Enables physics to the current scene
  148373. * @param gravity defines the scene's gravity for the physics engine
  148374. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  148375. * @return a boolean indicating if the physics engine was initialized
  148376. */
  148377. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  148378. /**
  148379. * Disables and disposes the physics engine associated with the scene
  148380. */
  148381. disablePhysicsEngine(): void;
  148382. /**
  148383. * Gets a boolean indicating if there is an active physics engine
  148384. * @returns a boolean indicating if there is an active physics engine
  148385. */
  148386. isPhysicsEnabled(): boolean;
  148387. /**
  148388. * Deletes a physics compound impostor
  148389. * @param compound defines the compound to delete
  148390. */
  148391. deleteCompoundImpostor(compound: any): void;
  148392. /**
  148393. * An event triggered when physic simulation is about to be run
  148394. */
  148395. onBeforePhysicsObservable: Observable<Scene>;
  148396. /**
  148397. * An event triggered when physic simulation has been done
  148398. */
  148399. onAfterPhysicsObservable: Observable<Scene>;
  148400. }
  148401. interface AbstractMesh {
  148402. /** @hidden */
  148403. _physicsImpostor: Nullable<PhysicsImpostor>;
  148404. /**
  148405. * Gets or sets impostor used for physic simulation
  148406. * @see https://doc.babylonjs.com/features/physics_engine
  148407. */
  148408. physicsImpostor: Nullable<PhysicsImpostor>;
  148409. /**
  148410. * Gets the current physics impostor
  148411. * @see https://doc.babylonjs.com/features/physics_engine
  148412. * @returns a physics impostor or null
  148413. */
  148414. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  148415. /** Apply a physic impulse to the mesh
  148416. * @param force defines the force to apply
  148417. * @param contactPoint defines where to apply the force
  148418. * @returns the current mesh
  148419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  148420. */
  148421. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  148422. /**
  148423. * Creates a physic joint between two meshes
  148424. * @param otherMesh defines the other mesh to use
  148425. * @param pivot1 defines the pivot to use on this mesh
  148426. * @param pivot2 defines the pivot to use on the other mesh
  148427. * @param options defines additional options (can be plugin dependent)
  148428. * @returns the current mesh
  148429. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  148430. */
  148431. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  148432. /** @hidden */
  148433. _disposePhysicsObserver: Nullable<Observer<Node>>;
  148434. }
  148435. /**
  148436. * Defines the physics engine scene component responsible to manage a physics engine
  148437. */
  148438. export class PhysicsEngineSceneComponent implements ISceneComponent {
  148439. /**
  148440. * The component name helpful to identify the component in the list of scene components.
  148441. */
  148442. readonly name: string;
  148443. /**
  148444. * The scene the component belongs to.
  148445. */
  148446. scene: Scene;
  148447. /**
  148448. * Creates a new instance of the component for the given scene
  148449. * @param scene Defines the scene to register the component in
  148450. */
  148451. constructor(scene: Scene);
  148452. /**
  148453. * Registers the component in a given scene
  148454. */
  148455. register(): void;
  148456. /**
  148457. * Rebuilds the elements related to this component in case of
  148458. * context lost for instance.
  148459. */
  148460. rebuild(): void;
  148461. /**
  148462. * Disposes the component and the associated ressources
  148463. */
  148464. dispose(): void;
  148465. }
  148466. }
  148467. declare module BABYLON {
  148468. /**
  148469. * A helper for physics simulations
  148470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148471. */
  148472. export class PhysicsHelper {
  148473. private _scene;
  148474. private _physicsEngine;
  148475. /**
  148476. * Initializes the Physics helper
  148477. * @param scene Babylon.js scene
  148478. */
  148479. constructor(scene: Scene);
  148480. /**
  148481. * Applies a radial explosion impulse
  148482. * @param origin the origin of the explosion
  148483. * @param radiusOrEventOptions the radius or the options of radial explosion
  148484. * @param strength the explosion strength
  148485. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148486. * @returns A physics radial explosion event, or null
  148487. */
  148488. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148489. /**
  148490. * Applies a radial explosion force
  148491. * @param origin the origin of the explosion
  148492. * @param radiusOrEventOptions the radius or the options of radial explosion
  148493. * @param strength the explosion strength
  148494. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148495. * @returns A physics radial explosion event, or null
  148496. */
  148497. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148498. /**
  148499. * Creates a gravitational field
  148500. * @param origin the origin of the explosion
  148501. * @param radiusOrEventOptions the radius or the options of radial explosion
  148502. * @param strength the explosion strength
  148503. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148504. * @returns A physics gravitational field event, or null
  148505. */
  148506. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  148507. /**
  148508. * Creates a physics updraft event
  148509. * @param origin the origin of the updraft
  148510. * @param radiusOrEventOptions the radius or the options of the updraft
  148511. * @param strength the strength of the updraft
  148512. * @param height the height of the updraft
  148513. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  148514. * @returns A physics updraft event, or null
  148515. */
  148516. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  148517. /**
  148518. * Creates a physics vortex event
  148519. * @param origin the of the vortex
  148520. * @param radiusOrEventOptions the radius or the options of the vortex
  148521. * @param strength the strength of the vortex
  148522. * @param height the height of the vortex
  148523. * @returns a Physics vortex event, or null
  148524. * A physics vortex event or null
  148525. */
  148526. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  148527. }
  148528. /**
  148529. * Represents a physics radial explosion event
  148530. */
  148531. class PhysicsRadialExplosionEvent {
  148532. private _scene;
  148533. private _options;
  148534. private _sphere;
  148535. private _dataFetched;
  148536. /**
  148537. * Initializes a radial explosioin event
  148538. * @param _scene BabylonJS scene
  148539. * @param _options The options for the vortex event
  148540. */
  148541. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  148542. /**
  148543. * Returns the data related to the radial explosion event (sphere).
  148544. * @returns The radial explosion event data
  148545. */
  148546. getData(): PhysicsRadialExplosionEventData;
  148547. /**
  148548. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  148549. * @param impostor A physics imposter
  148550. * @param origin the origin of the explosion
  148551. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  148552. */
  148553. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  148554. /**
  148555. * Triggers affecterd impostors callbacks
  148556. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  148557. */
  148558. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  148559. /**
  148560. * Disposes the sphere.
  148561. * @param force Specifies if the sphere should be disposed by force
  148562. */
  148563. dispose(force?: boolean): void;
  148564. /*** Helpers ***/
  148565. private _prepareSphere;
  148566. private _intersectsWithSphere;
  148567. }
  148568. /**
  148569. * Represents a gravitational field event
  148570. */
  148571. class PhysicsGravitationalFieldEvent {
  148572. private _physicsHelper;
  148573. private _scene;
  148574. private _origin;
  148575. private _options;
  148576. private _tickCallback;
  148577. private _sphere;
  148578. private _dataFetched;
  148579. /**
  148580. * Initializes the physics gravitational field event
  148581. * @param _physicsHelper A physics helper
  148582. * @param _scene BabylonJS scene
  148583. * @param _origin The origin position of the gravitational field event
  148584. * @param _options The options for the vortex event
  148585. */
  148586. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  148587. /**
  148588. * Returns the data related to the gravitational field event (sphere).
  148589. * @returns A gravitational field event
  148590. */
  148591. getData(): PhysicsGravitationalFieldEventData;
  148592. /**
  148593. * Enables the gravitational field.
  148594. */
  148595. enable(): void;
  148596. /**
  148597. * Disables the gravitational field.
  148598. */
  148599. disable(): void;
  148600. /**
  148601. * Disposes the sphere.
  148602. * @param force The force to dispose from the gravitational field event
  148603. */
  148604. dispose(force?: boolean): void;
  148605. private _tick;
  148606. }
  148607. /**
  148608. * Represents a physics updraft event
  148609. */
  148610. class PhysicsUpdraftEvent {
  148611. private _scene;
  148612. private _origin;
  148613. private _options;
  148614. private _physicsEngine;
  148615. private _originTop;
  148616. private _originDirection;
  148617. private _tickCallback;
  148618. private _cylinder;
  148619. private _cylinderPosition;
  148620. private _dataFetched;
  148621. /**
  148622. * Initializes the physics updraft event
  148623. * @param _scene BabylonJS scene
  148624. * @param _origin The origin position of the updraft
  148625. * @param _options The options for the updraft event
  148626. */
  148627. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  148628. /**
  148629. * Returns the data related to the updraft event (cylinder).
  148630. * @returns A physics updraft event
  148631. */
  148632. getData(): PhysicsUpdraftEventData;
  148633. /**
  148634. * Enables the updraft.
  148635. */
  148636. enable(): void;
  148637. /**
  148638. * Disables the updraft.
  148639. */
  148640. disable(): void;
  148641. /**
  148642. * Disposes the cylinder.
  148643. * @param force Specifies if the updraft should be disposed by force
  148644. */
  148645. dispose(force?: boolean): void;
  148646. private getImpostorHitData;
  148647. private _tick;
  148648. /*** Helpers ***/
  148649. private _prepareCylinder;
  148650. private _intersectsWithCylinder;
  148651. }
  148652. /**
  148653. * Represents a physics vortex event
  148654. */
  148655. class PhysicsVortexEvent {
  148656. private _scene;
  148657. private _origin;
  148658. private _options;
  148659. private _physicsEngine;
  148660. private _originTop;
  148661. private _tickCallback;
  148662. private _cylinder;
  148663. private _cylinderPosition;
  148664. private _dataFetched;
  148665. /**
  148666. * Initializes the physics vortex event
  148667. * @param _scene The BabylonJS scene
  148668. * @param _origin The origin position of the vortex
  148669. * @param _options The options for the vortex event
  148670. */
  148671. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  148672. /**
  148673. * Returns the data related to the vortex event (cylinder).
  148674. * @returns The physics vortex event data
  148675. */
  148676. getData(): PhysicsVortexEventData;
  148677. /**
  148678. * Enables the vortex.
  148679. */
  148680. enable(): void;
  148681. /**
  148682. * Disables the cortex.
  148683. */
  148684. disable(): void;
  148685. /**
  148686. * Disposes the sphere.
  148687. * @param force
  148688. */
  148689. dispose(force?: boolean): void;
  148690. private getImpostorHitData;
  148691. private _tick;
  148692. /*** Helpers ***/
  148693. private _prepareCylinder;
  148694. private _intersectsWithCylinder;
  148695. }
  148696. /**
  148697. * Options fot the radial explosion event
  148698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148699. */
  148700. export class PhysicsRadialExplosionEventOptions {
  148701. /**
  148702. * The radius of the sphere for the radial explosion.
  148703. */
  148704. radius: number;
  148705. /**
  148706. * The strenth of the explosion.
  148707. */
  148708. strength: number;
  148709. /**
  148710. * The strenght of the force in correspondence to the distance of the affected object
  148711. */
  148712. falloff: PhysicsRadialImpulseFalloff;
  148713. /**
  148714. * Sphere options for the radial explosion.
  148715. */
  148716. sphere: {
  148717. segments: number;
  148718. diameter: number;
  148719. };
  148720. /**
  148721. * Sphere options for the radial explosion.
  148722. */
  148723. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  148724. }
  148725. /**
  148726. * Options fot the updraft event
  148727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148728. */
  148729. export class PhysicsUpdraftEventOptions {
  148730. /**
  148731. * The radius of the cylinder for the vortex
  148732. */
  148733. radius: number;
  148734. /**
  148735. * The strenth of the updraft.
  148736. */
  148737. strength: number;
  148738. /**
  148739. * The height of the cylinder for the updraft.
  148740. */
  148741. height: number;
  148742. /**
  148743. * The mode for the the updraft.
  148744. */
  148745. updraftMode: PhysicsUpdraftMode;
  148746. }
  148747. /**
  148748. * Options fot the vortex event
  148749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148750. */
  148751. export class PhysicsVortexEventOptions {
  148752. /**
  148753. * The radius of the cylinder for the vortex
  148754. */
  148755. radius: number;
  148756. /**
  148757. * The strenth of the vortex.
  148758. */
  148759. strength: number;
  148760. /**
  148761. * The height of the cylinder for the vortex.
  148762. */
  148763. height: number;
  148764. /**
  148765. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  148766. */
  148767. centripetalForceThreshold: number;
  148768. /**
  148769. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  148770. */
  148771. centripetalForceMultiplier: number;
  148772. /**
  148773. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  148774. */
  148775. centrifugalForceMultiplier: number;
  148776. /**
  148777. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  148778. */
  148779. updraftForceMultiplier: number;
  148780. }
  148781. /**
  148782. * The strenght of the force in correspondence to the distance of the affected object
  148783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148784. */
  148785. export enum PhysicsRadialImpulseFalloff {
  148786. /** Defines that impulse is constant in strength across it's whole radius */
  148787. Constant = 0,
  148788. /** Defines that impulse gets weaker if it's further from the origin */
  148789. Linear = 1
  148790. }
  148791. /**
  148792. * The strength of the force in correspondence to the distance of the affected object
  148793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148794. */
  148795. export enum PhysicsUpdraftMode {
  148796. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  148797. Center = 0,
  148798. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  148799. Perpendicular = 1
  148800. }
  148801. /**
  148802. * Interface for a physics hit data
  148803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148804. */
  148805. export interface PhysicsHitData {
  148806. /**
  148807. * The force applied at the contact point
  148808. */
  148809. force: Vector3;
  148810. /**
  148811. * The contact point
  148812. */
  148813. contactPoint: Vector3;
  148814. /**
  148815. * The distance from the origin to the contact point
  148816. */
  148817. distanceFromOrigin: number;
  148818. }
  148819. /**
  148820. * Interface for radial explosion event data
  148821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148822. */
  148823. export interface PhysicsRadialExplosionEventData {
  148824. /**
  148825. * A sphere used for the radial explosion event
  148826. */
  148827. sphere: Mesh;
  148828. }
  148829. /**
  148830. * Interface for gravitational field event data
  148831. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148832. */
  148833. export interface PhysicsGravitationalFieldEventData {
  148834. /**
  148835. * A sphere mesh used for the gravitational field event
  148836. */
  148837. sphere: Mesh;
  148838. }
  148839. /**
  148840. * Interface for updraft event data
  148841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148842. */
  148843. export interface PhysicsUpdraftEventData {
  148844. /**
  148845. * A cylinder used for the updraft event
  148846. */
  148847. cylinder: Mesh;
  148848. }
  148849. /**
  148850. * Interface for vortex event data
  148851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148852. */
  148853. export interface PhysicsVortexEventData {
  148854. /**
  148855. * A cylinder used for the vortex event
  148856. */
  148857. cylinder: Mesh;
  148858. }
  148859. /**
  148860. * Interface for an affected physics impostor
  148861. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148862. */
  148863. export interface PhysicsAffectedImpostorWithData {
  148864. /**
  148865. * The impostor affected by the effect
  148866. */
  148867. impostor: PhysicsImpostor;
  148868. /**
  148869. * The data about the hit/horce from the explosion
  148870. */
  148871. hitData: PhysicsHitData;
  148872. }
  148873. }
  148874. declare module BABYLON {
  148875. /** @hidden */
  148876. export var blackAndWhitePixelShader: {
  148877. name: string;
  148878. shader: string;
  148879. };
  148880. }
  148881. declare module BABYLON {
  148882. /**
  148883. * Post process used to render in black and white
  148884. */
  148885. export class BlackAndWhitePostProcess extends PostProcess {
  148886. /**
  148887. * Linear about to convert he result to black and white (default: 1)
  148888. */
  148889. degree: number;
  148890. /**
  148891. * Gets a string identifying the name of the class
  148892. * @returns "BlackAndWhitePostProcess" string
  148893. */
  148894. getClassName(): string;
  148895. /**
  148896. * Creates a black and white post process
  148897. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  148898. * @param name The name of the effect.
  148899. * @param options The required width/height ratio to downsize to before computing the render pass.
  148900. * @param camera The camera to apply the render pass to.
  148901. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148902. * @param engine The engine which the post process will be applied. (default: current engine)
  148903. * @param reusable If the post process can be reused on the same frame. (default: false)
  148904. */
  148905. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148906. /** @hidden */
  148907. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  148908. }
  148909. }
  148910. declare module BABYLON {
  148911. /**
  148912. * This represents a set of one or more post processes in Babylon.
  148913. * A post process can be used to apply a shader to a texture after it is rendered.
  148914. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148915. */
  148916. export class PostProcessRenderEffect {
  148917. private _postProcesses;
  148918. private _getPostProcesses;
  148919. private _singleInstance;
  148920. private _cameras;
  148921. private _indicesForCamera;
  148922. /**
  148923. * Name of the effect
  148924. * @hidden
  148925. */
  148926. _name: string;
  148927. /**
  148928. * Instantiates a post process render effect.
  148929. * A post process can be used to apply a shader to a texture after it is rendered.
  148930. * @param engine The engine the effect is tied to
  148931. * @param name The name of the effect
  148932. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  148933. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  148934. */
  148935. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  148936. /**
  148937. * Checks if all the post processes in the effect are supported.
  148938. */
  148939. get isSupported(): boolean;
  148940. /**
  148941. * Updates the current state of the effect
  148942. * @hidden
  148943. */
  148944. _update(): void;
  148945. /**
  148946. * Attaches the effect on cameras
  148947. * @param cameras The camera to attach to.
  148948. * @hidden
  148949. */
  148950. _attachCameras(cameras: Camera): void;
  148951. /**
  148952. * Attaches the effect on cameras
  148953. * @param cameras The camera to attach to.
  148954. * @hidden
  148955. */
  148956. _attachCameras(cameras: Camera[]): void;
  148957. /**
  148958. * Detaches the effect on cameras
  148959. * @param cameras The camera to detatch from.
  148960. * @hidden
  148961. */
  148962. _detachCameras(cameras: Camera): void;
  148963. /**
  148964. * Detatches the effect on cameras
  148965. * @param cameras The camera to detatch from.
  148966. * @hidden
  148967. */
  148968. _detachCameras(cameras: Camera[]): void;
  148969. /**
  148970. * Enables the effect on given cameras
  148971. * @param cameras The camera to enable.
  148972. * @hidden
  148973. */
  148974. _enable(cameras: Camera): void;
  148975. /**
  148976. * Enables the effect on given cameras
  148977. * @param cameras The camera to enable.
  148978. * @hidden
  148979. */
  148980. _enable(cameras: Nullable<Camera[]>): void;
  148981. /**
  148982. * Disables the effect on the given cameras
  148983. * @param cameras The camera to disable.
  148984. * @hidden
  148985. */
  148986. _disable(cameras: Camera): void;
  148987. /**
  148988. * Disables the effect on the given cameras
  148989. * @param cameras The camera to disable.
  148990. * @hidden
  148991. */
  148992. _disable(cameras: Nullable<Camera[]>): void;
  148993. /**
  148994. * Gets a list of the post processes contained in the effect.
  148995. * @param camera The camera to get the post processes on.
  148996. * @returns The list of the post processes in the effect.
  148997. */
  148998. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  148999. }
  149000. }
  149001. declare module BABYLON {
  149002. /** @hidden */
  149003. export var extractHighlightsPixelShader: {
  149004. name: string;
  149005. shader: string;
  149006. };
  149007. }
  149008. declare module BABYLON {
  149009. /**
  149010. * 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.
  149011. */
  149012. export class ExtractHighlightsPostProcess extends PostProcess {
  149013. /**
  149014. * The luminance threshold, pixels below this value will be set to black.
  149015. */
  149016. threshold: number;
  149017. /** @hidden */
  149018. _exposure: number;
  149019. /**
  149020. * Post process which has the input texture to be used when performing highlight extraction
  149021. * @hidden
  149022. */
  149023. _inputPostProcess: Nullable<PostProcess>;
  149024. /**
  149025. * Gets a string identifying the name of the class
  149026. * @returns "ExtractHighlightsPostProcess" string
  149027. */
  149028. getClassName(): string;
  149029. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149030. }
  149031. }
  149032. declare module BABYLON {
  149033. /** @hidden */
  149034. export var bloomMergePixelShader: {
  149035. name: string;
  149036. shader: string;
  149037. };
  149038. }
  149039. declare module BABYLON {
  149040. /**
  149041. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149042. */
  149043. export class BloomMergePostProcess extends PostProcess {
  149044. /** Weight of the bloom to be added to the original input. */
  149045. weight: number;
  149046. /**
  149047. * Gets a string identifying the name of the class
  149048. * @returns "BloomMergePostProcess" string
  149049. */
  149050. getClassName(): string;
  149051. /**
  149052. * Creates a new instance of @see BloomMergePostProcess
  149053. * @param name The name of the effect.
  149054. * @param originalFromInput Post process which's input will be used for the merge.
  149055. * @param blurred Blurred highlights post process which's output will be used.
  149056. * @param weight Weight of the bloom to be added to the original input.
  149057. * @param options The required width/height ratio to downsize to before computing the render pass.
  149058. * @param camera The camera to apply the render pass to.
  149059. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149060. * @param engine The engine which the post process will be applied. (default: current engine)
  149061. * @param reusable If the post process can be reused on the same frame. (default: false)
  149062. * @param textureType Type of textures used when performing the post process. (default: 0)
  149063. * @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)
  149064. */
  149065. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  149066. /** Weight of the bloom to be added to the original input. */
  149067. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149068. }
  149069. }
  149070. declare module BABYLON {
  149071. /**
  149072. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  149073. */
  149074. export class BloomEffect extends PostProcessRenderEffect {
  149075. private bloomScale;
  149076. /**
  149077. * @hidden Internal
  149078. */
  149079. _effects: Array<PostProcess>;
  149080. /**
  149081. * @hidden Internal
  149082. */
  149083. _downscale: ExtractHighlightsPostProcess;
  149084. private _blurX;
  149085. private _blurY;
  149086. private _merge;
  149087. /**
  149088. * The luminance threshold to find bright areas of the image to bloom.
  149089. */
  149090. get threshold(): number;
  149091. set threshold(value: number);
  149092. /**
  149093. * The strength of the bloom.
  149094. */
  149095. get weight(): number;
  149096. set weight(value: number);
  149097. /**
  149098. * Specifies the size of the bloom blur kernel, relative to the final output size
  149099. */
  149100. get kernel(): number;
  149101. set kernel(value: number);
  149102. /**
  149103. * Creates a new instance of @see BloomEffect
  149104. * @param scene The scene the effect belongs to.
  149105. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  149106. * @param bloomKernel The size of the kernel to be used when applying the blur.
  149107. * @param bloomWeight The the strength of bloom.
  149108. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149109. * @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)
  149110. */
  149111. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  149112. /**
  149113. * Disposes each of the internal effects for a given camera.
  149114. * @param camera The camera to dispose the effect on.
  149115. */
  149116. disposeEffects(camera: Camera): void;
  149117. /**
  149118. * @hidden Internal
  149119. */
  149120. _updateEffects(): void;
  149121. /**
  149122. * Internal
  149123. * @returns if all the contained post processes are ready.
  149124. * @hidden
  149125. */
  149126. _isReady(): boolean;
  149127. }
  149128. }
  149129. declare module BABYLON {
  149130. /** @hidden */
  149131. export var chromaticAberrationPixelShader: {
  149132. name: string;
  149133. shader: string;
  149134. };
  149135. }
  149136. declare module BABYLON {
  149137. /**
  149138. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  149139. */
  149140. export class ChromaticAberrationPostProcess extends PostProcess {
  149141. /**
  149142. * The amount of seperation of rgb channels (default: 30)
  149143. */
  149144. aberrationAmount: number;
  149145. /**
  149146. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  149147. */
  149148. radialIntensity: number;
  149149. /**
  149150. * 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))
  149151. */
  149152. direction: Vector2;
  149153. /**
  149154. * 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))
  149155. */
  149156. centerPosition: Vector2;
  149157. /** The width of the screen to apply the effect on */
  149158. screenWidth: number;
  149159. /** The height of the screen to apply the effect on */
  149160. screenHeight: number;
  149161. /**
  149162. * Gets a string identifying the name of the class
  149163. * @returns "ChromaticAberrationPostProcess" string
  149164. */
  149165. getClassName(): string;
  149166. /**
  149167. * Creates a new instance ChromaticAberrationPostProcess
  149168. * @param name The name of the effect.
  149169. * @param screenWidth The width of the screen to apply the effect on.
  149170. * @param screenHeight The height of the screen to apply the effect on.
  149171. * @param options The required width/height ratio to downsize to before computing the render pass.
  149172. * @param camera The camera to apply the render pass to.
  149173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149174. * @param engine The engine which the post process will be applied. (default: current engine)
  149175. * @param reusable If the post process can be reused on the same frame. (default: false)
  149176. * @param textureType Type of textures used when performing the post process. (default: 0)
  149177. * @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)
  149178. */
  149179. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149180. /** @hidden */
  149181. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  149182. }
  149183. }
  149184. declare module BABYLON {
  149185. /** @hidden */
  149186. export var circleOfConfusionPixelShader: {
  149187. name: string;
  149188. shader: string;
  149189. };
  149190. }
  149191. declare module BABYLON {
  149192. /**
  149193. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  149194. */
  149195. export class CircleOfConfusionPostProcess extends PostProcess {
  149196. /**
  149197. * 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.
  149198. */
  149199. lensSize: number;
  149200. /**
  149201. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149202. */
  149203. fStop: number;
  149204. /**
  149205. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149206. */
  149207. focusDistance: number;
  149208. /**
  149209. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  149210. */
  149211. focalLength: number;
  149212. /**
  149213. * Gets a string identifying the name of the class
  149214. * @returns "CircleOfConfusionPostProcess" string
  149215. */
  149216. getClassName(): string;
  149217. private _depthTexture;
  149218. /**
  149219. * Creates a new instance CircleOfConfusionPostProcess
  149220. * @param name The name of the effect.
  149221. * @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.
  149222. * @param options The required width/height ratio to downsize to before computing the render pass.
  149223. * @param camera The camera to apply the render pass to.
  149224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149225. * @param engine The engine which the post process will be applied. (default: current engine)
  149226. * @param reusable If the post process can be reused on the same frame. (default: false)
  149227. * @param textureType Type of textures used when performing the post process. (default: 0)
  149228. * @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)
  149229. */
  149230. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149231. /**
  149232. * 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.
  149233. */
  149234. set depthTexture(value: RenderTargetTexture);
  149235. }
  149236. }
  149237. declare module BABYLON {
  149238. /** @hidden */
  149239. export var colorCorrectionPixelShader: {
  149240. name: string;
  149241. shader: string;
  149242. };
  149243. }
  149244. declare module BABYLON {
  149245. /**
  149246. *
  149247. * This post-process allows the modification of rendered colors by using
  149248. * a 'look-up table' (LUT). This effect is also called Color Grading.
  149249. *
  149250. * The object needs to be provided an url to a texture containing the color
  149251. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  149252. * Use an image editing software to tweak the LUT to match your needs.
  149253. *
  149254. * For an example of a color LUT, see here:
  149255. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  149256. * For explanations on color grading, see here:
  149257. * @see http://udn.epicgames.com/Three/ColorGrading.html
  149258. *
  149259. */
  149260. export class ColorCorrectionPostProcess extends PostProcess {
  149261. private _colorTableTexture;
  149262. /**
  149263. * Gets the color table url used to create the LUT texture
  149264. */
  149265. colorTableUrl: string;
  149266. /**
  149267. * Gets a string identifying the name of the class
  149268. * @returns "ColorCorrectionPostProcess" string
  149269. */
  149270. getClassName(): string;
  149271. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149272. /** @hidden */
  149273. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  149274. }
  149275. }
  149276. declare module BABYLON {
  149277. /** @hidden */
  149278. export var convolutionPixelShader: {
  149279. name: string;
  149280. shader: string;
  149281. };
  149282. }
  149283. declare module BABYLON {
  149284. /**
  149285. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  149286. * input texture to perform effects such as edge detection or sharpening
  149287. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  149288. */
  149289. export class ConvolutionPostProcess extends PostProcess {
  149290. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  149291. kernel: number[];
  149292. /**
  149293. * Gets a string identifying the name of the class
  149294. * @returns "ConvolutionPostProcess" string
  149295. */
  149296. getClassName(): string;
  149297. /**
  149298. * Creates a new instance ConvolutionPostProcess
  149299. * @param name The name of the effect.
  149300. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  149301. * @param options The required width/height ratio to downsize to before computing the render pass.
  149302. * @param camera The camera to apply the render pass to.
  149303. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149304. * @param engine The engine which the post process will be applied. (default: current engine)
  149305. * @param reusable If the post process can be reused on the same frame. (default: false)
  149306. * @param textureType Type of textures used when performing the post process. (default: 0)
  149307. */
  149308. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149309. /** @hidden */
  149310. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  149311. /**
  149312. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149313. */
  149314. static EdgeDetect0Kernel: number[];
  149315. /**
  149316. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149317. */
  149318. static EdgeDetect1Kernel: number[];
  149319. /**
  149320. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149321. */
  149322. static EdgeDetect2Kernel: number[];
  149323. /**
  149324. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149325. */
  149326. static SharpenKernel: number[];
  149327. /**
  149328. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149329. */
  149330. static EmbossKernel: number[];
  149331. /**
  149332. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149333. */
  149334. static GaussianKernel: number[];
  149335. }
  149336. }
  149337. declare module BABYLON {
  149338. /**
  149339. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  149340. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  149341. * based on samples that have a large difference in distance than the center pixel.
  149342. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  149343. */
  149344. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  149345. /**
  149346. * The direction the blur should be applied
  149347. */
  149348. direction: Vector2;
  149349. /**
  149350. * Gets a string identifying the name of the class
  149351. * @returns "DepthOfFieldBlurPostProcess" string
  149352. */
  149353. getClassName(): string;
  149354. /**
  149355. * Creates a new instance CircleOfConfusionPostProcess
  149356. * @param name The name of the effect.
  149357. * @param scene The scene the effect belongs to.
  149358. * @param direction The direction the blur should be applied.
  149359. * @param kernel The size of the kernel used to blur.
  149360. * @param options The required width/height ratio to downsize to before computing the render pass.
  149361. * @param camera The camera to apply the render pass to.
  149362. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  149363. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  149364. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149365. * @param engine The engine which the post process will be applied. (default: current engine)
  149366. * @param reusable If the post process can be reused on the same frame. (default: false)
  149367. * @param textureType Type of textures used when performing the post process. (default: 0)
  149368. * @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)
  149369. */
  149370. 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);
  149371. }
  149372. }
  149373. declare module BABYLON {
  149374. /** @hidden */
  149375. export var depthOfFieldMergePixelShader: {
  149376. name: string;
  149377. shader: string;
  149378. };
  149379. }
  149380. declare module BABYLON {
  149381. /**
  149382. * Options to be set when merging outputs from the default pipeline.
  149383. */
  149384. export class DepthOfFieldMergePostProcessOptions {
  149385. /**
  149386. * The original image to merge on top of
  149387. */
  149388. originalFromInput: PostProcess;
  149389. /**
  149390. * Parameters to perform the merge of the depth of field effect
  149391. */
  149392. depthOfField?: {
  149393. circleOfConfusion: PostProcess;
  149394. blurSteps: Array<PostProcess>;
  149395. };
  149396. /**
  149397. * Parameters to perform the merge of bloom effect
  149398. */
  149399. bloom?: {
  149400. blurred: PostProcess;
  149401. weight: number;
  149402. };
  149403. }
  149404. /**
  149405. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149406. */
  149407. export class DepthOfFieldMergePostProcess extends PostProcess {
  149408. private blurSteps;
  149409. /**
  149410. * Gets a string identifying the name of the class
  149411. * @returns "DepthOfFieldMergePostProcess" string
  149412. */
  149413. getClassName(): string;
  149414. /**
  149415. * Creates a new instance of DepthOfFieldMergePostProcess
  149416. * @param name The name of the effect.
  149417. * @param originalFromInput Post process which's input will be used for the merge.
  149418. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  149419. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  149420. * @param options The required width/height ratio to downsize to before computing the render pass.
  149421. * @param camera The camera to apply the render pass to.
  149422. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149423. * @param engine The engine which the post process will be applied. (default: current engine)
  149424. * @param reusable If the post process can be reused on the same frame. (default: false)
  149425. * @param textureType Type of textures used when performing the post process. (default: 0)
  149426. * @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)
  149427. */
  149428. 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);
  149429. /**
  149430. * Updates the effect with the current post process compile time values and recompiles the shader.
  149431. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  149432. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  149433. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  149434. * @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
  149435. * @param onCompiled Called when the shader has been compiled.
  149436. * @param onError Called if there is an error when compiling a shader.
  149437. */
  149438. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  149439. }
  149440. }
  149441. declare module BABYLON {
  149442. /**
  149443. * Specifies the level of max blur that should be applied when using the depth of field effect
  149444. */
  149445. export enum DepthOfFieldEffectBlurLevel {
  149446. /**
  149447. * Subtle blur
  149448. */
  149449. Low = 0,
  149450. /**
  149451. * Medium blur
  149452. */
  149453. Medium = 1,
  149454. /**
  149455. * Large blur
  149456. */
  149457. High = 2
  149458. }
  149459. /**
  149460. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  149461. */
  149462. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  149463. private _circleOfConfusion;
  149464. /**
  149465. * @hidden Internal, blurs from high to low
  149466. */
  149467. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  149468. private _depthOfFieldBlurY;
  149469. private _dofMerge;
  149470. /**
  149471. * @hidden Internal post processes in depth of field effect
  149472. */
  149473. _effects: Array<PostProcess>;
  149474. /**
  149475. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  149476. */
  149477. set focalLength(value: number);
  149478. get focalLength(): number;
  149479. /**
  149480. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149481. */
  149482. set fStop(value: number);
  149483. get fStop(): number;
  149484. /**
  149485. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149486. */
  149487. set focusDistance(value: number);
  149488. get focusDistance(): number;
  149489. /**
  149490. * 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.
  149491. */
  149492. set lensSize(value: number);
  149493. get lensSize(): number;
  149494. /**
  149495. * Creates a new instance DepthOfFieldEffect
  149496. * @param scene The scene the effect belongs to.
  149497. * @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.
  149498. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149499. * @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)
  149500. */
  149501. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  149502. /**
  149503. * Get the current class name of the current effet
  149504. * @returns "DepthOfFieldEffect"
  149505. */
  149506. getClassName(): string;
  149507. /**
  149508. * 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.
  149509. */
  149510. set depthTexture(value: RenderTargetTexture);
  149511. /**
  149512. * Disposes each of the internal effects for a given camera.
  149513. * @param camera The camera to dispose the effect on.
  149514. */
  149515. disposeEffects(camera: Camera): void;
  149516. /**
  149517. * @hidden Internal
  149518. */
  149519. _updateEffects(): void;
  149520. /**
  149521. * Internal
  149522. * @returns if all the contained post processes are ready.
  149523. * @hidden
  149524. */
  149525. _isReady(): boolean;
  149526. }
  149527. }
  149528. declare module BABYLON {
  149529. /** @hidden */
  149530. export var displayPassPixelShader: {
  149531. name: string;
  149532. shader: string;
  149533. };
  149534. }
  149535. declare module BABYLON {
  149536. /**
  149537. * DisplayPassPostProcess which produces an output the same as it's input
  149538. */
  149539. export class DisplayPassPostProcess extends PostProcess {
  149540. /**
  149541. * Gets a string identifying the name of the class
  149542. * @returns "DisplayPassPostProcess" string
  149543. */
  149544. getClassName(): string;
  149545. /**
  149546. * Creates the DisplayPassPostProcess
  149547. * @param name The name of the effect.
  149548. * @param options The required width/height ratio to downsize to before computing the render pass.
  149549. * @param camera The camera to apply the render pass to.
  149550. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149551. * @param engine The engine which the post process will be applied. (default: current engine)
  149552. * @param reusable If the post process can be reused on the same frame. (default: false)
  149553. */
  149554. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149555. /** @hidden */
  149556. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  149557. }
  149558. }
  149559. declare module BABYLON {
  149560. /** @hidden */
  149561. export var filterPixelShader: {
  149562. name: string;
  149563. shader: string;
  149564. };
  149565. }
  149566. declare module BABYLON {
  149567. /**
  149568. * Applies a kernel filter to the image
  149569. */
  149570. export class FilterPostProcess extends PostProcess {
  149571. /** The matrix to be applied to the image */
  149572. kernelMatrix: Matrix;
  149573. /**
  149574. * Gets a string identifying the name of the class
  149575. * @returns "FilterPostProcess" string
  149576. */
  149577. getClassName(): string;
  149578. /**
  149579. *
  149580. * @param name The name of the effect.
  149581. * @param kernelMatrix The matrix to be applied to the image
  149582. * @param options The required width/height ratio to downsize to before computing the render pass.
  149583. * @param camera The camera to apply the render pass to.
  149584. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149585. * @param engine The engine which the post process will be applied. (default: current engine)
  149586. * @param reusable If the post process can be reused on the same frame. (default: false)
  149587. */
  149588. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149589. /** @hidden */
  149590. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  149591. }
  149592. }
  149593. declare module BABYLON {
  149594. /** @hidden */
  149595. export var fxaaPixelShader: {
  149596. name: string;
  149597. shader: string;
  149598. };
  149599. }
  149600. declare module BABYLON {
  149601. /** @hidden */
  149602. export var fxaaVertexShader: {
  149603. name: string;
  149604. shader: string;
  149605. };
  149606. }
  149607. declare module BABYLON {
  149608. /**
  149609. * Fxaa post process
  149610. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  149611. */
  149612. export class FxaaPostProcess extends PostProcess {
  149613. /**
  149614. * Gets a string identifying the name of the class
  149615. * @returns "FxaaPostProcess" string
  149616. */
  149617. getClassName(): string;
  149618. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149619. private _getDefines;
  149620. /** @hidden */
  149621. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  149622. }
  149623. }
  149624. declare module BABYLON {
  149625. /** @hidden */
  149626. export var grainPixelShader: {
  149627. name: string;
  149628. shader: string;
  149629. };
  149630. }
  149631. declare module BABYLON {
  149632. /**
  149633. * The GrainPostProcess adds noise to the image at mid luminance levels
  149634. */
  149635. export class GrainPostProcess extends PostProcess {
  149636. /**
  149637. * The intensity of the grain added (default: 30)
  149638. */
  149639. intensity: number;
  149640. /**
  149641. * If the grain should be randomized on every frame
  149642. */
  149643. animated: boolean;
  149644. /**
  149645. * Gets a string identifying the name of the class
  149646. * @returns "GrainPostProcess" string
  149647. */
  149648. getClassName(): string;
  149649. /**
  149650. * Creates a new instance of @see GrainPostProcess
  149651. * @param name The name of the effect.
  149652. * @param options The required width/height ratio to downsize to before computing the render pass.
  149653. * @param camera The camera to apply the render pass to.
  149654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149655. * @param engine The engine which the post process will be applied. (default: current engine)
  149656. * @param reusable If the post process can be reused on the same frame. (default: false)
  149657. * @param textureType Type of textures used when performing the post process. (default: 0)
  149658. * @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)
  149659. */
  149660. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149661. /** @hidden */
  149662. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  149663. }
  149664. }
  149665. declare module BABYLON {
  149666. /** @hidden */
  149667. export var highlightsPixelShader: {
  149668. name: string;
  149669. shader: string;
  149670. };
  149671. }
  149672. declare module BABYLON {
  149673. /**
  149674. * Extracts highlights from the image
  149675. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  149676. */
  149677. export class HighlightsPostProcess extends PostProcess {
  149678. /**
  149679. * Gets a string identifying the name of the class
  149680. * @returns "HighlightsPostProcess" string
  149681. */
  149682. getClassName(): string;
  149683. /**
  149684. * Extracts highlights from the image
  149685. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  149686. * @param name The name of the effect.
  149687. * @param options The required width/height ratio to downsize to before computing the render pass.
  149688. * @param camera The camera to apply the render pass to.
  149689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149690. * @param engine The engine which the post process will be applied. (default: current engine)
  149691. * @param reusable If the post process can be reused on the same frame. (default: false)
  149692. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  149693. */
  149694. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149695. }
  149696. }
  149697. declare module BABYLON {
  149698. /** @hidden */
  149699. export var mrtFragmentDeclaration: {
  149700. name: string;
  149701. shader: string;
  149702. };
  149703. }
  149704. declare module BABYLON {
  149705. /** @hidden */
  149706. export var geometryPixelShader: {
  149707. name: string;
  149708. shader: string;
  149709. };
  149710. }
  149711. declare module BABYLON {
  149712. /** @hidden */
  149713. export var geometryVertexShader: {
  149714. name: string;
  149715. shader: string;
  149716. };
  149717. }
  149718. declare module BABYLON {
  149719. /** @hidden */
  149720. interface ISavedTransformationMatrix {
  149721. world: Matrix;
  149722. viewProjection: Matrix;
  149723. }
  149724. /**
  149725. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  149726. */
  149727. export class GeometryBufferRenderer {
  149728. /**
  149729. * Constant used to retrieve the position texture index in the G-Buffer textures array
  149730. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  149731. */
  149732. static readonly POSITION_TEXTURE_TYPE: number;
  149733. /**
  149734. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  149735. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  149736. */
  149737. static readonly VELOCITY_TEXTURE_TYPE: number;
  149738. /**
  149739. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  149740. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  149741. */
  149742. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  149743. /**
  149744. * Dictionary used to store the previous transformation matrices of each rendered mesh
  149745. * in order to compute objects velocities when enableVelocity is set to "true"
  149746. * @hidden
  149747. */
  149748. _previousTransformationMatrices: {
  149749. [index: number]: ISavedTransformationMatrix;
  149750. };
  149751. /**
  149752. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  149753. * in order to compute objects velocities when enableVelocity is set to "true"
  149754. * @hidden
  149755. */
  149756. _previousBonesTransformationMatrices: {
  149757. [index: number]: Float32Array;
  149758. };
  149759. /**
  149760. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  149761. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  149762. */
  149763. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  149764. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  149765. renderTransparentMeshes: boolean;
  149766. private _scene;
  149767. private _resizeObserver;
  149768. private _multiRenderTarget;
  149769. private _ratio;
  149770. private _enablePosition;
  149771. private _enableVelocity;
  149772. private _enableReflectivity;
  149773. private _positionIndex;
  149774. private _velocityIndex;
  149775. private _reflectivityIndex;
  149776. protected _effect: Effect;
  149777. protected _cachedDefines: string;
  149778. /**
  149779. * Set the render list (meshes to be rendered) used in the G buffer.
  149780. */
  149781. set renderList(meshes: Mesh[]);
  149782. /**
  149783. * Gets wether or not G buffer are supported by the running hardware.
  149784. * This requires draw buffer supports
  149785. */
  149786. get isSupported(): boolean;
  149787. /**
  149788. * Returns the index of the given texture type in the G-Buffer textures array
  149789. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  149790. * @returns the index of the given texture type in the G-Buffer textures array
  149791. */
  149792. getTextureIndex(textureType: number): number;
  149793. /**
  149794. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  149795. */
  149796. get enablePosition(): boolean;
  149797. /**
  149798. * Sets whether or not objects positions are enabled for the G buffer.
  149799. */
  149800. set enablePosition(enable: boolean);
  149801. /**
  149802. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  149803. */
  149804. get enableVelocity(): boolean;
  149805. /**
  149806. * Sets wether or not objects velocities are enabled for the G buffer.
  149807. */
  149808. set enableVelocity(enable: boolean);
  149809. /**
  149810. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  149811. */
  149812. get enableReflectivity(): boolean;
  149813. /**
  149814. * Sets wether or not objects roughness are enabled for the G buffer.
  149815. */
  149816. set enableReflectivity(enable: boolean);
  149817. /**
  149818. * Gets the scene associated with the buffer.
  149819. */
  149820. get scene(): Scene;
  149821. /**
  149822. * Gets the ratio used by the buffer during its creation.
  149823. * How big is the buffer related to the main canvas.
  149824. */
  149825. get ratio(): number;
  149826. /** @hidden */
  149827. static _SceneComponentInitialization: (scene: Scene) => void;
  149828. /**
  149829. * Creates a new G Buffer for the scene
  149830. * @param scene The scene the buffer belongs to
  149831. * @param ratio How big is the buffer related to the main canvas.
  149832. */
  149833. constructor(scene: Scene, ratio?: number);
  149834. /**
  149835. * Checks wether everything is ready to render a submesh to the G buffer.
  149836. * @param subMesh the submesh to check readiness for
  149837. * @param useInstances is the mesh drawn using instance or not
  149838. * @returns true if ready otherwise false
  149839. */
  149840. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149841. /**
  149842. * Gets the current underlying G Buffer.
  149843. * @returns the buffer
  149844. */
  149845. getGBuffer(): MultiRenderTarget;
  149846. /**
  149847. * Gets the number of samples used to render the buffer (anti aliasing).
  149848. */
  149849. get samples(): number;
  149850. /**
  149851. * Sets the number of samples used to render the buffer (anti aliasing).
  149852. */
  149853. set samples(value: number);
  149854. /**
  149855. * Disposes the renderer and frees up associated resources.
  149856. */
  149857. dispose(): void;
  149858. protected _createRenderTargets(): void;
  149859. private _copyBonesTransformationMatrices;
  149860. }
  149861. }
  149862. declare module BABYLON {
  149863. interface Scene {
  149864. /** @hidden (Backing field) */
  149865. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  149866. /**
  149867. * Gets or Sets the current geometry buffer associated to the scene.
  149868. */
  149869. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  149870. /**
  149871. * Enables a GeometryBufferRender and associates it with the scene
  149872. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  149873. * @returns the GeometryBufferRenderer
  149874. */
  149875. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  149876. /**
  149877. * Disables the GeometryBufferRender associated with the scene
  149878. */
  149879. disableGeometryBufferRenderer(): void;
  149880. }
  149881. /**
  149882. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  149883. * in several rendering techniques.
  149884. */
  149885. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  149886. /**
  149887. * The component name helpful to identify the component in the list of scene components.
  149888. */
  149889. readonly name: string;
  149890. /**
  149891. * The scene the component belongs to.
  149892. */
  149893. scene: Scene;
  149894. /**
  149895. * Creates a new instance of the component for the given scene
  149896. * @param scene Defines the scene to register the component in
  149897. */
  149898. constructor(scene: Scene);
  149899. /**
  149900. * Registers the component in a given scene
  149901. */
  149902. register(): void;
  149903. /**
  149904. * Rebuilds the elements related to this component in case of
  149905. * context lost for instance.
  149906. */
  149907. rebuild(): void;
  149908. /**
  149909. * Disposes the component and the associated ressources
  149910. */
  149911. dispose(): void;
  149912. private _gatherRenderTargets;
  149913. }
  149914. }
  149915. declare module BABYLON {
  149916. /** @hidden */
  149917. export var motionBlurPixelShader: {
  149918. name: string;
  149919. shader: string;
  149920. };
  149921. }
  149922. declare module BABYLON {
  149923. /**
  149924. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  149925. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  149926. * As an example, all you have to do is to create the post-process:
  149927. * var mb = new BABYLON.MotionBlurPostProcess(
  149928. * 'mb', // The name of the effect.
  149929. * scene, // The scene containing the objects to blur according to their velocity.
  149930. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  149931. * camera // The camera to apply the render pass to.
  149932. * );
  149933. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  149934. */
  149935. export class MotionBlurPostProcess extends PostProcess {
  149936. /**
  149937. * Defines how much the image is blurred by the movement. Default value is equal to 1
  149938. */
  149939. motionStrength: number;
  149940. /**
  149941. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  149942. */
  149943. get motionBlurSamples(): number;
  149944. /**
  149945. * Sets the number of iterations to be used for motion blur quality
  149946. */
  149947. set motionBlurSamples(samples: number);
  149948. private _motionBlurSamples;
  149949. private _geometryBufferRenderer;
  149950. /**
  149951. * Gets a string identifying the name of the class
  149952. * @returns "MotionBlurPostProcess" string
  149953. */
  149954. getClassName(): string;
  149955. /**
  149956. * Creates a new instance MotionBlurPostProcess
  149957. * @param name The name of the effect.
  149958. * @param scene The scene containing the objects to blur according to their velocity.
  149959. * @param options The required width/height ratio to downsize to before computing the render pass.
  149960. * @param camera The camera to apply the render pass to.
  149961. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149962. * @param engine The engine which the post process will be applied. (default: current engine)
  149963. * @param reusable If the post process can be reused on the same frame. (default: false)
  149964. * @param textureType Type of textures used when performing the post process. (default: 0)
  149965. * @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)
  149966. */
  149967. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149968. /**
  149969. * Excludes the given skinned mesh from computing bones velocities.
  149970. * 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.
  149971. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  149972. */
  149973. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  149974. /**
  149975. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  149976. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  149977. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  149978. */
  149979. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  149980. /**
  149981. * Disposes the post process.
  149982. * @param camera The camera to dispose the post process on.
  149983. */
  149984. dispose(camera?: Camera): void;
  149985. /** @hidden */
  149986. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  149987. }
  149988. }
  149989. declare module BABYLON {
  149990. /** @hidden */
  149991. export var refractionPixelShader: {
  149992. name: string;
  149993. shader: string;
  149994. };
  149995. }
  149996. declare module BABYLON {
  149997. /**
  149998. * Post process which applies a refractin texture
  149999. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150000. */
  150001. export class RefractionPostProcess extends PostProcess {
  150002. private _refTexture;
  150003. private _ownRefractionTexture;
  150004. /** the base color of the refraction (used to taint the rendering) */
  150005. color: Color3;
  150006. /** simulated refraction depth */
  150007. depth: number;
  150008. /** the coefficient of the base color (0 to remove base color tainting) */
  150009. colorLevel: number;
  150010. /** Gets the url used to load the refraction texture */
  150011. refractionTextureUrl: string;
  150012. /**
  150013. * Gets or sets the refraction texture
  150014. * Please note that you are responsible for disposing the texture if you set it manually
  150015. */
  150016. get refractionTexture(): Texture;
  150017. set refractionTexture(value: Texture);
  150018. /**
  150019. * Gets a string identifying the name of the class
  150020. * @returns "RefractionPostProcess" string
  150021. */
  150022. getClassName(): string;
  150023. /**
  150024. * Initializes the RefractionPostProcess
  150025. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150026. * @param name The name of the effect.
  150027. * @param refractionTextureUrl Url of the refraction texture to use
  150028. * @param color the base color of the refraction (used to taint the rendering)
  150029. * @param depth simulated refraction depth
  150030. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  150031. * @param camera The camera to apply the render pass to.
  150032. * @param options The required width/height ratio to downsize to before computing the render pass.
  150033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150034. * @param engine The engine which the post process will be applied. (default: current engine)
  150035. * @param reusable If the post process can be reused on the same frame. (default: false)
  150036. */
  150037. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150038. /**
  150039. * Disposes of the post process
  150040. * @param camera Camera to dispose post process on
  150041. */
  150042. dispose(camera: Camera): void;
  150043. /** @hidden */
  150044. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  150045. }
  150046. }
  150047. declare module BABYLON {
  150048. /** @hidden */
  150049. export var sharpenPixelShader: {
  150050. name: string;
  150051. shader: string;
  150052. };
  150053. }
  150054. declare module BABYLON {
  150055. /**
  150056. * The SharpenPostProcess applies a sharpen kernel to every pixel
  150057. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150058. */
  150059. export class SharpenPostProcess extends PostProcess {
  150060. /**
  150061. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  150062. */
  150063. colorAmount: number;
  150064. /**
  150065. * How much sharpness should be applied (default: 0.3)
  150066. */
  150067. edgeAmount: number;
  150068. /**
  150069. * Gets a string identifying the name of the class
  150070. * @returns "SharpenPostProcess" string
  150071. */
  150072. getClassName(): string;
  150073. /**
  150074. * Creates a new instance ConvolutionPostProcess
  150075. * @param name The name of the effect.
  150076. * @param options The required width/height ratio to downsize to before computing the render pass.
  150077. * @param camera The camera to apply the render pass to.
  150078. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150079. * @param engine The engine which the post process will be applied. (default: current engine)
  150080. * @param reusable If the post process can be reused on the same frame. (default: false)
  150081. * @param textureType Type of textures used when performing the post process. (default: 0)
  150082. * @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)
  150083. */
  150084. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150085. /** @hidden */
  150086. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  150087. }
  150088. }
  150089. declare module BABYLON {
  150090. /**
  150091. * PostProcessRenderPipeline
  150092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150093. */
  150094. export class PostProcessRenderPipeline {
  150095. private engine;
  150096. private _renderEffects;
  150097. private _renderEffectsForIsolatedPass;
  150098. /**
  150099. * List of inspectable custom properties (used by the Inspector)
  150100. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  150101. */
  150102. inspectableCustomProperties: IInspectable[];
  150103. /**
  150104. * @hidden
  150105. */
  150106. protected _cameras: Camera[];
  150107. /** @hidden */
  150108. _name: string;
  150109. /**
  150110. * Gets pipeline name
  150111. */
  150112. get name(): string;
  150113. /** Gets the list of attached cameras */
  150114. get cameras(): Camera[];
  150115. /**
  150116. * Initializes a PostProcessRenderPipeline
  150117. * @param engine engine to add the pipeline to
  150118. * @param name name of the pipeline
  150119. */
  150120. constructor(engine: Engine, name: string);
  150121. /**
  150122. * Gets the class name
  150123. * @returns "PostProcessRenderPipeline"
  150124. */
  150125. getClassName(): string;
  150126. /**
  150127. * If all the render effects in the pipeline are supported
  150128. */
  150129. get isSupported(): boolean;
  150130. /**
  150131. * Adds an effect to the pipeline
  150132. * @param renderEffect the effect to add
  150133. */
  150134. addEffect(renderEffect: PostProcessRenderEffect): void;
  150135. /** @hidden */
  150136. _rebuild(): void;
  150137. /** @hidden */
  150138. _enableEffect(renderEffectName: string, cameras: Camera): void;
  150139. /** @hidden */
  150140. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  150141. /** @hidden */
  150142. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150143. /** @hidden */
  150144. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150145. /** @hidden */
  150146. _attachCameras(cameras: Camera, unique: boolean): void;
  150147. /** @hidden */
  150148. _attachCameras(cameras: Camera[], unique: boolean): void;
  150149. /** @hidden */
  150150. _detachCameras(cameras: Camera): void;
  150151. /** @hidden */
  150152. _detachCameras(cameras: Nullable<Camera[]>): void;
  150153. /** @hidden */
  150154. _update(): void;
  150155. /** @hidden */
  150156. _reset(): void;
  150157. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  150158. /**
  150159. * Sets the required values to the prepass renderer.
  150160. * @param prePassRenderer defines the prepass renderer to setup.
  150161. * @returns true if the pre pass is needed.
  150162. */
  150163. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150164. /**
  150165. * Disposes of the pipeline
  150166. */
  150167. dispose(): void;
  150168. }
  150169. }
  150170. declare module BABYLON {
  150171. /**
  150172. * PostProcessRenderPipelineManager class
  150173. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150174. */
  150175. export class PostProcessRenderPipelineManager {
  150176. private _renderPipelines;
  150177. /**
  150178. * Initializes a PostProcessRenderPipelineManager
  150179. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150180. */
  150181. constructor();
  150182. /**
  150183. * Gets the list of supported render pipelines
  150184. */
  150185. get supportedPipelines(): PostProcessRenderPipeline[];
  150186. /**
  150187. * Adds a pipeline to the manager
  150188. * @param renderPipeline The pipeline to add
  150189. */
  150190. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  150191. /**
  150192. * Attaches a camera to the pipeline
  150193. * @param renderPipelineName The name of the pipeline to attach to
  150194. * @param cameras the camera to attach
  150195. * @param unique if the camera can be attached multiple times to the pipeline
  150196. */
  150197. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  150198. /**
  150199. * Detaches a camera from the pipeline
  150200. * @param renderPipelineName The name of the pipeline to detach from
  150201. * @param cameras the camera to detach
  150202. */
  150203. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  150204. /**
  150205. * Enables an effect by name on a pipeline
  150206. * @param renderPipelineName the name of the pipeline to enable the effect in
  150207. * @param renderEffectName the name of the effect to enable
  150208. * @param cameras the cameras that the effect should be enabled on
  150209. */
  150210. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150211. /**
  150212. * Disables an effect by name on a pipeline
  150213. * @param renderPipelineName the name of the pipeline to disable the effect in
  150214. * @param renderEffectName the name of the effect to disable
  150215. * @param cameras the cameras that the effect should be disabled on
  150216. */
  150217. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150218. /**
  150219. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  150220. */
  150221. update(): void;
  150222. /** @hidden */
  150223. _rebuild(): void;
  150224. /**
  150225. * Disposes of the manager and pipelines
  150226. */
  150227. dispose(): void;
  150228. }
  150229. }
  150230. declare module BABYLON {
  150231. interface Scene {
  150232. /** @hidden (Backing field) */
  150233. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150234. /**
  150235. * Gets the postprocess render pipeline manager
  150236. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150237. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150238. */
  150239. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150240. }
  150241. /**
  150242. * Defines the Render Pipeline scene component responsible to rendering pipelines
  150243. */
  150244. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  150245. /**
  150246. * The component name helpfull to identify the component in the list of scene components.
  150247. */
  150248. readonly name: string;
  150249. /**
  150250. * The scene the component belongs to.
  150251. */
  150252. scene: Scene;
  150253. /**
  150254. * Creates a new instance of the component for the given scene
  150255. * @param scene Defines the scene to register the component in
  150256. */
  150257. constructor(scene: Scene);
  150258. /**
  150259. * Registers the component in a given scene
  150260. */
  150261. register(): void;
  150262. /**
  150263. * Rebuilds the elements related to this component in case of
  150264. * context lost for instance.
  150265. */
  150266. rebuild(): void;
  150267. /**
  150268. * Disposes the component and the associated ressources
  150269. */
  150270. dispose(): void;
  150271. private _gatherRenderTargets;
  150272. }
  150273. }
  150274. declare module BABYLON {
  150275. /**
  150276. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  150277. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150278. */
  150279. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  150280. private _scene;
  150281. private _camerasToBeAttached;
  150282. /**
  150283. * ID of the sharpen post process,
  150284. */
  150285. private readonly SharpenPostProcessId;
  150286. /**
  150287. * @ignore
  150288. * ID of the image processing post process;
  150289. */
  150290. readonly ImageProcessingPostProcessId: string;
  150291. /**
  150292. * @ignore
  150293. * ID of the Fast Approximate Anti-Aliasing post process;
  150294. */
  150295. readonly FxaaPostProcessId: string;
  150296. /**
  150297. * ID of the chromatic aberration post process,
  150298. */
  150299. private readonly ChromaticAberrationPostProcessId;
  150300. /**
  150301. * ID of the grain post process
  150302. */
  150303. private readonly GrainPostProcessId;
  150304. /**
  150305. * Sharpen post process which will apply a sharpen convolution to enhance edges
  150306. */
  150307. sharpen: SharpenPostProcess;
  150308. private _sharpenEffect;
  150309. private bloom;
  150310. /**
  150311. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  150312. */
  150313. depthOfField: DepthOfFieldEffect;
  150314. /**
  150315. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  150316. */
  150317. fxaa: FxaaPostProcess;
  150318. /**
  150319. * Image post processing pass used to perform operations such as tone mapping or color grading.
  150320. */
  150321. imageProcessing: ImageProcessingPostProcess;
  150322. /**
  150323. * Chromatic aberration post process which will shift rgb colors in the image
  150324. */
  150325. chromaticAberration: ChromaticAberrationPostProcess;
  150326. private _chromaticAberrationEffect;
  150327. /**
  150328. * Grain post process which add noise to the image
  150329. */
  150330. grain: GrainPostProcess;
  150331. private _grainEffect;
  150332. /**
  150333. * Glow post process which adds a glow to emissive areas of the image
  150334. */
  150335. private _glowLayer;
  150336. /**
  150337. * Animations which can be used to tweak settings over a period of time
  150338. */
  150339. animations: Animation[];
  150340. private _imageProcessingConfigurationObserver;
  150341. private _sharpenEnabled;
  150342. private _bloomEnabled;
  150343. private _depthOfFieldEnabled;
  150344. private _depthOfFieldBlurLevel;
  150345. private _fxaaEnabled;
  150346. private _imageProcessingEnabled;
  150347. private _defaultPipelineTextureType;
  150348. private _bloomScale;
  150349. private _chromaticAberrationEnabled;
  150350. private _grainEnabled;
  150351. private _buildAllowed;
  150352. /**
  150353. * Gets active scene
  150354. */
  150355. get scene(): Scene;
  150356. /**
  150357. * Enable or disable the sharpen process from the pipeline
  150358. */
  150359. set sharpenEnabled(enabled: boolean);
  150360. get sharpenEnabled(): boolean;
  150361. private _resizeObserver;
  150362. private _hardwareScaleLevel;
  150363. private _bloomKernel;
  150364. /**
  150365. * Specifies the size of the bloom blur kernel, relative to the final output size
  150366. */
  150367. get bloomKernel(): number;
  150368. set bloomKernel(value: number);
  150369. /**
  150370. * Specifies the weight of the bloom in the final rendering
  150371. */
  150372. private _bloomWeight;
  150373. /**
  150374. * Specifies the luma threshold for the area that will be blurred by the bloom
  150375. */
  150376. private _bloomThreshold;
  150377. private _hdr;
  150378. /**
  150379. * The strength of the bloom.
  150380. */
  150381. set bloomWeight(value: number);
  150382. get bloomWeight(): number;
  150383. /**
  150384. * The strength of the bloom.
  150385. */
  150386. set bloomThreshold(value: number);
  150387. get bloomThreshold(): number;
  150388. /**
  150389. * The scale of the bloom, lower value will provide better performance.
  150390. */
  150391. set bloomScale(value: number);
  150392. get bloomScale(): number;
  150393. /**
  150394. * Enable or disable the bloom from the pipeline
  150395. */
  150396. set bloomEnabled(enabled: boolean);
  150397. get bloomEnabled(): boolean;
  150398. private _rebuildBloom;
  150399. /**
  150400. * If the depth of field is enabled.
  150401. */
  150402. get depthOfFieldEnabled(): boolean;
  150403. set depthOfFieldEnabled(enabled: boolean);
  150404. /**
  150405. * Blur level of the depth of field effect. (Higher blur will effect performance)
  150406. */
  150407. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  150408. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  150409. /**
  150410. * If the anti aliasing is enabled.
  150411. */
  150412. set fxaaEnabled(enabled: boolean);
  150413. get fxaaEnabled(): boolean;
  150414. private _samples;
  150415. /**
  150416. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  150417. */
  150418. set samples(sampleCount: number);
  150419. get samples(): number;
  150420. /**
  150421. * If image processing is enabled.
  150422. */
  150423. set imageProcessingEnabled(enabled: boolean);
  150424. get imageProcessingEnabled(): boolean;
  150425. /**
  150426. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  150427. */
  150428. set glowLayerEnabled(enabled: boolean);
  150429. get glowLayerEnabled(): boolean;
  150430. /**
  150431. * Gets the glow layer (or null if not defined)
  150432. */
  150433. get glowLayer(): Nullable<GlowLayer>;
  150434. /**
  150435. * Enable or disable the chromaticAberration process from the pipeline
  150436. */
  150437. set chromaticAberrationEnabled(enabled: boolean);
  150438. get chromaticAberrationEnabled(): boolean;
  150439. /**
  150440. * Enable or disable the grain process from the pipeline
  150441. */
  150442. set grainEnabled(enabled: boolean);
  150443. get grainEnabled(): boolean;
  150444. /**
  150445. * @constructor
  150446. * @param name - The rendering pipeline name (default: "")
  150447. * @param hdr - If high dynamic range textures should be used (default: true)
  150448. * @param scene - The scene linked to this pipeline (default: the last created scene)
  150449. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  150450. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  150451. */
  150452. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  150453. /**
  150454. * Get the class name
  150455. * @returns "DefaultRenderingPipeline"
  150456. */
  150457. getClassName(): string;
  150458. /**
  150459. * Force the compilation of the entire pipeline.
  150460. */
  150461. prepare(): void;
  150462. private _hasCleared;
  150463. private _prevPostProcess;
  150464. private _prevPrevPostProcess;
  150465. private _setAutoClearAndTextureSharing;
  150466. private _depthOfFieldSceneObserver;
  150467. private _buildPipeline;
  150468. private _disposePostProcesses;
  150469. /**
  150470. * Adds a camera to the pipeline
  150471. * @param camera the camera to be added
  150472. */
  150473. addCamera(camera: Camera): void;
  150474. /**
  150475. * Removes a camera from the pipeline
  150476. * @param camera the camera to remove
  150477. */
  150478. removeCamera(camera: Camera): void;
  150479. /**
  150480. * Dispose of the pipeline and stop all post processes
  150481. */
  150482. dispose(): void;
  150483. /**
  150484. * Serialize the rendering pipeline (Used when exporting)
  150485. * @returns the serialized object
  150486. */
  150487. serialize(): any;
  150488. /**
  150489. * Parse the serialized pipeline
  150490. * @param source Source pipeline.
  150491. * @param scene The scene to load the pipeline to.
  150492. * @param rootUrl The URL of the serialized pipeline.
  150493. * @returns An instantiated pipeline from the serialized object.
  150494. */
  150495. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  150496. }
  150497. }
  150498. declare module BABYLON {
  150499. /** @hidden */
  150500. export var lensHighlightsPixelShader: {
  150501. name: string;
  150502. shader: string;
  150503. };
  150504. }
  150505. declare module BABYLON {
  150506. /** @hidden */
  150507. export var depthOfFieldPixelShader: {
  150508. name: string;
  150509. shader: string;
  150510. };
  150511. }
  150512. declare module BABYLON {
  150513. /**
  150514. * BABYLON.JS Chromatic Aberration GLSL Shader
  150515. * Author: Olivier Guyot
  150516. * Separates very slightly R, G and B colors on the edges of the screen
  150517. * Inspired by Francois Tarlier & Martins Upitis
  150518. */
  150519. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  150520. /**
  150521. * @ignore
  150522. * The chromatic aberration PostProcess id in the pipeline
  150523. */
  150524. LensChromaticAberrationEffect: string;
  150525. /**
  150526. * @ignore
  150527. * The highlights enhancing PostProcess id in the pipeline
  150528. */
  150529. HighlightsEnhancingEffect: string;
  150530. /**
  150531. * @ignore
  150532. * The depth-of-field PostProcess id in the pipeline
  150533. */
  150534. LensDepthOfFieldEffect: string;
  150535. private _scene;
  150536. private _depthTexture;
  150537. private _grainTexture;
  150538. private _chromaticAberrationPostProcess;
  150539. private _highlightsPostProcess;
  150540. private _depthOfFieldPostProcess;
  150541. private _edgeBlur;
  150542. private _grainAmount;
  150543. private _chromaticAberration;
  150544. private _distortion;
  150545. private _highlightsGain;
  150546. private _highlightsThreshold;
  150547. private _dofDistance;
  150548. private _dofAperture;
  150549. private _dofDarken;
  150550. private _dofPentagon;
  150551. private _blurNoise;
  150552. /**
  150553. * @constructor
  150554. *
  150555. * Effect parameters are as follow:
  150556. * {
  150557. * chromatic_aberration: number; // from 0 to x (1 for realism)
  150558. * edge_blur: number; // from 0 to x (1 for realism)
  150559. * distortion: number; // from 0 to x (1 for realism)
  150560. * grain_amount: number; // from 0 to 1
  150561. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  150562. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  150563. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  150564. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  150565. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  150566. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  150567. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  150568. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  150569. * }
  150570. * Note: if an effect parameter is unset, effect is disabled
  150571. *
  150572. * @param name The rendering pipeline name
  150573. * @param parameters - An object containing all parameters (see above)
  150574. * @param scene The scene linked to this pipeline
  150575. * @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)
  150576. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150577. */
  150578. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  150579. /**
  150580. * Get the class name
  150581. * @returns "LensRenderingPipeline"
  150582. */
  150583. getClassName(): string;
  150584. /**
  150585. * Gets associated scene
  150586. */
  150587. get scene(): Scene;
  150588. /**
  150589. * Gets or sets the edge blur
  150590. */
  150591. get edgeBlur(): number;
  150592. set edgeBlur(value: number);
  150593. /**
  150594. * Gets or sets the grain amount
  150595. */
  150596. get grainAmount(): number;
  150597. set grainAmount(value: number);
  150598. /**
  150599. * Gets or sets the chromatic aberration amount
  150600. */
  150601. get chromaticAberration(): number;
  150602. set chromaticAberration(value: number);
  150603. /**
  150604. * Gets or sets the depth of field aperture
  150605. */
  150606. get dofAperture(): number;
  150607. set dofAperture(value: number);
  150608. /**
  150609. * Gets or sets the edge distortion
  150610. */
  150611. get edgeDistortion(): number;
  150612. set edgeDistortion(value: number);
  150613. /**
  150614. * Gets or sets the depth of field distortion
  150615. */
  150616. get dofDistortion(): number;
  150617. set dofDistortion(value: number);
  150618. /**
  150619. * Gets or sets the darken out of focus amount
  150620. */
  150621. get darkenOutOfFocus(): number;
  150622. set darkenOutOfFocus(value: number);
  150623. /**
  150624. * Gets or sets a boolean indicating if blur noise is enabled
  150625. */
  150626. get blurNoise(): boolean;
  150627. set blurNoise(value: boolean);
  150628. /**
  150629. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  150630. */
  150631. get pentagonBokeh(): boolean;
  150632. set pentagonBokeh(value: boolean);
  150633. /**
  150634. * Gets or sets the highlight grain amount
  150635. */
  150636. get highlightsGain(): number;
  150637. set highlightsGain(value: number);
  150638. /**
  150639. * Gets or sets the highlight threshold
  150640. */
  150641. get highlightsThreshold(): number;
  150642. set highlightsThreshold(value: number);
  150643. /**
  150644. * Sets the amount of blur at the edges
  150645. * @param amount blur amount
  150646. */
  150647. setEdgeBlur(amount: number): void;
  150648. /**
  150649. * Sets edge blur to 0
  150650. */
  150651. disableEdgeBlur(): void;
  150652. /**
  150653. * Sets the amout of grain
  150654. * @param amount Amount of grain
  150655. */
  150656. setGrainAmount(amount: number): void;
  150657. /**
  150658. * Set grain amount to 0
  150659. */
  150660. disableGrain(): void;
  150661. /**
  150662. * Sets the chromatic aberration amount
  150663. * @param amount amount of chromatic aberration
  150664. */
  150665. setChromaticAberration(amount: number): void;
  150666. /**
  150667. * Sets chromatic aberration amount to 0
  150668. */
  150669. disableChromaticAberration(): void;
  150670. /**
  150671. * Sets the EdgeDistortion amount
  150672. * @param amount amount of EdgeDistortion
  150673. */
  150674. setEdgeDistortion(amount: number): void;
  150675. /**
  150676. * Sets edge distortion to 0
  150677. */
  150678. disableEdgeDistortion(): void;
  150679. /**
  150680. * Sets the FocusDistance amount
  150681. * @param amount amount of FocusDistance
  150682. */
  150683. setFocusDistance(amount: number): void;
  150684. /**
  150685. * Disables depth of field
  150686. */
  150687. disableDepthOfField(): void;
  150688. /**
  150689. * Sets the Aperture amount
  150690. * @param amount amount of Aperture
  150691. */
  150692. setAperture(amount: number): void;
  150693. /**
  150694. * Sets the DarkenOutOfFocus amount
  150695. * @param amount amount of DarkenOutOfFocus
  150696. */
  150697. setDarkenOutOfFocus(amount: number): void;
  150698. private _pentagonBokehIsEnabled;
  150699. /**
  150700. * Creates a pentagon bokeh effect
  150701. */
  150702. enablePentagonBokeh(): void;
  150703. /**
  150704. * Disables the pentagon bokeh effect
  150705. */
  150706. disablePentagonBokeh(): void;
  150707. /**
  150708. * Enables noise blur
  150709. */
  150710. enableNoiseBlur(): void;
  150711. /**
  150712. * Disables noise blur
  150713. */
  150714. disableNoiseBlur(): void;
  150715. /**
  150716. * Sets the HighlightsGain amount
  150717. * @param amount amount of HighlightsGain
  150718. */
  150719. setHighlightsGain(amount: number): void;
  150720. /**
  150721. * Sets the HighlightsThreshold amount
  150722. * @param amount amount of HighlightsThreshold
  150723. */
  150724. setHighlightsThreshold(amount: number): void;
  150725. /**
  150726. * Disables highlights
  150727. */
  150728. disableHighlights(): void;
  150729. /**
  150730. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  150731. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  150732. */
  150733. dispose(disableDepthRender?: boolean): void;
  150734. private _createChromaticAberrationPostProcess;
  150735. private _createHighlightsPostProcess;
  150736. private _createDepthOfFieldPostProcess;
  150737. private _createGrainTexture;
  150738. }
  150739. }
  150740. declare module BABYLON {
  150741. /** @hidden */
  150742. export var ssao2PixelShader: {
  150743. name: string;
  150744. shader: string;
  150745. };
  150746. }
  150747. declare module BABYLON {
  150748. /** @hidden */
  150749. export var ssaoCombinePixelShader: {
  150750. name: string;
  150751. shader: string;
  150752. };
  150753. }
  150754. declare module BABYLON {
  150755. /**
  150756. * Render pipeline to produce ssao effect
  150757. */
  150758. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  150759. /**
  150760. * @ignore
  150761. * The PassPostProcess id in the pipeline that contains the original scene color
  150762. */
  150763. SSAOOriginalSceneColorEffect: string;
  150764. /**
  150765. * @ignore
  150766. * The SSAO PostProcess id in the pipeline
  150767. */
  150768. SSAORenderEffect: string;
  150769. /**
  150770. * @ignore
  150771. * The horizontal blur PostProcess id in the pipeline
  150772. */
  150773. SSAOBlurHRenderEffect: string;
  150774. /**
  150775. * @ignore
  150776. * The vertical blur PostProcess id in the pipeline
  150777. */
  150778. SSAOBlurVRenderEffect: string;
  150779. /**
  150780. * @ignore
  150781. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  150782. */
  150783. SSAOCombineRenderEffect: string;
  150784. /**
  150785. * The output strength of the SSAO post-process. Default value is 1.0.
  150786. */
  150787. totalStrength: number;
  150788. /**
  150789. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  150790. */
  150791. maxZ: number;
  150792. /**
  150793. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  150794. */
  150795. minZAspect: number;
  150796. private _samples;
  150797. /**
  150798. * Number of samples used for the SSAO calculations. Default value is 8
  150799. */
  150800. set samples(n: number);
  150801. get samples(): number;
  150802. private _textureSamples;
  150803. /**
  150804. * Number of samples to use for antialiasing
  150805. */
  150806. set textureSamples(n: number);
  150807. get textureSamples(): number;
  150808. /**
  150809. * Force rendering the geometry through geometry buffer
  150810. */
  150811. private _forceGeometryBuffer;
  150812. /**
  150813. * Ratio object used for SSAO ratio and blur ratio
  150814. */
  150815. private _ratio;
  150816. /**
  150817. * Dynamically generated sphere sampler.
  150818. */
  150819. private _sampleSphere;
  150820. /**
  150821. * Blur filter offsets
  150822. */
  150823. private _samplerOffsets;
  150824. private _expensiveBlur;
  150825. /**
  150826. * If bilateral blur should be used
  150827. */
  150828. set expensiveBlur(b: boolean);
  150829. get expensiveBlur(): boolean;
  150830. /**
  150831. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  150832. */
  150833. radius: number;
  150834. /**
  150835. * The base color of the SSAO post-process
  150836. * The final result is "base + ssao" between [0, 1]
  150837. */
  150838. base: number;
  150839. /**
  150840. * Support test.
  150841. */
  150842. static get IsSupported(): boolean;
  150843. private _scene;
  150844. private _randomTexture;
  150845. private _originalColorPostProcess;
  150846. private _ssaoPostProcess;
  150847. private _blurHPostProcess;
  150848. private _blurVPostProcess;
  150849. private _ssaoCombinePostProcess;
  150850. private _prePassRenderer;
  150851. /**
  150852. * Gets active scene
  150853. */
  150854. get scene(): Scene;
  150855. /**
  150856. * @constructor
  150857. * @param name The rendering pipeline name
  150858. * @param scene The scene linked to this pipeline
  150859. * @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 }
  150860. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150861. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  150862. */
  150863. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  150864. /**
  150865. * Get the class name
  150866. * @returns "SSAO2RenderingPipeline"
  150867. */
  150868. getClassName(): string;
  150869. /**
  150870. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  150871. */
  150872. dispose(disableGeometryBufferRenderer?: boolean): void;
  150873. private _createBlurPostProcess;
  150874. /** @hidden */
  150875. _rebuild(): void;
  150876. private _bits;
  150877. private _radicalInverse_VdC;
  150878. private _hammersley;
  150879. private _hemisphereSample_uniform;
  150880. private _generateHemisphere;
  150881. private _getDefinesForSSAO;
  150882. private _createSSAOPostProcess;
  150883. private _createSSAOCombinePostProcess;
  150884. private _createRandomTexture;
  150885. /**
  150886. * Serialize the rendering pipeline (Used when exporting)
  150887. * @returns the serialized object
  150888. */
  150889. serialize(): any;
  150890. /**
  150891. * Parse the serialized pipeline
  150892. * @param source Source pipeline.
  150893. * @param scene The scene to load the pipeline to.
  150894. * @param rootUrl The URL of the serialized pipeline.
  150895. * @returns An instantiated pipeline from the serialized object.
  150896. */
  150897. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  150898. /**
  150899. * Sets the required values to the prepass renderer.
  150900. * @param prePassRenderer defines the prepass renderer to setup
  150901. * @returns true if the pre pass is needed.
  150902. */
  150903. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150904. }
  150905. }
  150906. declare module BABYLON {
  150907. /** @hidden */
  150908. export var ssaoPixelShader: {
  150909. name: string;
  150910. shader: string;
  150911. };
  150912. }
  150913. declare module BABYLON {
  150914. /**
  150915. * Render pipeline to produce ssao effect
  150916. */
  150917. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  150918. /**
  150919. * @ignore
  150920. * The PassPostProcess id in the pipeline that contains the original scene color
  150921. */
  150922. SSAOOriginalSceneColorEffect: string;
  150923. /**
  150924. * @ignore
  150925. * The SSAO PostProcess id in the pipeline
  150926. */
  150927. SSAORenderEffect: string;
  150928. /**
  150929. * @ignore
  150930. * The horizontal blur PostProcess id in the pipeline
  150931. */
  150932. SSAOBlurHRenderEffect: string;
  150933. /**
  150934. * @ignore
  150935. * The vertical blur PostProcess id in the pipeline
  150936. */
  150937. SSAOBlurVRenderEffect: string;
  150938. /**
  150939. * @ignore
  150940. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  150941. */
  150942. SSAOCombineRenderEffect: string;
  150943. /**
  150944. * The output strength of the SSAO post-process. Default value is 1.0.
  150945. */
  150946. totalStrength: number;
  150947. /**
  150948. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  150949. */
  150950. radius: number;
  150951. /**
  150952. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  150953. * Must not be equal to fallOff and superior to fallOff.
  150954. * Default value is 0.0075
  150955. */
  150956. area: number;
  150957. /**
  150958. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  150959. * Must not be equal to area and inferior to area.
  150960. * Default value is 0.000001
  150961. */
  150962. fallOff: number;
  150963. /**
  150964. * The base color of the SSAO post-process
  150965. * The final result is "base + ssao" between [0, 1]
  150966. */
  150967. base: number;
  150968. private _scene;
  150969. private _depthTexture;
  150970. private _randomTexture;
  150971. private _originalColorPostProcess;
  150972. private _ssaoPostProcess;
  150973. private _blurHPostProcess;
  150974. private _blurVPostProcess;
  150975. private _ssaoCombinePostProcess;
  150976. private _firstUpdate;
  150977. /**
  150978. * Gets active scene
  150979. */
  150980. get scene(): Scene;
  150981. /**
  150982. * @constructor
  150983. * @param name - The rendering pipeline name
  150984. * @param scene - The scene linked to this pipeline
  150985. * @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 }
  150986. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  150987. */
  150988. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  150989. /**
  150990. * Get the class name
  150991. * @returns "SSAORenderingPipeline"
  150992. */
  150993. getClassName(): string;
  150994. /**
  150995. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  150996. */
  150997. dispose(disableDepthRender?: boolean): void;
  150998. private _createBlurPostProcess;
  150999. /** @hidden */
  151000. _rebuild(): void;
  151001. private _createSSAOPostProcess;
  151002. private _createSSAOCombinePostProcess;
  151003. private _createRandomTexture;
  151004. }
  151005. }
  151006. declare module BABYLON {
  151007. /** @hidden */
  151008. export var screenSpaceReflectionPixelShader: {
  151009. name: string;
  151010. shader: string;
  151011. };
  151012. }
  151013. declare module BABYLON {
  151014. /**
  151015. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  151016. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  151017. */
  151018. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  151019. /**
  151020. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  151021. */
  151022. threshold: number;
  151023. /**
  151024. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  151025. */
  151026. strength: number;
  151027. /**
  151028. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  151029. */
  151030. reflectionSpecularFalloffExponent: number;
  151031. /**
  151032. * 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]
  151033. */
  151034. step: number;
  151035. /**
  151036. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  151037. */
  151038. roughnessFactor: number;
  151039. private _geometryBufferRenderer;
  151040. private _enableSmoothReflections;
  151041. private _reflectionSamples;
  151042. private _smoothSteps;
  151043. /**
  151044. * Gets a string identifying the name of the class
  151045. * @returns "ScreenSpaceReflectionPostProcess" string
  151046. */
  151047. getClassName(): string;
  151048. /**
  151049. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  151050. * @param name The name of the effect.
  151051. * @param scene The scene containing the objects to calculate reflections.
  151052. * @param options The required width/height ratio to downsize to before computing the render pass.
  151053. * @param camera The camera to apply the render pass to.
  151054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151055. * @param engine The engine which the post process will be applied. (default: current engine)
  151056. * @param reusable If the post process can be reused on the same frame. (default: false)
  151057. * @param textureType Type of textures used when performing the post process. (default: 0)
  151058. * @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)
  151059. */
  151060. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151061. /**
  151062. * Gets wether or not smoothing reflections is enabled.
  151063. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151064. */
  151065. get enableSmoothReflections(): boolean;
  151066. /**
  151067. * Sets wether or not smoothing reflections is enabled.
  151068. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151069. */
  151070. set enableSmoothReflections(enabled: boolean);
  151071. /**
  151072. * Gets the number of samples taken while computing reflections. More samples count is high,
  151073. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151074. */
  151075. get reflectionSamples(): number;
  151076. /**
  151077. * Sets the number of samples taken while computing reflections. More samples count is high,
  151078. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151079. */
  151080. set reflectionSamples(samples: number);
  151081. /**
  151082. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  151083. * more the post-process will require GPU power and can generate a drop in FPS.
  151084. * Default value (5.0) work pretty well in all cases but can be adjusted.
  151085. */
  151086. get smoothSteps(): number;
  151087. set smoothSteps(steps: number);
  151088. private _updateEffectDefines;
  151089. /** @hidden */
  151090. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  151091. }
  151092. }
  151093. declare module BABYLON {
  151094. /** @hidden */
  151095. export var standardPixelShader: {
  151096. name: string;
  151097. shader: string;
  151098. };
  151099. }
  151100. declare module BABYLON {
  151101. /**
  151102. * Standard rendering pipeline
  151103. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151104. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  151105. */
  151106. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151107. /**
  151108. * Public members
  151109. */
  151110. /**
  151111. * Post-process which contains the original scene color before the pipeline applies all the effects
  151112. */
  151113. originalPostProcess: Nullable<PostProcess>;
  151114. /**
  151115. * Post-process used to down scale an image x4
  151116. */
  151117. downSampleX4PostProcess: Nullable<PostProcess>;
  151118. /**
  151119. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  151120. */
  151121. brightPassPostProcess: Nullable<PostProcess>;
  151122. /**
  151123. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  151124. */
  151125. blurHPostProcesses: PostProcess[];
  151126. /**
  151127. * Post-process array storing all the vertical blur post-processes used by the pipeline
  151128. */
  151129. blurVPostProcesses: PostProcess[];
  151130. /**
  151131. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  151132. */
  151133. textureAdderPostProcess: Nullable<PostProcess>;
  151134. /**
  151135. * Post-process used to create volumetric lighting effect
  151136. */
  151137. volumetricLightPostProcess: Nullable<PostProcess>;
  151138. /**
  151139. * Post-process used to smooth the previous volumetric light post-process on the X axis
  151140. */
  151141. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  151142. /**
  151143. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  151144. */
  151145. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  151146. /**
  151147. * Post-process used to merge the volumetric light effect and the real scene color
  151148. */
  151149. volumetricLightMergePostProces: Nullable<PostProcess>;
  151150. /**
  151151. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  151152. */
  151153. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  151154. /**
  151155. * Base post-process used to calculate the average luminance of the final image for HDR
  151156. */
  151157. luminancePostProcess: Nullable<PostProcess>;
  151158. /**
  151159. * Post-processes used to create down sample post-processes in order to get
  151160. * the average luminance of the final image for HDR
  151161. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  151162. */
  151163. luminanceDownSamplePostProcesses: PostProcess[];
  151164. /**
  151165. * Post-process used to create a HDR effect (light adaptation)
  151166. */
  151167. hdrPostProcess: Nullable<PostProcess>;
  151168. /**
  151169. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  151170. */
  151171. textureAdderFinalPostProcess: Nullable<PostProcess>;
  151172. /**
  151173. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  151174. */
  151175. lensFlareFinalPostProcess: Nullable<PostProcess>;
  151176. /**
  151177. * Post-process used to merge the final HDR post-process and the real scene color
  151178. */
  151179. hdrFinalPostProcess: Nullable<PostProcess>;
  151180. /**
  151181. * Post-process used to create a lens flare effect
  151182. */
  151183. lensFlarePostProcess: Nullable<PostProcess>;
  151184. /**
  151185. * Post-process that merges the result of the lens flare post-process and the real scene color
  151186. */
  151187. lensFlareComposePostProcess: Nullable<PostProcess>;
  151188. /**
  151189. * Post-process used to create a motion blur effect
  151190. */
  151191. motionBlurPostProcess: Nullable<PostProcess>;
  151192. /**
  151193. * Post-process used to create a depth of field effect
  151194. */
  151195. depthOfFieldPostProcess: Nullable<PostProcess>;
  151196. /**
  151197. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151198. */
  151199. fxaaPostProcess: Nullable<FxaaPostProcess>;
  151200. /**
  151201. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  151202. */
  151203. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  151204. /**
  151205. * Represents the brightness threshold in order to configure the illuminated surfaces
  151206. */
  151207. brightThreshold: number;
  151208. /**
  151209. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  151210. */
  151211. blurWidth: number;
  151212. /**
  151213. * Sets if the blur for highlighted surfaces must be only horizontal
  151214. */
  151215. horizontalBlur: boolean;
  151216. /**
  151217. * Gets the overall exposure used by the pipeline
  151218. */
  151219. get exposure(): number;
  151220. /**
  151221. * Sets the overall exposure used by the pipeline
  151222. */
  151223. set exposure(value: number);
  151224. /**
  151225. * Texture used typically to simulate "dirty" on camera lens
  151226. */
  151227. lensTexture: Nullable<Texture>;
  151228. /**
  151229. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  151230. */
  151231. volumetricLightCoefficient: number;
  151232. /**
  151233. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  151234. */
  151235. volumetricLightPower: number;
  151236. /**
  151237. * Used the set the blur intensity to smooth the volumetric lights
  151238. */
  151239. volumetricLightBlurScale: number;
  151240. /**
  151241. * Light (spot or directional) used to generate the volumetric lights rays
  151242. * The source light must have a shadow generate so the pipeline can get its
  151243. * depth map
  151244. */
  151245. sourceLight: Nullable<SpotLight | DirectionalLight>;
  151246. /**
  151247. * For eye adaptation, represents the minimum luminance the eye can see
  151248. */
  151249. hdrMinimumLuminance: number;
  151250. /**
  151251. * For eye adaptation, represents the decrease luminance speed
  151252. */
  151253. hdrDecreaseRate: number;
  151254. /**
  151255. * For eye adaptation, represents the increase luminance speed
  151256. */
  151257. hdrIncreaseRate: number;
  151258. /**
  151259. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151260. */
  151261. get hdrAutoExposure(): boolean;
  151262. /**
  151263. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151264. */
  151265. set hdrAutoExposure(value: boolean);
  151266. /**
  151267. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  151268. */
  151269. lensColorTexture: Nullable<Texture>;
  151270. /**
  151271. * The overall strengh for the lens flare effect
  151272. */
  151273. lensFlareStrength: number;
  151274. /**
  151275. * Dispersion coefficient for lens flare ghosts
  151276. */
  151277. lensFlareGhostDispersal: number;
  151278. /**
  151279. * Main lens flare halo width
  151280. */
  151281. lensFlareHaloWidth: number;
  151282. /**
  151283. * Based on the lens distortion effect, defines how much the lens flare result
  151284. * is distorted
  151285. */
  151286. lensFlareDistortionStrength: number;
  151287. /**
  151288. * Configures the blur intensity used for for lens flare (halo)
  151289. */
  151290. lensFlareBlurWidth: number;
  151291. /**
  151292. * Lens star texture must be used to simulate rays on the flares and is available
  151293. * in the documentation
  151294. */
  151295. lensStarTexture: Nullable<Texture>;
  151296. /**
  151297. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  151298. * flare effect by taking account of the dirt texture
  151299. */
  151300. lensFlareDirtTexture: Nullable<Texture>;
  151301. /**
  151302. * Represents the focal length for the depth of field effect
  151303. */
  151304. depthOfFieldDistance: number;
  151305. /**
  151306. * Represents the blur intensity for the blurred part of the depth of field effect
  151307. */
  151308. depthOfFieldBlurWidth: number;
  151309. /**
  151310. * Gets how much the image is blurred by the movement while using the motion blur post-process
  151311. */
  151312. get motionStrength(): number;
  151313. /**
  151314. * Sets how much the image is blurred by the movement while using the motion blur post-process
  151315. */
  151316. set motionStrength(strength: number);
  151317. /**
  151318. * Gets wether or not the motion blur post-process is object based or screen based.
  151319. */
  151320. get objectBasedMotionBlur(): boolean;
  151321. /**
  151322. * Sets wether or not the motion blur post-process should be object based or screen based
  151323. */
  151324. set objectBasedMotionBlur(value: boolean);
  151325. /**
  151326. * List of animations for the pipeline (IAnimatable implementation)
  151327. */
  151328. animations: Animation[];
  151329. /**
  151330. * Private members
  151331. */
  151332. private _scene;
  151333. private _currentDepthOfFieldSource;
  151334. private _basePostProcess;
  151335. private _fixedExposure;
  151336. private _currentExposure;
  151337. private _hdrAutoExposure;
  151338. private _hdrCurrentLuminance;
  151339. private _motionStrength;
  151340. private _isObjectBasedMotionBlur;
  151341. private _floatTextureType;
  151342. private _camerasToBeAttached;
  151343. private _ratio;
  151344. private _bloomEnabled;
  151345. private _depthOfFieldEnabled;
  151346. private _vlsEnabled;
  151347. private _lensFlareEnabled;
  151348. private _hdrEnabled;
  151349. private _motionBlurEnabled;
  151350. private _fxaaEnabled;
  151351. private _screenSpaceReflectionsEnabled;
  151352. private _motionBlurSamples;
  151353. private _volumetricLightStepsCount;
  151354. private _samples;
  151355. /**
  151356. * @ignore
  151357. * Specifies if the bloom pipeline is enabled
  151358. */
  151359. get BloomEnabled(): boolean;
  151360. set BloomEnabled(enabled: boolean);
  151361. /**
  151362. * @ignore
  151363. * Specifies if the depth of field pipeline is enabed
  151364. */
  151365. get DepthOfFieldEnabled(): boolean;
  151366. set DepthOfFieldEnabled(enabled: boolean);
  151367. /**
  151368. * @ignore
  151369. * Specifies if the lens flare pipeline is enabed
  151370. */
  151371. get LensFlareEnabled(): boolean;
  151372. set LensFlareEnabled(enabled: boolean);
  151373. /**
  151374. * @ignore
  151375. * Specifies if the HDR pipeline is enabled
  151376. */
  151377. get HDREnabled(): boolean;
  151378. set HDREnabled(enabled: boolean);
  151379. /**
  151380. * @ignore
  151381. * Specifies if the volumetric lights scattering effect is enabled
  151382. */
  151383. get VLSEnabled(): boolean;
  151384. set VLSEnabled(enabled: boolean);
  151385. /**
  151386. * @ignore
  151387. * Specifies if the motion blur effect is enabled
  151388. */
  151389. get MotionBlurEnabled(): boolean;
  151390. set MotionBlurEnabled(enabled: boolean);
  151391. /**
  151392. * Specifies if anti-aliasing is enabled
  151393. */
  151394. get fxaaEnabled(): boolean;
  151395. set fxaaEnabled(enabled: boolean);
  151396. /**
  151397. * Specifies if screen space reflections are enabled.
  151398. */
  151399. get screenSpaceReflectionsEnabled(): boolean;
  151400. set screenSpaceReflectionsEnabled(enabled: boolean);
  151401. /**
  151402. * Specifies the number of steps used to calculate the volumetric lights
  151403. * Typically in interval [50, 200]
  151404. */
  151405. get volumetricLightStepsCount(): number;
  151406. set volumetricLightStepsCount(count: number);
  151407. /**
  151408. * Specifies the number of samples used for the motion blur effect
  151409. * Typically in interval [16, 64]
  151410. */
  151411. get motionBlurSamples(): number;
  151412. set motionBlurSamples(samples: number);
  151413. /**
  151414. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151415. */
  151416. get samples(): number;
  151417. set samples(sampleCount: number);
  151418. /**
  151419. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151420. * @constructor
  151421. * @param name The rendering pipeline name
  151422. * @param scene The scene linked to this pipeline
  151423. * @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)
  151424. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  151425. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151426. */
  151427. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  151428. private _buildPipeline;
  151429. private _createDownSampleX4PostProcess;
  151430. private _createBrightPassPostProcess;
  151431. private _createBlurPostProcesses;
  151432. private _createTextureAdderPostProcess;
  151433. private _createVolumetricLightPostProcess;
  151434. private _createLuminancePostProcesses;
  151435. private _createHdrPostProcess;
  151436. private _createLensFlarePostProcess;
  151437. private _createDepthOfFieldPostProcess;
  151438. private _createMotionBlurPostProcess;
  151439. private _getDepthTexture;
  151440. private _disposePostProcesses;
  151441. /**
  151442. * Dispose of the pipeline and stop all post processes
  151443. */
  151444. dispose(): void;
  151445. /**
  151446. * Serialize the rendering pipeline (Used when exporting)
  151447. * @returns the serialized object
  151448. */
  151449. serialize(): any;
  151450. /**
  151451. * Parse the serialized pipeline
  151452. * @param source Source pipeline.
  151453. * @param scene The scene to load the pipeline to.
  151454. * @param rootUrl The URL of the serialized pipeline.
  151455. * @returns An instantiated pipeline from the serialized object.
  151456. */
  151457. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  151458. /**
  151459. * Luminance steps
  151460. */
  151461. static LuminanceSteps: number;
  151462. }
  151463. }
  151464. declare module BABYLON {
  151465. /** @hidden */
  151466. export var stereoscopicInterlacePixelShader: {
  151467. name: string;
  151468. shader: string;
  151469. };
  151470. }
  151471. declare module BABYLON {
  151472. /**
  151473. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  151474. */
  151475. export class StereoscopicInterlacePostProcessI extends PostProcess {
  151476. private _stepSize;
  151477. private _passedProcess;
  151478. /**
  151479. * Gets a string identifying the name of the class
  151480. * @returns "StereoscopicInterlacePostProcessI" string
  151481. */
  151482. getClassName(): string;
  151483. /**
  151484. * Initializes a StereoscopicInterlacePostProcessI
  151485. * @param name The name of the effect.
  151486. * @param rigCameras The rig cameras to be appled to the post process
  151487. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  151488. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  151489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151490. * @param engine The engine which the post process will be applied. (default: current engine)
  151491. * @param reusable If the post process can be reused on the same frame. (default: false)
  151492. */
  151493. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151494. }
  151495. /**
  151496. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  151497. */
  151498. export class StereoscopicInterlacePostProcess extends PostProcess {
  151499. private _stepSize;
  151500. private _passedProcess;
  151501. /**
  151502. * Gets a string identifying the name of the class
  151503. * @returns "StereoscopicInterlacePostProcess" string
  151504. */
  151505. getClassName(): string;
  151506. /**
  151507. * Initializes a StereoscopicInterlacePostProcess
  151508. * @param name The name of the effect.
  151509. * @param rigCameras The rig cameras to be appled to the post process
  151510. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  151511. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151512. * @param engine The engine which the post process will be applied. (default: current engine)
  151513. * @param reusable If the post process can be reused on the same frame. (default: false)
  151514. */
  151515. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151516. }
  151517. }
  151518. declare module BABYLON {
  151519. /** @hidden */
  151520. export var tonemapPixelShader: {
  151521. name: string;
  151522. shader: string;
  151523. };
  151524. }
  151525. declare module BABYLON {
  151526. /** Defines operator used for tonemapping */
  151527. export enum TonemappingOperator {
  151528. /** Hable */
  151529. Hable = 0,
  151530. /** Reinhard */
  151531. Reinhard = 1,
  151532. /** HejiDawson */
  151533. HejiDawson = 2,
  151534. /** Photographic */
  151535. Photographic = 3
  151536. }
  151537. /**
  151538. * Defines a post process to apply tone mapping
  151539. */
  151540. export class TonemapPostProcess extends PostProcess {
  151541. private _operator;
  151542. /** Defines the required exposure adjustement */
  151543. exposureAdjustment: number;
  151544. /**
  151545. * Gets a string identifying the name of the class
  151546. * @returns "TonemapPostProcess" string
  151547. */
  151548. getClassName(): string;
  151549. /**
  151550. * Creates a new TonemapPostProcess
  151551. * @param name defines the name of the postprocess
  151552. * @param _operator defines the operator to use
  151553. * @param exposureAdjustment defines the required exposure adjustement
  151554. * @param camera defines the camera to use (can be null)
  151555. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  151556. * @param engine defines the hosting engine (can be ignore if camera is set)
  151557. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  151558. */
  151559. constructor(name: string, _operator: TonemappingOperator,
  151560. /** Defines the required exposure adjustement */
  151561. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  151562. }
  151563. }
  151564. declare module BABYLON {
  151565. /** @hidden */
  151566. export var volumetricLightScatteringPixelShader: {
  151567. name: string;
  151568. shader: string;
  151569. };
  151570. }
  151571. declare module BABYLON {
  151572. /** @hidden */
  151573. export var volumetricLightScatteringPassVertexShader: {
  151574. name: string;
  151575. shader: string;
  151576. };
  151577. }
  151578. declare module BABYLON {
  151579. /** @hidden */
  151580. export var volumetricLightScatteringPassPixelShader: {
  151581. name: string;
  151582. shader: string;
  151583. };
  151584. }
  151585. declare module BABYLON {
  151586. /**
  151587. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  151588. */
  151589. export class VolumetricLightScatteringPostProcess extends PostProcess {
  151590. private _volumetricLightScatteringPass;
  151591. private _volumetricLightScatteringRTT;
  151592. private _viewPort;
  151593. private _screenCoordinates;
  151594. private _cachedDefines;
  151595. /**
  151596. * If not undefined, the mesh position is computed from the attached node position
  151597. */
  151598. attachedNode: {
  151599. position: Vector3;
  151600. };
  151601. /**
  151602. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  151603. */
  151604. customMeshPosition: Vector3;
  151605. /**
  151606. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  151607. */
  151608. useCustomMeshPosition: boolean;
  151609. /**
  151610. * If the post-process should inverse the light scattering direction
  151611. */
  151612. invert: boolean;
  151613. /**
  151614. * The internal mesh used by the post-process
  151615. */
  151616. mesh: Mesh;
  151617. /**
  151618. * @hidden
  151619. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  151620. */
  151621. get useDiffuseColor(): boolean;
  151622. set useDiffuseColor(useDiffuseColor: boolean);
  151623. /**
  151624. * Array containing the excluded meshes not rendered in the internal pass
  151625. */
  151626. excludedMeshes: AbstractMesh[];
  151627. /**
  151628. * Controls the overall intensity of the post-process
  151629. */
  151630. exposure: number;
  151631. /**
  151632. * Dissipates each sample's contribution in range [0, 1]
  151633. */
  151634. decay: number;
  151635. /**
  151636. * Controls the overall intensity of each sample
  151637. */
  151638. weight: number;
  151639. /**
  151640. * Controls the density of each sample
  151641. */
  151642. density: number;
  151643. /**
  151644. * @constructor
  151645. * @param name The post-process name
  151646. * @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)
  151647. * @param camera The camera that the post-process will be attached to
  151648. * @param mesh The mesh used to create the light scattering
  151649. * @param samples The post-process quality, default 100
  151650. * @param samplingModeThe post-process filtering mode
  151651. * @param engine The babylon engine
  151652. * @param reusable If the post-process is reusable
  151653. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  151654. */
  151655. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  151656. /**
  151657. * Returns the string "VolumetricLightScatteringPostProcess"
  151658. * @returns "VolumetricLightScatteringPostProcess"
  151659. */
  151660. getClassName(): string;
  151661. private _isReady;
  151662. /**
  151663. * Sets the new light position for light scattering effect
  151664. * @param position The new custom light position
  151665. */
  151666. setCustomMeshPosition(position: Vector3): void;
  151667. /**
  151668. * Returns the light position for light scattering effect
  151669. * @return Vector3 The custom light position
  151670. */
  151671. getCustomMeshPosition(): Vector3;
  151672. /**
  151673. * Disposes the internal assets and detaches the post-process from the camera
  151674. */
  151675. dispose(camera: Camera): void;
  151676. /**
  151677. * Returns the render target texture used by the post-process
  151678. * @return the render target texture used by the post-process
  151679. */
  151680. getPass(): RenderTargetTexture;
  151681. private _meshExcluded;
  151682. private _createPass;
  151683. private _updateMeshScreenCoordinates;
  151684. /**
  151685. * Creates a default mesh for the Volumeric Light Scattering post-process
  151686. * @param name The mesh name
  151687. * @param scene The scene where to create the mesh
  151688. * @return the default mesh
  151689. */
  151690. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  151691. }
  151692. }
  151693. declare module BABYLON {
  151694. /** @hidden */
  151695. export var screenSpaceCurvaturePixelShader: {
  151696. name: string;
  151697. shader: string;
  151698. };
  151699. }
  151700. declare module BABYLON {
  151701. /**
  151702. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  151703. */
  151704. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  151705. /**
  151706. * Defines how much ridge the curvature effect displays.
  151707. */
  151708. ridge: number;
  151709. /**
  151710. * Defines how much valley the curvature effect displays.
  151711. */
  151712. valley: number;
  151713. private _geometryBufferRenderer;
  151714. /**
  151715. * Gets a string identifying the name of the class
  151716. * @returns "ScreenSpaceCurvaturePostProcess" string
  151717. */
  151718. getClassName(): string;
  151719. /**
  151720. * Creates a new instance ScreenSpaceCurvaturePostProcess
  151721. * @param name The name of the effect.
  151722. * @param scene The scene containing the objects to blur according to their velocity.
  151723. * @param options The required width/height ratio to downsize to before computing the render pass.
  151724. * @param camera The camera to apply the render pass to.
  151725. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151726. * @param engine The engine which the post process will be applied. (default: current engine)
  151727. * @param reusable If the post process can be reused on the same frame. (default: false)
  151728. * @param textureType Type of textures used when performing the post process. (default: 0)
  151729. * @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)
  151730. */
  151731. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151732. /**
  151733. * Support test.
  151734. */
  151735. static get IsSupported(): boolean;
  151736. /** @hidden */
  151737. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  151738. }
  151739. }
  151740. declare module BABYLON {
  151741. interface Scene {
  151742. /** @hidden (Backing field) */
  151743. _boundingBoxRenderer: BoundingBoxRenderer;
  151744. /** @hidden (Backing field) */
  151745. _forceShowBoundingBoxes: boolean;
  151746. /**
  151747. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  151748. */
  151749. forceShowBoundingBoxes: boolean;
  151750. /**
  151751. * Gets the bounding box renderer associated with the scene
  151752. * @returns a BoundingBoxRenderer
  151753. */
  151754. getBoundingBoxRenderer(): BoundingBoxRenderer;
  151755. }
  151756. interface AbstractMesh {
  151757. /** @hidden (Backing field) */
  151758. _showBoundingBox: boolean;
  151759. /**
  151760. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  151761. */
  151762. showBoundingBox: boolean;
  151763. }
  151764. /**
  151765. * Component responsible of rendering the bounding box of the meshes in a scene.
  151766. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  151767. */
  151768. export class BoundingBoxRenderer implements ISceneComponent {
  151769. /**
  151770. * The component name helpfull to identify the component in the list of scene components.
  151771. */
  151772. readonly name: string;
  151773. /**
  151774. * The scene the component belongs to.
  151775. */
  151776. scene: Scene;
  151777. /**
  151778. * Color of the bounding box lines placed in front of an object
  151779. */
  151780. frontColor: Color3;
  151781. /**
  151782. * Color of the bounding box lines placed behind an object
  151783. */
  151784. backColor: Color3;
  151785. /**
  151786. * Defines if the renderer should show the back lines or not
  151787. */
  151788. showBackLines: boolean;
  151789. /**
  151790. * Observable raised before rendering a bounding box
  151791. */
  151792. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  151793. /**
  151794. * Observable raised after rendering a bounding box
  151795. */
  151796. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  151797. /**
  151798. * @hidden
  151799. */
  151800. renderList: SmartArray<BoundingBox>;
  151801. private _colorShader;
  151802. private _vertexBuffers;
  151803. private _indexBuffer;
  151804. private _fillIndexBuffer;
  151805. private _fillIndexData;
  151806. /**
  151807. * Instantiates a new bounding box renderer in a scene.
  151808. * @param scene the scene the renderer renders in
  151809. */
  151810. constructor(scene: Scene);
  151811. /**
  151812. * Registers the component in a given scene
  151813. */
  151814. register(): void;
  151815. private _evaluateSubMesh;
  151816. private _activeMesh;
  151817. private _prepareRessources;
  151818. private _createIndexBuffer;
  151819. /**
  151820. * Rebuilds the elements related to this component in case of
  151821. * context lost for instance.
  151822. */
  151823. rebuild(): void;
  151824. /**
  151825. * @hidden
  151826. */
  151827. reset(): void;
  151828. /**
  151829. * Render the bounding boxes of a specific rendering group
  151830. * @param renderingGroupId defines the rendering group to render
  151831. */
  151832. render(renderingGroupId: number): void;
  151833. /**
  151834. * In case of occlusion queries, we can render the occlusion bounding box through this method
  151835. * @param mesh Define the mesh to render the occlusion bounding box for
  151836. */
  151837. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  151838. /**
  151839. * Dispose and release the resources attached to this renderer.
  151840. */
  151841. dispose(): void;
  151842. }
  151843. }
  151844. declare module BABYLON {
  151845. interface Scene {
  151846. /** @hidden (Backing field) */
  151847. _depthRenderer: {
  151848. [id: string]: DepthRenderer;
  151849. };
  151850. /**
  151851. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  151852. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  151853. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  151854. * @returns the created depth renderer
  151855. */
  151856. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  151857. /**
  151858. * Disables a depth renderer for a given camera
  151859. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  151860. */
  151861. disableDepthRenderer(camera?: Nullable<Camera>): void;
  151862. }
  151863. /**
  151864. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  151865. * in several rendering techniques.
  151866. */
  151867. export class DepthRendererSceneComponent implements ISceneComponent {
  151868. /**
  151869. * The component name helpfull to identify the component in the list of scene components.
  151870. */
  151871. readonly name: string;
  151872. /**
  151873. * The scene the component belongs to.
  151874. */
  151875. scene: Scene;
  151876. /**
  151877. * Creates a new instance of the component for the given scene
  151878. * @param scene Defines the scene to register the component in
  151879. */
  151880. constructor(scene: Scene);
  151881. /**
  151882. * Registers the component in a given scene
  151883. */
  151884. register(): void;
  151885. /**
  151886. * Rebuilds the elements related to this component in case of
  151887. * context lost for instance.
  151888. */
  151889. rebuild(): void;
  151890. /**
  151891. * Disposes the component and the associated ressources
  151892. */
  151893. dispose(): void;
  151894. private _gatherRenderTargets;
  151895. private _gatherActiveCameraRenderTargets;
  151896. }
  151897. }
  151898. declare module BABYLON {
  151899. interface AbstractScene {
  151900. /** @hidden (Backing field) */
  151901. _prePassRenderer: Nullable<PrePassRenderer>;
  151902. /**
  151903. * Gets or Sets the current prepass renderer associated to the scene.
  151904. */
  151905. prePassRenderer: Nullable<PrePassRenderer>;
  151906. /**
  151907. * Enables the prepass and associates it with the scene
  151908. * @returns the PrePassRenderer
  151909. */
  151910. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  151911. /**
  151912. * Disables the prepass associated with the scene
  151913. */
  151914. disablePrePassRenderer(): void;
  151915. }
  151916. /**
  151917. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  151918. * in several rendering techniques.
  151919. */
  151920. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  151921. /**
  151922. * The component name helpful to identify the component in the list of scene components.
  151923. */
  151924. readonly name: string;
  151925. /**
  151926. * The scene the component belongs to.
  151927. */
  151928. scene: Scene;
  151929. /**
  151930. * Creates a new instance of the component for the given scene
  151931. * @param scene Defines the scene to register the component in
  151932. */
  151933. constructor(scene: Scene);
  151934. /**
  151935. * Registers the component in a given scene
  151936. */
  151937. register(): void;
  151938. private _beforeCameraDraw;
  151939. private _afterCameraDraw;
  151940. private _beforeClearStage;
  151941. /**
  151942. * Serializes the component data to the specified json object
  151943. * @param serializationObject The object to serialize to
  151944. */
  151945. serialize(serializationObject: any): void;
  151946. /**
  151947. * Adds all the elements from the container to the scene
  151948. * @param container the container holding the elements
  151949. */
  151950. addFromContainer(container: AbstractScene): void;
  151951. /**
  151952. * Removes all the elements in the container from the scene
  151953. * @param container contains the elements to remove
  151954. * @param dispose if the removed element should be disposed (default: false)
  151955. */
  151956. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  151957. /**
  151958. * Rebuilds the elements related to this component in case of
  151959. * context lost for instance.
  151960. */
  151961. rebuild(): void;
  151962. /**
  151963. * Disposes the component and the associated ressources
  151964. */
  151965. dispose(): void;
  151966. }
  151967. }
  151968. declare module BABYLON {
  151969. /** @hidden */
  151970. export var outlinePixelShader: {
  151971. name: string;
  151972. shader: string;
  151973. };
  151974. }
  151975. declare module BABYLON {
  151976. /** @hidden */
  151977. export var outlineVertexShader: {
  151978. name: string;
  151979. shader: string;
  151980. };
  151981. }
  151982. declare module BABYLON {
  151983. interface Scene {
  151984. /** @hidden */
  151985. _outlineRenderer: OutlineRenderer;
  151986. /**
  151987. * Gets the outline renderer associated with the scene
  151988. * @returns a OutlineRenderer
  151989. */
  151990. getOutlineRenderer(): OutlineRenderer;
  151991. }
  151992. interface AbstractMesh {
  151993. /** @hidden (Backing field) */
  151994. _renderOutline: boolean;
  151995. /**
  151996. * Gets or sets a boolean indicating if the outline must be rendered as well
  151997. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  151998. */
  151999. renderOutline: boolean;
  152000. /** @hidden (Backing field) */
  152001. _renderOverlay: boolean;
  152002. /**
  152003. * Gets or sets a boolean indicating if the overlay must be rendered as well
  152004. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  152005. */
  152006. renderOverlay: boolean;
  152007. }
  152008. /**
  152009. * This class is responsible to draw bothe outline/overlay of meshes.
  152010. * It should not be used directly but through the available method on mesh.
  152011. */
  152012. export class OutlineRenderer implements ISceneComponent {
  152013. /**
  152014. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  152015. */
  152016. private static _StencilReference;
  152017. /**
  152018. * The name of the component. Each component must have a unique name.
  152019. */
  152020. name: string;
  152021. /**
  152022. * The scene the component belongs to.
  152023. */
  152024. scene: Scene;
  152025. /**
  152026. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  152027. */
  152028. zOffset: number;
  152029. private _engine;
  152030. private _effect;
  152031. private _cachedDefines;
  152032. private _savedDepthWrite;
  152033. /**
  152034. * Instantiates a new outline renderer. (There could be only one per scene).
  152035. * @param scene Defines the scene it belongs to
  152036. */
  152037. constructor(scene: Scene);
  152038. /**
  152039. * Register the component to one instance of a scene.
  152040. */
  152041. register(): void;
  152042. /**
  152043. * Rebuilds the elements related to this component in case of
  152044. * context lost for instance.
  152045. */
  152046. rebuild(): void;
  152047. /**
  152048. * Disposes the component and the associated ressources.
  152049. */
  152050. dispose(): void;
  152051. /**
  152052. * Renders the outline in the canvas.
  152053. * @param subMesh Defines the sumesh to render
  152054. * @param batch Defines the batch of meshes in case of instances
  152055. * @param useOverlay Defines if the rendering is for the overlay or the outline
  152056. */
  152057. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  152058. /**
  152059. * Returns whether or not the outline renderer is ready for a given submesh.
  152060. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  152061. * @param subMesh Defines the submesh to check readyness for
  152062. * @param useInstances Defines wheter wee are trying to render instances or not
  152063. * @returns true if ready otherwise false
  152064. */
  152065. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  152066. private _beforeRenderingMesh;
  152067. private _afterRenderingMesh;
  152068. }
  152069. }
  152070. declare module BABYLON {
  152071. /**
  152072. * Defines the basic options interface of a Sprite Frame Source Size.
  152073. */
  152074. export interface ISpriteJSONSpriteSourceSize {
  152075. /**
  152076. * number of the original width of the Frame
  152077. */
  152078. w: number;
  152079. /**
  152080. * number of the original height of the Frame
  152081. */
  152082. h: number;
  152083. }
  152084. /**
  152085. * Defines the basic options interface of a Sprite Frame Data.
  152086. */
  152087. export interface ISpriteJSONSpriteFrameData {
  152088. /**
  152089. * number of the x offset of the Frame
  152090. */
  152091. x: number;
  152092. /**
  152093. * number of the y offset of the Frame
  152094. */
  152095. y: number;
  152096. /**
  152097. * number of the width of the Frame
  152098. */
  152099. w: number;
  152100. /**
  152101. * number of the height of the Frame
  152102. */
  152103. h: number;
  152104. }
  152105. /**
  152106. * Defines the basic options interface of a JSON Sprite.
  152107. */
  152108. export interface ISpriteJSONSprite {
  152109. /**
  152110. * string name of the Frame
  152111. */
  152112. filename: string;
  152113. /**
  152114. * ISpriteJSONSpriteFrame basic object of the frame data
  152115. */
  152116. frame: ISpriteJSONSpriteFrameData;
  152117. /**
  152118. * boolean to flag is the frame was rotated.
  152119. */
  152120. rotated: boolean;
  152121. /**
  152122. * boolean to flag is the frame was trimmed.
  152123. */
  152124. trimmed: boolean;
  152125. /**
  152126. * ISpriteJSONSpriteFrame basic object of the source data
  152127. */
  152128. spriteSourceSize: ISpriteJSONSpriteFrameData;
  152129. /**
  152130. * ISpriteJSONSpriteFrame basic object of the source data
  152131. */
  152132. sourceSize: ISpriteJSONSpriteSourceSize;
  152133. }
  152134. /**
  152135. * Defines the basic options interface of a JSON atlas.
  152136. */
  152137. export interface ISpriteJSONAtlas {
  152138. /**
  152139. * Array of objects that contain the frame data.
  152140. */
  152141. frames: Array<ISpriteJSONSprite>;
  152142. /**
  152143. * object basic object containing the sprite meta data.
  152144. */
  152145. meta?: object;
  152146. }
  152147. }
  152148. declare module BABYLON {
  152149. /** @hidden */
  152150. export var spriteMapPixelShader: {
  152151. name: string;
  152152. shader: string;
  152153. };
  152154. }
  152155. declare module BABYLON {
  152156. /** @hidden */
  152157. export var spriteMapVertexShader: {
  152158. name: string;
  152159. shader: string;
  152160. };
  152161. }
  152162. declare module BABYLON {
  152163. /**
  152164. * Defines the basic options interface of a SpriteMap
  152165. */
  152166. export interface ISpriteMapOptions {
  152167. /**
  152168. * Vector2 of the number of cells in the grid.
  152169. */
  152170. stageSize?: Vector2;
  152171. /**
  152172. * Vector2 of the size of the output plane in World Units.
  152173. */
  152174. outputSize?: Vector2;
  152175. /**
  152176. * Vector3 of the position of the output plane in World Units.
  152177. */
  152178. outputPosition?: Vector3;
  152179. /**
  152180. * Vector3 of the rotation of the output plane.
  152181. */
  152182. outputRotation?: Vector3;
  152183. /**
  152184. * number of layers that the system will reserve in resources.
  152185. */
  152186. layerCount?: number;
  152187. /**
  152188. * number of max animation frames a single cell will reserve in resources.
  152189. */
  152190. maxAnimationFrames?: number;
  152191. /**
  152192. * number cell index of the base tile when the system compiles.
  152193. */
  152194. baseTile?: number;
  152195. /**
  152196. * boolean flip the sprite after its been repositioned by the framing data.
  152197. */
  152198. flipU?: boolean;
  152199. /**
  152200. * Vector3 scalar of the global RGB values of the SpriteMap.
  152201. */
  152202. colorMultiply?: Vector3;
  152203. }
  152204. /**
  152205. * Defines the IDisposable interface in order to be cleanable from resources.
  152206. */
  152207. export interface ISpriteMap extends IDisposable {
  152208. /**
  152209. * String name of the SpriteMap.
  152210. */
  152211. name: string;
  152212. /**
  152213. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  152214. */
  152215. atlasJSON: ISpriteJSONAtlas;
  152216. /**
  152217. * Texture of the SpriteMap.
  152218. */
  152219. spriteSheet: Texture;
  152220. /**
  152221. * The parameters to initialize the SpriteMap with.
  152222. */
  152223. options: ISpriteMapOptions;
  152224. }
  152225. /**
  152226. * Class used to manage a grid restricted sprite deployment on an Output plane.
  152227. */
  152228. export class SpriteMap implements ISpriteMap {
  152229. /** The Name of the spriteMap */
  152230. name: string;
  152231. /** The JSON file with the frame and meta data */
  152232. atlasJSON: ISpriteJSONAtlas;
  152233. /** The systems Sprite Sheet Texture */
  152234. spriteSheet: Texture;
  152235. /** Arguments passed with the Constructor */
  152236. options: ISpriteMapOptions;
  152237. /** Public Sprite Storage array, parsed from atlasJSON */
  152238. sprites: Array<ISpriteJSONSprite>;
  152239. /** Returns the Number of Sprites in the System */
  152240. get spriteCount(): number;
  152241. /** Returns the Position of Output Plane*/
  152242. get position(): Vector3;
  152243. /** Returns the Position of Output Plane*/
  152244. set position(v: Vector3);
  152245. /** Returns the Rotation of Output Plane*/
  152246. get rotation(): Vector3;
  152247. /** Returns the Rotation of Output Plane*/
  152248. set rotation(v: Vector3);
  152249. /** Sets the AnimationMap*/
  152250. get animationMap(): RawTexture;
  152251. /** Sets the AnimationMap*/
  152252. set animationMap(v: RawTexture);
  152253. /** Scene that the SpriteMap was created in */
  152254. private _scene;
  152255. /** Texture Buffer of Float32 that holds tile frame data*/
  152256. private _frameMap;
  152257. /** Texture Buffers of Float32 that holds tileMap data*/
  152258. private _tileMaps;
  152259. /** Texture Buffer of Float32 that holds Animation Data*/
  152260. private _animationMap;
  152261. /** Custom ShaderMaterial Central to the System*/
  152262. private _material;
  152263. /** Custom ShaderMaterial Central to the System*/
  152264. private _output;
  152265. /** Systems Time Ticker*/
  152266. private _time;
  152267. /**
  152268. * Creates a new SpriteMap
  152269. * @param name defines the SpriteMaps Name
  152270. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  152271. * @param spriteSheet is the Texture that the Sprites are on.
  152272. * @param options a basic deployment configuration
  152273. * @param scene The Scene that the map is deployed on
  152274. */
  152275. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  152276. /**
  152277. * Returns tileID location
  152278. * @returns Vector2 the cell position ID
  152279. */
  152280. getTileID(): Vector2;
  152281. /**
  152282. * Gets the UV location of the mouse over the SpriteMap.
  152283. * @returns Vector2 the UV position of the mouse interaction
  152284. */
  152285. getMousePosition(): Vector2;
  152286. /**
  152287. * Creates the "frame" texture Buffer
  152288. * -------------------------------------
  152289. * Structure of frames
  152290. * "filename": "Falling-Water-2.png",
  152291. * "frame": {"x":69,"y":103,"w":24,"h":32},
  152292. * "rotated": true,
  152293. * "trimmed": true,
  152294. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  152295. * "sourceSize": {"w":32,"h":32}
  152296. * @returns RawTexture of the frameMap
  152297. */
  152298. private _createFrameBuffer;
  152299. /**
  152300. * Creates the tileMap texture Buffer
  152301. * @param buffer normally and array of numbers, or a false to generate from scratch
  152302. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  152303. * @returns RawTexture of the tileMap
  152304. */
  152305. private _createTileBuffer;
  152306. /**
  152307. * Modifies the data of the tileMaps
  152308. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  152309. * @param pos is the iVector2 Coordinates of the Tile
  152310. * @param tile The SpriteIndex of the new Tile
  152311. */
  152312. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  152313. /**
  152314. * Creates the animationMap texture Buffer
  152315. * @param buffer normally and array of numbers, or a false to generate from scratch
  152316. * @returns RawTexture of the animationMap
  152317. */
  152318. private _createTileAnimationBuffer;
  152319. /**
  152320. * Modifies the data of the animationMap
  152321. * @param cellID is the Index of the Sprite
  152322. * @param _frame is the target Animation frame
  152323. * @param toCell is the Target Index of the next frame of the animation
  152324. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  152325. * @param speed is a global scalar of the time variable on the map.
  152326. */
  152327. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  152328. /**
  152329. * Exports the .tilemaps file
  152330. */
  152331. saveTileMaps(): void;
  152332. /**
  152333. * Imports the .tilemaps file
  152334. * @param url of the .tilemaps file
  152335. */
  152336. loadTileMaps(url: string): void;
  152337. /**
  152338. * Release associated resources
  152339. */
  152340. dispose(): void;
  152341. }
  152342. }
  152343. declare module BABYLON {
  152344. /**
  152345. * Class used to manage multiple sprites of different sizes on the same spritesheet
  152346. * @see https://doc.babylonjs.com/babylon101/sprites
  152347. */
  152348. export class SpritePackedManager extends SpriteManager {
  152349. /** defines the packed manager's name */
  152350. name: string;
  152351. /**
  152352. * Creates a new sprite manager from a packed sprite sheet
  152353. * @param name defines the manager's name
  152354. * @param imgUrl defines the sprite sheet url
  152355. * @param capacity defines the maximum allowed number of sprites
  152356. * @param scene defines the hosting scene
  152357. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  152358. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  152359. * @param samplingMode defines the smapling mode to use with spritesheet
  152360. * @param fromPacked set to true; do not alter
  152361. */
  152362. constructor(
  152363. /** defines the packed manager's name */
  152364. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  152365. }
  152366. }
  152367. declare module BABYLON {
  152368. /**
  152369. * Defines the list of states available for a task inside a AssetsManager
  152370. */
  152371. export enum AssetTaskState {
  152372. /**
  152373. * Initialization
  152374. */
  152375. INIT = 0,
  152376. /**
  152377. * Running
  152378. */
  152379. RUNNING = 1,
  152380. /**
  152381. * Done
  152382. */
  152383. DONE = 2,
  152384. /**
  152385. * Error
  152386. */
  152387. ERROR = 3
  152388. }
  152389. /**
  152390. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  152391. */
  152392. export abstract class AbstractAssetTask {
  152393. /**
  152394. * Task name
  152395. */ name: string;
  152396. /**
  152397. * Callback called when the task is successful
  152398. */
  152399. onSuccess: (task: any) => void;
  152400. /**
  152401. * Callback called when the task is not successful
  152402. */
  152403. onError: (task: any, message?: string, exception?: any) => void;
  152404. /**
  152405. * Creates a new AssetsManager
  152406. * @param name defines the name of the task
  152407. */
  152408. constructor(
  152409. /**
  152410. * Task name
  152411. */ name: string);
  152412. private _isCompleted;
  152413. private _taskState;
  152414. private _errorObject;
  152415. /**
  152416. * Get if the task is completed
  152417. */
  152418. get isCompleted(): boolean;
  152419. /**
  152420. * Gets the current state of the task
  152421. */
  152422. get taskState(): AssetTaskState;
  152423. /**
  152424. * Gets the current error object (if task is in error)
  152425. */
  152426. get errorObject(): {
  152427. message?: string;
  152428. exception?: any;
  152429. };
  152430. /**
  152431. * Internal only
  152432. * @hidden
  152433. */
  152434. _setErrorObject(message?: string, exception?: any): void;
  152435. /**
  152436. * Execute the current task
  152437. * @param scene defines the scene where you want your assets to be loaded
  152438. * @param onSuccess is a callback called when the task is successfully executed
  152439. * @param onError is a callback called if an error occurs
  152440. */
  152441. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152442. /**
  152443. * Execute the current task
  152444. * @param scene defines the scene where you want your assets to be loaded
  152445. * @param onSuccess is a callback called when the task is successfully executed
  152446. * @param onError is a callback called if an error occurs
  152447. */
  152448. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152449. /**
  152450. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  152451. * This can be used with failed tasks that have the reason for failure fixed.
  152452. */
  152453. reset(): void;
  152454. private onErrorCallback;
  152455. private onDoneCallback;
  152456. }
  152457. /**
  152458. * Define the interface used by progress events raised during assets loading
  152459. */
  152460. export interface IAssetsProgressEvent {
  152461. /**
  152462. * Defines the number of remaining tasks to process
  152463. */
  152464. remainingCount: number;
  152465. /**
  152466. * Defines the total number of tasks
  152467. */
  152468. totalCount: number;
  152469. /**
  152470. * Defines the task that was just processed
  152471. */
  152472. task: AbstractAssetTask;
  152473. }
  152474. /**
  152475. * Class used to share progress information about assets loading
  152476. */
  152477. export class AssetsProgressEvent implements IAssetsProgressEvent {
  152478. /**
  152479. * Defines the number of remaining tasks to process
  152480. */
  152481. remainingCount: number;
  152482. /**
  152483. * Defines the total number of tasks
  152484. */
  152485. totalCount: number;
  152486. /**
  152487. * Defines the task that was just processed
  152488. */
  152489. task: AbstractAssetTask;
  152490. /**
  152491. * Creates a AssetsProgressEvent
  152492. * @param remainingCount defines the number of remaining tasks to process
  152493. * @param totalCount defines the total number of tasks
  152494. * @param task defines the task that was just processed
  152495. */
  152496. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  152497. }
  152498. /**
  152499. * Define a task used by AssetsManager to load assets into a container
  152500. */
  152501. export class ContainerAssetTask extends AbstractAssetTask {
  152502. /**
  152503. * Defines the name of the task
  152504. */
  152505. name: string;
  152506. /**
  152507. * Defines the list of mesh's names you want to load
  152508. */
  152509. meshesNames: any;
  152510. /**
  152511. * Defines the root url to use as a base to load your meshes and associated resources
  152512. */
  152513. rootUrl: string;
  152514. /**
  152515. * Defines the filename or File of the scene to load from
  152516. */
  152517. sceneFilename: string | File;
  152518. /**
  152519. * Get the loaded asset container
  152520. */
  152521. loadedContainer: AssetContainer;
  152522. /**
  152523. * Gets the list of loaded meshes
  152524. */
  152525. loadedMeshes: Array<AbstractMesh>;
  152526. /**
  152527. * Gets the list of loaded particle systems
  152528. */
  152529. loadedParticleSystems: Array<IParticleSystem>;
  152530. /**
  152531. * Gets the list of loaded skeletons
  152532. */
  152533. loadedSkeletons: Array<Skeleton>;
  152534. /**
  152535. * Gets the list of loaded animation groups
  152536. */
  152537. loadedAnimationGroups: Array<AnimationGroup>;
  152538. /**
  152539. * Callback called when the task is successful
  152540. */
  152541. onSuccess: (task: ContainerAssetTask) => void;
  152542. /**
  152543. * Callback called when the task is successful
  152544. */
  152545. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  152546. /**
  152547. * Creates a new ContainerAssetTask
  152548. * @param name defines the name of the task
  152549. * @param meshesNames defines the list of mesh's names you want to load
  152550. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  152551. * @param sceneFilename defines the filename or File of the scene to load from
  152552. */
  152553. constructor(
  152554. /**
  152555. * Defines the name of the task
  152556. */
  152557. name: string,
  152558. /**
  152559. * Defines the list of mesh's names you want to load
  152560. */
  152561. meshesNames: any,
  152562. /**
  152563. * Defines the root url to use as a base to load your meshes and associated resources
  152564. */
  152565. rootUrl: string,
  152566. /**
  152567. * Defines the filename or File of the scene to load from
  152568. */
  152569. sceneFilename: string | File);
  152570. /**
  152571. * Execute the current task
  152572. * @param scene defines the scene where you want your assets to be loaded
  152573. * @param onSuccess is a callback called when the task is successfully executed
  152574. * @param onError is a callback called if an error occurs
  152575. */
  152576. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152577. }
  152578. /**
  152579. * Define a task used by AssetsManager to load meshes
  152580. */
  152581. export class MeshAssetTask extends AbstractAssetTask {
  152582. /**
  152583. * Defines the name of the task
  152584. */
  152585. name: string;
  152586. /**
  152587. * Defines the list of mesh's names you want to load
  152588. */
  152589. meshesNames: any;
  152590. /**
  152591. * Defines the root url to use as a base to load your meshes and associated resources
  152592. */
  152593. rootUrl: string;
  152594. /**
  152595. * Defines the filename or File of the scene to load from
  152596. */
  152597. sceneFilename: string | File;
  152598. /**
  152599. * Gets the list of loaded meshes
  152600. */
  152601. loadedMeshes: Array<AbstractMesh>;
  152602. /**
  152603. * Gets the list of loaded particle systems
  152604. */
  152605. loadedParticleSystems: Array<IParticleSystem>;
  152606. /**
  152607. * Gets the list of loaded skeletons
  152608. */
  152609. loadedSkeletons: Array<Skeleton>;
  152610. /**
  152611. * Gets the list of loaded animation groups
  152612. */
  152613. loadedAnimationGroups: Array<AnimationGroup>;
  152614. /**
  152615. * Callback called when the task is successful
  152616. */
  152617. onSuccess: (task: MeshAssetTask) => void;
  152618. /**
  152619. * Callback called when the task is successful
  152620. */
  152621. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  152622. /**
  152623. * Creates a new MeshAssetTask
  152624. * @param name defines the name of the task
  152625. * @param meshesNames defines the list of mesh's names you want to load
  152626. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  152627. * @param sceneFilename defines the filename or File of the scene to load from
  152628. */
  152629. constructor(
  152630. /**
  152631. * Defines the name of the task
  152632. */
  152633. name: string,
  152634. /**
  152635. * Defines the list of mesh's names you want to load
  152636. */
  152637. meshesNames: any,
  152638. /**
  152639. * Defines the root url to use as a base to load your meshes and associated resources
  152640. */
  152641. rootUrl: string,
  152642. /**
  152643. * Defines the filename or File of the scene to load from
  152644. */
  152645. sceneFilename: string | File);
  152646. /**
  152647. * Execute the current task
  152648. * @param scene defines the scene where you want your assets to be loaded
  152649. * @param onSuccess is a callback called when the task is successfully executed
  152650. * @param onError is a callback called if an error occurs
  152651. */
  152652. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152653. }
  152654. /**
  152655. * Define a task used by AssetsManager to load text content
  152656. */
  152657. export class TextFileAssetTask extends AbstractAssetTask {
  152658. /**
  152659. * Defines the name of the task
  152660. */
  152661. name: string;
  152662. /**
  152663. * Defines the location of the file to load
  152664. */
  152665. url: string;
  152666. /**
  152667. * Gets the loaded text string
  152668. */
  152669. text: string;
  152670. /**
  152671. * Callback called when the task is successful
  152672. */
  152673. onSuccess: (task: TextFileAssetTask) => void;
  152674. /**
  152675. * Callback called when the task is successful
  152676. */
  152677. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  152678. /**
  152679. * Creates a new TextFileAssetTask object
  152680. * @param name defines the name of the task
  152681. * @param url defines the location of the file to load
  152682. */
  152683. constructor(
  152684. /**
  152685. * Defines the name of the task
  152686. */
  152687. name: string,
  152688. /**
  152689. * Defines the location of the file to load
  152690. */
  152691. url: string);
  152692. /**
  152693. * Execute the current task
  152694. * @param scene defines the scene where you want your assets to be loaded
  152695. * @param onSuccess is a callback called when the task is successfully executed
  152696. * @param onError is a callback called if an error occurs
  152697. */
  152698. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152699. }
  152700. /**
  152701. * Define a task used by AssetsManager to load binary data
  152702. */
  152703. export class BinaryFileAssetTask extends AbstractAssetTask {
  152704. /**
  152705. * Defines the name of the task
  152706. */
  152707. name: string;
  152708. /**
  152709. * Defines the location of the file to load
  152710. */
  152711. url: string;
  152712. /**
  152713. * Gets the lodaded data (as an array buffer)
  152714. */
  152715. data: ArrayBuffer;
  152716. /**
  152717. * Callback called when the task is successful
  152718. */
  152719. onSuccess: (task: BinaryFileAssetTask) => void;
  152720. /**
  152721. * Callback called when the task is successful
  152722. */
  152723. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  152724. /**
  152725. * Creates a new BinaryFileAssetTask object
  152726. * @param name defines the name of the new task
  152727. * @param url defines the location of the file to load
  152728. */
  152729. constructor(
  152730. /**
  152731. * Defines the name of the task
  152732. */
  152733. name: string,
  152734. /**
  152735. * Defines the location of the file to load
  152736. */
  152737. url: string);
  152738. /**
  152739. * Execute the current task
  152740. * @param scene defines the scene where you want your assets to be loaded
  152741. * @param onSuccess is a callback called when the task is successfully executed
  152742. * @param onError is a callback called if an error occurs
  152743. */
  152744. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152745. }
  152746. /**
  152747. * Define a task used by AssetsManager to load images
  152748. */
  152749. export class ImageAssetTask extends AbstractAssetTask {
  152750. /**
  152751. * Defines the name of the task
  152752. */
  152753. name: string;
  152754. /**
  152755. * Defines the location of the image to load
  152756. */
  152757. url: string;
  152758. /**
  152759. * Gets the loaded images
  152760. */
  152761. image: HTMLImageElement;
  152762. /**
  152763. * Callback called when the task is successful
  152764. */
  152765. onSuccess: (task: ImageAssetTask) => void;
  152766. /**
  152767. * Callback called when the task is successful
  152768. */
  152769. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  152770. /**
  152771. * Creates a new ImageAssetTask
  152772. * @param name defines the name of the task
  152773. * @param url defines the location of the image to load
  152774. */
  152775. constructor(
  152776. /**
  152777. * Defines the name of the task
  152778. */
  152779. name: string,
  152780. /**
  152781. * Defines the location of the image to load
  152782. */
  152783. url: string);
  152784. /**
  152785. * Execute the current task
  152786. * @param scene defines the scene where you want your assets to be loaded
  152787. * @param onSuccess is a callback called when the task is successfully executed
  152788. * @param onError is a callback called if an error occurs
  152789. */
  152790. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152791. }
  152792. /**
  152793. * Defines the interface used by texture loading tasks
  152794. */
  152795. export interface ITextureAssetTask<TEX extends BaseTexture> {
  152796. /**
  152797. * Gets the loaded texture
  152798. */
  152799. texture: TEX;
  152800. }
  152801. /**
  152802. * Define a task used by AssetsManager to load 2D textures
  152803. */
  152804. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  152805. /**
  152806. * Defines the name of the task
  152807. */
  152808. name: string;
  152809. /**
  152810. * Defines the location of the file to load
  152811. */
  152812. url: string;
  152813. /**
  152814. * Defines if mipmap should not be generated (default is false)
  152815. */
  152816. noMipmap?: boolean | undefined;
  152817. /**
  152818. * Defines if texture must be inverted on Y axis (default is true)
  152819. */
  152820. invertY: boolean;
  152821. /**
  152822. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152823. */
  152824. samplingMode: number;
  152825. /**
  152826. * Gets the loaded texture
  152827. */
  152828. texture: Texture;
  152829. /**
  152830. * Callback called when the task is successful
  152831. */
  152832. onSuccess: (task: TextureAssetTask) => void;
  152833. /**
  152834. * Callback called when the task is successful
  152835. */
  152836. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  152837. /**
  152838. * Creates a new TextureAssetTask object
  152839. * @param name defines the name of the task
  152840. * @param url defines the location of the file to load
  152841. * @param noMipmap defines if mipmap should not be generated (default is false)
  152842. * @param invertY defines if texture must be inverted on Y axis (default is true)
  152843. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152844. */
  152845. constructor(
  152846. /**
  152847. * Defines the name of the task
  152848. */
  152849. name: string,
  152850. /**
  152851. * Defines the location of the file to load
  152852. */
  152853. url: string,
  152854. /**
  152855. * Defines if mipmap should not be generated (default is false)
  152856. */
  152857. noMipmap?: boolean | undefined,
  152858. /**
  152859. * Defines if texture must be inverted on Y axis (default is true)
  152860. */
  152861. invertY?: boolean,
  152862. /**
  152863. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152864. */
  152865. samplingMode?: number);
  152866. /**
  152867. * Execute the current task
  152868. * @param scene defines the scene where you want your assets to be loaded
  152869. * @param onSuccess is a callback called when the task is successfully executed
  152870. * @param onError is a callback called if an error occurs
  152871. */
  152872. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152873. }
  152874. /**
  152875. * Define a task used by AssetsManager to load cube textures
  152876. */
  152877. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  152878. /**
  152879. * Defines the name of the task
  152880. */
  152881. name: string;
  152882. /**
  152883. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152884. */
  152885. url: string;
  152886. /**
  152887. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152888. */
  152889. extensions?: string[] | undefined;
  152890. /**
  152891. * Defines if mipmaps should not be generated (default is false)
  152892. */
  152893. noMipmap?: boolean | undefined;
  152894. /**
  152895. * Defines the explicit list of files (undefined by default)
  152896. */
  152897. files?: string[] | undefined;
  152898. /**
  152899. * Gets the loaded texture
  152900. */
  152901. texture: CubeTexture;
  152902. /**
  152903. * Callback called when the task is successful
  152904. */
  152905. onSuccess: (task: CubeTextureAssetTask) => void;
  152906. /**
  152907. * Callback called when the task is successful
  152908. */
  152909. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  152910. /**
  152911. * Creates a new CubeTextureAssetTask
  152912. * @param name defines the name of the task
  152913. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152914. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152915. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152916. * @param files defines the explicit list of files (undefined by default)
  152917. */
  152918. constructor(
  152919. /**
  152920. * Defines the name of the task
  152921. */
  152922. name: string,
  152923. /**
  152924. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152925. */
  152926. url: string,
  152927. /**
  152928. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152929. */
  152930. extensions?: string[] | undefined,
  152931. /**
  152932. * Defines if mipmaps should not be generated (default is false)
  152933. */
  152934. noMipmap?: boolean | undefined,
  152935. /**
  152936. * Defines the explicit list of files (undefined by default)
  152937. */
  152938. files?: string[] | undefined);
  152939. /**
  152940. * Execute the current task
  152941. * @param scene defines the scene where you want your assets to be loaded
  152942. * @param onSuccess is a callback called when the task is successfully executed
  152943. * @param onError is a callback called if an error occurs
  152944. */
  152945. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152946. }
  152947. /**
  152948. * Define a task used by AssetsManager to load HDR cube textures
  152949. */
  152950. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  152951. /**
  152952. * Defines the name of the task
  152953. */
  152954. name: string;
  152955. /**
  152956. * Defines the location of the file to load
  152957. */
  152958. url: string;
  152959. /**
  152960. * Defines the desired size (the more it increases the longer the generation will be)
  152961. */
  152962. size: number;
  152963. /**
  152964. * Defines if mipmaps should not be generated (default is false)
  152965. */
  152966. noMipmap: boolean;
  152967. /**
  152968. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152969. */
  152970. generateHarmonics: boolean;
  152971. /**
  152972. * 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)
  152973. */
  152974. gammaSpace: boolean;
  152975. /**
  152976. * Internal Use Only
  152977. */
  152978. reserved: boolean;
  152979. /**
  152980. * Gets the loaded texture
  152981. */
  152982. texture: HDRCubeTexture;
  152983. /**
  152984. * Callback called when the task is successful
  152985. */
  152986. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  152987. /**
  152988. * Callback called when the task is successful
  152989. */
  152990. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  152991. /**
  152992. * Creates a new HDRCubeTextureAssetTask object
  152993. * @param name defines the name of the task
  152994. * @param url defines the location of the file to load
  152995. * @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.
  152996. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152997. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152998. * @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)
  152999. * @param reserved Internal use only
  153000. */
  153001. constructor(
  153002. /**
  153003. * Defines the name of the task
  153004. */
  153005. name: string,
  153006. /**
  153007. * Defines the location of the file to load
  153008. */
  153009. url: string,
  153010. /**
  153011. * Defines the desired size (the more it increases the longer the generation will be)
  153012. */
  153013. size: number,
  153014. /**
  153015. * Defines if mipmaps should not be generated (default is false)
  153016. */
  153017. noMipmap?: boolean,
  153018. /**
  153019. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153020. */
  153021. generateHarmonics?: boolean,
  153022. /**
  153023. * 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)
  153024. */
  153025. gammaSpace?: boolean,
  153026. /**
  153027. * Internal Use Only
  153028. */
  153029. reserved?: boolean);
  153030. /**
  153031. * Execute the current task
  153032. * @param scene defines the scene where you want your assets to be loaded
  153033. * @param onSuccess is a callback called when the task is successfully executed
  153034. * @param onError is a callback called if an error occurs
  153035. */
  153036. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153037. }
  153038. /**
  153039. * Define a task used by AssetsManager to load Equirectangular cube textures
  153040. */
  153041. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  153042. /**
  153043. * Defines the name of the task
  153044. */
  153045. name: string;
  153046. /**
  153047. * Defines the location of the file to load
  153048. */
  153049. url: string;
  153050. /**
  153051. * Defines the desired size (the more it increases the longer the generation will be)
  153052. */
  153053. size: number;
  153054. /**
  153055. * Defines if mipmaps should not be generated (default is false)
  153056. */
  153057. noMipmap: boolean;
  153058. /**
  153059. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153060. * but the standard material would require them in Gamma space) (default is true)
  153061. */
  153062. gammaSpace: boolean;
  153063. /**
  153064. * Gets the loaded texture
  153065. */
  153066. texture: EquiRectangularCubeTexture;
  153067. /**
  153068. * Callback called when the task is successful
  153069. */
  153070. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  153071. /**
  153072. * Callback called when the task is successful
  153073. */
  153074. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  153075. /**
  153076. * Creates a new EquiRectangularCubeTextureAssetTask object
  153077. * @param name defines the name of the task
  153078. * @param url defines the location of the file to load
  153079. * @param size defines the desired size (the more it increases the longer the generation will be)
  153080. * If the size is omitted this implies you are using a preprocessed cubemap.
  153081. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153082. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  153083. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  153084. * (default is true)
  153085. */
  153086. constructor(
  153087. /**
  153088. * Defines the name of the task
  153089. */
  153090. name: string,
  153091. /**
  153092. * Defines the location of the file to load
  153093. */
  153094. url: string,
  153095. /**
  153096. * Defines the desired size (the more it increases the longer the generation will be)
  153097. */
  153098. size: number,
  153099. /**
  153100. * Defines if mipmaps should not be generated (default is false)
  153101. */
  153102. noMipmap?: boolean,
  153103. /**
  153104. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153105. * but the standard material would require them in Gamma space) (default is true)
  153106. */
  153107. gammaSpace?: boolean);
  153108. /**
  153109. * Execute the current task
  153110. * @param scene defines the scene where you want your assets to be loaded
  153111. * @param onSuccess is a callback called when the task is successfully executed
  153112. * @param onError is a callback called if an error occurs
  153113. */
  153114. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153115. }
  153116. /**
  153117. * This class can be used to easily import assets into a scene
  153118. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  153119. */
  153120. export class AssetsManager {
  153121. private _scene;
  153122. private _isLoading;
  153123. protected _tasks: AbstractAssetTask[];
  153124. protected _waitingTasksCount: number;
  153125. protected _totalTasksCount: number;
  153126. /**
  153127. * Callback called when all tasks are processed
  153128. */
  153129. onFinish: (tasks: AbstractAssetTask[]) => void;
  153130. /**
  153131. * Callback called when a task is successful
  153132. */
  153133. onTaskSuccess: (task: AbstractAssetTask) => void;
  153134. /**
  153135. * Callback called when a task had an error
  153136. */
  153137. onTaskError: (task: AbstractAssetTask) => void;
  153138. /**
  153139. * Callback called when a task is done (whatever the result is)
  153140. */
  153141. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  153142. /**
  153143. * Observable called when all tasks are processed
  153144. */
  153145. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  153146. /**
  153147. * Observable called when a task had an error
  153148. */
  153149. onTaskErrorObservable: Observable<AbstractAssetTask>;
  153150. /**
  153151. * Observable called when all tasks were executed
  153152. */
  153153. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  153154. /**
  153155. * Observable called when a task is done (whatever the result is)
  153156. */
  153157. onProgressObservable: Observable<IAssetsProgressEvent>;
  153158. /**
  153159. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  153160. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  153161. */
  153162. useDefaultLoadingScreen: boolean;
  153163. /**
  153164. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  153165. * when all assets have been downloaded.
  153166. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  153167. */
  153168. autoHideLoadingUI: boolean;
  153169. /**
  153170. * Creates a new AssetsManager
  153171. * @param scene defines the scene to work on
  153172. */
  153173. constructor(scene: Scene);
  153174. /**
  153175. * Add a ContainerAssetTask to the list of active tasks
  153176. * @param taskName defines the name of the new task
  153177. * @param meshesNames defines the name of meshes to load
  153178. * @param rootUrl defines the root url to use to locate files
  153179. * @param sceneFilename defines the filename of the scene file
  153180. * @returns a new ContainerAssetTask object
  153181. */
  153182. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  153183. /**
  153184. * Add a MeshAssetTask to the list of active tasks
  153185. * @param taskName defines the name of the new task
  153186. * @param meshesNames defines the name of meshes to load
  153187. * @param rootUrl defines the root url to use to locate files
  153188. * @param sceneFilename defines the filename of the scene file
  153189. * @returns a new MeshAssetTask object
  153190. */
  153191. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  153192. /**
  153193. * Add a TextFileAssetTask to the list of active tasks
  153194. * @param taskName defines the name of the new task
  153195. * @param url defines the url of the file to load
  153196. * @returns a new TextFileAssetTask object
  153197. */
  153198. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  153199. /**
  153200. * Add a BinaryFileAssetTask to the list of active tasks
  153201. * @param taskName defines the name of the new task
  153202. * @param url defines the url of the file to load
  153203. * @returns a new BinaryFileAssetTask object
  153204. */
  153205. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  153206. /**
  153207. * Add a ImageAssetTask to the list of active tasks
  153208. * @param taskName defines the name of the new task
  153209. * @param url defines the url of the file to load
  153210. * @returns a new ImageAssetTask object
  153211. */
  153212. addImageTask(taskName: string, url: string): ImageAssetTask;
  153213. /**
  153214. * Add a TextureAssetTask to the list of active tasks
  153215. * @param taskName defines the name of the new task
  153216. * @param url defines the url of the file to load
  153217. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153218. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  153219. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  153220. * @returns a new TextureAssetTask object
  153221. */
  153222. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  153223. /**
  153224. * Add a CubeTextureAssetTask to the list of active tasks
  153225. * @param taskName defines the name of the new task
  153226. * @param url defines the url of the file to load
  153227. * @param extensions defines the extension to use to load the cube map (can be null)
  153228. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153229. * @param files defines the list of files to load (can be null)
  153230. * @returns a new CubeTextureAssetTask object
  153231. */
  153232. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  153233. /**
  153234. *
  153235. * Add a HDRCubeTextureAssetTask to the list of active tasks
  153236. * @param taskName defines the name of the new task
  153237. * @param url defines the url of the file to load
  153238. * @param size defines the size you want for the cubemap (can be null)
  153239. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153240. * @param generateHarmonics defines if you want to automatically generate (true by default)
  153241. * @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)
  153242. * @param reserved Internal use only
  153243. * @returns a new HDRCubeTextureAssetTask object
  153244. */
  153245. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  153246. /**
  153247. *
  153248. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  153249. * @param taskName defines the name of the new task
  153250. * @param url defines the url of the file to load
  153251. * @param size defines the size you want for the cubemap (can be null)
  153252. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153253. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  153254. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  153255. * @returns a new EquiRectangularCubeTextureAssetTask object
  153256. */
  153257. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  153258. /**
  153259. * Remove a task from the assets manager.
  153260. * @param task the task to remove
  153261. */
  153262. removeTask(task: AbstractAssetTask): void;
  153263. private _decreaseWaitingTasksCount;
  153264. private _runTask;
  153265. /**
  153266. * Reset the AssetsManager and remove all tasks
  153267. * @return the current instance of the AssetsManager
  153268. */
  153269. reset(): AssetsManager;
  153270. /**
  153271. * Start the loading process
  153272. * @return the current instance of the AssetsManager
  153273. */
  153274. load(): AssetsManager;
  153275. /**
  153276. * Start the loading process as an async operation
  153277. * @return a promise returning the list of failed tasks
  153278. */
  153279. loadAsync(): Promise<void>;
  153280. }
  153281. }
  153282. declare module BABYLON {
  153283. /**
  153284. * Wrapper class for promise with external resolve and reject.
  153285. */
  153286. export class Deferred<T> {
  153287. /**
  153288. * The promise associated with this deferred object.
  153289. */
  153290. readonly promise: Promise<T>;
  153291. private _resolve;
  153292. private _reject;
  153293. /**
  153294. * The resolve method of the promise associated with this deferred object.
  153295. */
  153296. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  153297. /**
  153298. * The reject method of the promise associated with this deferred object.
  153299. */
  153300. get reject(): (reason?: any) => void;
  153301. /**
  153302. * Constructor for this deferred object.
  153303. */
  153304. constructor();
  153305. }
  153306. }
  153307. declare module BABYLON {
  153308. /**
  153309. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  153310. */
  153311. export class MeshExploder {
  153312. private _centerMesh;
  153313. private _meshes;
  153314. private _meshesOrigins;
  153315. private _toCenterVectors;
  153316. private _scaledDirection;
  153317. private _newPosition;
  153318. private _centerPosition;
  153319. /**
  153320. * Explodes meshes from a center mesh.
  153321. * @param meshes The meshes to explode.
  153322. * @param centerMesh The mesh to be center of explosion.
  153323. */
  153324. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  153325. private _setCenterMesh;
  153326. /**
  153327. * Get class name
  153328. * @returns "MeshExploder"
  153329. */
  153330. getClassName(): string;
  153331. /**
  153332. * "Exploded meshes"
  153333. * @returns Array of meshes with the centerMesh at index 0.
  153334. */
  153335. getMeshes(): Array<Mesh>;
  153336. /**
  153337. * Explodes meshes giving a specific direction
  153338. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  153339. */
  153340. explode(direction?: number): void;
  153341. }
  153342. }
  153343. declare module BABYLON {
  153344. /**
  153345. * Class used to help managing file picking and drag'n'drop
  153346. */
  153347. export class FilesInput {
  153348. /**
  153349. * List of files ready to be loaded
  153350. */
  153351. static get FilesToLoad(): {
  153352. [key: string]: File;
  153353. };
  153354. /**
  153355. * Callback called when a file is processed
  153356. */
  153357. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  153358. private _engine;
  153359. private _currentScene;
  153360. private _sceneLoadedCallback;
  153361. private _progressCallback;
  153362. private _additionalRenderLoopLogicCallback;
  153363. private _textureLoadingCallback;
  153364. private _startingProcessingFilesCallback;
  153365. private _onReloadCallback;
  153366. private _errorCallback;
  153367. private _elementToMonitor;
  153368. private _sceneFileToLoad;
  153369. private _filesToLoad;
  153370. /**
  153371. * Creates a new FilesInput
  153372. * @param engine defines the rendering engine
  153373. * @param scene defines the hosting scene
  153374. * @param sceneLoadedCallback callback called when scene is loaded
  153375. * @param progressCallback callback called to track progress
  153376. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  153377. * @param textureLoadingCallback callback called when a texture is loading
  153378. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  153379. * @param onReloadCallback callback called when a reload is requested
  153380. * @param errorCallback callback call if an error occurs
  153381. */
  153382. 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>);
  153383. private _dragEnterHandler;
  153384. private _dragOverHandler;
  153385. private _dropHandler;
  153386. /**
  153387. * Calls this function to listen to drag'n'drop events on a specific DOM element
  153388. * @param elementToMonitor defines the DOM element to track
  153389. */
  153390. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  153391. /** Gets the current list of files to load */
  153392. get filesToLoad(): File[];
  153393. /**
  153394. * Release all associated resources
  153395. */
  153396. dispose(): void;
  153397. private renderFunction;
  153398. private drag;
  153399. private drop;
  153400. private _traverseFolder;
  153401. private _processFiles;
  153402. /**
  153403. * Load files from a drop event
  153404. * @param event defines the drop event to use as source
  153405. */
  153406. loadFiles(event: any): void;
  153407. private _processReload;
  153408. /**
  153409. * Reload the current scene from the loaded files
  153410. */
  153411. reload(): void;
  153412. }
  153413. }
  153414. declare module BABYLON {
  153415. /**
  153416. * Defines the root class used to create scene optimization to use with SceneOptimizer
  153417. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153418. */
  153419. export class SceneOptimization {
  153420. /**
  153421. * Defines the priority of this optimization (0 by default which means first in the list)
  153422. */
  153423. priority: number;
  153424. /**
  153425. * Gets a string describing the action executed by the current optimization
  153426. * @returns description string
  153427. */
  153428. getDescription(): string;
  153429. /**
  153430. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153431. * @param scene defines the current scene where to apply this optimization
  153432. * @param optimizer defines the current optimizer
  153433. * @returns true if everything that can be done was applied
  153434. */
  153435. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153436. /**
  153437. * Creates the SceneOptimization object
  153438. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153439. * @param desc defines the description associated with the optimization
  153440. */
  153441. constructor(
  153442. /**
  153443. * Defines the priority of this optimization (0 by default which means first in the list)
  153444. */
  153445. priority?: number);
  153446. }
  153447. /**
  153448. * Defines an optimization used to reduce the size of render target textures
  153449. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153450. */
  153451. export class TextureOptimization extends SceneOptimization {
  153452. /**
  153453. * Defines the priority of this optimization (0 by default which means first in the list)
  153454. */
  153455. priority: number;
  153456. /**
  153457. * 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
  153458. */
  153459. maximumSize: number;
  153460. /**
  153461. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153462. */
  153463. step: number;
  153464. /**
  153465. * Gets a string describing the action executed by the current optimization
  153466. * @returns description string
  153467. */
  153468. getDescription(): string;
  153469. /**
  153470. * Creates the TextureOptimization object
  153471. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153472. * @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
  153473. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153474. */
  153475. constructor(
  153476. /**
  153477. * Defines the priority of this optimization (0 by default which means first in the list)
  153478. */
  153479. priority?: number,
  153480. /**
  153481. * 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
  153482. */
  153483. maximumSize?: number,
  153484. /**
  153485. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153486. */
  153487. step?: number);
  153488. /**
  153489. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153490. * @param scene defines the current scene where to apply this optimization
  153491. * @param optimizer defines the current optimizer
  153492. * @returns true if everything that can be done was applied
  153493. */
  153494. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153495. }
  153496. /**
  153497. * Defines an optimization used to increase or decrease the rendering resolution
  153498. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153499. */
  153500. export class HardwareScalingOptimization extends SceneOptimization {
  153501. /**
  153502. * Defines the priority of this optimization (0 by default which means first in the list)
  153503. */
  153504. priority: number;
  153505. /**
  153506. * Defines the maximum scale to use (2 by default)
  153507. */
  153508. maximumScale: number;
  153509. /**
  153510. * Defines the step to use between two passes (0.5 by default)
  153511. */
  153512. step: number;
  153513. private _currentScale;
  153514. private _directionOffset;
  153515. /**
  153516. * Gets a string describing the action executed by the current optimization
  153517. * @return description string
  153518. */
  153519. getDescription(): string;
  153520. /**
  153521. * Creates the HardwareScalingOptimization object
  153522. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153523. * @param maximumScale defines the maximum scale to use (2 by default)
  153524. * @param step defines the step to use between two passes (0.5 by default)
  153525. */
  153526. constructor(
  153527. /**
  153528. * Defines the priority of this optimization (0 by default which means first in the list)
  153529. */
  153530. priority?: number,
  153531. /**
  153532. * Defines the maximum scale to use (2 by default)
  153533. */
  153534. maximumScale?: number,
  153535. /**
  153536. * Defines the step to use between two passes (0.5 by default)
  153537. */
  153538. step?: number);
  153539. /**
  153540. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153541. * @param scene defines the current scene where to apply this optimization
  153542. * @param optimizer defines the current optimizer
  153543. * @returns true if everything that can be done was applied
  153544. */
  153545. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153546. }
  153547. /**
  153548. * Defines an optimization used to remove shadows
  153549. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153550. */
  153551. export class ShadowsOptimization extends SceneOptimization {
  153552. /**
  153553. * Gets a string describing the action executed by the current optimization
  153554. * @return description string
  153555. */
  153556. getDescription(): string;
  153557. /**
  153558. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153559. * @param scene defines the current scene where to apply this optimization
  153560. * @param optimizer defines the current optimizer
  153561. * @returns true if everything that can be done was applied
  153562. */
  153563. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153564. }
  153565. /**
  153566. * Defines an optimization used to turn post-processes off
  153567. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153568. */
  153569. export class PostProcessesOptimization extends SceneOptimization {
  153570. /**
  153571. * Gets a string describing the action executed by the current optimization
  153572. * @return description string
  153573. */
  153574. getDescription(): string;
  153575. /**
  153576. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153577. * @param scene defines the current scene where to apply this optimization
  153578. * @param optimizer defines the current optimizer
  153579. * @returns true if everything that can be done was applied
  153580. */
  153581. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153582. }
  153583. /**
  153584. * Defines an optimization used to turn lens flares off
  153585. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153586. */
  153587. export class LensFlaresOptimization extends SceneOptimization {
  153588. /**
  153589. * Gets a string describing the action executed by the current optimization
  153590. * @return description string
  153591. */
  153592. getDescription(): string;
  153593. /**
  153594. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153595. * @param scene defines the current scene where to apply this optimization
  153596. * @param optimizer defines the current optimizer
  153597. * @returns true if everything that can be done was applied
  153598. */
  153599. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153600. }
  153601. /**
  153602. * Defines an optimization based on user defined callback.
  153603. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153604. */
  153605. export class CustomOptimization extends SceneOptimization {
  153606. /**
  153607. * Callback called to apply the custom optimization.
  153608. */
  153609. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  153610. /**
  153611. * Callback called to get custom description
  153612. */
  153613. onGetDescription: () => string;
  153614. /**
  153615. * Gets a string describing the action executed by the current optimization
  153616. * @returns description string
  153617. */
  153618. getDescription(): string;
  153619. /**
  153620. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153621. * @param scene defines the current scene where to apply this optimization
  153622. * @param optimizer defines the current optimizer
  153623. * @returns true if everything that can be done was applied
  153624. */
  153625. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153626. }
  153627. /**
  153628. * Defines an optimization used to turn particles off
  153629. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153630. */
  153631. export class ParticlesOptimization extends SceneOptimization {
  153632. /**
  153633. * Gets a string describing the action executed by the current optimization
  153634. * @return description string
  153635. */
  153636. getDescription(): string;
  153637. /**
  153638. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153639. * @param scene defines the current scene where to apply this optimization
  153640. * @param optimizer defines the current optimizer
  153641. * @returns true if everything that can be done was applied
  153642. */
  153643. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153644. }
  153645. /**
  153646. * Defines an optimization used to turn render targets off
  153647. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153648. */
  153649. export class RenderTargetsOptimization extends SceneOptimization {
  153650. /**
  153651. * Gets a string describing the action executed by the current optimization
  153652. * @return description string
  153653. */
  153654. getDescription(): string;
  153655. /**
  153656. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153657. * @param scene defines the current scene where to apply this optimization
  153658. * @param optimizer defines the current optimizer
  153659. * @returns true if everything that can be done was applied
  153660. */
  153661. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153662. }
  153663. /**
  153664. * Defines an optimization used to merge meshes with compatible materials
  153665. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153666. */
  153667. export class MergeMeshesOptimization extends SceneOptimization {
  153668. private static _UpdateSelectionTree;
  153669. /**
  153670. * Gets or sets a boolean which defines if optimization octree has to be updated
  153671. */
  153672. static get UpdateSelectionTree(): boolean;
  153673. /**
  153674. * Gets or sets a boolean which defines if optimization octree has to be updated
  153675. */
  153676. static set UpdateSelectionTree(value: boolean);
  153677. /**
  153678. * Gets a string describing the action executed by the current optimization
  153679. * @return description string
  153680. */
  153681. getDescription(): string;
  153682. private _canBeMerged;
  153683. /**
  153684. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153685. * @param scene defines the current scene where to apply this optimization
  153686. * @param optimizer defines the current optimizer
  153687. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  153688. * @returns true if everything that can be done was applied
  153689. */
  153690. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  153691. }
  153692. /**
  153693. * Defines a list of options used by SceneOptimizer
  153694. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153695. */
  153696. export class SceneOptimizerOptions {
  153697. /**
  153698. * Defines the target frame rate to reach (60 by default)
  153699. */
  153700. targetFrameRate: number;
  153701. /**
  153702. * Defines the interval between two checkes (2000ms by default)
  153703. */
  153704. trackerDuration: number;
  153705. /**
  153706. * Gets the list of optimizations to apply
  153707. */
  153708. optimizations: SceneOptimization[];
  153709. /**
  153710. * Creates a new list of options used by SceneOptimizer
  153711. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  153712. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  153713. */
  153714. constructor(
  153715. /**
  153716. * Defines the target frame rate to reach (60 by default)
  153717. */
  153718. targetFrameRate?: number,
  153719. /**
  153720. * Defines the interval between two checkes (2000ms by default)
  153721. */
  153722. trackerDuration?: number);
  153723. /**
  153724. * Add a new optimization
  153725. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  153726. * @returns the current SceneOptimizerOptions
  153727. */
  153728. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  153729. /**
  153730. * Add a new custom optimization
  153731. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  153732. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  153733. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153734. * @returns the current SceneOptimizerOptions
  153735. */
  153736. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  153737. /**
  153738. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  153739. * @param targetFrameRate defines the target frame rate (60 by default)
  153740. * @returns a SceneOptimizerOptions object
  153741. */
  153742. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153743. /**
  153744. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  153745. * @param targetFrameRate defines the target frame rate (60 by default)
  153746. * @returns a SceneOptimizerOptions object
  153747. */
  153748. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153749. /**
  153750. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  153751. * @param targetFrameRate defines the target frame rate (60 by default)
  153752. * @returns a SceneOptimizerOptions object
  153753. */
  153754. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153755. }
  153756. /**
  153757. * Class used to run optimizations in order to reach a target frame rate
  153758. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153759. */
  153760. export class SceneOptimizer implements IDisposable {
  153761. private _isRunning;
  153762. private _options;
  153763. private _scene;
  153764. private _currentPriorityLevel;
  153765. private _targetFrameRate;
  153766. private _trackerDuration;
  153767. private _currentFrameRate;
  153768. private _sceneDisposeObserver;
  153769. private _improvementMode;
  153770. /**
  153771. * Defines an observable called when the optimizer reaches the target frame rate
  153772. */
  153773. onSuccessObservable: Observable<SceneOptimizer>;
  153774. /**
  153775. * Defines an observable called when the optimizer enables an optimization
  153776. */
  153777. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  153778. /**
  153779. * Defines an observable called when the optimizer is not able to reach the target frame rate
  153780. */
  153781. onFailureObservable: Observable<SceneOptimizer>;
  153782. /**
  153783. * Gets a boolean indicating if the optimizer is in improvement mode
  153784. */
  153785. get isInImprovementMode(): boolean;
  153786. /**
  153787. * Gets the current priority level (0 at start)
  153788. */
  153789. get currentPriorityLevel(): number;
  153790. /**
  153791. * Gets the current frame rate checked by the SceneOptimizer
  153792. */
  153793. get currentFrameRate(): number;
  153794. /**
  153795. * Gets or sets the current target frame rate (60 by default)
  153796. */
  153797. get targetFrameRate(): number;
  153798. /**
  153799. * Gets or sets the current target frame rate (60 by default)
  153800. */
  153801. set targetFrameRate(value: number);
  153802. /**
  153803. * Gets or sets the current interval between two checks (every 2000ms by default)
  153804. */
  153805. get trackerDuration(): number;
  153806. /**
  153807. * Gets or sets the current interval between two checks (every 2000ms by default)
  153808. */
  153809. set trackerDuration(value: number);
  153810. /**
  153811. * Gets the list of active optimizations
  153812. */
  153813. get optimizations(): SceneOptimization[];
  153814. /**
  153815. * Creates a new SceneOptimizer
  153816. * @param scene defines the scene to work on
  153817. * @param options defines the options to use with the SceneOptimizer
  153818. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  153819. * @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)
  153820. */
  153821. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  153822. /**
  153823. * Stops the current optimizer
  153824. */
  153825. stop(): void;
  153826. /**
  153827. * Reset the optimizer to initial step (current priority level = 0)
  153828. */
  153829. reset(): void;
  153830. /**
  153831. * Start the optimizer. By default it will try to reach a specific framerate
  153832. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  153833. */
  153834. start(): void;
  153835. private _checkCurrentState;
  153836. /**
  153837. * Release all resources
  153838. */
  153839. dispose(): void;
  153840. /**
  153841. * Helper function to create a SceneOptimizer with one single line of code
  153842. * @param scene defines the scene to work on
  153843. * @param options defines the options to use with the SceneOptimizer
  153844. * @param onSuccess defines a callback to call on success
  153845. * @param onFailure defines a callback to call on failure
  153846. * @returns the new SceneOptimizer object
  153847. */
  153848. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  153849. }
  153850. }
  153851. declare module BABYLON {
  153852. /**
  153853. * Class used to serialize a scene into a string
  153854. */
  153855. export class SceneSerializer {
  153856. /**
  153857. * Clear cache used by a previous serialization
  153858. */
  153859. static ClearCache(): void;
  153860. /**
  153861. * Serialize a scene into a JSON compatible object
  153862. * @param scene defines the scene to serialize
  153863. * @returns a JSON compatible object
  153864. */
  153865. static Serialize(scene: Scene): any;
  153866. /**
  153867. * Serialize a mesh into a JSON compatible object
  153868. * @param toSerialize defines the mesh to serialize
  153869. * @param withParents defines if parents must be serialized as well
  153870. * @param withChildren defines if children must be serialized as well
  153871. * @returns a JSON compatible object
  153872. */
  153873. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  153874. }
  153875. }
  153876. declare module BABYLON {
  153877. /**
  153878. * Class used to host texture specific utilities
  153879. */
  153880. export class TextureTools {
  153881. /**
  153882. * Uses the GPU to create a copy texture rescaled at a given size
  153883. * @param texture Texture to copy from
  153884. * @param width defines the desired width
  153885. * @param height defines the desired height
  153886. * @param useBilinearMode defines if bilinear mode has to be used
  153887. * @return the generated texture
  153888. */
  153889. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  153890. }
  153891. }
  153892. declare module BABYLON {
  153893. /**
  153894. * This represents the different options available for the video capture.
  153895. */
  153896. export interface VideoRecorderOptions {
  153897. /** Defines the mime type of the video. */
  153898. mimeType: string;
  153899. /** Defines the FPS the video should be recorded at. */
  153900. fps: number;
  153901. /** Defines the chunk size for the recording data. */
  153902. recordChunckSize: number;
  153903. /** The audio tracks to attach to the recording. */
  153904. audioTracks?: MediaStreamTrack[];
  153905. }
  153906. /**
  153907. * This can help with recording videos from BabylonJS.
  153908. * This is based on the available WebRTC functionalities of the browser.
  153909. *
  153910. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  153911. */
  153912. export class VideoRecorder {
  153913. private static readonly _defaultOptions;
  153914. /**
  153915. * Returns whether or not the VideoRecorder is available in your browser.
  153916. * @param engine Defines the Babylon Engine.
  153917. * @returns true if supported otherwise false.
  153918. */
  153919. static IsSupported(engine: Engine): boolean;
  153920. private readonly _options;
  153921. private _canvas;
  153922. private _mediaRecorder;
  153923. private _recordedChunks;
  153924. private _fileName;
  153925. private _resolve;
  153926. private _reject;
  153927. /**
  153928. * True when a recording is already in progress.
  153929. */
  153930. get isRecording(): boolean;
  153931. /**
  153932. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  153933. * @param engine Defines the BabylonJS Engine you wish to record.
  153934. * @param options Defines options that can be used to customize the capture.
  153935. */
  153936. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  153937. /**
  153938. * Stops the current recording before the default capture timeout passed in the startRecording function.
  153939. */
  153940. stopRecording(): void;
  153941. /**
  153942. * Starts recording the canvas for a max duration specified in parameters.
  153943. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  153944. * If null no automatic download will start and you can rely on the promise to get the data back.
  153945. * @param maxDuration Defines the maximum recording time in seconds.
  153946. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  153947. * @return A promise callback at the end of the recording with the video data in Blob.
  153948. */
  153949. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  153950. /**
  153951. * Releases internal resources used during the recording.
  153952. */
  153953. dispose(): void;
  153954. private _handleDataAvailable;
  153955. private _handleError;
  153956. private _handleStop;
  153957. }
  153958. }
  153959. declare module BABYLON {
  153960. /**
  153961. * Class containing a set of static utilities functions for screenshots
  153962. */
  153963. export class ScreenshotTools {
  153964. /**
  153965. * Captures a screenshot of the current rendering
  153966. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153967. * @param engine defines the rendering engine
  153968. * @param camera defines the source camera
  153969. * @param size This parameter can be set to a single number or to an object with the
  153970. * following (optional) properties: precision, width, height. If a single number is passed,
  153971. * it will be used for both width and height. If an object is passed, the screenshot size
  153972. * will be derived from the parameters. The precision property is a multiplier allowing
  153973. * rendering at a higher or lower resolution
  153974. * @param successCallback defines the callback receives a single parameter which contains the
  153975. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  153976. * src parameter of an <img> to display it
  153977. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  153978. * Check your browser for supported MIME types
  153979. */
  153980. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  153981. /**
  153982. * Captures a screenshot of the current rendering
  153983. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153984. * @param engine defines the rendering engine
  153985. * @param camera defines the source camera
  153986. * @param size This parameter can be set to a single number or to an object with the
  153987. * following (optional) properties: precision, width, height. If a single number is passed,
  153988. * it will be used for both width and height. If an object is passed, the screenshot size
  153989. * will be derived from the parameters. The precision property is a multiplier allowing
  153990. * rendering at a higher or lower resolution
  153991. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  153992. * Check your browser for supported MIME types
  153993. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  153994. * to the src parameter of an <img> to display it
  153995. */
  153996. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  153997. /**
  153998. * Generates an image screenshot from the specified camera.
  153999. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154000. * @param engine The engine to use for rendering
  154001. * @param camera The camera to use for rendering
  154002. * @param size This parameter can be set to a single number or to an object with the
  154003. * following (optional) properties: precision, width, height. If a single number is passed,
  154004. * it will be used for both width and height. If an object is passed, the screenshot size
  154005. * will be derived from the parameters. The precision property is a multiplier allowing
  154006. * rendering at a higher or lower resolution
  154007. * @param successCallback The callback receives a single parameter which contains the
  154008. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154009. * src parameter of an <img> to display it
  154010. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154011. * Check your browser for supported MIME types
  154012. * @param samples Texture samples (default: 1)
  154013. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154014. * @param fileName A name for for the downloaded file.
  154015. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154016. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  154017. */
  154018. 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;
  154019. /**
  154020. * Generates an image screenshot from the specified camera.
  154021. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154022. * @param engine The engine to use for rendering
  154023. * @param camera The camera to use for rendering
  154024. * @param size This parameter can be set to a single number or to an object with the
  154025. * following (optional) properties: precision, width, height. If a single number is passed,
  154026. * it will be used for both width and height. If an object is passed, the screenshot size
  154027. * will be derived from the parameters. The precision property is a multiplier allowing
  154028. * rendering at a higher or lower resolution
  154029. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154030. * Check your browser for supported MIME types
  154031. * @param samples Texture samples (default: 1)
  154032. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154033. * @param fileName A name for for the downloaded file.
  154034. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154035. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154036. * to the src parameter of an <img> to display it
  154037. */
  154038. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  154039. /**
  154040. * Gets height and width for screenshot size
  154041. * @private
  154042. */
  154043. private static _getScreenshotSize;
  154044. }
  154045. }
  154046. declare module BABYLON {
  154047. /**
  154048. * Interface for a data buffer
  154049. */
  154050. export interface IDataBuffer {
  154051. /**
  154052. * Reads bytes from the data buffer.
  154053. * @param byteOffset The byte offset to read
  154054. * @param byteLength The byte length to read
  154055. * @returns A promise that resolves when the bytes are read
  154056. */
  154057. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  154058. /**
  154059. * The byte length of the buffer.
  154060. */
  154061. readonly byteLength: number;
  154062. }
  154063. /**
  154064. * Utility class for reading from a data buffer
  154065. */
  154066. export class DataReader {
  154067. /**
  154068. * The data buffer associated with this data reader.
  154069. */
  154070. readonly buffer: IDataBuffer;
  154071. /**
  154072. * The current byte offset from the beginning of the data buffer.
  154073. */
  154074. byteOffset: number;
  154075. private _dataView;
  154076. private _dataByteOffset;
  154077. /**
  154078. * Constructor
  154079. * @param buffer The buffer to read
  154080. */
  154081. constructor(buffer: IDataBuffer);
  154082. /**
  154083. * Loads the given byte length.
  154084. * @param byteLength The byte length to load
  154085. * @returns A promise that resolves when the load is complete
  154086. */
  154087. loadAsync(byteLength: number): Promise<void>;
  154088. /**
  154089. * Read a unsigned 32-bit integer from the currently loaded data range.
  154090. * @returns The 32-bit integer read
  154091. */
  154092. readUint32(): number;
  154093. /**
  154094. * Read a byte array from the currently loaded data range.
  154095. * @param byteLength The byte length to read
  154096. * @returns The byte array read
  154097. */
  154098. readUint8Array(byteLength: number): Uint8Array;
  154099. /**
  154100. * Read a string from the currently loaded data range.
  154101. * @param byteLength The byte length to read
  154102. * @returns The string read
  154103. */
  154104. readString(byteLength: number): string;
  154105. /**
  154106. * Skips the given byte length the currently loaded data range.
  154107. * @param byteLength The byte length to skip
  154108. */
  154109. skipBytes(byteLength: number): void;
  154110. }
  154111. }
  154112. declare module BABYLON {
  154113. /**
  154114. * Class for storing data to local storage if available or in-memory storage otherwise
  154115. */
  154116. export class DataStorage {
  154117. private static _Storage;
  154118. private static _GetStorage;
  154119. /**
  154120. * Reads a string from the data storage
  154121. * @param key The key to read
  154122. * @param defaultValue The value if the key doesn't exist
  154123. * @returns The string value
  154124. */
  154125. static ReadString(key: string, defaultValue: string): string;
  154126. /**
  154127. * Writes a string to the data storage
  154128. * @param key The key to write
  154129. * @param value The value to write
  154130. */
  154131. static WriteString(key: string, value: string): void;
  154132. /**
  154133. * Reads a boolean from the data storage
  154134. * @param key The key to read
  154135. * @param defaultValue The value if the key doesn't exist
  154136. * @returns The boolean value
  154137. */
  154138. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  154139. /**
  154140. * Writes a boolean to the data storage
  154141. * @param key The key to write
  154142. * @param value The value to write
  154143. */
  154144. static WriteBoolean(key: string, value: boolean): void;
  154145. /**
  154146. * Reads a number from the data storage
  154147. * @param key The key to read
  154148. * @param defaultValue The value if the key doesn't exist
  154149. * @returns The number value
  154150. */
  154151. static ReadNumber(key: string, defaultValue: number): number;
  154152. /**
  154153. * Writes a number to the data storage
  154154. * @param key The key to write
  154155. * @param value The value to write
  154156. */
  154157. static WriteNumber(key: string, value: number): void;
  154158. }
  154159. }
  154160. declare module BABYLON {
  154161. /**
  154162. * Class used to record delta files between 2 scene states
  154163. */
  154164. export class SceneRecorder {
  154165. private _trackedScene;
  154166. private _savedJSON;
  154167. /**
  154168. * Track a given scene. This means the current scene state will be considered the original state
  154169. * @param scene defines the scene to track
  154170. */
  154171. track(scene: Scene): void;
  154172. /**
  154173. * Get the delta between current state and original state
  154174. * @returns a string containing the delta
  154175. */
  154176. getDelta(): any;
  154177. private _compareArray;
  154178. private _compareObjects;
  154179. private _compareCollections;
  154180. private static GetShadowGeneratorById;
  154181. /**
  154182. * Apply a given delta to a given scene
  154183. * @param deltaJSON defines the JSON containing the delta
  154184. * @param scene defines the scene to apply the delta to
  154185. */
  154186. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  154187. private static _ApplyPropertiesToEntity;
  154188. private static _ApplyDeltaForEntity;
  154189. }
  154190. }
  154191. declare module BABYLON {
  154192. /**
  154193. * An interface for all Hit test features
  154194. */
  154195. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  154196. /**
  154197. * Triggered when new babylon (transformed) hit test results are available
  154198. */
  154199. onHitTestResultObservable: Observable<T[]>;
  154200. }
  154201. /**
  154202. * Options used for hit testing
  154203. */
  154204. export interface IWebXRLegacyHitTestOptions {
  154205. /**
  154206. * Only test when user interacted with the scene. Default - hit test every frame
  154207. */
  154208. testOnPointerDownOnly?: boolean;
  154209. /**
  154210. * The node to use to transform the local results to world coordinates
  154211. */
  154212. worldParentNode?: TransformNode;
  154213. }
  154214. /**
  154215. * Interface defining the babylon result of raycasting/hit-test
  154216. */
  154217. export interface IWebXRLegacyHitResult {
  154218. /**
  154219. * Transformation matrix that can be applied to a node that will put it in the hit point location
  154220. */
  154221. transformationMatrix: Matrix;
  154222. /**
  154223. * The native hit test result
  154224. */
  154225. xrHitResult: XRHitResult | XRHitTestResult;
  154226. }
  154227. /**
  154228. * The currently-working hit-test module.
  154229. * Hit test (or Ray-casting) is used to interact with the real world.
  154230. * For further information read here - https://github.com/immersive-web/hit-test
  154231. */
  154232. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  154233. /**
  154234. * options to use when constructing this feature
  154235. */
  154236. readonly options: IWebXRLegacyHitTestOptions;
  154237. private _direction;
  154238. private _mat;
  154239. private _onSelectEnabled;
  154240. private _origin;
  154241. /**
  154242. * The module's name
  154243. */
  154244. static readonly Name: string;
  154245. /**
  154246. * The (Babylon) version of this module.
  154247. * This is an integer representing the implementation version.
  154248. * This number does not correspond to the WebXR specs version
  154249. */
  154250. static readonly Version: number;
  154251. /**
  154252. * Populated with the last native XR Hit Results
  154253. */
  154254. lastNativeXRHitResults: XRHitResult[];
  154255. /**
  154256. * Triggered when new babylon (transformed) hit test results are available
  154257. */
  154258. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  154259. /**
  154260. * Creates a new instance of the (legacy version) hit test feature
  154261. * @param _xrSessionManager an instance of WebXRSessionManager
  154262. * @param options options to use when constructing this feature
  154263. */
  154264. constructor(_xrSessionManager: WebXRSessionManager,
  154265. /**
  154266. * options to use when constructing this feature
  154267. */
  154268. options?: IWebXRLegacyHitTestOptions);
  154269. /**
  154270. * execute a hit test with an XR Ray
  154271. *
  154272. * @param xrSession a native xrSession that will execute this hit test
  154273. * @param xrRay the ray (position and direction) to use for ray-casting
  154274. * @param referenceSpace native XR reference space to use for the hit-test
  154275. * @param filter filter function that will filter the results
  154276. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  154277. */
  154278. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  154279. /**
  154280. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  154281. * @param event the (select) event to use to select with
  154282. * @param referenceSpace the reference space to use for this hit test
  154283. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  154284. */
  154285. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  154286. /**
  154287. * attach this feature
  154288. * Will usually be called by the features manager
  154289. *
  154290. * @returns true if successful.
  154291. */
  154292. attach(): boolean;
  154293. /**
  154294. * detach this feature.
  154295. * Will usually be called by the features manager
  154296. *
  154297. * @returns true if successful.
  154298. */
  154299. detach(): boolean;
  154300. /**
  154301. * Dispose this feature and all of the resources attached
  154302. */
  154303. dispose(): void;
  154304. protected _onXRFrame(frame: XRFrame): void;
  154305. private _onHitTestResults;
  154306. private _onSelect;
  154307. }
  154308. }
  154309. declare module BABYLON {
  154310. /**
  154311. * Options used for hit testing (version 2)
  154312. */
  154313. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  154314. /**
  154315. * Do not create a permanent hit test. Will usually be used when only
  154316. * transient inputs are needed.
  154317. */
  154318. disablePermanentHitTest?: boolean;
  154319. /**
  154320. * Enable transient (for example touch-based) hit test inspections
  154321. */
  154322. enableTransientHitTest?: boolean;
  154323. /**
  154324. * Offset ray for the permanent hit test
  154325. */
  154326. offsetRay?: Vector3;
  154327. /**
  154328. * Offset ray for the transient hit test
  154329. */
  154330. transientOffsetRay?: Vector3;
  154331. /**
  154332. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  154333. */
  154334. useReferenceSpace?: boolean;
  154335. /**
  154336. * Override the default entity type(s) of the hit-test result
  154337. */
  154338. entityTypes?: XRHitTestTrackableType[];
  154339. }
  154340. /**
  154341. * Interface defining the babylon result of hit-test
  154342. */
  154343. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  154344. /**
  154345. * The input source that generated this hit test (if transient)
  154346. */
  154347. inputSource?: XRInputSource;
  154348. /**
  154349. * Is this a transient hit test
  154350. */
  154351. isTransient?: boolean;
  154352. /**
  154353. * Position of the hit test result
  154354. */
  154355. position: Vector3;
  154356. /**
  154357. * Rotation of the hit test result
  154358. */
  154359. rotationQuaternion: Quaternion;
  154360. /**
  154361. * The native hit test result
  154362. */
  154363. xrHitResult: XRHitTestResult;
  154364. }
  154365. /**
  154366. * The currently-working hit-test module.
  154367. * Hit test (or Ray-casting) is used to interact with the real world.
  154368. * For further information read here - https://github.com/immersive-web/hit-test
  154369. *
  154370. * Tested on chrome (mobile) 80.
  154371. */
  154372. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  154373. /**
  154374. * options to use when constructing this feature
  154375. */
  154376. readonly options: IWebXRHitTestOptions;
  154377. private _tmpMat;
  154378. private _tmpPos;
  154379. private _tmpQuat;
  154380. private _transientXrHitTestSource;
  154381. private _xrHitTestSource;
  154382. private initHitTestSource;
  154383. /**
  154384. * The module's name
  154385. */
  154386. static readonly Name: string;
  154387. /**
  154388. * The (Babylon) version of this module.
  154389. * This is an integer representing the implementation version.
  154390. * This number does not correspond to the WebXR specs version
  154391. */
  154392. static readonly Version: number;
  154393. /**
  154394. * When set to true, each hit test will have its own position/rotation objects
  154395. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  154396. * the developers will clone them or copy them as they see fit.
  154397. */
  154398. autoCloneTransformation: boolean;
  154399. /**
  154400. * Triggered when new babylon (transformed) hit test results are available
  154401. * Note - this will be called when results come back from the device. It can be an empty array!!
  154402. */
  154403. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  154404. /**
  154405. * Use this to temporarily pause hit test checks.
  154406. */
  154407. paused: boolean;
  154408. /**
  154409. * Creates a new instance of the hit test feature
  154410. * @param _xrSessionManager an instance of WebXRSessionManager
  154411. * @param options options to use when constructing this feature
  154412. */
  154413. constructor(_xrSessionManager: WebXRSessionManager,
  154414. /**
  154415. * options to use when constructing this feature
  154416. */
  154417. options?: IWebXRHitTestOptions);
  154418. /**
  154419. * attach this feature
  154420. * Will usually be called by the features manager
  154421. *
  154422. * @returns true if successful.
  154423. */
  154424. attach(): boolean;
  154425. /**
  154426. * detach this feature.
  154427. * Will usually be called by the features manager
  154428. *
  154429. * @returns true if successful.
  154430. */
  154431. detach(): boolean;
  154432. /**
  154433. * Dispose this feature and all of the resources attached
  154434. */
  154435. dispose(): void;
  154436. protected _onXRFrame(frame: XRFrame): void;
  154437. private _processWebXRHitTestResult;
  154438. }
  154439. }
  154440. declare module BABYLON {
  154441. /**
  154442. * Configuration options of the anchor system
  154443. */
  154444. export interface IWebXRAnchorSystemOptions {
  154445. /**
  154446. * a node that will be used to convert local to world coordinates
  154447. */
  154448. worldParentNode?: TransformNode;
  154449. /**
  154450. * If set to true a reference of the created anchors will be kept until the next session starts
  154451. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  154452. */
  154453. doNotRemoveAnchorsOnSessionEnded?: boolean;
  154454. }
  154455. /**
  154456. * A babylon container for an XR Anchor
  154457. */
  154458. export interface IWebXRAnchor {
  154459. /**
  154460. * A babylon-assigned ID for this anchor
  154461. */
  154462. id: number;
  154463. /**
  154464. * Transformation matrix to apply to an object attached to this anchor
  154465. */
  154466. transformationMatrix: Matrix;
  154467. /**
  154468. * The native anchor object
  154469. */
  154470. xrAnchor: XRAnchor;
  154471. /**
  154472. * if defined, this object will be constantly updated by the anchor's position and rotation
  154473. */
  154474. attachedNode?: TransformNode;
  154475. }
  154476. /**
  154477. * An implementation of the anchor system for WebXR.
  154478. * For further information see https://github.com/immersive-web/anchors/
  154479. */
  154480. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  154481. private _options;
  154482. private _lastFrameDetected;
  154483. private _trackedAnchors;
  154484. private _referenceSpaceForFrameAnchors;
  154485. private _futureAnchors;
  154486. /**
  154487. * The module's name
  154488. */
  154489. static readonly Name: string;
  154490. /**
  154491. * The (Babylon) version of this module.
  154492. * This is an integer representing the implementation version.
  154493. * This number does not correspond to the WebXR specs version
  154494. */
  154495. static readonly Version: number;
  154496. /**
  154497. * Observers registered here will be executed when a new anchor was added to the session
  154498. */
  154499. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  154500. /**
  154501. * Observers registered here will be executed when an anchor was removed from the session
  154502. */
  154503. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  154504. /**
  154505. * Observers registered here will be executed when an existing anchor updates
  154506. * This can execute N times every frame
  154507. */
  154508. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  154509. /**
  154510. * Set the reference space to use for anchor creation, when not using a hit test.
  154511. * Will default to the session's reference space if not defined
  154512. */
  154513. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  154514. /**
  154515. * constructs a new anchor system
  154516. * @param _xrSessionManager an instance of WebXRSessionManager
  154517. * @param _options configuration object for this feature
  154518. */
  154519. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  154520. private _tmpVector;
  154521. private _tmpQuaternion;
  154522. private _populateTmpTransformation;
  154523. /**
  154524. * Create a new anchor point using a hit test result at a specific point in the scene
  154525. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  154526. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  154527. *
  154528. * @param hitTestResult The hit test result to use for this anchor creation
  154529. * @param position an optional position offset for this anchor
  154530. * @param rotationQuaternion an optional rotation offset for this anchor
  154531. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  154532. */
  154533. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  154534. /**
  154535. * Add a new anchor at a specific position and rotation
  154536. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  154537. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  154538. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  154539. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  154540. *
  154541. * @param position the position in which to add an anchor
  154542. * @param rotationQuaternion an optional rotation for the anchor transformation
  154543. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  154544. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  154545. */
  154546. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  154547. /**
  154548. * detach this feature.
  154549. * Will usually be called by the features manager
  154550. *
  154551. * @returns true if successful.
  154552. */
  154553. detach(): boolean;
  154554. /**
  154555. * Dispose this feature and all of the resources attached
  154556. */
  154557. dispose(): void;
  154558. protected _onXRFrame(frame: XRFrame): void;
  154559. /**
  154560. * avoiding using Array.find for global support.
  154561. * @param xrAnchor the plane to find in the array
  154562. */
  154563. private _findIndexInAnchorArray;
  154564. private _updateAnchorWithXRFrame;
  154565. private _createAnchorAtTransformation;
  154566. }
  154567. }
  154568. declare module BABYLON {
  154569. /**
  154570. * Options used in the plane detector module
  154571. */
  154572. export interface IWebXRPlaneDetectorOptions {
  154573. /**
  154574. * The node to use to transform the local results to world coordinates
  154575. */
  154576. worldParentNode?: TransformNode;
  154577. /**
  154578. * If set to true a reference of the created planes will be kept until the next session starts
  154579. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  154580. */
  154581. doNotRemovePlanesOnSessionEnded?: boolean;
  154582. }
  154583. /**
  154584. * A babylon interface for a WebXR plane.
  154585. * A Plane is actually a polygon, built from N points in space
  154586. *
  154587. * Supported in chrome 79, not supported in canary 81 ATM
  154588. */
  154589. export interface IWebXRPlane {
  154590. /**
  154591. * a babylon-assigned ID for this polygon
  154592. */
  154593. id: number;
  154594. /**
  154595. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  154596. */
  154597. polygonDefinition: Array<Vector3>;
  154598. /**
  154599. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  154600. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  154601. */
  154602. transformationMatrix: Matrix;
  154603. /**
  154604. * the native xr-plane object
  154605. */
  154606. xrPlane: XRPlane;
  154607. }
  154608. /**
  154609. * The plane detector is used to detect planes in the real world when in AR
  154610. * For more information see https://github.com/immersive-web/real-world-geometry/
  154611. */
  154612. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  154613. private _options;
  154614. private _detectedPlanes;
  154615. private _enabled;
  154616. private _lastFrameDetected;
  154617. /**
  154618. * The module's name
  154619. */
  154620. static readonly Name: string;
  154621. /**
  154622. * The (Babylon) version of this module.
  154623. * This is an integer representing the implementation version.
  154624. * This number does not correspond to the WebXR specs version
  154625. */
  154626. static readonly Version: number;
  154627. /**
  154628. * Observers registered here will be executed when a new plane was added to the session
  154629. */
  154630. onPlaneAddedObservable: Observable<IWebXRPlane>;
  154631. /**
  154632. * Observers registered here will be executed when a plane is no longer detected in the session
  154633. */
  154634. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  154635. /**
  154636. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  154637. * This can execute N times every frame
  154638. */
  154639. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  154640. /**
  154641. * construct a new Plane Detector
  154642. * @param _xrSessionManager an instance of xr Session manager
  154643. * @param _options configuration to use when constructing this feature
  154644. */
  154645. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  154646. /**
  154647. * detach this feature.
  154648. * Will usually be called by the features manager
  154649. *
  154650. * @returns true if successful.
  154651. */
  154652. detach(): boolean;
  154653. /**
  154654. * Dispose this feature and all of the resources attached
  154655. */
  154656. dispose(): void;
  154657. protected _onXRFrame(frame: XRFrame): void;
  154658. private _init;
  154659. private _updatePlaneWithXRPlane;
  154660. /**
  154661. * avoiding using Array.find for global support.
  154662. * @param xrPlane the plane to find in the array
  154663. */
  154664. private findIndexInPlaneArray;
  154665. }
  154666. }
  154667. declare module BABYLON {
  154668. /**
  154669. * Options interface for the background remover plugin
  154670. */
  154671. export interface IWebXRBackgroundRemoverOptions {
  154672. /**
  154673. * Further background meshes to disable when entering AR
  154674. */
  154675. backgroundMeshes?: AbstractMesh[];
  154676. /**
  154677. * flags to configure the removal of the environment helper.
  154678. * If not set, the entire background will be removed. If set, flags should be set as well.
  154679. */
  154680. environmentHelperRemovalFlags?: {
  154681. /**
  154682. * Should the skybox be removed (default false)
  154683. */
  154684. skyBox?: boolean;
  154685. /**
  154686. * Should the ground be removed (default false)
  154687. */
  154688. ground?: boolean;
  154689. };
  154690. /**
  154691. * don't disable the environment helper
  154692. */
  154693. ignoreEnvironmentHelper?: boolean;
  154694. }
  154695. /**
  154696. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  154697. */
  154698. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  154699. /**
  154700. * read-only options to be used in this module
  154701. */
  154702. readonly options: IWebXRBackgroundRemoverOptions;
  154703. /**
  154704. * The module's name
  154705. */
  154706. static readonly Name: string;
  154707. /**
  154708. * The (Babylon) version of this module.
  154709. * This is an integer representing the implementation version.
  154710. * This number does not correspond to the WebXR specs version
  154711. */
  154712. static readonly Version: number;
  154713. /**
  154714. * registered observers will be triggered when the background state changes
  154715. */
  154716. onBackgroundStateChangedObservable: Observable<boolean>;
  154717. /**
  154718. * constructs a new background remover module
  154719. * @param _xrSessionManager the session manager for this module
  154720. * @param options read-only options to be used in this module
  154721. */
  154722. constructor(_xrSessionManager: WebXRSessionManager,
  154723. /**
  154724. * read-only options to be used in this module
  154725. */
  154726. options?: IWebXRBackgroundRemoverOptions);
  154727. /**
  154728. * attach this feature
  154729. * Will usually be called by the features manager
  154730. *
  154731. * @returns true if successful.
  154732. */
  154733. attach(): boolean;
  154734. /**
  154735. * detach this feature.
  154736. * Will usually be called by the features manager
  154737. *
  154738. * @returns true if successful.
  154739. */
  154740. detach(): boolean;
  154741. /**
  154742. * Dispose this feature and all of the resources attached
  154743. */
  154744. dispose(): void;
  154745. protected _onXRFrame(_xrFrame: XRFrame): void;
  154746. private _setBackgroundState;
  154747. }
  154748. }
  154749. declare module BABYLON {
  154750. /**
  154751. * Options for the controller physics feature
  154752. */
  154753. export class IWebXRControllerPhysicsOptions {
  154754. /**
  154755. * Should the headset get its own impostor
  154756. */
  154757. enableHeadsetImpostor?: boolean;
  154758. /**
  154759. * Optional parameters for the headset impostor
  154760. */
  154761. headsetImpostorParams?: {
  154762. /**
  154763. * The type of impostor to create. Default is sphere
  154764. */
  154765. impostorType: number;
  154766. /**
  154767. * the size of the impostor. Defaults to 10cm
  154768. */
  154769. impostorSize?: number | {
  154770. width: number;
  154771. height: number;
  154772. depth: number;
  154773. };
  154774. /**
  154775. * Friction definitions
  154776. */
  154777. friction?: number;
  154778. /**
  154779. * Restitution
  154780. */
  154781. restitution?: number;
  154782. };
  154783. /**
  154784. * The physics properties of the future impostors
  154785. */
  154786. physicsProperties?: {
  154787. /**
  154788. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  154789. * Note that this requires a physics engine that supports mesh impostors!
  154790. */
  154791. useControllerMesh?: boolean;
  154792. /**
  154793. * The type of impostor to create. Default is sphere
  154794. */
  154795. impostorType?: number;
  154796. /**
  154797. * the size of the impostor. Defaults to 10cm
  154798. */
  154799. impostorSize?: number | {
  154800. width: number;
  154801. height: number;
  154802. depth: number;
  154803. };
  154804. /**
  154805. * Friction definitions
  154806. */
  154807. friction?: number;
  154808. /**
  154809. * Restitution
  154810. */
  154811. restitution?: number;
  154812. };
  154813. /**
  154814. * the xr input to use with this pointer selection
  154815. */
  154816. xrInput: WebXRInput;
  154817. }
  154818. /**
  154819. * Add physics impostor to your webxr controllers,
  154820. * including naive calculation of their linear and angular velocity
  154821. */
  154822. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  154823. private readonly _options;
  154824. private _attachController;
  154825. private _controllers;
  154826. private _debugMode;
  154827. private _delta;
  154828. private _headsetImpostor?;
  154829. private _headsetMesh?;
  154830. private _lastTimestamp;
  154831. private _tmpQuaternion;
  154832. private _tmpVector;
  154833. /**
  154834. * The module's name
  154835. */
  154836. static readonly Name: string;
  154837. /**
  154838. * The (Babylon) version of this module.
  154839. * This is an integer representing the implementation version.
  154840. * This number does not correspond to the webxr specs version
  154841. */
  154842. static readonly Version: number;
  154843. /**
  154844. * Construct a new Controller Physics Feature
  154845. * @param _xrSessionManager the corresponding xr session manager
  154846. * @param _options options to create this feature with
  154847. */
  154848. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  154849. /**
  154850. * @hidden
  154851. * enable debugging - will show console outputs and the impostor mesh
  154852. */
  154853. _enablePhysicsDebug(): void;
  154854. /**
  154855. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  154856. * @param xrController the controller to add
  154857. */
  154858. addController(xrController: WebXRInputSource): void;
  154859. /**
  154860. * attach this feature
  154861. * Will usually be called by the features manager
  154862. *
  154863. * @returns true if successful.
  154864. */
  154865. attach(): boolean;
  154866. /**
  154867. * detach this feature.
  154868. * Will usually be called by the features manager
  154869. *
  154870. * @returns true if successful.
  154871. */
  154872. detach(): boolean;
  154873. /**
  154874. * Get the headset impostor, if enabled
  154875. * @returns the impostor
  154876. */
  154877. getHeadsetImpostor(): PhysicsImpostor | undefined;
  154878. /**
  154879. * Get the physics impostor of a specific controller.
  154880. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  154881. * @param controller the controller or the controller id of which to get the impostor
  154882. * @returns the impostor or null
  154883. */
  154884. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  154885. /**
  154886. * Update the physics properties provided in the constructor
  154887. * @param newProperties the new properties object
  154888. */
  154889. setPhysicsProperties(newProperties: {
  154890. impostorType?: number;
  154891. impostorSize?: number | {
  154892. width: number;
  154893. height: number;
  154894. depth: number;
  154895. };
  154896. friction?: number;
  154897. restitution?: number;
  154898. }): void;
  154899. protected _onXRFrame(_xrFrame: any): void;
  154900. private _detachController;
  154901. }
  154902. }
  154903. declare module BABYLON {
  154904. /**
  154905. * A babylon interface for a "WebXR" feature point.
  154906. * Represents the position and confidence value of a given feature point.
  154907. */
  154908. export interface IWebXRFeaturePoint {
  154909. /**
  154910. * Represents the position of the feature point in world space.
  154911. */
  154912. position: Vector3;
  154913. /**
  154914. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  154915. */
  154916. confidenceValue: number;
  154917. }
  154918. /**
  154919. * The feature point system is used to detect feature points from real world geometry.
  154920. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  154921. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  154922. */
  154923. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  154924. private _enabled;
  154925. private _featurePointCloud;
  154926. /**
  154927. * The module's name
  154928. */
  154929. static readonly Name: string;
  154930. /**
  154931. * The (Babylon) version of this module.
  154932. * This is an integer representing the implementation version.
  154933. * This number does not correspond to the WebXR specs version
  154934. */
  154935. static readonly Version: number;
  154936. /**
  154937. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  154938. * Will notify the observers about which feature points have been added.
  154939. */
  154940. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  154941. /**
  154942. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  154943. * Will notify the observers about which feature points have been updated.
  154944. */
  154945. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  154946. /**
  154947. * The current feature point cloud maintained across frames.
  154948. */
  154949. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  154950. /**
  154951. * construct the feature point system
  154952. * @param _xrSessionManager an instance of xr Session manager
  154953. */
  154954. constructor(_xrSessionManager: WebXRSessionManager);
  154955. /**
  154956. * Detach this feature.
  154957. * Will usually be called by the features manager
  154958. *
  154959. * @returns true if successful.
  154960. */
  154961. detach(): boolean;
  154962. /**
  154963. * Dispose this feature and all of the resources attached
  154964. */
  154965. dispose(): void;
  154966. /**
  154967. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  154968. */
  154969. protected _onXRFrame(frame: XRFrame): void;
  154970. /**
  154971. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  154972. */
  154973. private _init;
  154974. }
  154975. }
  154976. declare module BABYLON {
  154977. /**
  154978. * Configuration interface for the hand tracking feature
  154979. */
  154980. export interface IWebXRHandTrackingOptions {
  154981. /**
  154982. * The xrInput that will be used as source for new hands
  154983. */
  154984. xrInput: WebXRInput;
  154985. /**
  154986. * Configuration object for the joint meshes
  154987. */
  154988. jointMeshes?: {
  154989. /**
  154990. * Should the meshes created be invisible (defaults to false)
  154991. */
  154992. invisible?: boolean;
  154993. /**
  154994. * A source mesh to be used to create instances. Defaults to a sphere.
  154995. * This mesh will be the source for all other (25) meshes.
  154996. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  154997. */
  154998. sourceMesh?: Mesh;
  154999. /**
  155000. * Should the source mesh stay visible. Defaults to false
  155001. */
  155002. keepOriginalVisible?: boolean;
  155003. /**
  155004. * Scale factor for all instances (defaults to 2)
  155005. */
  155006. scaleFactor?: number;
  155007. /**
  155008. * Should each instance have its own physics impostor
  155009. */
  155010. enablePhysics?: boolean;
  155011. /**
  155012. * If enabled, override default physics properties
  155013. */
  155014. physicsProps?: {
  155015. friction?: number;
  155016. restitution?: number;
  155017. impostorType?: number;
  155018. };
  155019. /**
  155020. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  155021. */
  155022. handMesh?: AbstractMesh;
  155023. };
  155024. }
  155025. /**
  155026. * Parts of the hands divided to writs and finger names
  155027. */
  155028. export const enum HandPart {
  155029. /**
  155030. * HandPart - Wrist
  155031. */
  155032. WRIST = "wrist",
  155033. /**
  155034. * HandPart - The THumb
  155035. */
  155036. THUMB = "thumb",
  155037. /**
  155038. * HandPart - Index finger
  155039. */
  155040. INDEX = "index",
  155041. /**
  155042. * HandPart - Middle finger
  155043. */
  155044. MIDDLE = "middle",
  155045. /**
  155046. * HandPart - Ring finger
  155047. */
  155048. RING = "ring",
  155049. /**
  155050. * HandPart - Little finger
  155051. */
  155052. LITTLE = "little"
  155053. }
  155054. /**
  155055. * Representing a single hand (with its corresponding native XRHand object)
  155056. */
  155057. export class WebXRHand implements IDisposable {
  155058. /** the controller to which the hand correlates */
  155059. readonly xrController: WebXRInputSource;
  155060. /** the meshes to be used to track the hand joints */
  155061. readonly trackedMeshes: AbstractMesh[];
  155062. /**
  155063. * Hand-parts definition (key is HandPart)
  155064. */
  155065. handPartsDefinition: {
  155066. [key: string]: number[];
  155067. };
  155068. /**
  155069. * Populate the HandPartsDefinition object.
  155070. * This is called as a side effect since certain browsers don't have XRHand defined.
  155071. */
  155072. private generateHandPartsDefinition;
  155073. /**
  155074. * Construct a new hand object
  155075. * @param xrController the controller to which the hand correlates
  155076. * @param trackedMeshes the meshes to be used to track the hand joints
  155077. */
  155078. constructor(
  155079. /** the controller to which the hand correlates */
  155080. xrController: WebXRInputSource,
  155081. /** the meshes to be used to track the hand joints */
  155082. trackedMeshes: AbstractMesh[]);
  155083. /**
  155084. * Update this hand from the latest xr frame
  155085. * @param xrFrame xrFrame to update from
  155086. * @param referenceSpace The current viewer reference space
  155087. * @param scaleFactor optional scale factor for the meshes
  155088. */
  155089. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  155090. /**
  155091. * Get meshes of part of the hand
  155092. * @param part the part of hand to get
  155093. * @returns An array of meshes that correlate to the hand part requested
  155094. */
  155095. getHandPartMeshes(part: HandPart): AbstractMesh[];
  155096. /**
  155097. * Dispose this Hand object
  155098. */
  155099. dispose(): void;
  155100. }
  155101. /**
  155102. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  155103. */
  155104. export class WebXRHandTracking extends WebXRAbstractFeature {
  155105. /**
  155106. * options to use when constructing this feature
  155107. */
  155108. readonly options: IWebXRHandTrackingOptions;
  155109. private static _idCounter;
  155110. /**
  155111. * The module's name
  155112. */
  155113. static readonly Name: string;
  155114. /**
  155115. * The (Babylon) version of this module.
  155116. * This is an integer representing the implementation version.
  155117. * This number does not correspond to the WebXR specs version
  155118. */
  155119. static readonly Version: number;
  155120. /**
  155121. * This observable will notify registered observers when a new hand object was added and initialized
  155122. */
  155123. onHandAddedObservable: Observable<WebXRHand>;
  155124. /**
  155125. * This observable will notify its observers right before the hand object is disposed
  155126. */
  155127. onHandRemovedObservable: Observable<WebXRHand>;
  155128. private _hands;
  155129. /**
  155130. * Creates a new instance of the hit test feature
  155131. * @param _xrSessionManager an instance of WebXRSessionManager
  155132. * @param options options to use when constructing this feature
  155133. */
  155134. constructor(_xrSessionManager: WebXRSessionManager,
  155135. /**
  155136. * options to use when constructing this feature
  155137. */
  155138. options: IWebXRHandTrackingOptions);
  155139. /**
  155140. * Check if the needed objects are defined.
  155141. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  155142. */
  155143. isCompatible(): boolean;
  155144. /**
  155145. * attach this feature
  155146. * Will usually be called by the features manager
  155147. *
  155148. * @returns true if successful.
  155149. */
  155150. attach(): boolean;
  155151. /**
  155152. * detach this feature.
  155153. * Will usually be called by the features manager
  155154. *
  155155. * @returns true if successful.
  155156. */
  155157. detach(): boolean;
  155158. /**
  155159. * Dispose this feature and all of the resources attached
  155160. */
  155161. dispose(): void;
  155162. /**
  155163. * Get the hand object according to the controller id
  155164. * @param controllerId the controller id to which we want to get the hand
  155165. * @returns null if not found or the WebXRHand object if found
  155166. */
  155167. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  155168. /**
  155169. * Get a hand object according to the requested handedness
  155170. * @param handedness the handedness to request
  155171. * @returns null if not found or the WebXRHand object if found
  155172. */
  155173. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  155174. protected _onXRFrame(_xrFrame: XRFrame): void;
  155175. private _attachHand;
  155176. private _detachHand;
  155177. }
  155178. }
  155179. declare module BABYLON {
  155180. /**
  155181. * The motion controller class for all microsoft mixed reality controllers
  155182. */
  155183. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  155184. protected readonly _mapping: {
  155185. defaultButton: {
  155186. valueNodeName: string;
  155187. unpressedNodeName: string;
  155188. pressedNodeName: string;
  155189. };
  155190. defaultAxis: {
  155191. valueNodeName: string;
  155192. minNodeName: string;
  155193. maxNodeName: string;
  155194. };
  155195. buttons: {
  155196. "xr-standard-trigger": {
  155197. rootNodeName: string;
  155198. componentProperty: string;
  155199. states: string[];
  155200. };
  155201. "xr-standard-squeeze": {
  155202. rootNodeName: string;
  155203. componentProperty: string;
  155204. states: string[];
  155205. };
  155206. "xr-standard-touchpad": {
  155207. rootNodeName: string;
  155208. labelAnchorNodeName: string;
  155209. touchPointNodeName: string;
  155210. };
  155211. "xr-standard-thumbstick": {
  155212. rootNodeName: string;
  155213. componentProperty: string;
  155214. states: string[];
  155215. };
  155216. };
  155217. axes: {
  155218. "xr-standard-touchpad": {
  155219. "x-axis": {
  155220. rootNodeName: string;
  155221. };
  155222. "y-axis": {
  155223. rootNodeName: string;
  155224. };
  155225. };
  155226. "xr-standard-thumbstick": {
  155227. "x-axis": {
  155228. rootNodeName: string;
  155229. };
  155230. "y-axis": {
  155231. rootNodeName: string;
  155232. };
  155233. };
  155234. };
  155235. };
  155236. /**
  155237. * The base url used to load the left and right controller models
  155238. */
  155239. static MODEL_BASE_URL: string;
  155240. /**
  155241. * The name of the left controller model file
  155242. */
  155243. static MODEL_LEFT_FILENAME: string;
  155244. /**
  155245. * The name of the right controller model file
  155246. */
  155247. static MODEL_RIGHT_FILENAME: string;
  155248. profileId: string;
  155249. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  155250. protected _getFilenameAndPath(): {
  155251. filename: string;
  155252. path: string;
  155253. };
  155254. protected _getModelLoadingConstraints(): boolean;
  155255. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  155256. protected _setRootMesh(meshes: AbstractMesh[]): void;
  155257. protected _updateModel(): void;
  155258. }
  155259. }
  155260. declare module BABYLON {
  155261. /**
  155262. * The motion controller class for oculus touch (quest, rift).
  155263. * This class supports legacy mapping as well the standard xr mapping
  155264. */
  155265. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  155266. private _forceLegacyControllers;
  155267. private _modelRootNode;
  155268. /**
  155269. * The base url used to load the left and right controller models
  155270. */
  155271. static MODEL_BASE_URL: string;
  155272. /**
  155273. * The name of the left controller model file
  155274. */
  155275. static MODEL_LEFT_FILENAME: string;
  155276. /**
  155277. * The name of the right controller model file
  155278. */
  155279. static MODEL_RIGHT_FILENAME: string;
  155280. /**
  155281. * Base Url for the Quest controller model.
  155282. */
  155283. static QUEST_MODEL_BASE_URL: string;
  155284. profileId: string;
  155285. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  155286. protected _getFilenameAndPath(): {
  155287. filename: string;
  155288. path: string;
  155289. };
  155290. protected _getModelLoadingConstraints(): boolean;
  155291. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  155292. protected _setRootMesh(meshes: AbstractMesh[]): void;
  155293. protected _updateModel(): void;
  155294. /**
  155295. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  155296. * between the touch and touch 2.
  155297. */
  155298. private _isQuest;
  155299. }
  155300. }
  155301. declare module BABYLON {
  155302. /**
  155303. * The motion controller class for the standard HTC-Vive controllers
  155304. */
  155305. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  155306. private _modelRootNode;
  155307. /**
  155308. * The base url used to load the left and right controller models
  155309. */
  155310. static MODEL_BASE_URL: string;
  155311. /**
  155312. * File name for the controller model.
  155313. */
  155314. static MODEL_FILENAME: string;
  155315. profileId: string;
  155316. /**
  155317. * Create a new Vive motion controller object
  155318. * @param scene the scene to use to create this controller
  155319. * @param gamepadObject the corresponding gamepad object
  155320. * @param handedness the handedness of the controller
  155321. */
  155322. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  155323. protected _getFilenameAndPath(): {
  155324. filename: string;
  155325. path: string;
  155326. };
  155327. protected _getModelLoadingConstraints(): boolean;
  155328. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  155329. protected _setRootMesh(meshes: AbstractMesh[]): void;
  155330. protected _updateModel(): void;
  155331. }
  155332. }
  155333. declare module BABYLON {
  155334. /**
  155335. * A cursor which tracks a point on a path
  155336. */
  155337. export class PathCursor {
  155338. private path;
  155339. /**
  155340. * Stores path cursor callbacks for when an onchange event is triggered
  155341. */
  155342. private _onchange;
  155343. /**
  155344. * The value of the path cursor
  155345. */
  155346. value: number;
  155347. /**
  155348. * The animation array of the path cursor
  155349. */
  155350. animations: Animation[];
  155351. /**
  155352. * Initializes the path cursor
  155353. * @param path The path to track
  155354. */
  155355. constructor(path: Path2);
  155356. /**
  155357. * Gets the cursor point on the path
  155358. * @returns A point on the path cursor at the cursor location
  155359. */
  155360. getPoint(): Vector3;
  155361. /**
  155362. * Moves the cursor ahead by the step amount
  155363. * @param step The amount to move the cursor forward
  155364. * @returns This path cursor
  155365. */
  155366. moveAhead(step?: number): PathCursor;
  155367. /**
  155368. * Moves the cursor behind by the step amount
  155369. * @param step The amount to move the cursor back
  155370. * @returns This path cursor
  155371. */
  155372. moveBack(step?: number): PathCursor;
  155373. /**
  155374. * Moves the cursor by the step amount
  155375. * If the step amount is greater than one, an exception is thrown
  155376. * @param step The amount to move the cursor
  155377. * @returns This path cursor
  155378. */
  155379. move(step: number): PathCursor;
  155380. /**
  155381. * Ensures that the value is limited between zero and one
  155382. * @returns This path cursor
  155383. */
  155384. private ensureLimits;
  155385. /**
  155386. * Runs onchange callbacks on change (used by the animation engine)
  155387. * @returns This path cursor
  155388. */
  155389. private raiseOnChange;
  155390. /**
  155391. * Executes a function on change
  155392. * @param f A path cursor onchange callback
  155393. * @returns This path cursor
  155394. */
  155395. onchange(f: (cursor: PathCursor) => void): PathCursor;
  155396. }
  155397. }
  155398. declare module BABYLON {
  155399. /** @hidden */
  155400. export var blurPixelShader: {
  155401. name: string;
  155402. shader: string;
  155403. };
  155404. }
  155405. declare module BABYLON {
  155406. /** @hidden */
  155407. export var pointCloudVertexDeclaration: {
  155408. name: string;
  155409. shader: string;
  155410. };
  155411. }
  155412. // Mixins
  155413. interface Window {
  155414. mozIndexedDB: IDBFactory;
  155415. webkitIndexedDB: IDBFactory;
  155416. msIndexedDB: IDBFactory;
  155417. webkitURL: typeof URL;
  155418. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  155419. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  155420. WebGLRenderingContext: WebGLRenderingContext;
  155421. MSGesture: MSGesture;
  155422. CANNON: any;
  155423. AudioContext: AudioContext;
  155424. webkitAudioContext: AudioContext;
  155425. PointerEvent: any;
  155426. Math: Math;
  155427. Uint8Array: Uint8ArrayConstructor;
  155428. Float32Array: Float32ArrayConstructor;
  155429. mozURL: typeof URL;
  155430. msURL: typeof URL;
  155431. VRFrameData: any; // WebVR, from specs 1.1
  155432. DracoDecoderModule: any;
  155433. setImmediate(handler: (...args: any[]) => void): number;
  155434. }
  155435. interface HTMLCanvasElement {
  155436. requestPointerLock(): void;
  155437. msRequestPointerLock?(): void;
  155438. mozRequestPointerLock?(): void;
  155439. webkitRequestPointerLock?(): void;
  155440. /** Track wether a record is in progress */
  155441. isRecording: boolean;
  155442. /** Capture Stream method defined by some browsers */
  155443. captureStream(fps?: number): MediaStream;
  155444. }
  155445. interface CanvasRenderingContext2D {
  155446. msImageSmoothingEnabled: boolean;
  155447. }
  155448. interface MouseEvent {
  155449. mozMovementX: number;
  155450. mozMovementY: number;
  155451. webkitMovementX: number;
  155452. webkitMovementY: number;
  155453. msMovementX: number;
  155454. msMovementY: number;
  155455. }
  155456. interface Navigator {
  155457. mozGetVRDevices: (any: any) => any;
  155458. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  155459. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  155460. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  155461. webkitGetGamepads(): Gamepad[];
  155462. msGetGamepads(): Gamepad[];
  155463. webkitGamepads(): Gamepad[];
  155464. }
  155465. interface HTMLVideoElement {
  155466. mozSrcObject: any;
  155467. }
  155468. interface Math {
  155469. fround(x: number): number;
  155470. imul(a: number, b: number): number;
  155471. }
  155472. interface WebGLRenderingContext {
  155473. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  155474. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  155475. vertexAttribDivisor(index: number, divisor: number): void;
  155476. createVertexArray(): any;
  155477. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  155478. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  155479. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  155480. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  155481. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  155482. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  155483. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  155484. // Queries
  155485. createQuery(): WebGLQuery;
  155486. deleteQuery(query: WebGLQuery): void;
  155487. beginQuery(target: number, query: WebGLQuery): void;
  155488. endQuery(target: number): void;
  155489. getQueryParameter(query: WebGLQuery, pname: number): any;
  155490. getQuery(target: number, pname: number): any;
  155491. MAX_SAMPLES: number;
  155492. RGBA8: number;
  155493. READ_FRAMEBUFFER: number;
  155494. DRAW_FRAMEBUFFER: number;
  155495. UNIFORM_BUFFER: number;
  155496. HALF_FLOAT_OES: number;
  155497. RGBA16F: number;
  155498. RGBA32F: number;
  155499. R32F: number;
  155500. RG32F: number;
  155501. RGB32F: number;
  155502. R16F: number;
  155503. RG16F: number;
  155504. RGB16F: number;
  155505. RED: number;
  155506. RG: number;
  155507. R8: number;
  155508. RG8: number;
  155509. UNSIGNED_INT_24_8: number;
  155510. DEPTH24_STENCIL8: number;
  155511. MIN: number;
  155512. MAX: number;
  155513. /* Multiple Render Targets */
  155514. drawBuffers(buffers: number[]): void;
  155515. readBuffer(src: number): void;
  155516. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  155517. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  155518. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  155519. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  155520. // Occlusion Query
  155521. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  155522. ANY_SAMPLES_PASSED: number;
  155523. QUERY_RESULT_AVAILABLE: number;
  155524. QUERY_RESULT: number;
  155525. }
  155526. interface WebGLProgram {
  155527. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  155528. }
  155529. interface EXT_disjoint_timer_query {
  155530. QUERY_COUNTER_BITS_EXT: number;
  155531. TIME_ELAPSED_EXT: number;
  155532. TIMESTAMP_EXT: number;
  155533. GPU_DISJOINT_EXT: number;
  155534. QUERY_RESULT_EXT: number;
  155535. QUERY_RESULT_AVAILABLE_EXT: number;
  155536. queryCounterEXT(query: WebGLQuery, target: number): void;
  155537. createQueryEXT(): WebGLQuery;
  155538. beginQueryEXT(target: number, query: WebGLQuery): void;
  155539. endQueryEXT(target: number): void;
  155540. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  155541. deleteQueryEXT(query: WebGLQuery): void;
  155542. }
  155543. interface WebGLUniformLocation {
  155544. _currentState: any;
  155545. }
  155546. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  155547. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  155548. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  155549. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  155550. interface WebGLRenderingContext {
  155551. readonly RASTERIZER_DISCARD: number;
  155552. readonly DEPTH_COMPONENT24: number;
  155553. readonly TEXTURE_3D: number;
  155554. readonly TEXTURE_2D_ARRAY: number;
  155555. readonly TEXTURE_COMPARE_FUNC: number;
  155556. readonly TEXTURE_COMPARE_MODE: number;
  155557. readonly COMPARE_REF_TO_TEXTURE: number;
  155558. readonly TEXTURE_WRAP_R: number;
  155559. readonly HALF_FLOAT: number;
  155560. readonly RGB8: number;
  155561. readonly RED_INTEGER: number;
  155562. readonly RG_INTEGER: number;
  155563. readonly RGB_INTEGER: number;
  155564. readonly RGBA_INTEGER: number;
  155565. readonly R8_SNORM: number;
  155566. readonly RG8_SNORM: number;
  155567. readonly RGB8_SNORM: number;
  155568. readonly RGBA8_SNORM: number;
  155569. readonly R8I: number;
  155570. readonly RG8I: number;
  155571. readonly RGB8I: number;
  155572. readonly RGBA8I: number;
  155573. readonly R8UI: number;
  155574. readonly RG8UI: number;
  155575. readonly RGB8UI: number;
  155576. readonly RGBA8UI: number;
  155577. readonly R16I: number;
  155578. readonly RG16I: number;
  155579. readonly RGB16I: number;
  155580. readonly RGBA16I: number;
  155581. readonly R16UI: number;
  155582. readonly RG16UI: number;
  155583. readonly RGB16UI: number;
  155584. readonly RGBA16UI: number;
  155585. readonly R32I: number;
  155586. readonly RG32I: number;
  155587. readonly RGB32I: number;
  155588. readonly RGBA32I: number;
  155589. readonly R32UI: number;
  155590. readonly RG32UI: number;
  155591. readonly RGB32UI: number;
  155592. readonly RGBA32UI: number;
  155593. readonly RGB10_A2UI: number;
  155594. readonly R11F_G11F_B10F: number;
  155595. readonly RGB9_E5: number;
  155596. readonly RGB10_A2: number;
  155597. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  155598. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  155599. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  155600. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  155601. readonly DEPTH_COMPONENT32F: number;
  155602. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  155603. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  155604. 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;
  155605. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  155606. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  155607. readonly TRANSFORM_FEEDBACK: number;
  155608. readonly INTERLEAVED_ATTRIBS: number;
  155609. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  155610. createTransformFeedback(): WebGLTransformFeedback;
  155611. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  155612. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  155613. beginTransformFeedback(primitiveMode: number): void;
  155614. endTransformFeedback(): void;
  155615. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  155616. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155617. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155618. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155619. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  155620. }
  155621. interface ImageBitmap {
  155622. readonly width: number;
  155623. readonly height: number;
  155624. close(): void;
  155625. }
  155626. interface WebGLQuery extends WebGLObject {
  155627. }
  155628. declare var WebGLQuery: {
  155629. prototype: WebGLQuery;
  155630. new(): WebGLQuery;
  155631. };
  155632. interface WebGLSampler extends WebGLObject {
  155633. }
  155634. declare var WebGLSampler: {
  155635. prototype: WebGLSampler;
  155636. new(): WebGLSampler;
  155637. };
  155638. interface WebGLSync extends WebGLObject {
  155639. }
  155640. declare var WebGLSync: {
  155641. prototype: WebGLSync;
  155642. new(): WebGLSync;
  155643. };
  155644. interface WebGLTransformFeedback extends WebGLObject {
  155645. }
  155646. declare var WebGLTransformFeedback: {
  155647. prototype: WebGLTransformFeedback;
  155648. new(): WebGLTransformFeedback;
  155649. };
  155650. interface WebGLVertexArrayObject extends WebGLObject {
  155651. }
  155652. declare var WebGLVertexArrayObject: {
  155653. prototype: WebGLVertexArrayObject;
  155654. new(): WebGLVertexArrayObject;
  155655. };
  155656. // Type definitions for WebVR API
  155657. // Project: https://w3c.github.io/webvr/
  155658. // Definitions by: six a <https://github.com/lostfictions>
  155659. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  155660. interface VRDisplay extends EventTarget {
  155661. /**
  155662. * Dictionary of capabilities describing the VRDisplay.
  155663. */
  155664. readonly capabilities: VRDisplayCapabilities;
  155665. /**
  155666. * z-depth defining the far plane of the eye view frustum
  155667. * enables mapping of values in the render target depth
  155668. * attachment to scene coordinates. Initially set to 10000.0.
  155669. */
  155670. depthFar: number;
  155671. /**
  155672. * z-depth defining the near plane of the eye view frustum
  155673. * enables mapping of values in the render target depth
  155674. * attachment to scene coordinates. Initially set to 0.01.
  155675. */
  155676. depthNear: number;
  155677. /**
  155678. * An identifier for this distinct VRDisplay. Used as an
  155679. * association point in the Gamepad API.
  155680. */
  155681. readonly displayId: number;
  155682. /**
  155683. * A display name, a user-readable name identifying it.
  155684. */
  155685. readonly displayName: string;
  155686. readonly isConnected: boolean;
  155687. readonly isPresenting: boolean;
  155688. /**
  155689. * If this VRDisplay supports room-scale experiences, the optional
  155690. * stage attribute contains details on the room-scale parameters.
  155691. */
  155692. readonly stageParameters: VRStageParameters | null;
  155693. /**
  155694. * Passing the value returned by `requestAnimationFrame` to
  155695. * `cancelAnimationFrame` will unregister the callback.
  155696. * @param handle Define the hanle of the request to cancel
  155697. */
  155698. cancelAnimationFrame(handle: number): void;
  155699. /**
  155700. * Stops presenting to the VRDisplay.
  155701. * @returns a promise to know when it stopped
  155702. */
  155703. exitPresent(): Promise<void>;
  155704. /**
  155705. * Return the current VREyeParameters for the given eye.
  155706. * @param whichEye Define the eye we want the parameter for
  155707. * @returns the eye parameters
  155708. */
  155709. getEyeParameters(whichEye: string): VREyeParameters;
  155710. /**
  155711. * Populates the passed VRFrameData with the information required to render
  155712. * the current frame.
  155713. * @param frameData Define the data structure to populate
  155714. * @returns true if ok otherwise false
  155715. */
  155716. getFrameData(frameData: VRFrameData): boolean;
  155717. /**
  155718. * Get the layers currently being presented.
  155719. * @returns the list of VR layers
  155720. */
  155721. getLayers(): VRLayer[];
  155722. /**
  155723. * Return a VRPose containing the future predicted pose of the VRDisplay
  155724. * when the current frame will be presented. The value returned will not
  155725. * change until JavaScript has returned control to the browser.
  155726. *
  155727. * The VRPose will contain the position, orientation, velocity,
  155728. * and acceleration of each of these properties.
  155729. * @returns the pose object
  155730. */
  155731. getPose(): VRPose;
  155732. /**
  155733. * Return the current instantaneous pose of the VRDisplay, with no
  155734. * prediction applied.
  155735. * @returns the current instantaneous pose
  155736. */
  155737. getImmediatePose(): VRPose;
  155738. /**
  155739. * The callback passed to `requestAnimationFrame` will be called
  155740. * any time a new frame should be rendered. When the VRDisplay is
  155741. * presenting the callback will be called at the native refresh
  155742. * rate of the HMD. When not presenting this function acts
  155743. * identically to how window.requestAnimationFrame acts. Content should
  155744. * make no assumptions of frame rate or vsync behavior as the HMD runs
  155745. * asynchronously from other displays and at differing refresh rates.
  155746. * @param callback Define the eaction to run next frame
  155747. * @returns the request handle it
  155748. */
  155749. requestAnimationFrame(callback: FrameRequestCallback): number;
  155750. /**
  155751. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  155752. * Repeat calls while already presenting will update the VRLayers being displayed.
  155753. * @param layers Define the list of layer to present
  155754. * @returns a promise to know when the request has been fulfilled
  155755. */
  155756. requestPresent(layers: VRLayer[]): Promise<void>;
  155757. /**
  155758. * Reset the pose for this display, treating its current position and
  155759. * orientation as the "origin/zero" values. VRPose.position,
  155760. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  155761. * updated when calling resetPose(). This should be called in only
  155762. * sitting-space experiences.
  155763. */
  155764. resetPose(): void;
  155765. /**
  155766. * The VRLayer provided to the VRDisplay will be captured and presented
  155767. * in the HMD. Calling this function has the same effect on the source
  155768. * canvas as any other operation that uses its source image, and canvases
  155769. * created without preserveDrawingBuffer set to true will be cleared.
  155770. * @param pose Define the pose to submit
  155771. */
  155772. submitFrame(pose?: VRPose): void;
  155773. }
  155774. declare var VRDisplay: {
  155775. prototype: VRDisplay;
  155776. new(): VRDisplay;
  155777. };
  155778. interface VRLayer {
  155779. leftBounds?: number[] | Float32Array | null;
  155780. rightBounds?: number[] | Float32Array | null;
  155781. source?: HTMLCanvasElement | null;
  155782. }
  155783. interface VRDisplayCapabilities {
  155784. readonly canPresent: boolean;
  155785. readonly hasExternalDisplay: boolean;
  155786. readonly hasOrientation: boolean;
  155787. readonly hasPosition: boolean;
  155788. readonly maxLayers: number;
  155789. }
  155790. interface VREyeParameters {
  155791. /** @deprecated */
  155792. readonly fieldOfView: VRFieldOfView;
  155793. readonly offset: Float32Array;
  155794. readonly renderHeight: number;
  155795. readonly renderWidth: number;
  155796. }
  155797. interface VRFieldOfView {
  155798. readonly downDegrees: number;
  155799. readonly leftDegrees: number;
  155800. readonly rightDegrees: number;
  155801. readonly upDegrees: number;
  155802. }
  155803. interface VRFrameData {
  155804. readonly leftProjectionMatrix: Float32Array;
  155805. readonly leftViewMatrix: Float32Array;
  155806. readonly pose: VRPose;
  155807. readonly rightProjectionMatrix: Float32Array;
  155808. readonly rightViewMatrix: Float32Array;
  155809. readonly timestamp: number;
  155810. }
  155811. interface VRPose {
  155812. readonly angularAcceleration: Float32Array | null;
  155813. readonly angularVelocity: Float32Array | null;
  155814. readonly linearAcceleration: Float32Array | null;
  155815. readonly linearVelocity: Float32Array | null;
  155816. readonly orientation: Float32Array | null;
  155817. readonly position: Float32Array | null;
  155818. readonly timestamp: number;
  155819. }
  155820. interface VRStageParameters {
  155821. sittingToStandingTransform?: Float32Array;
  155822. sizeX?: number;
  155823. sizeY?: number;
  155824. }
  155825. interface Navigator {
  155826. getVRDisplays(): Promise<VRDisplay[]>;
  155827. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  155828. }
  155829. interface Window {
  155830. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  155831. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  155832. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  155833. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  155834. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  155835. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  155836. }
  155837. interface Gamepad {
  155838. readonly displayId: number;
  155839. }
  155840. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  155841. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  155842. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  155843. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  155844. type XRHandedness = "none" | "left" | "right";
  155845. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  155846. type XREye = "none" | "left" | "right";
  155847. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  155848. interface XRSpace extends EventTarget {}
  155849. interface XRRenderState {
  155850. depthNear?: number;
  155851. depthFar?: number;
  155852. inlineVerticalFieldOfView?: number;
  155853. baseLayer?: XRWebGLLayer;
  155854. }
  155855. interface XRInputSource {
  155856. handedness: XRHandedness;
  155857. targetRayMode: XRTargetRayMode;
  155858. targetRaySpace: XRSpace;
  155859. gripSpace: XRSpace | undefined;
  155860. gamepad: Gamepad | undefined;
  155861. profiles: Array<string>;
  155862. hand: XRHand | undefined;
  155863. }
  155864. interface XRSessionInit {
  155865. optionalFeatures?: string[];
  155866. requiredFeatures?: string[];
  155867. }
  155868. interface XRSession {
  155869. addEventListener: Function;
  155870. removeEventListener: Function;
  155871. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  155872. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  155873. requestAnimationFrame: Function;
  155874. end(): Promise<void>;
  155875. renderState: XRRenderState;
  155876. inputSources: Array<XRInputSource>;
  155877. // hit test
  155878. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  155879. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  155880. // legacy AR hit test
  155881. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155882. // legacy plane detection
  155883. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  155884. }
  155885. interface XRReferenceSpace extends XRSpace {
  155886. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  155887. onreset: any;
  155888. }
  155889. type XRPlaneSet = Set<XRPlane>;
  155890. type XRAnchorSet = Set<XRAnchor>;
  155891. interface XRFrame {
  155892. session: XRSession;
  155893. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  155894. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  155895. // AR
  155896. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  155897. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  155898. // Anchors
  155899. trackedAnchors?: XRAnchorSet;
  155900. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  155901. // Planes
  155902. worldInformation: {
  155903. detectedPlanes?: XRPlaneSet;
  155904. };
  155905. // Hand tracking
  155906. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  155907. }
  155908. interface XRViewerPose extends XRPose {
  155909. views: Array<XRView>;
  155910. }
  155911. interface XRPose {
  155912. transform: XRRigidTransform;
  155913. emulatedPosition: boolean;
  155914. }
  155915. interface XRWebGLLayerOptions {
  155916. antialias?: boolean;
  155917. depth?: boolean;
  155918. stencil?: boolean;
  155919. alpha?: boolean;
  155920. multiview?: boolean;
  155921. framebufferScaleFactor?: number;
  155922. }
  155923. declare var XRWebGLLayer: {
  155924. prototype: XRWebGLLayer;
  155925. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  155926. };
  155927. interface XRWebGLLayer {
  155928. framebuffer: WebGLFramebuffer;
  155929. framebufferWidth: number;
  155930. framebufferHeight: number;
  155931. getViewport: Function;
  155932. }
  155933. declare class XRRigidTransform {
  155934. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  155935. position: DOMPointReadOnly;
  155936. orientation: DOMPointReadOnly;
  155937. matrix: Float32Array;
  155938. inverse: XRRigidTransform;
  155939. }
  155940. interface XRView {
  155941. eye: XREye;
  155942. projectionMatrix: Float32Array;
  155943. transform: XRRigidTransform;
  155944. }
  155945. interface XRInputSourceChangeEvent {
  155946. session: XRSession;
  155947. removed: Array<XRInputSource>;
  155948. added: Array<XRInputSource>;
  155949. }
  155950. interface XRInputSourceEvent extends Event {
  155951. readonly frame: XRFrame;
  155952. readonly inputSource: XRInputSource;
  155953. }
  155954. // Experimental(er) features
  155955. declare class XRRay {
  155956. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  155957. origin: DOMPointReadOnly;
  155958. direction: DOMPointReadOnly;
  155959. matrix: Float32Array;
  155960. }
  155961. declare enum XRHitTestTrackableType {
  155962. "point",
  155963. "plane",
  155964. "mesh",
  155965. }
  155966. interface XRHitResult {
  155967. hitMatrix: Float32Array;
  155968. }
  155969. interface XRTransientInputHitTestResult {
  155970. readonly inputSource: XRInputSource;
  155971. readonly results: Array<XRHitTestResult>;
  155972. }
  155973. interface XRHitTestResult {
  155974. getPose(baseSpace: XRSpace): XRPose | undefined;
  155975. // When anchor system is enabled
  155976. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  155977. }
  155978. interface XRHitTestSource {
  155979. cancel(): void;
  155980. }
  155981. interface XRTransientInputHitTestSource {
  155982. cancel(): void;
  155983. }
  155984. interface XRHitTestOptionsInit {
  155985. space: XRSpace;
  155986. entityTypes?: Array<XRHitTestTrackableType>;
  155987. offsetRay?: XRRay;
  155988. }
  155989. interface XRTransientInputHitTestOptionsInit {
  155990. profile: string;
  155991. entityTypes?: Array<XRHitTestTrackableType>;
  155992. offsetRay?: XRRay;
  155993. }
  155994. interface XRAnchor {
  155995. anchorSpace: XRSpace;
  155996. delete(): void;
  155997. }
  155998. interface XRPlane {
  155999. orientation: "Horizontal" | "Vertical";
  156000. planeSpace: XRSpace;
  156001. polygon: Array<DOMPointReadOnly>;
  156002. lastChangedTime: number;
  156003. }
  156004. interface XRJointSpace extends XRSpace {}
  156005. interface XRJointPose extends XRPose {
  156006. radius: number | undefined;
  156007. }
  156008. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  156009. readonly length: number;
  156010. [index: number]: XRJointSpace;
  156011. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  156012. readonly WRIST: number;
  156013. readonly THUMB_METACARPAL: number;
  156014. readonly THUMB_PHALANX_PROXIMAL: number;
  156015. readonly THUMB_PHALANX_DISTAL: number;
  156016. readonly THUMB_PHALANX_TIP: number;
  156017. readonly INDEX_METACARPAL: number;
  156018. readonly INDEX_PHALANX_PROXIMAL: number;
  156019. readonly INDEX_PHALANX_INTERMEDIATE: number;
  156020. readonly INDEX_PHALANX_DISTAL: number;
  156021. readonly INDEX_PHALANX_TIP: number;
  156022. readonly MIDDLE_METACARPAL: number;
  156023. readonly MIDDLE_PHALANX_PROXIMAL: number;
  156024. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  156025. readonly MIDDLE_PHALANX_DISTAL: number;
  156026. readonly MIDDLE_PHALANX_TIP: number;
  156027. readonly RING_METACARPAL: number;
  156028. readonly RING_PHALANX_PROXIMAL: number;
  156029. readonly RING_PHALANX_INTERMEDIATE: number;
  156030. readonly RING_PHALANX_DISTAL: number;
  156031. readonly RING_PHALANX_TIP: number;
  156032. readonly LITTLE_METACARPAL: number;
  156033. readonly LITTLE_PHALANX_PROXIMAL: number;
  156034. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  156035. readonly LITTLE_PHALANX_DISTAL: number;
  156036. readonly LITTLE_PHALANX_TIP: number;
  156037. }
  156038. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  156039. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  156040. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  156041. interface XRSession {
  156042. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  156043. }
  156044. interface XRFrame {
  156045. featurePointCloud? : Array<number>;
  156046. }